From b2b9cf5717ee6317d23f87706c71064f357e74e5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 26 Sep 2014 12:56:03 +0200 Subject: [PATCH] Rewrite input_push_analog_dpad --- input/input_common.c | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/input/input_common.c b/input/input_common.c index 64f39028ed..9d6767660f 100644 --- a/input/input_common.c +++ b/input/input_common.c @@ -1567,38 +1567,26 @@ void input_config_autoconfigure_joypad(unsigned index, const char *name, void input_push_analog_dpad(struct retro_keybind *binds, unsigned mode) { - unsigned i; + unsigned i, j; + + for (i = RETRO_DEVICE_ID_JOYPAD_UP; i <= RETRO_DEVICE_ID_JOYPAD_RIGHT; i++) + binds[i].orig_joyaxis = binds[i].joyaxis; switch (mode) { case ANALOG_DPAD_LSTICK: - 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; + j = RARCH_ANALOG_LEFT_X_PLUS + 3; /* Inherit joyaxis from analogs. */ - 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; + for (i = RETRO_DEVICE_ID_JOYPAD_UP; i <= RETRO_DEVICE_ID_JOYPAD_RIGHT; i++) + binds[i].joyaxis = binds[j--].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; + j = RARCH_ANALOG_RIGHT_X_PLUS + 3; /* 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: for (i = RETRO_DEVICE_ID_JOYPAD_UP; i <= RETRO_DEVICE_ID_JOYPAD_RIGHT; i++) - binds[i].orig_joyaxis = binds[i].joyaxis; + binds[i].joyaxis = binds[j--].joyaxis; break; } }