Refactor input_push_analog_dpad

This commit is contained in:
twinaphex 2014-08-12 20:59:05 +02:00
parent e56edfe2b7
commit b1d7cd038d

View File

@ -1455,22 +1455,32 @@ void input_push_analog_dpad(struct retro_keybind *binds, unsigned mode)
{
unsigned i;
unsigned analog_base;
switch (mode)
{
case ANALOG_DPAD_LSTICK:
case ANALOG_DPAD_RSTICK:
analog_base = mode == ANALOG_DPAD_LSTICK ? RARCH_ANALOG_LEFT_X_PLUS : RARCH_ANALOG_RIGHT_X_PLUS;
binds[RETRO_DEVICE_ID_JOYPAD_RIGHT].orig_joyaxis = binds[RETRO_DEVICE_ID_JOYPAD_RIGHT].joyaxis;
binds[RETRO_DEVICE_ID_JOYPAD_LEFT].orig_joyaxis = binds[RETRO_DEVICE_ID_JOYPAD_LEFT].joyaxis;
binds[RETRO_DEVICE_ID_JOYPAD_DOWN].orig_joyaxis = binds[RETRO_DEVICE_ID_JOYPAD_DOWN].joyaxis;
binds[RETRO_DEVICE_ID_JOYPAD_UP].orig_joyaxis = binds[RETRO_DEVICE_ID_JOYPAD_UP].joyaxis;
// Inherit joyaxis from analogs.
binds[RETRO_DEVICE_ID_JOYPAD_RIGHT].joyaxis = binds[analog_base + 0].joyaxis;
binds[RETRO_DEVICE_ID_JOYPAD_LEFT].joyaxis = binds[analog_base + 1].joyaxis;
binds[RETRO_DEVICE_ID_JOYPAD_DOWN].joyaxis = binds[analog_base + 2].joyaxis;
binds[RETRO_DEVICE_ID_JOYPAD_UP].joyaxis = binds[analog_base + 3].joyaxis;
binds[RETRO_DEVICE_ID_JOYPAD_RIGHT].joyaxis = binds[RARCH_ANALOG_LEFT_X_PLUS + 0].joyaxis;
binds[RETRO_DEVICE_ID_JOYPAD_LEFT].joyaxis = binds[RARCH_ANALOG_LEFT_X_PLUS + 1].joyaxis;
binds[RETRO_DEVICE_ID_JOYPAD_DOWN].joyaxis = binds[RARCH_ANALOG_LEFT_X_PLUS + 2].joyaxis;
binds[RETRO_DEVICE_ID_JOYPAD_UP].joyaxis = binds[RARCH_ANALOG_LEFT_X_PLUS + 3].joyaxis;
break;
case ANALOG_DPAD_RSTICK:
binds[RETRO_DEVICE_ID_JOYPAD_RIGHT].orig_joyaxis = binds[RETRO_DEVICE_ID_JOYPAD_RIGHT].joyaxis;
binds[RETRO_DEVICE_ID_JOYPAD_LEFT].orig_joyaxis = binds[RETRO_DEVICE_ID_JOYPAD_LEFT].joyaxis;
binds[RETRO_DEVICE_ID_JOYPAD_DOWN].orig_joyaxis = binds[RETRO_DEVICE_ID_JOYPAD_DOWN].joyaxis;
binds[RETRO_DEVICE_ID_JOYPAD_UP].orig_joyaxis = binds[RETRO_DEVICE_ID_JOYPAD_UP].joyaxis;
// Inherit joyaxis from analogs.
binds[RETRO_DEVICE_ID_JOYPAD_RIGHT].joyaxis = binds[RARCH_ANALOG_RIGHT_X_PLUS + 0].joyaxis;
binds[RETRO_DEVICE_ID_JOYPAD_LEFT].joyaxis = binds[RARCH_ANALOG_RIGHT_X_PLUS + 1].joyaxis;
binds[RETRO_DEVICE_ID_JOYPAD_DOWN].joyaxis = binds[RARCH_ANALOG_RIGHT_X_PLUS + 2].joyaxis;
binds[RETRO_DEVICE_ID_JOYPAD_UP].joyaxis = binds[RARCH_ANALOG_RIGHT_X_PLUS + 3].joyaxis;
break;
default: