Slightly rewrite input_state implementations of cocoa_input.c

and linuxraw_input.c
This commit is contained in:
twinaphex 2017-06-10 11:09:58 +02:00
parent 37656eed84
commit d32cf4c866
2 changed files with 32 additions and 20 deletions

View File

@ -282,36 +282,43 @@ static int16_t cocoa_input_state(void *data,
const struct retro_keybind **binds, unsigned port, const struct retro_keybind **binds, unsigned port,
unsigned device, unsigned idx, unsigned id) unsigned device, unsigned idx, unsigned id)
{ {
int16_t ret = 0;
cocoa_input_data_t *apple = (cocoa_input_data_t*)data; cocoa_input_data_t *apple = (cocoa_input_data_t*)data;
switch (device) switch (device)
{ {
case RETRO_DEVICE_JOYPAD: case RETRO_DEVICE_JOYPAD:
if (id < RARCH_BIND_LIST_END) {
return apple_key_state[rarch_keysym_lut[binds[port][id].key]]; int16_t ret = id < RARCH_BIND_LIST_END ?
return apple_key_state[rarch_keysym_lut[binds[port][id].key]] : 0;
input_joypad_pressed(apple->joypad, joypad_info, port, binds[port], id) if (!ret)
ret = input_joypad_pressed(apple->joypad, joypad_info, port, binds[port], id);
#ifdef HAVE_MFI #ifdef HAVE_MFI
|| input_joypad_pressed(apple->sec_joypad, joypad_info, port, binds[port], id) if (!ret)
ret = input_joypad_pressed(apple->sec_joypad, joypad_info, port, binds[port], id);
#endif #endif
; return ret;
}
break;
case RETRO_DEVICE_ANALOG: case RETRO_DEVICE_ANALOG:
#ifdef HAVE_MFI
if (binds[port]) if (binds[port])
{
int16_t ret = 0;
#ifdef HAVE_MFI
ret = input_joypad_analog(apple->sec_joypad, joypad_info, port, ret = input_joypad_analog(apple->sec_joypad, joypad_info, port,
idx, id, binds[port]);
#endif
if (!ret && binds[port])
ret = input_joypad_analog(apple->joypad, joypad_info, port,
idx, id, binds[port]); idx, id, binds[port]);
return ret; #endif
if (!ret && binds[port])
ret = input_joypad_analog(apple->joypad, joypad_info, port,
idx, id, binds[port]);
return ret;
}
break;
case RETRO_DEVICE_KEYBOARD: case RETRO_DEVICE_KEYBOARD:
return (id < RETROK_LAST) && apple_key_state[rarch_keysym_lut[(enum retro_key)id]]; return (id < RETROK_LAST) && apple_key_state[rarch_keysym_lut[(enum retro_key)id]];
case RETRO_DEVICE_MOUSE: case RETRO_DEVICE_MOUSE:
return cocoa_mouse_state(apple, id); return cocoa_mouse_state(apple, id);
case RARCH_DEVICE_MOUSE_SCREEN: case RARCH_DEVICE_MOUSE_SCREEN:
return cocoa_mouse_state_screen(apple, id); return cocoa_mouse_state_screen(apple, id);
case RETRO_DEVICE_POINTER: case RETRO_DEVICE_POINTER:
case RARCH_DEVICE_POINTER_SCREEN: case RARCH_DEVICE_POINTER_SCREEN:
return cocoa_pointer_state(apple, device, idx, id); return cocoa_pointer_state(apple, device, idx, id);

View File

@ -108,11 +108,16 @@ static int16_t linuxraw_input_state(void *data,
switch (device) switch (device)
{ {
case RETRO_DEVICE_JOYPAD: case RETRO_DEVICE_JOYPAD:
return ((id < RARCH_BIND_LIST_END) && binds[port]->valid && {
linuxraw->state[rarch_keysym_lut[(enum retro_key)binds[port][id].key]] int16_t ret = ((id < RARCH_BIND_LIST_END) && binds[port]->valid &&
) linuxraw->state[rarch_keysym_lut[(enum retro_key)binds[port][id].key]]
|| input_joypad_pressed(linuxraw->joypad, );
joypad_info, port, binds[port], id); if (!ret)
ret = input_joypad_pressed(linuxraw->joypad,
joypad_info, port, binds[port], id);
return ret;
}
break;
case RETRO_DEVICE_ANALOG: case RETRO_DEVICE_ANALOG:
if (binds[port]) if (binds[port])
{ {