Optimal way of grabbing all button states in a bitmasked value -

should allow us to do only one function call to the RA input
driver's input state callback
This commit is contained in:
twinaphex 2019-06-23 06:09:45 +02:00
parent eaf221125a
commit 1e863b0f4d
23 changed files with 401 additions and 81 deletions

View File

@ -1473,19 +1473,35 @@ static int16_t android_input_state(void *data,
switch (device)
{
case RETRO_DEVICE_KEYBOARD:
return (id < RETROK_LAST) && BIT_GET(android_key_state[ANDROID_KEYBOARD_PORT], rarch_keysym_lut[id]);
case RETRO_DEVICE_JOYPAD:
ret = input_joypad_pressed(android->joypad, joypad_info,
port, binds[port], id);
if (!ret && (id < RARCH_BIND_LIST_END))
ret = android_keyboard_port_input_pressed(binds[port],id);
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
{
unsigned i;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
bool res = input_joypad_pressed(android->joypad, joypad_info,
port, binds[port], i);
if (!res)
res = android_keyboard_port_input_pressed(binds[port], i);
if (res)
ret |= (1 << i);
}
}
else
{
ret = input_joypad_pressed(android->joypad, joypad_info,
port, binds[port], id);
if (!ret && (id < RARCH_BIND_LIST_END))
ret = android_keyboard_port_input_pressed(binds[port],id);
}
return ret;
case RETRO_DEVICE_ANALOG:
if (binds[port])
return input_joypad_analog(android->joypad, joypad_info,
port, idx, id, binds[port]);
break;
case RETRO_DEVICE_KEYBOARD:
return (id < RETROK_LAST) && BIT_GET(android_key_state[ANDROID_KEYBOARD_PORT], rarch_keysym_lut[id]);
case RETRO_DEVICE_MOUSE:
ret = android_mouse_state(android, id);
return ret;

View File

@ -52,7 +52,8 @@ static int16_t ctr_input_state(void *data,
unsigned port, unsigned device,
unsigned idx, unsigned id)
{
ctr_input_t *ctr = (ctr_input_t*)data;
int16_t ret = 0;
ctr_input_t *ctr = (ctr_input_t*)data;
if (port > 0)
return 0;
@ -60,8 +61,20 @@ static int16_t ctr_input_state(void *data,
switch (device)
{
case RETRO_DEVICE_JOYPAD:
return input_joypad_pressed(ctr->joypad,
joypad_info, port, binds[port], id);
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
{
unsigned i;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
if (input_joypad_pressed(ctr->joypad,
joypad_info, port, binds[port], i))
ret |= (1 << i);
}
}
else
ret = input_joypad_pressed(ctr->joypad,
joypad_info, port, binds[port], id);
return ret;
case RETRO_DEVICE_ANALOG:
if (binds[port])
return input_joypad_analog(ctr->joypad,

View File

@ -590,15 +590,28 @@ static int16_t dinput_input_state(void *data,
const struct retro_keybind **binds, unsigned port,
unsigned device, unsigned idx, unsigned id)
{
int16_t ret;
int16_t ret = 0;
struct dinput_input *di = (struct dinput_input*)data;
switch (device)
{
case RETRO_DEVICE_JOYPAD:
if (id < RARCH_BIND_LIST_END)
return dinput_is_pressed(di, joypad_info, binds[port], port, id);
break;
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
{
unsigned i;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
if (dinput_is_pressed(di, joypad_info, binds[port], port,
i))
ret |= (1 << i);
}
}
else
{
if (id < RARCH_BIND_LIST_END)
ret = dinput_is_pressed(di, joypad_info, binds[port], port, id);
}
return ret;
case RETRO_DEVICE_KEYBOARD:
return (id < RETROK_LAST) && di->state[
rarch_keysym_lut[(enum retro_key)id]] & 0x80;

View File

@ -73,7 +73,8 @@ static int16_t dos_input_state(void *data,
unsigned port, unsigned device,
unsigned idx, unsigned id)
{
dos_input_t *dos = (dos_input_t*)data;
int16_t ret = 0;
dos_input_t *dos = (dos_input_t*)data;
if (port > 0)
return 0;
@ -81,8 +82,24 @@ static int16_t dos_input_state(void *data,
switch (device)
{
case RETRO_DEVICE_JOYPAD:
return input_joypad_pressed(dos->joypad, joypad_info, port, binds[port], id) ||
dos_keyboard_port_input_pressed(binds[port], id);
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
{
unsigned i;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
bool res = input_joypad_pressed(ctr->joypad,
joypad_info, port, binds[port], i);
if (!res)
res = dos_keyboard_port_input_pressed(binds[port], i);
if (res)
ret |= (1 << i);
}
}
else
ret = input_joypad_pressed(
dos->joypad, joypad_info, port, binds[port], id) ||
dos_keyboard_port_input_pressed(binds[port], id);
return ret;
case RETRO_DEVICE_KEYBOARD:
return dos_keyboard_port_input_pressed(binds[port], id);
}

View File

@ -54,6 +54,19 @@ static int16_t gx_input_state(void *data,
switch (device)
{
case RETRO_DEVICE_JOYPAD:
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
{
unsigned i;
int16_t ret = 0;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
if (input_joypad_pressed(gx->joypad, joypad_info,
port, binds[port], i))
ret |= (1 << i);
}
return ret;
}
return input_joypad_pressed(gx->joypad,
joypad_info, port, binds[port], id);
case RETRO_DEVICE_ANALOG:

View File

@ -1,6 +1,6 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2017 - Daniel De Matteis
* Copyright (C) 2011-2019 - Daniel De Matteis
* Copyright (C) 2012-2015 - Michael Lelli
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
@ -107,12 +107,31 @@ static int16_t linuxraw_input_state(void *data,
switch (device)
{
case RETRO_DEVICE_JOYPAD:
ret = ((id < RARCH_BIND_LIST_END) && binds[port]->valid &&
linuxraw->state[rarch_keysym_lut[(enum retro_key)binds[port][id].key]]
);
if (!ret)
ret = input_joypad_pressed(linuxraw->joypad,
joypad_info, port, binds[port], id);
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
{
unsigned i;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
bool res = (binds[port]->valid &&
linuxraw->state[rarch_keysym_lut[
(enum retro_key)binds[port][i].key]]
);
if (!res)
res = input_joypad_pressed(linuxraw->joypad,
joypad_info, port, binds[port], i);
if (res)
ret |= (1 << i);
}
}
else
{
ret = ((id < RARCH_BIND_LIST_END) && binds[port]->valid &&
linuxraw->state[rarch_keysym_lut[(enum retro_key)binds[port][id].key]]
);
if (!ret)
ret = input_joypad_pressed(linuxraw->joypad,
joypad_info, port, binds[port], id);
}
return ret;
case RETRO_DEVICE_ANALOG:
ret = linuxraw_analog_pressed(linuxraw, binds[port], idx, id);

View File

@ -48,12 +48,25 @@ static int16_t ps2_input_state(void *data,
unsigned port, unsigned device,
unsigned idx, unsigned id)
{
int16_t ret = 0;
ps2_input_t *ps2 = (ps2_input_t*)data;
switch (device)
{
case RETRO_DEVICE_JOYPAD:
return input_joypad_pressed(ps2->joypad, joypad_info, port, binds[port], id);
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
{
unsigned i;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
if (input_joypad_pressed(
ps2->joypad, joypad_info, port, binds[port], i))
ret |= (1 << i);
}
}
else
ret = input_joypad_pressed(ps2->joypad, joypad_info, port, binds[port], id);
return ret;
case RETRO_DEVICE_ANALOG:
if (binds[port])
return input_joypad_analog(ps2->joypad, joypad_info, port, idx, id, binds[port]);

View File

@ -107,6 +107,7 @@ static int16_t ps3_input_state(void *data,
unsigned port, unsigned device,
unsigned idx, unsigned id)
{
int16_t ret = 0;
ps3_input_t *ps3 = (ps3_input_t*)data;
if (!ps3)
@ -115,7 +116,19 @@ static int16_t ps3_input_state(void *data,
switch (device)
{
case RETRO_DEVICE_JOYPAD:
return input_joypad_pressed(ps3->joypad, joypad_info, port, binds[port], id);
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
{
unsigned i;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
if (input_joypad_pressed(
ps3->joypad, joypad_info, port, binds[port], i))
ret |= (1 << i);
}
}
else
ret = input_joypad_pressed(ps3->joypad, joypad_info, port, binds[port], id);
return ret;
case RETRO_DEVICE_ANALOG:
if (binds[port])
return input_joypad_analog(ps3->joypad, joypad_info, port, idx, id, binds[port]);

View File

@ -52,12 +52,25 @@ static int16_t ps4_input_state(void *data,
unsigned port, unsigned device,
unsigned idx, unsigned id)
{
int16_t ret = 0;
ps4_input_t *ps4 = (ps4_input_t*)data;
switch (device)
{
case RETRO_DEVICE_JOYPAD:
return input_joypad_pressed(ps4->joypad, joypad_info, port, binds[port], id);
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
{
unsigned i;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
if (input_joypad_pressed(
ps4->joypad, joypad_info, port, binds[port], i))
ret |= (1 << i);
}
}
else
ret = input_joypad_pressed(ps4->joypad, joypad_info, port, binds[port], id);
return ret;
case RETRO_DEVICE_ANALOG:
if (binds[port])
return input_joypad_analog(ps4->joypad, joypad_info, port, idx, id, binds[port]);

View File

@ -302,6 +302,7 @@ static int16_t psp_input_state(void *data,
unsigned port, unsigned device,
unsigned idx, unsigned id)
{
int16_t ret = 0;
psp_input_t *psp = (psp_input_t*)data;
#if !defined(SN_TARGET_PSP2) && !defined(VITA)
@ -312,7 +313,19 @@ static int16_t psp_input_state(void *data,
switch (device)
{
case RETRO_DEVICE_JOYPAD:
return input_joypad_pressed(psp->joypad, joypad_info, port, binds[port], id);
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
{
unsigned i;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
if (input_joypad_pressed(
psp->joypad, joypad_info, port, binds[port], i))
ret |= (1 << i);
}
}
else
ret = input_joypad_pressed(psp->joypad, joypad_info, port, binds[port], id);
return ret;
case RETRO_DEVICE_ANALOG:
if (binds[port])
return input_joypad_analog(psp->joypad, joypad_info, port, idx, id, binds[port]);

View File

@ -786,12 +786,25 @@ static int16_t qnx_input_state(void *data,
const struct retro_keybind **binds,
unsigned port, unsigned device, unsigned idx, unsigned id)
{
qnx_input_t *qnx = (qnx_input_t*)data;
int16_t ret = 0;
qnx_input_t *qnx = (qnx_input_t*)data;
switch (device)
{
case RETRO_DEVICE_JOYPAD:
return qnx_is_pressed(qnx, joypad_info, binds[port], port, id);
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
{
unsigned i;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
if (qnx_is_pressed(
qnx, joypad_info, port, binds[port], i))
ret |= (1 << i);
}
}
else
ret = qnx_is_pressed(qnx, joypad_info, port, binds[port], id);
return ret;
case RETRO_DEVICE_KEYBOARD:
return qnx_keyboard_pressed(qnx, id);
case RETRO_DEVICE_POINTER:

View File

@ -521,16 +521,29 @@ static int16_t rwebinput_input_state(void *data,
const struct retro_keybind **binds,
unsigned port, unsigned device, unsigned idx, unsigned id)
{
int16_t ret;
int16_t ret = 0;
rwebinput_input_t *rwebinput = (rwebinput_input_t*)data;
switch (device)
{
case RETRO_DEVICE_JOYPAD:
if (id < RARCH_BIND_LIST_END)
return rwebinput_is_pressed(rwebinput, joypad_info, binds[port],
port, id);
break;
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
{
unsigned i;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
if (rwebinput_is_pressed(
rwebinput, joypad_info, port, binds[port], i))
ret |= (1 << i);
}
}
else
{
if (id < RARCH_BIND_LIST_END)
ret = rwebinput_is_pressed(rwebinput, joypad_info, binds[port],
port, id);
}
return ret;
case RETRO_DEVICE_ANALOG:
ret = rwebinput_analog_pressed(rwebinput, joypad_info, binds[port],
idx, id);

View File

@ -211,16 +211,30 @@ static int16_t sdl_input_state(void *data,
const struct retro_keybind **binds,
unsigned port, unsigned device, unsigned idx, unsigned id)
{
int16_t ret = 0;
enum input_device_type type = INPUT_DEVICE_TYPE_NONE;
sdl_input_t *sdl = (sdl_input_t*)data;
sdl_input_t *sdl = (sdl_input_t*)data;
switch (device)
{
case RETRO_DEVICE_JOYPAD:
if (id < RARCH_BIND_LIST_END)
return sdl_joypad_device_state(sdl,
joypad_info, binds[port], port, id, &type);
break;
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
{
unsigned i;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
if (sdl_joypad_device_state(
sdl, joypad_info, binds[port], port, i, &type))
ret |= (1 << i);
}
}
else
{
if (id < RARCH_BIND_LIST_END)
ret = sdl_joypad_device_state(sdl,
joypad_info, binds[port], port, id, &type);
}
return ret;
case RETRO_DEVICE_ANALOG:
if (binds[port])
{

View File

@ -257,6 +257,7 @@ static int16_t switch_input_state(void *data,
unsigned port, unsigned device,
unsigned idx, unsigned id)
{
int16_t ret = 0;
switch_input_t *sw = (switch_input_t*) data;
if (port > MAX_PADS-1)
@ -265,9 +266,22 @@ static int16_t switch_input_state(void *data,
switch (device)
{
case RETRO_DEVICE_JOYPAD:
return input_joypad_pressed(sw->joypad,
joypad_info, port, binds[port], id);
break;
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
{
unsigned i;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
if (input_joypad_pressed(
sw->joypad, joypad_info, port, binds[port], i))
ret |= (1 << i);
}
}
else
{
ret = input_joypad_pressed(sw->joypad,
joypad_info, port, binds[port], id);
}
return ret;
case RETRO_DEVICE_ANALOG:
if (binds[port])
return input_joypad_analog(sw->joypad,

View File

@ -965,10 +965,22 @@ static int16_t udev_input_state(void *data,
switch (device)
{
case RETRO_DEVICE_JOYPAD:
if (id < RARCH_BIND_LIST_END)
return udev_is_pressed(udev, joypad_info, binds[port], port, id);
break;
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
{
unsigned i;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
if (udev_is_pressed(
udev, joypad_info, binds[port], port, i))
ret |= (1 << i);
}
}
else
{
if (id < RARCH_BIND_LIST_END)
ret = udev_is_pressed(udev, joypad_info, binds[port], port, id);
}
return ret;
case RETRO_DEVICE_ANALOG:
ret = udev_analog_pressed(binds[port], idx, id);
if (!ret && binds[port])

View File

@ -184,13 +184,28 @@ static int16_t uwp_input_state(void *data,
unsigned port, unsigned device,
unsigned index, unsigned id)
{
int16_t ret = 0;
uwp_input_t *uwp = (uwp_input_t*)data;
switch (device)
{
case RETRO_DEVICE_JOYPAD:
if (id < RARCH_BIND_LIST_END)
return uwp_pressed_joypad(uwp, joypad_info, binds[port], port, id);
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
{
unsigned i;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
if (uwp_pressed_joypad(
uwp, joypad_info, binds[port], port, i))
ret |= (1 << i);
}
}
else
{
if (id < RARCH_BIND_LIST_END)
ret = uwp_pressed_joypad(uwp, joypad_info, binds[port], port, id);
}
return ret;
case RETRO_DEVICE_ANALOG:
if (binds[port])
return uwp_pressed_analog(uwp, joypad_info, binds[port], port, index, id);

View File

@ -292,10 +292,21 @@ static int16_t input_wl_state(void *data,
switch (device)
{
case RETRO_DEVICE_JOYPAD:
if (id < RARCH_BIND_LIST_END)
ret = BIT_GET(wl->key_state, rarch_keysym_lut[binds[port][id].key]);
if (!ret && binds[port])
ret = input_joypad_pressed(wl->joypad, joypad_info, port, binds[port], id);
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
{
bool res = BIT_GET(wl->key_state, rarch_keysym_lut[binds[port][i].key]) ;
if (!res && binds[port])
res = input_joypad_pressed(wl->joypad, joypad_info, port, binds[port], i);
if (res)
ret |= (1 << i);
}
else
{
if (id < RARCH_BIND_LIST_END)
ret = BIT_GET(wl->key_state, rarch_keysym_lut[binds[port][id].key]);
if (!ret && binds[port])
ret = input_joypad_pressed(wl->joypad, joypad_info, port, binds[port], id);
}
return ret;
case RETRO_DEVICE_ANALOG:
ret = input_wl_analog_pressed(wl, binds[port], idx, id);

View File

@ -133,6 +133,7 @@ static int16_t wiiu_input_state(void *data,
unsigned port, unsigned device,
unsigned idx, unsigned id)
{
int16_t ret = 0;
wiiu_input_t *wiiu = (wiiu_input_t*)data;
if(!wiiu || !(port < MAX_PADS) || !binds || !binds[port])
@ -141,8 +142,22 @@ static int16_t wiiu_input_state(void *data,
switch (device)
{
case RETRO_DEVICE_JOYPAD:
return input_joypad_pressed(wiiu->joypad,
joypad_info, port, binds[port], id);
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
{
unsigned i;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
if (input_joypad_pressed(
wiiu->joypad, joypad_info, port, binds[port], i))
ret |= (1 << i);
}
}
else
{
ret = input_joypad_pressed(wiiu->joypad,
joypad_info, port, binds[port], id);
}
return ret;
case RETRO_DEVICE_KEYBOARD:
if (id < RETROK_LAST && keyboardState[id] && (keyboardChannel > 0))
return true;

View File

@ -695,13 +695,32 @@ static int16_t winraw_input_state(void *d,
const struct retro_keybind **binds,
unsigned port, unsigned device, unsigned index, unsigned id)
{
int16_t ret = 0;
winraw_input_t *wr = (winraw_input_t*)d;
switch (device)
{
case RETRO_DEVICE_JOYPAD:
if (id < RARCH_BIND_LIST_END)
return winraw_is_pressed(wr, joypad_info, binds[port], port, id);
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
{
unsigned i;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
if (winraw_is_pressed(
wr, joypad_info, binds[port], port, i))
ret |= (1 << i);
}
}
else
{
if (id < RARCH_BIND_LIST_END)
ret = winraw_is_pressed(wr, joypad_info, binds[port], port, id);
}
return ret;
case RETRO_DEVICE_ANALOG:
if (binds[port])
return input_joypad_analog(wr->joypad, joypad_info,
port, index, id, binds[port]);
break;
case RETRO_DEVICE_KEYBOARD:
return (id < RETROK_LAST) && winraw_keyboard_pressed(wr, id);
@ -709,11 +728,6 @@ static int16_t winraw_input_state(void *d,
return winraw_mouse_state(wr, port, false, id);
case RARCH_DEVICE_MOUSE_SCREEN:
return winraw_mouse_state(wr, port, true, id);
case RETRO_DEVICE_ANALOG:
if (binds[port])
return input_joypad_analog(wr->joypad, joypad_info,
port, index, id, binds[port]);
break;
case RETRO_DEVICE_LIGHTGUN:
switch ( id )
{

View File

@ -309,11 +309,22 @@ static int16_t x_input_state(void *data,
switch (device)
{
case RETRO_DEVICE_JOYPAD:
if (id < RARCH_BIND_LIST_END)
return x_is_pressed(x11, joypad_info, binds[port], port, id);
break;
case RETRO_DEVICE_KEYBOARD:
return (id < RETROK_LAST) && x_keyboard_pressed(x11, id);
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
{
unsigned i;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
if (x_is_pressed(
x11, joypad_info, binds[port], port, i))
ret |= (1 << i);
}
}
else
{
if (id < RARCH_BIND_LIST_END)
ret = x_is_pressed(x11, joypad_info, binds[port], port, id);
}
return ret;
case RETRO_DEVICE_ANALOG:
ret = x_pressed_analog(x11, binds[port], idx, id);
if (!ret && binds[port])
@ -321,6 +332,8 @@ static int16_t x_input_state(void *data,
port, idx,
id, binds[port]);
return ret;
case RETRO_DEVICE_KEYBOARD:
return (id < RETROK_LAST) && x_keyboard_pressed(x11, id);
case RETRO_DEVICE_MOUSE:
return x_mouse_state(x11, id);
case RARCH_DEVICE_MOUSE_SCREEN:

View File

@ -55,6 +55,7 @@ static int16_t xdk_input_state(void *data,
unsigned port, unsigned device,
unsigned index, unsigned id)
{
int16_t ret = 0;
xdk_input_t *xdk = (xdk_input_t*)data;
if (port >= MAX_PADS)
@ -63,7 +64,19 @@ static int16_t xdk_input_state(void *data,
switch (device)
{
case RETRO_DEVICE_JOYPAD:
return input_joypad_pressed(xdk->joypad, joypad_info, port, binds[port], id);
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
{
unsigned i;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
if (input_joypad_pressed(
xdk->joypad, joypad_info, port, binds[port], i))
ret |= (1 << i);
}
}
else
ret = input_joypad_pressed(xdk->joypad, joypad_info, port, binds[port], id);
return ret;
case RETRO_DEVICE_ANALOG:
if (binds[port])
return input_joypad_analog(xdk->joypad, joypad_info, port, index, id, binds[port]);

View File

@ -64,16 +64,27 @@ static int16_t xenon360_input_state(void *data,
bool port, unsigned device,
unsigned idx, unsigned id)
{
unsigned user = port;
uint64_t button = binds[user][id].joykey;
int16_t ret = 0;
uint64_t button = binds[port][id].joykey;
if (user >= MAX_PADS)
if (port >= MAX_PADS)
return 0;
switch (device)
{
case RETRO_DEVICE_JOYPAD:
return (state[user] & button) ? 1 : 0;
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
{
unsigned i;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
if (state[port] & binds[port][i].joykey)
ret |= (1 << i);
}
}
else
ret = (state[port] & binds[port][id].joykey) ? 1 : 0;
return ret;
default:
break;
}

View File

@ -2517,8 +2517,11 @@ static void input_poll(void)
#endif
}
static int16_t input_state_internal(unsigned port, unsigned device,
unsigned idx, unsigned id)
static int16_t input_state_internal(
int16_t ret,
unsigned port, unsigned device,
unsigned idx, unsigned id,
bool button_mask)
{
int16_t bsv_result;
int16_t res = 0;
@ -2601,15 +2604,24 @@ static int16_t input_state_internal(unsigned port, unsigned device,
if (bind_valid || device == RETRO_DEVICE_KEYBOARD)
{
rarch_joypad_info_t joypad_info;
joypad_info.axis_threshold = input_driver_axis_threshold;
joypad_info.joy_idx = settings->uints.input_joypad_map[port];
joypad_info.auto_binds = input_autoconf_binds[joypad_info.joy_idx];
if (!reset_state)
{
res = current_input->input_state(
current_input_data, joypad_info, libretro_input_binds, port, device, idx, id);
if (button_mask)
{
res = 0;
if (ret & (1 << id))
res |= (1 << id);
}
else
{
rarch_joypad_info_t joypad_info;
joypad_info.axis_threshold = input_driver_axis_threshold;
joypad_info.joy_idx = settings->uints.input_joypad_map[port];
joypad_info.auto_binds = input_autoconf_binds[joypad_info.joy_idx];
res = current_input->input_state(
current_input_data, joypad_info, libretro_input_binds, port, device, idx, id);
}
#ifdef HAVE_OVERLAY
if (input_overlay_is_alive(overlay_ptr) && port == 0)
@ -2677,14 +2689,21 @@ int16_t input_state(unsigned port, unsigned device,
{
unsigned i;
int16_t res = 0;
int16_t ret = 0;
rarch_joypad_info_t joypad_info;
joypad_info.axis_threshold = input_driver_axis_threshold;
joypad_info.joy_idx = configuration_settings->uints.input_joypad_map[port];
joypad_info.auto_binds = input_autoconf_binds[joypad_info.joy_idx];
ret = current_input->input_state(
current_input_data, joypad_info, libretro_input_binds, port, device, idx, id);
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
if (input_state_internal(port, device, idx, i))
if (input_state_internal(ret, port, device, idx, i, true))
res |= (1 << i);
return res;
}
return input_state_internal(port, device, idx, id);
return input_state_internal(0, port, device, idx, id, false);
}
/**