Simplify input_push_analog_dpad

This commit is contained in:
twinaphex 2016-12-04 22:20:47 +01:00
parent 6cdb823bb4
commit bbbcc97f57
4 changed files with 15 additions and 30 deletions

View File

@ -394,9 +394,6 @@ float py_state_get(py_state_t *handle, const char *id,
if (dpad_mode == ANALOG_DPAD_NONE) if (dpad_mode == ANALOG_DPAD_NONE)
continue; continue;
input_push_analog_dpad_pre(general_binds);
input_push_analog_dpad_pre(auto_binds);
input_push_analog_dpad(general_binds, dpad_mode); input_push_analog_dpad(general_binds, dpad_mode);
input_push_analog_dpad(auto_binds, dpad_mode); input_push_analog_dpad(auto_binds, dpad_mode);
} }

View File

@ -513,9 +513,6 @@ void state_tracker_update_input(uint16_t *input1, uint16_t *input2)
if (dpad_mode == ANALOG_DPAD_NONE) if (dpad_mode == ANALOG_DPAD_NONE)
continue; continue;
input_push_analog_dpad_pre(general_binds);
input_push_analog_dpad_pre(auto_binds);
input_push_analog_dpad(general_binds, dpad_mode); input_push_analog_dpad(general_binds, dpad_mode);
input_push_analog_dpad(auto_binds, dpad_mode); input_push_analog_dpad(auto_binds, dpad_mode);
} }
@ -733,7 +730,6 @@ uint64_t input_menu_keys_pressed(void)
{ {
struct retro_keybind *auto_binds = settings->input.autoconf_binds[i]; struct retro_keybind *auto_binds = settings->input.autoconf_binds[i];
input_push_analog_dpad_pre(auto_binds);
input_push_analog_dpad(auto_binds, ANALOG_DPAD_LSTICK); input_push_analog_dpad(auto_binds, ANALOG_DPAD_LSTICK);
} }

View File

@ -181,6 +181,19 @@ bool input_translate_coord_viewport(int mouse_x, int mouse_y,
#define inherit_joyaxis(binds) (((binds)[x_plus].joyaxis == (binds)[x_minus].joyaxis) || ( (binds)[y_plus].joyaxis == (binds)[y_minus].joyaxis)) #define inherit_joyaxis(binds) (((binds)[x_plus].joyaxis == (binds)[x_minus].joyaxis) || ( (binds)[y_plus].joyaxis == (binds)[y_minus].joyaxis))
/**
* input_pop_analog_dpad:
* @binds : Binds to modify.
*
* Restores binds temporarily overridden by input_push_analog_dpad().
**/
#define input_pop_analog_dpad(binds) \
{ \
unsigned j; \
for (j = RETRO_DEVICE_ID_JOYPAD_UP; j <= RETRO_DEVICE_ID_JOYPAD_RIGHT; j++) \
(binds)[j].joyaxis = (binds)[j].orig_joyaxis; \
}
/** /**
* input_push_analog_dpad: * input_push_analog_dpad:
* @binds : Binds to modify. * @binds : Binds to modify.
@ -205,6 +218,8 @@ bool input_translate_coord_viewport(int mouse_x, int mouse_y,
x_minus = RARCH_ANALOG_LEFT_X_MINUS; \ x_minus = RARCH_ANALOG_LEFT_X_MINUS; \
y_minus = RARCH_ANALOG_LEFT_Y_MINUS; \ y_minus = RARCH_ANALOG_LEFT_Y_MINUS; \
} \ } \
for (k = RETRO_DEVICE_ID_JOYPAD_UP; k <= RETRO_DEVICE_ID_JOYPAD_RIGHT; k++) \
(binds)[k].orig_joyaxis = (binds)[k].joyaxis; \
if (!inherit_joyaxis(binds)) \ if (!inherit_joyaxis(binds)) \
{ \ { \
unsigned j = x_plus + 3; \ unsigned j = x_plus + 3; \
@ -214,26 +229,6 @@ bool input_translate_coord_viewport(int mouse_x, int mouse_y,
} \ } \
} }
#define input_push_analog_dpad_pre(binds) \
{ \
unsigned k; \
for (k = RETRO_DEVICE_ID_JOYPAD_UP; k <= RETRO_DEVICE_ID_JOYPAD_RIGHT; k++) \
(binds)[k].orig_joyaxis = (binds)[k].joyaxis; \
}
/**
* input_pop_analog_dpad:
* @binds : Binds to modify.
*
* Restores binds temporarily overridden by input_push_analog_dpad().
**/
#define input_pop_analog_dpad(binds) \
{ \
unsigned j; \
for (j = RETRO_DEVICE_ID_JOYPAD_UP; j <= RETRO_DEVICE_ID_JOYPAD_RIGHT; j++) \
(binds)[j].joyaxis = (binds)[j].orig_joyaxis; \
}
/** /**
* input_poll: * input_poll:
* *

View File

@ -1247,9 +1247,6 @@ int runloop_iterate(unsigned *sleep_ms)
if (dpad_mode == ANALOG_DPAD_NONE) if (dpad_mode == ANALOG_DPAD_NONE)
continue; continue;
input_push_analog_dpad_pre(general_binds);
input_push_analog_dpad_pre(auto_binds);
input_push_analog_dpad(general_binds, dpad_mode); input_push_analog_dpad(general_binds, dpad_mode);
input_push_analog_dpad(auto_binds, dpad_mode); input_push_analog_dpad(auto_binds, dpad_mode);
} }