(CTR) Refactor code

This commit is contained in:
twinaphex 2015-07-12 01:53:32 +02:00
parent a11f8419fe
commit 69a406809e
2 changed files with 6 additions and 7 deletions

View File

@ -29,7 +29,6 @@ typedef struct ctr_input
{
bool blocked;
const input_device_driver_t *joypad;
uint64_t lifecycle_state;
} ctr_input_t;
static void ctr_input_poll(void *data)
@ -87,8 +86,7 @@ static bool ctr_input_key_pressed(void *data, int key)
settings_t *settings = config_get_ptr();
ctr_input_t *ctr = (ctr_input_t*)data;
return (ctr->lifecycle_state & (1ULL << key)) ||
input_joypad_pressed(ctr->joypad, 0, settings->input.binds[0], key);
return (input_joypad_pressed(ctr->joypad, 0, settings->input.binds[0], key);
}
static uint64_t ctr_input_get_capabilities(void *data)

View File

@ -29,6 +29,7 @@
static uint64_t pad_state;
static int16_t analog_state[1][2][2];
static uint64_t lifecycle_state;
static const char *ctr_joypad_name(unsigned pad)
{
@ -65,7 +66,8 @@ static bool ctr_joypad_button(unsigned port_num, uint16_t joykey)
if (port_num >= MAX_PADS)
return false;
return (pad_state & (1ULL << joykey));
return (ctr->lifecycle_state & (1ULL << key)) ||
(pad_state & (1ULL << joykey));
}
static uint64_t ctr_joypad_get_buttons(unsigned port_num)
@ -124,7 +126,6 @@ static void ctr_joypad_poll(void)
unsigned i, j;
uint32_t state_tmp;
circlePosition state_tmp_analog;
ctr_input_t *ctr = (ctr_input_t*)input_driver_get_ptr();
hidScanInput();
@ -155,10 +156,10 @@ static void ctr_joypad_poll(void)
if (analog_state[0][i][j] == -0x8000)
analog_state[0][i][j] = -0x7fff;
ctr->lifecycle_state &= ~((1ULL << RARCH_MENU_TOGGLE));
lifecycle_state &= ~((1ULL << RARCH_MENU_TOGGLE));
if(state_tmp & KEY_TOUCH)
ctr->lifecycle_state |= (1ULL << RARCH_MENU_TOGGLE);
lifecycle_state |= (1ULL << RARCH_MENU_TOGGLE);
/* panic button */
if((state_tmp & KEY_START) &&