(PSP) Refactor input code

This commit is contained in:
twinaphex 2015-07-12 01:55:51 +02:00
parent 69a406809e
commit 2bdce53651
2 changed files with 7 additions and 8 deletions

View File

@ -43,7 +43,6 @@ typedef struct psp_input
{
bool blocked;
const input_device_driver_t *joypad;
uint64_t lifecycle_state;
} psp_input_t;
static void psp_input_poll(void *data)
@ -102,8 +101,7 @@ static bool psp_input_key_pressed(void *data, int key)
settings_t *settings = config_get_ptr();
psp_input_t *psp = (psp_input_t*)data;
return (psp->lifecycle_state & (1ULL << key)) ||
input_joypad_pressed(psp->joypad, 0, settings->input.binds[0], key);
return input_joypad_pressed(psp->joypad, 0, settings->input.binds[0], key);
}
static uint64_t psp_input_get_capabilities(void *data)

View File

@ -18,6 +18,7 @@
static uint64_t pad_state;
static int16_t analog_state[1][2][2];
static uint64_t lifecycle_state;
static const char *psp_joypad_name(unsigned pad)
{
@ -49,12 +50,13 @@ static bool psp_joypad_init(void *data)
return true;
}
static bool psp_joypad_button(unsigned port_num, uint16_t joykey)
static bool psp_joypad_button(unsigned port_num, uint16_t key)
{
if (port_num >= MAX_PADS)
return false;
return (pad_state & (1ULL << joykey));
return (lifecycle_state & (1ULL << key)) ||
(pad_state & (1ULL << key));
}
static uint64_t psp_joypad_get_buttons(unsigned port_num)
@ -112,7 +114,6 @@ static void psp_joypad_poll(void)
int32_t ret;
unsigned i, j;
SceCtrlData state_tmp;
psp_input_t *psp = (psp_input_t*)input_driver_get_ptr();
#ifdef PSP
sceCtrlSetSamplingCycle(0);
@ -152,7 +153,7 @@ static void psp_joypad_poll(void)
if (analog_state[0][i][j] == -0x8000)
analog_state[0][i][j] = -0x7fff;
psp->lifecycle_state &= ~((1ULL << RARCH_MENU_TOGGLE));
lifecycle_state &= ~((1ULL << RARCH_MENU_TOGGLE));
#ifdef HAVE_KERNEL_PRX
if (STATE_BUTTON(state_tmp) & PSP_CTRL_NOTE)
@ -164,7 +165,7 @@ static void psp_joypad_poll(void)
&& (pad_state & (1ULL << RETRO_DEVICE_ID_JOYPAD_START))
)
#endif
psp->lifecycle_state |= (1ULL << RARCH_MENU_TOGGLE);
lifecycle_state |= (1ULL << RARCH_MENU_TOGGLE);
}
static bool psp_joypad_query_pad(unsigned pad)