mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-28 10:40:39 +00:00
Convert input_conv_analog_id_to_bind into macro
This commit is contained in:
parent
84d246ad0b
commit
68cbd5048c
@ -345,7 +345,7 @@ static int16_t dinput_pressed_analog(struct dinput_input *di,
|
||||
int16_t pressed_minus = 0, pressed_plus = 0;
|
||||
unsigned id_minus = 0, id_plus = 0;
|
||||
|
||||
input_conv_analog_id_to_bind_id(idx, id, &id_minus, &id_plus);
|
||||
input_conv_analog_id_to_bind_id(idx, id, id_minus, id_plus);
|
||||
|
||||
bind_minus = &binds[id_minus];
|
||||
bind_plus = &binds[id_plus];
|
||||
|
@ -82,7 +82,7 @@ static int16_t linuxraw_analog_pressed(linuxraw_input_t *linuxraw,
|
||||
unsigned id_minus = 0;
|
||||
unsigned id_plus = 0;
|
||||
|
||||
input_conv_analog_id_to_bind_id(idx, id, &id_minus, &id_plus);
|
||||
input_conv_analog_id_to_bind_id(idx, id, id_minus, id_plus);
|
||||
|
||||
if ((id_minus < RARCH_BIND_LIST_END) && binds->valid &&
|
||||
linuxraw->state[rarch_keysym_lut[(enum retro_key)binds[id_minus].key]]
|
||||
|
@ -506,7 +506,7 @@ static int16_t rwebinput_analog_pressed(rwebinput_input_t *rwebinput,
|
||||
unsigned id_minus = 0;
|
||||
unsigned id_plus = 0;
|
||||
|
||||
input_conv_analog_id_to_bind_id(idx, id, &id_minus, &id_plus);
|
||||
input_conv_analog_id_to_bind_id(idx, id, id_minus, id_plus);
|
||||
|
||||
if (rwebinput_is_pressed(rwebinput, joypad_info, binds, idx, id_minus))
|
||||
pressed_minus = -0x7fff;
|
||||
|
@ -82,7 +82,7 @@ static int16_t sdl_analog_pressed(sdl_input_t *sdl, const struct retro_keybind *
|
||||
unsigned id_minus = 0;
|
||||
unsigned id_plus = 0;
|
||||
|
||||
input_conv_analog_id_to_bind_id(idx, id, &id_minus, &id_plus);
|
||||
input_conv_analog_id_to_bind_id(idx, id, id_minus, id_plus);
|
||||
|
||||
if ((binds[id_minus].key < RETROK_LAST) && sdl_key_pressed(binds[id_minus].key))
|
||||
pressed_minus = -0x7fff;
|
||||
|
@ -922,7 +922,7 @@ static int16_t udev_analog_pressed(const struct retro_keybind *binds,
|
||||
int16_t pressed_minus = 0;
|
||||
int16_t pressed_plus = 0;
|
||||
|
||||
input_conv_analog_id_to_bind_id(idx, id, &id_minus, &id_plus);
|
||||
input_conv_analog_id_to_bind_id(idx, id, id_minus, id_plus);
|
||||
|
||||
if ( binds[id_minus].valid
|
||||
&& BIT_GET(udev_key_state,
|
||||
|
@ -157,7 +157,7 @@ static int16_t uwp_pressed_analog(uwp_input_t *uwp,
|
||||
unsigned id_minus = 0, id_plus = 0;
|
||||
|
||||
/* First, process the keyboard bindings */
|
||||
input_conv_analog_id_to_bind_id(idx, id, &id_minus, &id_plus);
|
||||
input_conv_analog_id_to_bind_id(idx, id, id_minus, id_plus);
|
||||
|
||||
bind_minus = &binds[id_minus];
|
||||
bind_plus = &binds[id_plus];
|
||||
|
@ -157,7 +157,7 @@ static int16_t input_wl_analog_pressed(input_ctx_wayland_data_t *wl,
|
||||
int16_t pressed_minus = 0;
|
||||
int16_t pressed_plus = 0;
|
||||
|
||||
input_conv_analog_id_to_bind_id(idx, id, &id_minus, &id_plus);
|
||||
input_conv_analog_id_to_bind_id(idx, id, id_minus, id_plus);
|
||||
|
||||
if (binds
|
||||
&& binds[id_minus].valid
|
||||
|
@ -157,7 +157,7 @@ static int16_t x_pressed_analog(x11_input_t *x11,
|
||||
int id_plus_key = 0;
|
||||
unsigned keycode = 0;
|
||||
|
||||
input_conv_analog_id_to_bind_id(idx, id, &id_minus, &id_plus);
|
||||
input_conv_analog_id_to_bind_id(idx, id, id_minus, id_plus);
|
||||
|
||||
id_minus_key = binds[id_minus].key;
|
||||
id_plus_key = binds[id_plus].key;
|
||||
|
@ -432,8 +432,26 @@ const input_device_driver_t *input_joypad_init_driver(
|
||||
* Takes as input analog key identifiers and converts
|
||||
* them to corresponding bind IDs @ident_minus and @ident_plus.
|
||||
**/
|
||||
void input_conv_analog_id_to_bind_id(unsigned idx, unsigned ident,
|
||||
unsigned *ident_minus, unsigned *ident_plus);
|
||||
#define input_conv_analog_id_to_bind_id(idx, ident, ident_minus, ident_plus) \
|
||||
switch ((idx << 1) | ident) \
|
||||
{ \
|
||||
case (RETRO_DEVICE_INDEX_ANALOG_LEFT << 1) | RETRO_DEVICE_ID_ANALOG_X: \
|
||||
ident_minus = RARCH_ANALOG_LEFT_X_MINUS; \
|
||||
ident_plus = RARCH_ANALOG_LEFT_X_PLUS; \
|
||||
break; \
|
||||
case (RETRO_DEVICE_INDEX_ANALOG_LEFT << 1) | RETRO_DEVICE_ID_ANALOG_Y: \
|
||||
ident_minus = RARCH_ANALOG_LEFT_Y_MINUS; \
|
||||
ident_plus = RARCH_ANALOG_LEFT_Y_PLUS; \
|
||||
break; \
|
||||
case (RETRO_DEVICE_INDEX_ANALOG_RIGHT << 1) | RETRO_DEVICE_ID_ANALOG_X: \
|
||||
ident_minus = RARCH_ANALOG_RIGHT_X_MINUS; \
|
||||
ident_plus = RARCH_ANALOG_RIGHT_X_PLUS; \
|
||||
break; \
|
||||
case (RETRO_DEVICE_INDEX_ANALOG_RIGHT << 1) | RETRO_DEVICE_ID_ANALOG_Y: \
|
||||
ident_minus = RARCH_ANALOG_RIGHT_Y_MINUS; \
|
||||
ident_plus = RARCH_ANALOG_RIGHT_Y_PLUS; \
|
||||
break; \
|
||||
}
|
||||
|
||||
/**
|
||||
* input_joypad_pressed:
|
||||
|
45
retroarch.c
45
retroarch.c
@ -3228,7 +3228,7 @@ int16_t input_joypad_analog(const input_device_driver_t *drv,
|
||||
const struct retro_keybind *bind_minus = NULL;
|
||||
const struct retro_keybind *bind_plus = NULL;
|
||||
|
||||
input_conv_analog_id_to_bind_id(idx, ident, &ident_minus, &ident_plus);
|
||||
input_conv_analog_id_to_bind_id(idx, ident, ident_minus, ident_plus);
|
||||
|
||||
bind_minus = &binds[ident_minus];
|
||||
bind_plus = &binds[ident_plus];
|
||||
@ -3318,49 +3318,6 @@ void input_pad_connect(unsigned port, input_device_driver_t *driver)
|
||||
input_config_set_device_name(port, driver->name(port));
|
||||
}
|
||||
|
||||
/**
|
||||
* input_conv_analog_id_to_bind_id:
|
||||
* @idx : Analog key index.
|
||||
* E.g.:
|
||||
* - RETRO_DEVICE_INDEX_ANALOG_LEFT
|
||||
* - RETRO_DEVICE_INDEX_ANALOG_RIGHT
|
||||
* @ident : Analog key identifier.
|
||||
* E.g.:
|
||||
* - RETRO_DEVICE_ID_ANALOG_X
|
||||
* - RETRO_DEVICE_ID_ANALOG_Y
|
||||
* @ident_minus : Bind ID minus, will be set by function.
|
||||
* @ident_plus : Bind ID plus, will be set by function.
|
||||
*
|
||||
* Takes as input analog key identifiers and converts
|
||||
* them to corresponding bind IDs @ident_minus and @ident_plus.
|
||||
**/
|
||||
void input_conv_analog_id_to_bind_id(unsigned idx, unsigned ident,
|
||||
unsigned *ident_minus, unsigned *ident_plus)
|
||||
{
|
||||
switch ((idx << 1) | ident)
|
||||
{
|
||||
case (RETRO_DEVICE_INDEX_ANALOG_LEFT << 1) | RETRO_DEVICE_ID_ANALOG_X:
|
||||
*ident_minus = RARCH_ANALOG_LEFT_X_MINUS;
|
||||
*ident_plus = RARCH_ANALOG_LEFT_X_PLUS;
|
||||
break;
|
||||
|
||||
case (RETRO_DEVICE_INDEX_ANALOG_LEFT << 1) | RETRO_DEVICE_ID_ANALOG_Y:
|
||||
*ident_minus = RARCH_ANALOG_LEFT_Y_MINUS;
|
||||
*ident_plus = RARCH_ANALOG_LEFT_Y_PLUS;
|
||||
break;
|
||||
|
||||
case (RETRO_DEVICE_INDEX_ANALOG_RIGHT << 1) | RETRO_DEVICE_ID_ANALOG_X:
|
||||
*ident_minus = RARCH_ANALOG_RIGHT_X_MINUS;
|
||||
*ident_plus = RARCH_ANALOG_RIGHT_X_PLUS;
|
||||
break;
|
||||
|
||||
case (RETRO_DEVICE_INDEX_ANALOG_RIGHT << 1) | RETRO_DEVICE_ID_ANALOG_Y:
|
||||
*ident_minus = RARCH_ANALOG_RIGHT_Y_MINUS;
|
||||
*ident_plus = RARCH_ANALOG_RIGHT_Y_PLUS;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_HID
|
||||
/**
|
||||
* hid_driver_find_handle:
|
||||
|
Loading…
Reference in New Issue
Block a user