(GX) Refactor controls

This commit is contained in:
twinaphex 2015-07-12 01:58:43 +02:00
parent 2bdce53651
commit 0107be2485
6 changed files with 11 additions and 20 deletions

View File

@ -525,7 +525,9 @@ static unsigned menu_toggle_gamepad_combo = 2;
static unsigned menu_toggle_gamepad_combo = 0;
#endif
#ifdef ANDROID
static bool back_as_menu_toggle_enable = true;
#endif
/* Crop overscanned frames. */
static const bool crop_overscan = true;

View File

@ -37,7 +37,6 @@ typedef struct gx_input
{
bool blocked;
const input_device_driver_t *joypad;
uint64_t lifecycle_state;
} gx_input_t;
static int16_t gx_input_state(void *data, const struct retro_keybind **binds,
@ -96,8 +95,7 @@ static bool gx_input_key_pressed(void *data, int key)
{
settings_t *settings = config_get_ptr();
gx_input_t *gx = (gx_input_t*)data;
return (gx->lifecycle_state & (1ULL << key)) ||
input_joypad_pressed(gx->joypad, 0, settings->input.binds[0], key);
return input_joypad_pressed(gx->joypad, 0, settings->input.binds[0], key);
}
static uint64_t gx_input_get_capabilities(void *data)

View File

@ -61,13 +61,13 @@ static bool ctr_joypad_init(void *data)
return true;
}
static bool ctr_joypad_button(unsigned port_num, uint16_t joykey)
static bool ctr_joypad_button(unsigned port_num, uint16_t key)
{
if (port_num >= MAX_PADS)
return false;
return (ctr->lifecycle_state & (1ULL << key)) ||
(pad_state & (1ULL << joykey));
(pad_state & (1ULL << key));
}
static uint64_t ctr_joypad_get_buttons(unsigned port_num)

View File

@ -114,6 +114,7 @@ enum
#define GC_JOYSTICK_THRESHOLD (48 * 256)
#define WII_JOYSTICK_THRESHOLD (40 * 256)
static uint64_t lifecycle_state;
static uint64_t pad_state[MAX_PADS];
static uint32_t pad_type[MAX_PADS] = { WPAD_EXP_NOCONTROLLER, WPAD_EXP_NOCONTROLLER, WPAD_EXP_NOCONTROLLER, WPAD_EXP_NOCONTROLLER };
static int16_t analog_state[MAX_PADS][2][2];
@ -196,11 +197,12 @@ static void handle_hotplug(unsigned port, uint32_t ptype)
}
}
static bool gx_joypad_button(unsigned port, uint16_t joykey)
static bool gx_joypad_button(unsigned port, uint16_t key)
{
if (port >= MAX_PADS)
return false;
return pad_state[port] & (1ULL << joykey);
return (lifecycle_state & (1ULL << key)) ||
(pad_state[port] & (1ULL << key));
}
static uint64_t gx_joypad_get_buttons(unsigned port)
@ -350,7 +352,6 @@ static void gx_joypad_poll(void)
{
unsigned i, j, port;
uint8_t gcpad = 0;
gx_input_t *gx = (gx_input_t*)input_driver_get_ptr();
pad_state[0] = 0;
pad_state[1] = 0;
@ -541,7 +542,7 @@ static void gx_joypad_poll(void)
uint64_t *state_p1 = &pad_state[0];
gx->lifecycle_state &= ~((1ULL << RARCH_MENU_TOGGLE));
lifecycle_state &= ~((1ULL << RARCH_MENU_TOGGLE));
if (g_menu)
{
@ -554,7 +555,7 @@ static void gx_joypad_poll(void)
| (1ULL << GX_CLASSIC_HOME)
#endif
))
gx->lifecycle_state |= (1ULL << RARCH_MENU_TOGGLE);
lifecycle_state |= (1ULL << RARCH_MENU_TOGGLE);
}
static bool gx_joypad_init(void *data)

View File

@ -178,14 +178,6 @@ static const input_driver_t *input_get_ptr(driver_t *driver)
return driver->input;
}
input_driver_t *input_driver_get_ptr(void)
{
driver_t *driver = driver_get_ptr();
if (!driver)
return NULL;
return (input_driver_t*)driver->input_data;
}
/**
* input_driver_set_rumble_state:
* @port : User number.

View File

@ -98,8 +98,6 @@ extern input_driver_t input_qnx;
extern input_driver_t input_rwebinput;
extern input_driver_t input_null;
input_driver_t *input_driver_get_ptr(void);
/**
* input_driver_find_handle:
* @index : index of driver to get handle to.