Cleanups - add local variable

This commit is contained in:
twinaphex 2020-07-29 05:31:23 +02:00
parent 4f931f2729
commit ed3ee2511f
29 changed files with 115 additions and 88 deletions

View File

@ -1411,7 +1411,8 @@ static int16_t btstack_hid_joypad_state(
unsigned i;
int16_t ret = 0;
const struct retro_keybind *binds = (const struct retro_keybind*)binds_data;
const struct dinput_joypad_data *pad = &g_pads[joypad_info->joy_idx];
uint16_t port_idx = joypad_info->joy_idx;
const struct dinput_joypad_data *pad = &g_pads[port_idx];
if (!pad || !pad->joypad)
return 0;
@ -1425,11 +1426,10 @@ static int16_t btstack_hid_joypad_state(
? binds[i].joyaxis : joypad_info->auto_binds[i].joyaxis;
if (
(uint16_t)joykey != NO_BTN
&& btstack_hid_joypad_button(data,
joypad_info->joy_idx, (uint16_t)joykey))
&& btstack_hid_joypad_button(data, port_idx, (uint16_t)joykey))
ret |= ( 1 << i);
else if (joyaxis != AXIS_NONE &&
((float)abs(btstack_hid_joypad_axis(data, joypad_info->joy_idx, joyaxis))
((float)abs(btstack_hid_joypad_axis(data, port_idx, joyaxis))
/ 0x8000) > joypad_info->axis_threshold)
ret |= (1 << i);
}

View File

@ -224,6 +224,7 @@ static int16_t iohidmanager_hid_joypad_state(
unsigned i;
int16_t ret = 0;
const struct retro_keybind *binds = (const struct retro_keybind*)binds_data;
uint16_t port_idx = joypad_info->joy_idx;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
@ -234,11 +235,10 @@ static int16_t iohidmanager_hid_joypad_state(
? binds[i].joyaxis : joypad_info->auto_binds[i].joyaxis;
if (
(uint16_t)joykey != NO_BTN
&& iohidmanager_hid_joypad_button(data,
joypad_info->joy_idx, (uint16_t)joykey))
&& iohidmanager_hid_joypad_button(data, port_idx, (uint16_t)joykey))
ret |= ( 1 << i);
else if (joyaxis != AXIS_NONE &&
((float)abs(iohidmanager_hid_joypad_axis(data, joypad_info->joy_idx, joyaxis))
((float)abs(iohidmanager_hid_joypad_axis(data, port_idx, joyaxis))
/ 0x8000) > joypad_info->axis_threshold)
ret |= (1 << i);
}

View File

@ -513,6 +513,7 @@ static int16_t libusb_hid_joypad_state(
unsigned i;
int16_t ret = 0;
const struct retro_keybind *binds = (const struct retro_keybind*)binds_data;
uint16_t port_idx = joypad_info->joy_idx;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
@ -523,11 +524,10 @@ static int16_t libusb_hid_joypad_state(
? binds[i].joyaxis : joypad_info->auto_binds[i].joyaxis;
if (
(uint16_t)joykey != NO_BTN
&& libusb_hid_joypad_button(data,
joypad_info->joy_idx, (uint16_t)joykey))
&& libusb_hid_joypad_button(data, port_idx, (uint16_t)joykey))
ret |= ( 1 << i);
else if (joyaxis != AXIS_NONE &&
((float)abs(libusb_hid_joypad_axis(data, joypad_info->joy_idx, joyaxis))
((float)abs(libusb_hid_joypad_axis(data, port_idx, joyaxis))
/ 0x8000) > joypad_info->axis_threshold)
ret |= (1 << i);
}

View File

@ -92,7 +92,8 @@ static int16_t wiiu_hid_joypad_state(
int16_t ret = 0;
const struct retro_keybind *binds = (const struct retro_keybind*)
binds_data;
joypad_connection_t *pad = get_pad((wiiu_hid_t *)data, joypad_info->joy_idx);
uint16_t port_idx = joypad_info->joy_idx;
joypad_connection_t *pad = get_pad((wiiu_hid_t *)data, port_idx);
if (!pad)
return 0;
@ -105,8 +106,7 @@ static int16_t wiiu_hid_joypad_state(
? binds[i].joyaxis : joypad_info->auto_binds[i].joyaxis;
if (
(uint16_t)joykey != NO_BTN
&& pad->iface->button(pad->data,
(uint16_t)joykey))
&& pad->iface->button(pad->data, (uint16_t)joykey))
ret |= ( 1 << i);
else if (joyaxis != AXIS_NONE &&
((float)abs(pad->iface->get_axis(pad->data, joyaxis))

View File

@ -590,6 +590,7 @@ static int16_t wiiusb_hid_joypad_state(
unsigned i;
int16_t ret = 0;
const struct retro_keybind *binds = (const struct retro_keybind*)binds_data;
uint16_t port_idx = joypad_info->joy_idx;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
@ -600,12 +601,10 @@ static int16_t wiiusb_hid_joypad_state(
? binds[i].joyaxis : joypad_info->auto_binds[i].joyaxis;
if (
(uint16_t)joykey != NO_BTN
&& wiiusb_hid_joypad_button(
data,
joypad_info->joy_idx, (uint16_t)joykey))
&& wiiusb_hid_joypad_button(data, port_idx, (uint16_t)joykey))
ret |= ( 1 << i);
else if (joyaxis != AXIS_NONE &&
((float)abs(wiiusb_hid_joypad_axis(data, joypad_info->joy_idx, joyaxis))
((float)abs(wiiusb_hid_joypad_axis(data, port_idx, joyaxis))
/ 0x8000) > joypad_info->axis_threshold)
ret |= (1 << i);
}

View File

@ -106,8 +106,9 @@ static int16_t android_joypad_state(
int16_t ret = 0;
struct android_app *android_app = (struct android_app*)g_android;
uint8_t *buf = android_keyboard_state_get(port);
uint16_t port_idx = joypad_info->joy_idx;
if (port >= DEFAULT_MAX_PADS)
if (port_idx >= DEFAULT_MAX_PADS)
return 0;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
@ -121,11 +122,11 @@ static int16_t android_joypad_state(
&& android_joypad_button_state(
android_app,
buf,
joypad_info->joy_idx, (uint16_t)joykey))
port_idx, (uint16_t)joykey))
ret |= ( 1 << i);
else if (joyaxis != AXIS_NONE &&
((float)abs(android_joypad_axis_state(
android_app, joypad_info->joy_idx, joyaxis))
android_app, port_idx, joyaxis))
/ 0x8000) > joypad_info->axis_threshold)
ret |= (1 << i);
}

View File

@ -125,8 +125,9 @@ static int16_t ctr_joypad_state(
{
unsigned i;
int16_t ret = 0;
uint16_t port_idx = joypad_info->joy_idx;
if (joypad_info->joy_idx >= DEFAULT_MAX_PADS)
if (port_idx >= DEFAULT_MAX_PADS)
return 0;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
@ -141,7 +142,7 @@ static int16_t ctr_joypad_state(
(pad_state & (1 << (uint16_t)joykey)))
ret |= ( 1 << i);
else if (joyaxis != AXIS_NONE &&
((float)abs(ctr_joypad_axis_state(joypad_info->joy_idx, joyaxis))
((float)abs(ctr_joypad_axis_state(port_idx, joyaxis))
/ 0x8000) > joypad_info->axis_threshold)
ret |= (1 << i);
}

View File

@ -575,10 +575,13 @@ static int16_t dinput_joypad_state(
{
unsigned i;
int16_t ret = 0;
const struct dinput_joypad_data *pad = &g_pads[joypad_info->joy_idx];
uint16_t port_idx = joypad_info->joy_idx;
const struct dinput_joypad_data *pad = &g_pads[port_idx];
if (!pad || !pad->joypad)
return 0;
if (port_idx >= DEFAULT_MAX_PADS)
return 0;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{

View File

@ -209,10 +209,11 @@ static int16_t dos_joypad_state(
unsigned port)
{
unsigned i;
int16_t ret = 0;
uint16_t *buf = dos_keyboard_state_get(joypad_info->joy_idx);
int16_t ret = 0;
uint16_t port_idx = joypad_info->joy_idx;
uint16_t *buf = dos_keyboard_state_get(port_idx);
if (joypad_info->joy_idx >= DEFAULT_MAX_PADS)
if (port_idx >= DEFAULT_MAX_PADS)
return 0;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)

View File

@ -315,8 +315,9 @@ static int16_t gx_joypad_state(
{
unsigned i;
int16_t ret = 0;
uint16_t port_idx = joypad_info->joy_idx;
if (joypad_info->joy_idx >= DEFAULT_MAX_PADS)
if (port_idx >= DEFAULT_MAX_PADS)
return 0;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
@ -328,11 +329,11 @@ static int16_t gx_joypad_state(
? binds[i].joyaxis : joypad_info->auto_binds[i].joyaxis;
if (
(uint16_t)joykey != NO_BTN &&
(pad_state[joypad_info->joy_idx] & (UINT64_C(1) << joykey))
(pad_state[port_idx] & (UINT64_C(1) << joykey))
)
ret |= ( 1 << i);
else if (joyaxis != AXIS_NONE &&
((float)abs(gx_joypad_axis_state(joypad_info->joy_idx, joyaxis))
((float)abs(gx_joypad_axis_state(port_idx, joyaxis))
/ 0x8000) > joypad_info->axis_threshold)
ret |= (1 << i);
}

View File

@ -69,6 +69,10 @@ static int16_t hid_joypad_state(
{
unsigned i;
int16_t ret = 0;
uint16_t port_idx = joypad_info->joy_idx;
if (port_idx >= DEFAULT_MAX_PADS)
return 0;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
@ -78,10 +82,10 @@ static int16_t hid_joypad_state(
const uint32_t joyaxis = (binds[i].joyaxis != AXIS_NONE)
? binds[i].joyaxis : joypad_info->auto_binds[i].joyaxis;
if ((uint16_t)joykey != NO_BTN && hid_joypad_button(
joypad_info->joy_idx, (uint16_t)joykey))
port_idx, (uint16_t)joykey))
ret |= ( 1 << i);
else if (joyaxis != AXIS_NONE &&
((float)abs(hid_joypad_axis(joypad_info->joy_idx, joyaxis))
((float)abs(hid_joypad_axis(port_idx, joyaxis))
/ 0x8000) > joypad_info->axis_threshold)
ret |= (1 << i);
}

View File

@ -359,10 +359,11 @@ static int16_t linuxraw_joypad_state(
{
unsigned i;
int16_t ret = 0;
uint16_t port_idx = joypad_info->joy_idx;
const struct linuxraw_joypad *pad = (const struct linuxraw_joypad*)
&linuxraw_pads[joypad_info->joy_idx];
&linuxraw_pads[port_idx];
if (joypad_info->joy_idx >= DEFAULT_MAX_PADS)
if (port_idx >= DEFAULT_MAX_PADS)
return 0;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
@ -377,7 +378,7 @@ static int16_t linuxraw_joypad_state(
(BIT32_GET(pad->buttons, joykey)))
ret |= ( 1 << i);
else if (joyaxis != AXIS_NONE &&
((float)abs(linuxraw_joypad_axis_state(pad, joypad_info->joy_idx, joyaxis))
((float)abs(linuxraw_joypad_axis_state(pad, port_idx, joyaxis))
/ 0x8000) > joypad_info->axis_threshold)
ret |= (1 << i);
}

View File

@ -389,8 +389,9 @@ static int16_t apple_gamecontroller_joypad_state(
{
unsigned i;
int16_t ret = 0;
uint16_t port_idx = joypad_info->joy_idx;
if (joypad_info->joy_idx >= DEFAULT_MAX_PADS)
if (port_idx >= DEFAULT_MAX_PADS)
return 0;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
@ -403,11 +404,11 @@ static int16_t apple_gamecontroller_joypad_state(
if ( (uint16_t)joykey != NO_BTN
&& !GET_HAT_DIR(i)
&& (i < 32)
&& ((mfi_buttons[joypad_info->joy_idx] & (1 << i)) != 0)
&& ((mfi_buttons[port_idx] & (1 << i)) != 0)
)
ret |= ( 1 << i);
else if (joyaxis != AXIS_NONE &&
((float)abs(apple_gamecontroller_joypad_axis(joypad_info->joy_idx, joyaxis))
((float)abs(apple_gamecontroller_joypad_axis(port_idx, joyaxis))
/ 0x8000) > joypad_info->axis_threshold)
ret |= (1 << i);
}

View File

@ -353,10 +353,11 @@ static int16_t parport_joypad_state(
{
unsigned i;
int16_t ret = 0;
uint16_t port_idx = joypad_info->joy_idx;
const struct parport_joypad *pad = (const struct parport_joypad*)
&parport_pads[joypad_info->joy_idx];
&parport_pads[port_idx];
if (joypad_info->joy_idx >= DEFAULT_MAX_PADS)
if (port_idx >= DEFAULT_MAX_PADS)
return 0;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)

View File

@ -137,8 +137,9 @@ static int16_t ps2_joypad_state(
{
unsigned i;
int16_t ret = 0;
uint16_t port_idx = joypad_info->joy_idx;
if (joypad_info->joy_idx >= DEFAULT_MAX_PADS)
if (port_idx >= DEFAULT_MAX_PADS)
return 0;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
@ -150,11 +151,11 @@ static int16_t ps2_joypad_state(
? binds[i].joyaxis : joypad_info->auto_binds[i].joyaxis;
if (
(uint16_t)joykey != NO_BTN
&& pad_state[joypad_info->joy_idx] & (UINT64_C(1) << joykey)
&& pad_state[port_idx] & (UINT64_C(1) << joykey)
)
ret |= ( 1 << i);
else if (joyaxis != AXIS_NONE &&
((float)abs(ps2_joypad_axis_state(joypad_info->joy_idx, joyaxis))
((float)abs(ps2_joypad_axis_state(port_idx, joyaxis))
/ 0x8000) > joypad_info->axis_threshold)
ret |= (1 << i);
}

View File

@ -131,8 +131,9 @@ static int16_t ps3_joypad_state(
{
unsigned i;
int16_t ret = 0;
uint16_t port_idx = joypad_info->joy_idx;
if (joypad_info->joy_idx >= DEFAULT_MAX_PADS)
if (port_idx >= DEFAULT_MAX_PADS)
return 0;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
@ -144,11 +145,11 @@ static int16_t ps3_joypad_state(
? binds[i].joyaxis : joypad_info->auto_binds[i].joyaxis;
if (
(uint16_t)joykey != NO_BTN
&& pad_state[joypad_info->joy_idx] & (UINT64_C(1) << (uint16_t)joykey)
&& pad_state[port_idx] & (UINT64_C(1) << (uint16_t)joykey)
)
ret |= ( 1 << i);
else if (joyaxis != AXIS_NONE &&
((float)abs(ps3_joypad_axis_state(joypad_info->joy_idx, joyaxis))
((float)abs(ps3_joypad_axis_state(port_idx, joyaxis))
/ 0x8000) > joypad_info->axis_threshold)
ret |= (1 << i);
}

View File

@ -150,8 +150,9 @@ static int16_t ps4_joypad_state(
{
unsigned i;
int16_t ret = 0;
uint16_t port_idx = joypad_info->joy_idx;
if (joypad_info->joy_idx >= PS4_MAX_ORBISPADS)
if (port_idx >= PS4_MAX_ORBISPADS)
return 0;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
@ -161,7 +162,7 @@ static int16_t ps4_joypad_state(
? binds[i].joykey : joypad_info->auto_binds[i].joykey;
if (
(uint16_t)joykey != NO_BTN
&& pad_state[joypad_info->joy_idx] & (UINT64_C(1) << (uint16_t)joykey)
&& pad_state[port_idx] & (UINT64_C(1) << (uint16_t)joykey)
)
ret |= ( 1 << i);
}

View File

@ -184,8 +184,9 @@ static int16_t psp_joypad_state(
{
unsigned i;
int16_t ret = 0;
uint16_t port_idx = joypad_info->joy_idx;
if (joypad_info->joy_idx >= DEFAULT_MAX_PADS)
if (port_idx >= DEFAULT_MAX_PADS)
return 0;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
@ -197,11 +198,11 @@ static int16_t psp_joypad_state(
? binds[i].joyaxis : joypad_info->auto_binds[i].joyaxis;
if (
(uint16_t)joykey != NO_BTN
&& (pad_state[joypad_info->joy_idx] & (UINT64_C(1) << (uint16_t)joykey))
&& (pad_state[port_idx] & (UINT64_C(1) << (uint16_t)joykey))
)
ret |= ( 1 << i);
else if (joyaxis != AXIS_NONE &&
((float)abs(psp_joypad_axis_state(joypad_info->joy_idx, joyaxis))
((float)abs(psp_joypad_axis_state(port_idx, joyaxis))
/ 0x8000) > joypad_info->axis_threshold)
ret |= (1 << i);
}

View File

@ -116,9 +116,11 @@ static int16_t qnx_joypad_state(
int16_t ret = 0;
qnx_input_t *qnx = (qnx_input_t*)input_driver_get_data();
qnx_input_device_t* controller = NULL;
if (!qnx || joypad_info->joy_idx >= DEFAULT_MAX_PADS)
uint16_t port_idx = joypad_info->joy_idx;
if (!qnx || port_idx >= DEFAULT_MAX_PADS)
return 0;
controller = (qnx_input_device_t*)&qnx->devices[joypad_info->joy_idx];
controller = (qnx_input_device_t*)&qnx->devices[port_idx];
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
@ -134,7 +136,7 @@ static int16_t qnx_joypad_state(
)
ret |= ( 1 << i);
else if (joyaxis != AXIS_NONE &&
((float)abs(qnx_joypad_axis_state(qnx, controller, joypad_info->joy_idx, joyaxis))
((float)abs(qnx_joypad_axis_state(qnx, controller, port_idx, joyaxis))
/ 0x8000) > joypad_info->axis_threshold)
ret |= (1 << i);
}

View File

@ -172,11 +172,12 @@ static int16_t rwebpad_joypad_state(
unsigned i;
EmscriptenGamepadEvent gamepad_state;
int16_t ret = 0;
uint16_t port_idx = joypad_info->joy_idx;
EMSCRIPTEN_RESULT r = emscripten_get_gamepad_status(
joypad_info->joy_idx, &gamepad_state);
port_idx, &gamepad_state);
if (r != EMSCRIPTEN_RESULT_SUCCESS)
return 0;
if (joypad_info->joy_idx >= DEFAULT_MAX_PADS)
if (port_idx >= DEFAULT_MAX_PADS)
return 0;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
@ -194,7 +195,7 @@ static int16_t rwebpad_joypad_state(
ret |= ( 1 << i);
else if (joyaxis != AXIS_NONE &&
((float)abs(rwebpad_joypad_axis_state(
&gamepad_state, joypad_info->joy_idx, joyaxis))
&gamepad_state, port_idx, joyaxis))
/ 0x8000) > joypad_info->axis_threshold)
ret |= (1 << i);
}

View File

@ -379,11 +379,12 @@ static int16_t sdl_joypad_state(
{
unsigned i;
int16_t ret = 0;
sdl_joypad_t *pad = (sdl_joypad_t*)&sdl_pads[joypad_info->joy_idx];
uint16_t port_idx = joypad_info->joy_idx;
sdl_joypad_t *pad = (sdl_joypad_t*)&sdl_pads[port_idx];
if (!pad || !pad->joypad)
return 0;
if (joypad_info->joy_idx >= DEFAULT_MAX_PADS)
if (port_idx >= DEFAULT_MAX_PADS)
return 0;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
@ -395,11 +396,11 @@ static int16_t sdl_joypad_state(
? binds[i].joyaxis : joypad_info->auto_binds[i].joyaxis;
if (
(uint16_t)joykey != NO_BTN
&& sdl_joypad_button_state(pad, joypad_info->joy_idx, (uint16_t)joykey)
&& sdl_joypad_button_state(pad, port_idx, (uint16_t)joykey)
)
ret |= ( 1 << i);
else if (joyaxis != AXIS_NONE &&
((float)abs(sdl_joypad_axis_state(pad, joypad_info->joy_idx, joyaxis))
((float)abs(sdl_joypad_axis_state(pad, port_idx, joyaxis))
/ 0x8000) > joypad_info->axis_threshold)
ret |= (1 << i);
}

View File

@ -155,8 +155,9 @@ static int16_t switch_joypad_state(
{
unsigned i;
int16_t ret = 0;
uint16_t port_idx = joypad_info->joy_idx;
if (joypad_info->joy_idx >= DEFAULT_MAX_PADS)
if (port_idx >= DEFAULT_MAX_PADS)
return 0;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
@ -168,11 +169,11 @@ static int16_t switch_joypad_state(
? binds[i].joyaxis : joypad_info->auto_binds[i].joyaxis;
if (
(uint16_t)joykey != NO_BTN
&& (pad_state[joypad_info->joy_idx] & (1 << (uint16_t)joykey))
&& (pad_state[port_idx] & (1 << (uint16_t)joykey))
)
ret |= ( 1 << i);
else if (joyaxis != AXIS_NONE &&
((float)abs(switch_joypad_axis_state(joypad_info->joy_idx, joyaxis))
((float)abs(switch_joypad_axis_state(port_idx, joyaxis))
/ 0x8000) > joypad_info->axis_threshold)
ret |= (1 << i);
}

View File

@ -689,10 +689,11 @@ static int16_t udev_joypad_state(
{
unsigned i;
int16_t ret = 0;
uint16_t port_idx = joypad_info->joy_idx;
const struct udev_joypad *pad = (const struct udev_joypad*)
&udev_pads[joypad_info->joy_idx];
&udev_pads[port_idx];
if (joypad_info->joy_idx >= DEFAULT_MAX_PADS)
if (port_idx >= DEFAULT_MAX_PADS)
return 0;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
@ -704,11 +705,11 @@ static int16_t udev_joypad_state(
? binds[i].joyaxis : joypad_info->auto_binds[i].joyaxis;
if (
(uint16_t)joykey != NO_BTN
&& udev_joypad_button_state(pad, joypad_info->joy_idx, (uint16_t)joykey)
&& udev_joypad_button_state(pad, port_idx, (uint16_t)joykey)
)
ret |= ( 1 << i);
else if (joyaxis != AXIS_NONE &&
((float)abs(udev_joypad_axis_state(pad, joypad_info->joy_idx, joyaxis))
((float)abs(udev_joypad_axis_state(pad, port_idx, joyaxis))
/ 0x8000) > joypad_info->axis_threshold)
ret |= (1 << i);
}

View File

@ -87,8 +87,9 @@ static int16_t hidpad_state(
{
unsigned i;
int16_t ret = 0;
uint16_t port_idx = joypad_info->joy_idx;
if (!hidpad_query_pad(port))
if (!hidpad_query_pad(port_idx))
return 0;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
@ -100,11 +101,11 @@ static int16_t hidpad_state(
? binds[i].joyaxis : joypad_info->auto_binds[i].joyaxis;
if (
(uint16_t)joykey != NO_BTN
&& HID_BUTTON(port, (uint16_t)joykey)
&& HID_BUTTON(port_idx, (uint16_t)joykey)
)
ret |= ( 1 << i);
else if (joyaxis != AXIS_NONE &&
((float)abs(HID_AXIS(port, joyaxis))
((float)abs(HID_AXIS(port_idx, joyaxis))
/ 0x8000) > joypad_info->axis_threshold)
ret |= (1 << i);
}

View File

@ -140,6 +140,7 @@ static int16_t kpad_state(
{
unsigned i;
int16_t ret = 0;
uint16_t port_idx = joypad_info->joy_idx;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
@ -150,11 +151,10 @@ static int16_t kpad_state(
? binds[i].joyaxis : joypad_info->auto_binds[i].joyaxis;
if (
(uint16_t)joykey != NO_BTN
&& kpad_button(
port, (uint16_t)joykey))
&& kpad_button(port_idx, (uint16_t)joykey))
ret |= ( 1 << i);
else if (joyaxis != AXIS_NONE &&
((float)abs(kpad_axis(port, joyaxis))
((float)abs(kpad_axis(port_idx, joyaxis))
/ 0x8000) > joypad_info->axis_threshold)
ret |= (1 << i);
}

View File

@ -329,6 +329,7 @@ static int16_t wpad_state(
{
unsigned i;
int16_t ret = 0;
uint16_t port_idx = joypad_info->joy_idx;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
@ -339,11 +340,10 @@ static int16_t wpad_state(
? binds[i].joyaxis : joypad_info->auto_binds[i].joyaxis;
if (
(uint16_t)joykey != NO_BTN
&& wpad_button(
port, (uint16_t)joykey))
&& wpad_button(port_idx, (uint16_t)joykey))
ret |= ( 1 << i);
else if (joyaxis != AXIS_NONE &&
((float)abs(wpad_axis(port, joyaxis))
((float)abs(wpad_axis(port_idx, joyaxis))
/ 0x8000) > joypad_info->axis_threshold)
ret |= (1 << i);
}

View File

@ -91,10 +91,11 @@ static int16_t wiiu_joypad_state(
{
unsigned i;
int16_t ret = 0;
uint16_t port_idx = joypad_info->joy_idx;
if (!wiiu_joypad_query_pad(joypad_info->joy_idx))
if (!wiiu_joypad_query_pad(port_idx))
return 0;
if (joypad_info->joy_idx >= DEFAULT_MAX_PADS)
if (port_idx >= DEFAULT_MAX_PADS)
return 0;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
@ -106,11 +107,11 @@ static int16_t wiiu_joypad_state(
? binds[i].joyaxis : joypad_info->auto_binds[i].joyaxis;
if (
(uint16_t)joykey != NO_BTN
&& (pad_drivers[port]->button(joypad_info->joy_idx, (uint16_t)joykey))
&& (pad_drivers[port]->button(port_idx, (uint16_t)joykey))
)
ret |= ( 1 << i);
else if (joyaxis != AXIS_NONE &&
((float)abs(pad_drivers[port]->axis(joypad_info->joy_idx, joyaxis))
((float)abs(pad_drivers[port]->axis(port_idx, joyaxis))
/ 0x8000) > joypad_info->axis_threshold)
ret |= (1 << i);
}

View File

@ -239,11 +239,12 @@ static int16_t xdk_joypad_state(
int16_t ret = 0;
XINPUT_GAMEPAD *pad = NULL;
uint16_t btn_word = 0;
uint16_t port_idx = joypad_info->joy_idx;
if (joypad_info->joy_idx >= DEFAULT_MAX_PADS)
if (port_idx >= DEFAULT_MAX_PADS)
return 0;
pad = &(g_xinput_states[joypad_info->joy_idx].xstate.Gamepad);
pad = &(g_xinput_states[port_idx].xstate.Gamepad);
btn_word = pad->wButtons;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
@ -256,10 +257,10 @@ static int16_t xdk_joypad_state(
if (
(uint16_t)joykey != NO_BTN
&& xdk_joypad_button_state(
pad, btn_word, joypad_info->joy_idx, (uint16_t)joykey))
pad, btn_word, port_idx, (uint16_t)joykey))
ret |= ( 1 << i);
else if (joyaxis != AXIS_NONE &&
((float)abs(xdk_joypad_axis_state(pad, joypad_info->joy_idx, joyaxis))
((float)abs(xdk_joypad_axis_state(pad, port_idx, joyaxis))
/ 0x8000) > joypad_info->axis_threshold)
ret |= (1 << i);
}

View File

@ -524,11 +524,12 @@ static int16_t xinput_joypad_state_func(
unsigned i;
uint16_t btn_word;
int16_t ret = 0;
int xuser = pad_index_to_xuser_index(joypad_info->joy_idx);
uint16_t port_idx = joypad_info->joy_idx;
int xuser = pad_index_to_xuser_index(port_idx);
XINPUT_GAMEPAD *pad = &(g_xinput_states[xuser].xstate.Gamepad);
#ifdef HAVE_DINPUT
if (xuser == -1)
return dinput_joypad.state(joypad_info, binds, joypad_info->joy_idx);
return dinput_joypad.state(joypad_info, binds, port_idx);
#endif
if (!(g_xinput_states[xuser].connected))
return 0;
@ -544,10 +545,10 @@ static int16_t xinput_joypad_state_func(
if (
(uint16_t)joykey != NO_BTN
&& xinput_joypad_button_state(
xuser, btn_word, joypad_info->joy_idx, (uint16_t)joykey))
xuser, btn_word, port_idx, (uint16_t)joykey))
ret |= ( 1 << i);
else if (joyaxis != AXIS_NONE &&
((float)abs(xinput_joypad_axis_state(pad, joypad_info->joy_idx, joyaxis))
((float)abs(xinput_joypad_axis_state(pad, port_idx, joyaxis))
/ 0x8000) > joypad_info->axis_threshold)
ret |= (1 << i);
}