Merge pull request #2197 from aliaspider/master

(CTR/3DS) input: fix analog joypad polling.
This commit is contained in:
Twinaphex 2015-10-02 01:05:50 +02:00
commit b36ed6709c

View File

@ -119,9 +119,14 @@ static int16_t ctr_joypad_axis(unsigned port_num, uint32_t joyaxis)
return val;
}
static int16_t ctr_joypad_fix_range(int16_t val)
{
val = (val > 127)? 127: (val < -127)? -127: val;
return val * 256;
}
static void ctr_joypad_poll(void)
{
unsigned i, j;
uint32_t state_tmp;
circlePosition state_tmp_left_analog, state_tmp_right_analog;
touchPosition state_tmp_touch;
@ -133,8 +138,6 @@ static void ctr_joypad_poll(void)
irrstCstickRead(&state_tmp_right_analog);
hidTouchRead(&state_tmp_touch);
analog_state[0][0][0] = analog_state[0][0][1] =
analog_state[0][1][0] = analog_state[0][1][1] = 0;
pad_state = 0;
pad_state |= (state_tmp & KEY_DLEFT) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0;
pad_state |= (state_tmp & KEY_DDOWN) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_DOWN) : 0;
@ -151,15 +154,10 @@ static void ctr_joypad_poll(void)
pad_state |= (state_tmp & KEY_ZR) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_R2) : 0;
pad_state |= (state_tmp & KEY_ZL) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_L2) : 0;
analog_state[0][RETRO_DEVICE_INDEX_ANALOG_LEFT] [RETRO_DEVICE_ID_ANALOG_X] = (state_tmp_left_analog.dx * 200);
analog_state[0][RETRO_DEVICE_INDEX_ANALOG_LEFT] [RETRO_DEVICE_ID_ANALOG_Y] = -(state_tmp_left_analog.dy * 200);
analog_state[0][RETRO_DEVICE_INDEX_ANALOG_RIGHT] [RETRO_DEVICE_ID_ANALOG_X] = (state_tmp_right_analog.dx * 200);
analog_state[0][RETRO_DEVICE_INDEX_ANALOG_RIGHT] [RETRO_DEVICE_ID_ANALOG_Y] = -(state_tmp_right_analog.dy * 200);
for (i = 0; i < 2; i++)
for (j = 0; j < 2; j++)
if (analog_state[0][i][j] == -0x8000)
analog_state[0][i][j] = -0x7fff;
analog_state[0][RETRO_DEVICE_INDEX_ANALOG_LEFT] [RETRO_DEVICE_ID_ANALOG_X] = ctr_joypad_fix_range(state_tmp_left_analog.dx);
analog_state[0][RETRO_DEVICE_INDEX_ANALOG_LEFT] [RETRO_DEVICE_ID_ANALOG_Y] = -ctr_joypad_fix_range(state_tmp_left_analog.dy);
analog_state[0][RETRO_DEVICE_INDEX_ANALOG_RIGHT] [RETRO_DEVICE_ID_ANALOG_X] = ctr_joypad_fix_range(state_tmp_right_analog.dx);
analog_state[0][RETRO_DEVICE_INDEX_ANALOG_RIGHT] [RETRO_DEVICE_ID_ANALOG_Y] = -ctr_joypad_fix_range(state_tmp_right_analog.dy);
BIT64_CLEAR(lifecycle_state, RARCH_MENU_TOGGLE);