Small cleanups to button input handling code - several parameters

were no longer used
This commit is contained in:
twinaphex 2021-04-10 19:06:56 +02:00
parent 760fc6b3f7
commit ca5ce839ce
7 changed files with 33 additions and 41 deletions

View File

@ -756,7 +756,7 @@ static int16_t dinput_input_state(
{ {
if (button_is_pressed(joypad, if (button_is_pressed(joypad,
joypad_info, joypad_info,
binds[port], port, new_id)) binds[port], new_id))
return 1; return 1;
else if ( else if (
binds[port][new_id].key < RETROK_LAST binds[port][new_id].key < RETROK_LAST

View File

@ -986,7 +986,7 @@ static int16_t udev_input_lightgun_state(
unsigned new_id = id; unsigned new_id = id;
if (button_is_pressed(joypad, if (button_is_pressed(joypad,
joypad_info, binds[port], joypad_info, binds[port],
port, new_id) new_id)
|| udev_mouse_button_pressed(udev, port, || udev_mouse_button_pressed(udev, port,
binds[port][new_id].mbutton) binds[port][new_id].mbutton)
) )
@ -1204,7 +1204,7 @@ static int16_t udev_input_state(
unsigned new_id = RARCH_LIGHTGUN_START; unsigned new_id = RARCH_LIGHTGUN_START;
if (button_is_pressed(joypad, if (button_is_pressed(joypad,
joypad_info, binds[port], joypad_info, binds[port],
port, new_id) new_id)
|| udev_mouse_button_pressed(udev, port, || udev_mouse_button_pressed(udev, port,
binds[port][new_id].mbutton) binds[port][new_id].mbutton)
) )

View File

@ -660,7 +660,7 @@ static int16_t winraw_input_lightgun_state(
return 1; return 1;
return button_is_pressed( return button_is_pressed(
joypad, joypad_info, binds[port], joypad, joypad_info, binds[port],
port, id); id);
} }
return 0; return 0;
} }

View File

@ -353,7 +353,7 @@ static int16_t x_input_state(
{ {
if (button_is_pressed(joypad, if (button_is_pressed(joypad,
joypad_info, binds[port], joypad_info, binds[port],
port, new_id)) new_id))
return 1; return 1;
else if (settings->uints.input_mouse_index[port] == 0) else if (settings->uints.input_mouse_index[port] == 0)
{ {
@ -376,7 +376,7 @@ static int16_t x_input_state(
{ {
if (button_is_pressed(joypad, if (button_is_pressed(joypad,
joypad_info, binds[port], joypad_info, binds[port],
port, new_id)) new_id))
return 1; return 1;
else if (settings->uints.input_mouse_index[port] == 0) else if (settings->uints.input_mouse_index[port] == 0)
{ {
@ -399,7 +399,7 @@ static int16_t x_input_state(
{ {
if (button_is_pressed(joypad, if (button_is_pressed(joypad,
joypad_info, binds[port], joypad_info, binds[port],
port, new_id)) new_id))
return 1; return 1;
else if (settings->uints.input_mouse_index[port] == 0) else if (settings->uints.input_mouse_index[port] == 0)
{ {
@ -422,7 +422,7 @@ static int16_t x_input_state(
{ {
if (button_is_pressed(joypad, if (button_is_pressed(joypad,
joypad_info, binds[port], joypad_info, binds[port],
port, new_id)) new_id))
return 1; return 1;
else if (settings->uints.input_mouse_index[port] == 0) else if (settings->uints.input_mouse_index[port] == 0)
{ {
@ -445,7 +445,7 @@ static int16_t x_input_state(
{ {
if (button_is_pressed(joypad, if (button_is_pressed(joypad,
joypad_info, binds[port], joypad_info, binds[port],
port, new_id)) new_id))
return 1; return 1;
else if (settings->uints.input_mouse_index[port] == 0) else if (settings->uints.input_mouse_index[port] == 0)
{ {
@ -468,7 +468,7 @@ static int16_t x_input_state(
{ {
if (button_is_pressed(joypad, if (button_is_pressed(joypad,
joypad_info, binds[port], joypad_info, binds[port],
port, new_id)) new_id))
return 1; return 1;
else if (settings->uints.input_mouse_index[port] == 0) else if (settings->uints.input_mouse_index[port] == 0)
{ {
@ -491,7 +491,7 @@ static int16_t x_input_state(
{ {
if (button_is_pressed(joypad, if (button_is_pressed(joypad,
joypad_info, binds[port], joypad_info, binds[port],
port, new_id)) new_id))
return 1; return 1;
else if (settings->uints.input_mouse_index[port] == 0) else if (settings->uints.input_mouse_index[port] == 0)
{ {
@ -514,7 +514,7 @@ static int16_t x_input_state(
{ {
if (button_is_pressed(joypad, if (button_is_pressed(joypad,
joypad_info, binds[port], joypad_info, binds[port],
port, new_id)) new_id))
return 1; return 1;
else if (settings->uints.input_mouse_index[port] == 0) else if (settings->uints.input_mouse_index[port] == 0)
{ {
@ -537,7 +537,7 @@ static int16_t x_input_state(
{ {
if (button_is_pressed(joypad, if (button_is_pressed(joypad,
joypad_info, binds[port], joypad_info, binds[port],
port, new_id)) new_id))
return 1; return 1;
else if (settings->uints.input_mouse_index[port] == 0) else if (settings->uints.input_mouse_index[port] == 0)
{ {
@ -560,7 +560,7 @@ static int16_t x_input_state(
{ {
if (button_is_pressed(joypad, if (button_is_pressed(joypad,
joypad_info, binds[port], joypad_info, binds[port],
port, new_id)) new_id))
return 1; return 1;
else if (settings->uints.input_mouse_index[port] == 0) else if (settings->uints.input_mouse_index[port] == 0)
{ {
@ -583,7 +583,7 @@ static int16_t x_input_state(
{ {
if (button_is_pressed(joypad, if (button_is_pressed(joypad,
joypad_info, binds[port], joypad_info, binds[port],
port, new_id)) new_id))
return 1; return 1;
else if (settings->uints.input_mouse_index[port] == 0) else if (settings->uints.input_mouse_index[port] == 0)
{ {
@ -611,7 +611,7 @@ static int16_t x_input_state(
{ {
if (button_is_pressed(joypad, if (button_is_pressed(joypad,
joypad_info, binds[port], joypad_info, binds[port],
port, new_id)) new_id))
return 1; return 1;
else if (settings->uints.input_mouse_index[port] == 0) else if (settings->uints.input_mouse_index[port] == 0)
{ {

View File

@ -598,7 +598,7 @@ int16_t button_is_pressed(
const input_device_driver_t *joypad, const input_device_driver_t *joypad,
rarch_joypad_info_t *joypad_info, rarch_joypad_info_t *joypad_info,
const struct retro_keybind *binds, const struct retro_keybind *binds,
unsigned port, unsigned id); unsigned id);
RETRO_END_DECLS RETRO_END_DECLS

View File

@ -481,13 +481,13 @@ static int16_t input_state_wrap(
{ {
if (button_is_pressed( if (button_is_pressed(
joypad, joypad,
joypad_info, binds[port], port, id)) joypad_info, binds[port], id))
return 1; return 1;
#ifdef HAVE_MFI #ifdef HAVE_MFI
else if (sec_joypad && else if (sec_joypad &&
button_is_pressed( button_is_pressed(
sec_joypad, sec_joypad,
joypad_info, binds[port], port, id)) joypad_info, binds[port], id))
return 1; return 1;
#endif #endif
} }
@ -22147,8 +22147,8 @@ static void input_driver_poll(void)
input_joypad_analog_button( input_joypad_analog_button(
input_analog_deadzone, input_analog_deadzone,
input_analog_sensitivity, input_analog_sensitivity,
joypad_driver, &joypad_info[i], (unsigned)i, joypad_driver, &joypad_info[i],
RETRO_DEVICE_INDEX_ANALOG_BUTTON, k, k,
p_rarch->libretro_input_binds[i]); p_rarch->libretro_input_binds[i]);
if (val) if (val)
p_new_state->analog_buttons[k] = val; p_new_state->analog_buttons[k] = val;
@ -22172,7 +22172,6 @@ static void input_driver_poll(void)
input_analog_sensitivity, input_analog_sensitivity,
joypad_driver, joypad_driver,
&joypad_info[i], &joypad_info[i],
(unsigned)i,
k, k,
j, j,
p_rarch->libretro_input_binds[i]); p_rarch->libretro_input_binds[i]);
@ -22801,13 +22800,13 @@ static int16_t input_state(unsigned port, unsigned device,
input_analog_deadzone, input_analog_deadzone,
input_analog_sensitivity, input_analog_sensitivity,
sec_joypad, &joypad_info, sec_joypad, &joypad_info,
port, idx, id, p_rarch->libretro_input_binds[port]); id, p_rarch->libretro_input_binds[port]);
if (joypad && (ret == 0)) if (joypad && (ret == 0))
ret = input_joypad_analog_button( ret = input_joypad_analog_button(
input_analog_deadzone, input_analog_deadzone,
input_analog_sensitivity, input_analog_sensitivity,
joypad, &joypad_info, joypad, &joypad_info,
port, idx, id, p_rarch->libretro_input_binds[port]); id, p_rarch->libretro_input_binds[port]);
} }
} }
} }
@ -22820,7 +22819,6 @@ static int16_t input_state(unsigned port, unsigned device,
input_analog_sensitivity, input_analog_sensitivity,
sec_joypad, sec_joypad,
&joypad_info, &joypad_info,
port,
idx, idx,
id, id,
p_rarch->libretro_input_binds[port]); p_rarch->libretro_input_binds[port]);
@ -22831,7 +22829,6 @@ static int16_t input_state(unsigned port, unsigned device,
input_analog_sensitivity, input_analog_sensitivity,
joypad, joypad,
&joypad_info, &joypad_info,
port,
idx, idx,
id, id,
p_rarch->libretro_input_binds[port]); p_rarch->libretro_input_binds[port]);
@ -24980,7 +24977,6 @@ bool input_key_pressed(int key, bool keyboard_pressed)
return button_is_pressed( return button_is_pressed(
joypad, &joypad_info, joypad, &joypad_info,
input_config_binds[0], input_config_binds[0],
joypad_info.joy_idx,
key); key);
} }
return true; return true;
@ -24996,14 +24992,14 @@ int16_t button_is_pressed(
const input_device_driver_t *joypad, const input_device_driver_t *joypad,
rarch_joypad_info_t *joypad_info, rarch_joypad_info_t *joypad_info,
const struct retro_keybind *binds, const struct retro_keybind *binds,
unsigned port, unsigned id) unsigned id)
{ {
/* Auto-binds are per joypad, not per user. */ /* Auto-binds are per joypad, not per user. */
const uint64_t bind_joykey = binds[id].joykey; const uint64_t bind_joykey = binds[id].joykey;
const uint64_t bind_joyaxis = binds[id].joyaxis; const uint64_t bind_joyaxis = binds[id].joyaxis;
const uint64_t autobind_joykey = joypad_info->auto_binds[id].joykey; const uint64_t autobind_joykey = joypad_info->auto_binds[id].joykey;
const uint64_t autobind_joyaxis= joypad_info->auto_binds[id].joyaxis; const uint64_t autobind_joyaxis= joypad_info->auto_binds[id].joyaxis;
uint16_t joy_idx = joypad_info->joy_idx; uint16_t port = joypad_info->joy_idx;
float axis_threshold = joypad_info->axis_threshold; float axis_threshold = joypad_info->axis_threshold;
const uint64_t joykey = (bind_joykey != NO_BTN) const uint64_t joykey = (bind_joykey != NO_BTN)
? bind_joykey : autobind_joykey; ? bind_joykey : autobind_joykey;
@ -25011,10 +25007,10 @@ int16_t button_is_pressed(
? bind_joyaxis : autobind_joyaxis; ? bind_joyaxis : autobind_joyaxis;
if ((uint16_t)joykey != NO_BTN && joypad->button( if ((uint16_t)joykey != NO_BTN && joypad->button(
joy_idx, (uint16_t)joykey)) port, (uint16_t)joykey))
return 1; return 1;
if (joyaxis != AXIS_NONE && if (joyaxis != AXIS_NONE &&
((float)abs(joypad->axis(joy_idx, joyaxis)) ((float)abs(joypad->axis(port, joyaxis))
/ 0x8000) > axis_threshold) / 0x8000) > axis_threshold)
return 1; return 1;
return 0; return 0;
@ -25044,7 +25040,7 @@ static int16_t input_joypad_analog_button(
float input_analog_sensitivity, float input_analog_sensitivity,
const input_device_driver_t *drv, const input_device_driver_t *drv,
rarch_joypad_info_t *joypad_info, rarch_joypad_info_t *joypad_info,
unsigned port, unsigned idx, unsigned ident, unsigned ident,
const struct retro_keybind *binds) const struct retro_keybind *binds)
{ {
int16_t res = 0; int16_t res = 0;
@ -25064,15 +25060,13 @@ static int16_t input_joypad_analog_button(
normal_mag = fabs((1.0f / 0x7fff) * mult); normal_mag = fabs((1.0f / 0x7fff) * mult);
} }
res = abs(input_joypad_axis( /* If the result is zero, it's got a digital button
* attached to it instead */
if ((res = abs(input_joypad_axis(
input_analog_deadzone, input_analog_deadzone,
input_analog_sensitivity, input_analog_sensitivity,
drv, drv,
joypad_info->joy_idx, axis, normal_mag)); joypad_info->joy_idx, axis, normal_mag))) == 0)
/* If the result is zero, it's got a digital button
* attached to it instead */
if (res == 0)
{ {
uint16_t key = (bind->joykey == NO_BTN) uint16_t key = (bind->joykey == NO_BTN)
? joypad_info->auto_binds[ident].joykey ? joypad_info->auto_binds[ident].joykey
@ -25092,7 +25086,6 @@ static int16_t input_joypad_analog_axis(
float input_analog_sensitivity, float input_analog_sensitivity,
const input_device_driver_t *drv, const input_device_driver_t *drv,
rarch_joypad_info_t *joypad_info, rarch_joypad_info_t *joypad_info,
unsigned port,
unsigned idx, unsigned idx,
unsigned ident, unsigned ident,
const struct retro_keybind *binds) const struct retro_keybind *binds)

View File

@ -157,7 +157,7 @@ static int16_t input_joypad_analog_button(
float input_analog_sensitivity, float input_analog_sensitivity,
const input_device_driver_t *drv, const input_device_driver_t *drv,
rarch_joypad_info_t *joypad_info, rarch_joypad_info_t *joypad_info,
unsigned port, unsigned idx, unsigned ident, unsigned ident,
const struct retro_keybind *binds); const struct retro_keybind *binds);
static int16_t input_joypad_analog_axis( static int16_t input_joypad_analog_axis(
unsigned input_analog_dpad_mode, unsigned input_analog_dpad_mode,
@ -165,7 +165,6 @@ static int16_t input_joypad_analog_axis(
float input_analog_sensitivity, float input_analog_sensitivity,
const input_device_driver_t *drv, const input_device_driver_t *drv,
rarch_joypad_info_t *joypad_info, rarch_joypad_info_t *joypad_info,
unsigned port,
unsigned idx, unsigned idx,
unsigned ident, unsigned ident,
const struct retro_keybind *binds); const struct retro_keybind *binds);