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,18 +1348,11 @@ static int16_t android_input_state(
} }
return ret; return ret;
} }
else
if (binds[port][id].valid)
{ {
if (binds[port][id].valid) if (ANDROID_KEYBOARD_PORT_INPUT_PRESSED(binds[port], id))
{ return 1;
if (
button_is_pressed(
joypad, joypad_info, binds[port],
port, id)
|| ANDROID_KEYBOARD_PORT_INPUT_PRESSED(binds[port], id)
)
return 1;
}
} }
break; break;
case RETRO_DEVICE_ANALOG: case RETRO_DEVICE_ANALOG:

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,24 +406,12 @@ static int16_t cocoa_input_state(
} }
return ret; return ret;
} }
else
if (binds[port][id].valid)
{ {
if (binds[port][id].valid) if (id < RARCH_BIND_LIST_END)
{ if (apple_key_state[rarch_keysym_lut[binds[port][id].key]])
if (button_is_pressed(
joypad,
joypad_info, binds[port], port, id))
return 1; 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]])
return 1;
}
} }
break; break;
case RETRO_DEVICE_ANALOG: case RETRO_DEVICE_ANALOG:

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,30 +443,24 @@ 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 (binds[port][id].key < RETROK_LAST
{ && (di->state[rarch_keysym_lut
if (button_is_pressed( [(enum retro_key)binds[port][id].key]] & 0x80)
joypad, && ( (id == RARCH_GAME_FOCUS_TOGGLE)
joypad_info, binds[port], port, id)) || !keyboard_mapping_blocked)
return 1; )
else if (binds[port][id].key < RETROK_LAST return 1;
&& (di->state[rarch_keysym_lut else if (
[(enum retro_key)binds[port][id].key]] & 0x80) settings->uints.input_mouse_index[port] == 0
&& ( (id == RARCH_GAME_FOCUS_TOGGLE) && dinput_mouse_button_pressed(
|| !keyboard_mapping_blocked) di, port, binds[port][id].mbutton)
) )
return 1; return 1;
else if (
settings->uints.input_mouse_index[port] == 0
&& dinput_mouse_button_pressed(
di, port, binds[port][id].mbutton)
)
return 1;
}
} }
} }
} }

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,20 +90,15 @@ static int16_t dos_input_state(
return ret; return ret;
} }
else
if (binds[port][id].valid)
{ {
if (binds[port][id].valid) if (
{ (id < RARCH_BIND_LIST_END
if ( && dos_key_state[DOS_KEYBOARD_PORT]
button_is_pressed( [rarch_keysym_lut[binds[port][id].key]])
joypad, joypad_info, binds[port], )
port, id) return 1;
|| (id < RARCH_BIND_LIST_END
&& dos_key_state[DOS_KEYBOARD_PORT]
[rarch_keysym_lut[binds[port][id].key]])
)
return 1;
}
} }
break; break;
case RETRO_DEVICE_KEYBOARD: case RETRO_DEVICE_KEYBOARD:

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,23 +108,15 @@ 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 ((linuxraw->state[rarch_keysym_lut
{ [(enum retro_key)binds[port][id].key]]
if ( ))
button_is_pressed( return 1;
joypad, joypad_info, binds[port],
port, id)
)
return 1;
else if ((linuxraw->state[rarch_keysym_lut
[(enum retro_key)binds[port][id].key]]
))
return 1;
}
} }
} }
break; break;

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,18 +248,12 @@ static int16_t ps3_input_state(
return ret; return ret;
} }
else
if (binds[port][id].valid)
{ {
if (binds[port][id].valid) if (psl1ght_keyboard_port_input_pressed(
{ ps3, binds[port][id].key))
if ( return 1;
button_is_pressed(joypad, joypad_info, binds[port],
port, id))
return 1;
else if (psl1ght_keyboard_port_input_pressed(
ps3, binds[port][id].key))
return 1;
}
} }
break; break;
case RETRO_DEVICE_ANALOG: case RETRO_DEVICE_ANALOG:

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,22 +805,17 @@ 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 (
{ ((id == RARCH_GAME_FOCUS_TOGGLE) ||
if (button_is_pressed(joypad, !keyboard_mapping_blocked) &&
joypad_info, binds[port], port, id)) qnx_keyboard_pressed(qnx, key)
return 1; )
else if ( return 1;
((id == RARCH_GAME_FOCUS_TOGGLE) ||
!keyboard_mapping_blocked) &&
qnx_keyboard_pressed(qnx, key)
)
return 1;
}
} }
} }
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,18 +489,16 @@ 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_no_joypad(rwebinput,
{ binds[port],
if (rwebinput_is_pressed(rwebinput, joypad, port, id,
joypad_info, binds[port], keyboard_mapping_blocked))
port, id, return 1;
keyboard_mapping_blocked))
return 1;
}
} }
} }
break; break;

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 (sdl_key_pressed(binds[port][id].key))
if (binds[port][id].valid) return 1;
{
if (button_is_pressed(joypad,
joypad_info, binds[port], port, id))
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,26 +1028,21 @@ 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 (
{ (binds[port][id].key < RETROK_LAST) &&
if (button_is_pressed(joypad, udev_keyboard_pressed(udev, binds[port][id].key)
joypad_info, binds[port], port, id)) && (( id == RARCH_GAME_FOCUS_TOGGLE)
return 1; || !keyboard_mapping_blocked)
else if ( )
(binds[port][id].key < RETROK_LAST) && return 1;
udev_keyboard_pressed(udev, binds[port][id].key) else if (udev_mouse_button_pressed(udev, port,
&& (( id == RARCH_GAME_FOCUS_TOGGLE) binds[port][id].mbutton))
|| !keyboard_mapping_blocked) return 1;
)
return 1;
else if (udev_mouse_button_pressed(udev, port,
binds[port][id].mbutton))
return 1;
}
} }
} }
break; break;

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,25 +115,20 @@ 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 ((binds[port][id].key < RETROK_LAST)
{ && uwp_keyboard_pressed(binds[port][id].key)
if (button_is_pressed(joypad, joypad_info, && ((id == RARCH_GAME_FOCUS_TOGGLE) ||
binds[port], port, id)) !keyboard_mapping_blocked)
return 1; )
else if ((binds[port][id].key < RETROK_LAST) return 1;
&& uwp_keyboard_pressed(binds[port][id].key) else if (uwp_mouse_state(port,
&& ((id == RARCH_GAME_FOCUS_TOGGLE) || binds[port][id].mbutton, false))
!keyboard_mapping_blocked) return 1;
)
return 1;
else if (uwp_mouse_state(port,
binds[port][id].mbutton, false))
return 1;
}
} }
} }
break; break;

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,21 +181,13 @@ 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 (BIT_GET(wl->key_state,
if (binds[port][id].valid) rarch_keysym_lut[binds[port][id].key]))
{ return 1;
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]))
return 1;
}
}
} }
break; break;
case RETRO_DEVICE_ANALOG: case RETRO_DEVICE_ANALOG:

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,27 +654,21 @@ 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 (
{ (binds[port][id].key < RETROK_LAST)
if (button_is_pressed( && WINRAW_KEYBOARD_PRESSED(wr, binds[port][id].key)
joypad, && (( id == RARCH_GAME_FOCUS_TOGGLE)
joypad_info, binds[port], port, id)) || !keyboard_mapping_blocked)
return 1; )
else if ( return 1;
(binds[port][id].key < RETROK_LAST) else if (mouse && winraw_mouse_button_pressed(wr,
&& WINRAW_KEYBOARD_PRESSED(wr, binds[port][id].key) mouse, port, binds[port][id].mbutton))
&& (( id == RARCH_GAME_FOCUS_TOGGLE) return 1;
|| !keyboard_mapping_blocked)
)
return 1;
else if (mouse && winraw_mouse_button_pressed(wr,
mouse, port, binds[port][id].mbutton))
return 1;
}
} }
} }
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,28 +156,23 @@ 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 (
{ ((binds[port][id].key < RETROK_LAST) &&
if (button_is_pressed(joypad, x_keyboard_pressed(x11, binds[port][id].key))
joypad_info, binds[port], port, id)) && (( id == RARCH_GAME_FOCUS_TOGGLE)
return 1; || !keyboard_mapping_blocked)
else if (
((binds[port][id].key < RETROK_LAST) &&
x_keyboard_pressed(x11, binds[port][id].key))
&& (( id == RARCH_GAME_FOCUS_TOGGLE)
|| !keyboard_mapping_blocked)
) )
return 1;
else if (settings->uints.input_mouse_index[port] == 0)
{
if (x_mouse_button_pressed(x11, port,
binds[port][id].mbutton))
return 1; return 1;
else if (settings->uints.input_mouse_index[port] == 0)
{
if (x_mouse_button_pressed(x11, port,
binds[port][id].mbutton))
return 1;
}
} }
} }
} }

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)
{ return 1;
if (state[port] & binds[port][id].joykey)
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,