From b1d7cd038dd6af9630100aaa5e80f6b71e5752d6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 12 Aug 2014 20:59:05 +0200 Subject: [PATCH] Refactor input_push_analog_dpad --- input/input_common.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/input/input_common.c b/input/input_common.c index b975862209..40091c577d 100644 --- a/input/input_common.c +++ b/input/input_common.c @@ -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: