Start cutting down on input_state - move all joypad driver code up to

higher-level retroarch.c
This commit is contained in:
twinaphex 2020-09-02 15:26:03 +02:00
parent f10832b0d3
commit 1c5f4e1dee
25 changed files with 199 additions and 374 deletions

View File

@ -1337,8 +1337,7 @@ static int16_t android_input_state(
if (id == RETRO_DEVICE_ID_JOYPAD_MASK) if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
{ {
unsigned i; unsigned i;
int16_t ret = joypad->state( int16_t ret = 0;
joypad_info, binds[port], port);
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++) for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{ {
if (binds[port][i].valid) if (binds[port][i].valid)
@ -1349,19 +1348,12 @@ static int16_t android_input_state(
} }
return ret; return ret;
} }
else
{
if (binds[port][id].valid) if (binds[port][id].valid)
{ {
if ( if (ANDROID_KEYBOARD_PORT_INPUT_PRESSED(binds[port], id))
button_is_pressed(
joypad, joypad_info, binds[port],
port, id)
|| ANDROID_KEYBOARD_PORT_INPUT_PRESSED(binds[port], id)
)
return 1; return 1;
} }
}
break; break;
case RETRO_DEVICE_ANALOG: case RETRO_DEVICE_ANALOG:
break; break;

View File

@ -392,13 +392,7 @@ static int16_t cocoa_input_state(
unsigned i; unsigned i;
/* Do a bitwise OR to combine both input /* Do a bitwise OR to combine both input
* states together */ * states together */
int16_t ret = joypad->state( int16_t ret = 0;
joypad_info, binds[port], port)
#ifdef HAVE_MFI
| sec_joypad->state(
joypad_info, binds[port], port)
#endif
;
if (!keyboard_mapping_blocked) if (!keyboard_mapping_blocked)
{ {
@ -412,25 +406,13 @@ static int16_t cocoa_input_state(
} }
return ret; return ret;
} }
else
{
if (binds[port][id].valid) if (binds[port][id].valid)
{ {
if (button_is_pressed( if (id < RARCH_BIND_LIST_END)
joypad,
joypad_info, binds[port], port, id))
return 1;
#ifdef HAVE_MFI
else if (button_is_pressed(
sec_joypad,
joypad_info, binds[port], port, id))
return 1;
#endif
else if (id < RARCH_BIND_LIST_END)
if (apple_key_state[rarch_keysym_lut[binds[port][id].key]]) if (apple_key_state[rarch_keysym_lut[binds[port][id].key]])
return 1; return 1;
} }
}
break; break;
case RETRO_DEVICE_ANALOG: case RETRO_DEVICE_ANALOG:
break; break;

View File

@ -47,26 +47,6 @@ static int16_t ctr_input_state(
unsigned idx, unsigned idx,
unsigned id) unsigned id)
{ {
if (port >= MENU_ENUM_LABEL_VALUE_INPUT_MAX_USERS)
return 0;
switch (device)
{
case RETRO_DEVICE_JOYPAD:
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
return joypad->state(
joypad_info, binds[port], port);
if (id < RARCH_BIND_LIST_END)
if (binds[port][id].valid)
if (button_is_pressed(
joypad, joypad_info, binds[port], port, id))
return 1;
break;
case RETRO_DEVICE_ANALOG:
break;
}
return 0; return 0;
} }

View File

@ -412,8 +412,7 @@ static int16_t dinput_input_state(
if (id == RETRO_DEVICE_ID_JOYPAD_MASK) if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
{ {
unsigned i; unsigned i;
int16_t ret = joypad->state( int16_t ret = 0;
joypad_info, binds[port], port);
if (settings->uints.input_mouse_index[port] == 0) if (settings->uints.input_mouse_index[port] == 0)
{ {
@ -444,17 +443,12 @@ static int16_t dinput_input_state(
} }
return ret; return ret;
} }
else
{
if (id < RARCH_BIND_LIST_END) if (id < RARCH_BIND_LIST_END)
{ {
if (binds[port][id].valid) if (binds[port][id].valid)
{ {
if (button_is_pressed( if (binds[port][id].key < RETROK_LAST
joypad,
joypad_info, binds[port], port, id))
return 1;
else if (binds[port][id].key < RETROK_LAST
&& (di->state[rarch_keysym_lut && (di->state[rarch_keysym_lut
[(enum retro_key)binds[port][id].key]] & 0x80) [(enum retro_key)binds[port][id].key]] & 0x80)
&& ( (id == RARCH_GAME_FOCUS_TOGGLE) && ( (id == RARCH_GAME_FOCUS_TOGGLE)
@ -470,7 +464,6 @@ static int16_t dinput_input_state(
} }
} }
} }
}
break; break;
case RETRO_DEVICE_KEYBOARD: case RETRO_DEVICE_KEYBOARD:
return (id < RETROK_LAST) && return (id < RETROK_LAST) &&

View File

@ -75,8 +75,7 @@ static int16_t dos_input_state(
if (id == RETRO_DEVICE_ID_JOYPAD_MASK) if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
{ {
unsigned i; unsigned i;
int16_t ret = joypad->state( int16_t ret = 0;
joypad_info, binds[port], port);
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++) for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{ {
@ -91,21 +90,16 @@ static int16_t dos_input_state(
return ret; return ret;
} }
else
{
if (binds[port][id].valid) if (binds[port][id].valid)
{ {
if ( if (
button_is_pressed( (id < RARCH_BIND_LIST_END
joypad, joypad_info, binds[port],
port, id)
|| (id < RARCH_BIND_LIST_END
&& dos_key_state[DOS_KEYBOARD_PORT] && dos_key_state[DOS_KEYBOARD_PORT]
[rarch_keysym_lut[binds[port][id].key]]) [rarch_keysym_lut[binds[port][id].key]])
) )
return 1; return 1;
} }
}
break; break;
case RETRO_DEVICE_KEYBOARD: case RETRO_DEVICE_KEYBOARD:
if (id < RARCH_BIND_LIST_END) if (id < RARCH_BIND_LIST_END)

View File

@ -78,16 +78,6 @@ static int16_t gx_input_state(
switch (device) switch (device)
{ {
case RETRO_DEVICE_JOYPAD: case RETRO_DEVICE_JOYPAD:
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
return joypad->state(
joypad_info, binds[port], port);
if (binds[port][id].valid)
if (
button_is_pressed(joypad, joypad_info, binds[port],
port, id))
return 1;
break;
case RETRO_DEVICE_ANALOG: case RETRO_DEVICE_ANALOG:
break; break;
#ifdef HW_RVL #ifdef HW_RVL

View File

@ -92,8 +92,7 @@ static int16_t linuxraw_input_state(
if (id == RETRO_DEVICE_ID_JOYPAD_MASK) if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
{ {
unsigned i; unsigned i;
int16_t ret = joypad->state( int16_t ret = 0;
joypad_info, binds[port], port);
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++) for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{ {
@ -109,25 +108,17 @@ static int16_t linuxraw_input_state(
return ret; return ret;
} }
else
{
if (id < RARCH_BIND_LIST_END) if (id < RARCH_BIND_LIST_END)
{ {
if (binds[port][id].valid) if (binds[port][id].valid)
{ {
if ( if ((linuxraw->state[rarch_keysym_lut
button_is_pressed(
joypad, joypad_info, binds[port],
port, id)
)
return 1;
else if ((linuxraw->state[rarch_keysym_lut
[(enum retro_key)binds[port][id].key]] [(enum retro_key)binds[port][id].key]]
)) ))
return 1; return 1;
} }
} }
}
break; break;
case RETRO_DEVICE_ANALOG: case RETRO_DEVICE_ANALOG:
if (binds[port]) if (binds[port])

View File

@ -43,22 +43,6 @@ static int16_t ps2_input_state(
unsigned idx, unsigned idx,
unsigned id) unsigned id)
{ {
switch (device)
{
case RETRO_DEVICE_JOYPAD:
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
return joypad->state(
joypad_info, binds[port], port);
if (binds[port][id].valid)
if (button_is_pressed(joypad, joypad_info, binds[port],
port, id))
return 1;
break;
case RETRO_DEVICE_ANALOG:
break;
}
return 0; return 0;
} }

View File

@ -109,16 +109,6 @@ static int16_t ps3_input_state(
switch (device) switch (device)
{ {
case RETRO_DEVICE_JOYPAD: case RETRO_DEVICE_JOYPAD:
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
return joypad->state(
joypad_info, binds[port], port);
if (binds[port][id].valid)
if (button_is_pressed(joypad, joypad_info, binds[port],
port, id))
return 1;
break;
case RETRO_DEVICE_ANALOG: case RETRO_DEVICE_ANALOG:
break; break;
#if 0 #if 0

View File

@ -49,23 +49,6 @@ static int16_t ps4_input_state(
unsigned idx, unsigned idx,
unsigned id) unsigned id)
{ {
switch (device)
{
case RETRO_DEVICE_JOYPAD:
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
return joypad->state(
joypad_info, binds[port], port);
if (binds[port][id].valid)
if (
button_is_pressed(joypad, joypad_info, binds[port],
port, id))
return 1;
break;
case RETRO_DEVICE_ANALOG:
break;
}
return 0; return 0;
} }

View File

@ -234,8 +234,7 @@ static int16_t ps3_input_state(
if (id == RETRO_DEVICE_ID_JOYPAD_MASK) if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
{ {
unsigned i; unsigned i;
int16_t ret = joypad->state( int16_t ret = 0;
joypad_info, binds[port], port);
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++) for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{ {
@ -249,19 +248,13 @@ static int16_t ps3_input_state(
return ret; return ret;
} }
else
{
if (binds[port][id].valid) if (binds[port][id].valid)
{ {
if ( if (psl1ght_keyboard_port_input_pressed(
button_is_pressed(joypad, joypad_info, binds[port],
port, id))
return 1;
else if (psl1ght_keyboard_port_input_pressed(
ps3, binds[port][id].key)) ps3, binds[port][id].key))
return 1; return 1;
} }
}
break; break;
case RETRO_DEVICE_ANALOG: case RETRO_DEVICE_ANALOG:
break; break;

View File

@ -260,16 +260,6 @@ static int16_t psp_input_state(
switch (device) switch (device)
{ {
case RETRO_DEVICE_JOYPAD: case RETRO_DEVICE_JOYPAD:
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
return joypad->state(
joypad_info, binds[port], port);
if (binds[port][id].valid)
if (
button_is_pressed(joypad, joypad_info, binds[port],
port, id))
return 1;
break;
case RETRO_DEVICE_ANALOG: case RETRO_DEVICE_ANALOG:
break; break;
#ifdef VITA #ifdef VITA

View File

@ -789,8 +789,7 @@ static int16_t qnx_input_state(
if (id == RETRO_DEVICE_ID_JOYPAD_MASK) if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
{ {
unsigned i; unsigned i;
int16_t ret = joypad->state( int16_t ret = 0;
joypad_info, binds[port], port);
if (!keyboard_mapping_blocked) if (!keyboard_mapping_blocked)
{ {
@ -806,16 +805,12 @@ static int16_t qnx_input_state(
return ret; return ret;
} }
else
{
if (id < RARCH_BIND_LIST_END) if (id < RARCH_BIND_LIST_END)
{ {
if (binds[port][id].valid) if (binds[port][id].valid)
{ {
if (button_is_pressed(joypad, if (
joypad_info, binds[port], port, id))
return 1;
else if (
((id == RARCH_GAME_FOCUS_TOGGLE) || ((id == RARCH_GAME_FOCUS_TOGGLE) ||
!keyboard_mapping_blocked) && !keyboard_mapping_blocked) &&
qnx_keyboard_pressed(qnx, key) qnx_keyboard_pressed(qnx, key)
@ -823,7 +818,6 @@ static int16_t qnx_input_state(
return 1; return 1;
} }
} }
}
break; break;
case RETRO_DEVICE_ANALOG: case RETRO_DEVICE_ANALOG:
break; break;

View File

@ -437,6 +437,24 @@ static int16_t rwebinput_is_pressed(
return 0; return 0;
} }
static int16_t rwebinput_is_pressed_no_joypad(
rwebinput_input_t *rwebinput,
const struct retro_keybind *binds,
unsigned port, unsigned id,
bool keyboard_mapping_blocked)
{
const struct retro_keybind *bind = &binds[id];
int key = bind->key;
if ((key < RETROK_LAST) && rwebinput_key_pressed(rwebinput, key))
if ((id == RARCH_GAME_FOCUS_TOGGLE) || !keyboard_mapping_blocked)
return 1;
if (port == 0 && !!rwebinput_mouse_state(&rwebinput->mouse,
bind->mbutton, false))
return 1;
return 0;
}
static int16_t rwebinput_input_state( static int16_t rwebinput_input_state(
void *data, void *data,
const input_device_driver_t *joypad, const input_device_driver_t *joypad,
@ -462,9 +480,8 @@ static int16_t rwebinput_input_state(
{ {
if (binds[port][i].valid) if (binds[port][i].valid)
{ {
if (rwebinput_is_pressed( if (rwebinput_is_pressed_no_joypad(
rwebinput, joypad, rwebinput, binds[port], port, i,
joypad_info, binds[port], port, i,
keyboard_mapping_blocked)) keyboard_mapping_blocked))
ret |= (1 << i); ret |= (1 << i);
} }
@ -472,20 +489,18 @@ static int16_t rwebinput_input_state(
return ret; return ret;
} }
else
{
if (id < RARCH_BIND_LIST_END) if (id < RARCH_BIND_LIST_END)
{ {
if (binds[port][id].valid) if (binds[port][id].valid)
{ {
if (rwebinput_is_pressed(rwebinput, joypad, if (rwebinput_is_pressed_no_joypad(rwebinput,
joypad_info, binds[port], binds[port],
port, id, port, id,
keyboard_mapping_blocked)) keyboard_mapping_blocked))
return 1; return 1;
} }
} }
}
break; break;
case RETRO_DEVICE_ANALOG: case RETRO_DEVICE_ANALOG:
if (binds[port]) if (binds[port])

View File

@ -99,8 +99,7 @@ static int16_t sdl_input_state(
if (id == RETRO_DEVICE_ID_JOYPAD_MASK) if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
{ {
unsigned i; unsigned i;
int16_t ret = joypad->state( int16_t ret = 0;
joypad_info, binds[port], port);
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++) for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{ {
@ -111,19 +110,12 @@ static int16_t sdl_input_state(
return ret; return ret;
} }
else
{
if (id < RARCH_BIND_LIST_END) if (id < RARCH_BIND_LIST_END)
{ {
if (binds[port][id].valid) if (binds[port][id].valid)
{ if (sdl_key_pressed(binds[port][id].key))
if (button_is_pressed(joypad,
joypad_info, binds[port], port, id))
return 1; return 1;
else if (sdl_key_pressed(binds[port][id].key))
return 1;
}
}
} }
break; break;
case RETRO_DEVICE_ANALOG: case RETRO_DEVICE_ANALOG:

View File

@ -297,16 +297,6 @@ static int16_t switch_input_state(
switch (device) switch (device)
{ {
case RETRO_DEVICE_JOYPAD: case RETRO_DEVICE_JOYPAD:
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
return joypad->state(
joypad_info, binds[port], port);
if (binds[port][id].valid)
if (
button_is_pressed(joypad, joypad_info, binds[port],
port, id))
return 1;
break;
case RETRO_DEVICE_ANALOG: case RETRO_DEVICE_ANALOG:
break; break;
#ifdef HAVE_LIBNX #ifdef HAVE_LIBNX

View File

@ -1003,8 +1003,7 @@ static int16_t udev_input_state(
if (id == RETRO_DEVICE_ID_JOYPAD_MASK) if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
{ {
unsigned i; unsigned i;
int16_t ret = joypad->state( int16_t ret = 0;
joypad_info, binds[port], port);
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++) for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{ {
@ -1029,16 +1028,12 @@ static int16_t udev_input_state(
return ret; return ret;
} }
else
{
if (id < RARCH_BIND_LIST_END) if (id < RARCH_BIND_LIST_END)
{ {
if (binds[port][id].valid) if (binds[port][id].valid)
{ {
if (button_is_pressed(joypad, if (
joypad_info, binds[port], port, id))
return 1;
else if (
(binds[port][id].key < RETROK_LAST) && (binds[port][id].key < RETROK_LAST) &&
udev_keyboard_pressed(udev, binds[port][id].key) udev_keyboard_pressed(udev, binds[port][id].key)
&& (( id == RARCH_GAME_FOCUS_TOGGLE) && (( id == RARCH_GAME_FOCUS_TOGGLE)
@ -1050,7 +1045,6 @@ static int16_t udev_input_state(
return 1; return 1;
} }
} }
}
break; break;
case RETRO_DEVICE_ANALOG: case RETRO_DEVICE_ANALOG:
if (binds[port]) if (binds[port])

View File

@ -86,8 +86,7 @@ static int16_t uwp_input_state(
if (id == RETRO_DEVICE_ID_JOYPAD_MASK) if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
{ {
unsigned i; unsigned i;
int16_t ret = joypad->state( int16_t ret = 0;
joypad_info, binds[port], port);
if (!keyboard_mapping_blocked) if (!keyboard_mapping_blocked)
{ {
@ -116,16 +115,12 @@ static int16_t uwp_input_state(
return ret; return ret;
} }
else
{
if (id < RARCH_BIND_LIST_END) if (id < RARCH_BIND_LIST_END)
{ {
if (binds[port][id].valid) if (binds[port][id].valid)
{ {
if (button_is_pressed(joypad, joypad_info, if ((binds[port][id].key < RETROK_LAST)
binds[port], port, id))
return 1;
else if ((binds[port][id].key < RETROK_LAST)
&& uwp_keyboard_pressed(binds[port][id].key) && uwp_keyboard_pressed(binds[port][id].key)
&& ((id == RARCH_GAME_FOCUS_TOGGLE) || && ((id == RARCH_GAME_FOCUS_TOGGLE) ||
!keyboard_mapping_blocked) !keyboard_mapping_blocked)
@ -136,7 +131,6 @@ static int16_t uwp_input_state(
return 1; return 1;
} }
} }
}
break; break;
case RETRO_DEVICE_ANALOG: case RETRO_DEVICE_ANALOG:
if (binds[port]) if (binds[port])

View File

@ -167,8 +167,7 @@ static int16_t input_wl_state(
if (id == RETRO_DEVICE_ID_JOYPAD_MASK) if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
{ {
unsigned i; unsigned i;
int16_t ret = joypad->state( int16_t ret = 0;
joypad_info, binds[port], port);
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++) for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{ {
@ -182,22 +181,14 @@ static int16_t input_wl_state(
return ret; return ret;
} }
else
{
if (id < RARCH_BIND_LIST_END) if (id < RARCH_BIND_LIST_END)
{ {
if (binds[port][id].valid) if (binds[port][id].valid)
{ if (BIT_GET(wl->key_state,
if (button_is_pressed(joypad,
joypad_info, binds[port],
port, id))
return 1;
else if (BIT_GET(wl->key_state,
rarch_keysym_lut[binds[port][id].key])) rarch_keysym_lut[binds[port][id].key]))
return 1; return 1;
} }
}
}
break; break;
case RETRO_DEVICE_ANALOG: case RETRO_DEVICE_ANALOG:
if (binds[port]) if (binds[port])

View File

@ -108,21 +108,12 @@ static int16_t wiiu_input_state(
switch (device) switch (device)
{ {
case RETRO_DEVICE_JOYPAD: case RETRO_DEVICE_JOYPAD:
if (id == RETRO_DEVICE_ID_JOYPAD_MASK) case RETRO_DEVICE_ANALOG:
return joypad->state(
joypad_info, binds[port], port);
if (binds[port][id].valid)
return button_is_pressed(
joypad,
joypad_info, binds[port], port, id);
break; break;
case RETRO_DEVICE_KEYBOARD: case RETRO_DEVICE_KEYBOARD:
if (id < RETROK_LAST && keyboard_state[id] && (keyboard_channel > 0)) if (id < RETROK_LAST && keyboard_state[id] && (keyboard_channel > 0))
return 1; return 1;
break; break;
case RETRO_DEVICE_ANALOG:
break;
case RETRO_DEVICE_POINTER: case RETRO_DEVICE_POINTER:
case RARCH_DEVICE_POINTER_SCREEN: case RARCH_DEVICE_POINTER_SCREEN:
/* TODO: Emulate a relative mouse. /* TODO: Emulate a relative mouse.

View File

@ -624,8 +624,7 @@ static int16_t winraw_input_state(
if (id == RETRO_DEVICE_ID_JOYPAD_MASK) if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
{ {
unsigned i; unsigned i;
int16_t ret = joypad->state( int16_t ret = 0;
joypad_info, binds[port], port);
if (mouse) if (mouse)
{ {
@ -655,17 +654,12 @@ static int16_t winraw_input_state(
return ret; return ret;
} }
else
{
if (id < RARCH_BIND_LIST_END) if (id < RARCH_BIND_LIST_END)
{ {
if (binds[port][id].valid) if (binds[port][id].valid)
{ {
if (button_is_pressed( if (
joypad,
joypad_info, binds[port], port, id))
return 1;
else if (
(binds[port][id].key < RETROK_LAST) (binds[port][id].key < RETROK_LAST)
&& WINRAW_KEYBOARD_PRESSED(wr, binds[port][id].key) && WINRAW_KEYBOARD_PRESSED(wr, binds[port][id].key)
&& (( id == RARCH_GAME_FOCUS_TOGGLE) && (( id == RARCH_GAME_FOCUS_TOGGLE)
@ -677,7 +671,6 @@ static int16_t winraw_input_state(
return 1; return 1;
} }
} }
}
break; break;
case RETRO_DEVICE_ANALOG: case RETRO_DEVICE_ANALOG:
break; break;

View File

@ -127,8 +127,7 @@ static int16_t x_input_state(
if (id == RETRO_DEVICE_ID_JOYPAD_MASK) if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
{ {
unsigned i; unsigned i;
int16_t ret = joypad->state( int16_t ret = 0;
joypad_info, binds[port], port);
if (settings->uints.input_mouse_index[port] == 0) if (settings->uints.input_mouse_index[port] == 0)
{ {
@ -157,16 +156,12 @@ static int16_t x_input_state(
return ret; return ret;
} }
else
{
if (id < RARCH_BIND_LIST_END) if (id < RARCH_BIND_LIST_END)
{ {
if (binds[port][id].valid) if (binds[port][id].valid)
{ {
if (button_is_pressed(joypad, if (
joypad_info, binds[port], port, id))
return 1;
else if (
((binds[port][id].key < RETROK_LAST) && ((binds[port][id].key < RETROK_LAST) &&
x_keyboard_pressed(x11, binds[port][id].key)) x_keyboard_pressed(x11, binds[port][id].key))
&& (( id == RARCH_GAME_FOCUS_TOGGLE) && (( id == RARCH_GAME_FOCUS_TOGGLE)
@ -181,7 +176,6 @@ static int16_t x_input_state(
} }
} }
} }
}
break; break;
case RETRO_DEVICE_ANALOG: case RETRO_DEVICE_ANALOG:
if (binds[port]) if (binds[port])

View File

@ -52,26 +52,6 @@ static int16_t xdk_input_state(
unsigned index, unsigned index,
unsigned id) unsigned id)
{ {
if (port >= DEFAULT_MAX_PADS)
return 0;
switch (device)
{
case RETRO_DEVICE_JOYPAD:
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
return joypad->state(
joypad_info, binds[port], port);
if (binds[port][id].valid)
if (
button_is_pressed(joypad, joypad_info, binds[port],
port, id))
return 1;
break;
case RETRO_DEVICE_ANALOG:
break;
}
return 0; return 0;
} }

View File

@ -27,6 +27,8 @@
#include "../input_driver.h" #include "../input_driver.h"
/* TODO/FIXME - add joypad driver */
/* TODO/FIXME - /* TODO/FIXME -
* fix game focus toggle */ * fix game focus toggle */
@ -80,6 +82,7 @@ static int16_t xenon360_input_state(
switch (device) switch (device)
{ {
case RETRO_DEVICE_JOYPAD: case RETRO_DEVICE_JOYPAD:
#if 0
if (id == RETRO_DEVICE_ID_JOYPAD_MASK) if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
{ {
unsigned i; unsigned i;
@ -96,14 +99,13 @@ static int16_t xenon360_input_state(
return ret; return ret;
} }
else
{
if (binds[port][id].valid) if (binds[port][id].valid)
{ {
if (state[port] & binds[port][id].joykey) if (state[port] & binds[port][id].joykey)
return 1; return 1;
} }
} #endif
break; break;
default: default:
break; break;

View File

@ -3623,7 +3623,40 @@ static int16_t input_state_wrap(
unsigned id) unsigned id)
{ {
input_driver_t *current_input = p_rarch->current_input; input_driver_t *current_input = p_rarch->current_input;
int16_t ret = current_input->input_state( int16_t ret = 0;
/* Do a bitwise OR to combine input states together */
if (device == RETRO_DEVICE_JOYPAD)
{
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
{
ret |= joypad->state(
joypad_info, binds[port], port);
if (sec_joypad)
ret |= sec_joypad->state(
joypad_info, binds[port], port);
}
else
{
/* Do a bitwise OR to combine both input
* states together */
if (binds[port][id].valid)
{
if (button_is_pressed(
joypad,
joypad_info, binds[port], port, id))
return 1;
else if (sec_joypad &&
button_is_pressed(
sec_joypad,
joypad_info, binds[port], port, id))
return 1;
}
}
}
ret |= current_input->input_state(
data, data,
joypad, joypad,
sec_joypad, sec_joypad,