Rewrite other input drivers too

This commit is contained in:
twinaphex 2017-06-10 11:22:24 +02:00
parent d32cf4c866
commit e8c73c6683
4 changed files with 49 additions and 71 deletions

View File

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

View File

@ -103,31 +103,25 @@ static int16_t linuxraw_input_state(void *data,
const struct retro_keybind **binds, unsigned port,
unsigned device, unsigned idx, unsigned id)
{
int16_t ret = 0;
linuxraw_input_t *linuxraw = (linuxraw_input_t*)data;
switch (device)
{
case RETRO_DEVICE_JOYPAD:
{
int16_t 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;
}
break;
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:
if (binds[port])
{
int16_t ret = linuxraw_analog_pressed(linuxraw, binds[port], idx, id);
if (!ret)
ret = input_joypad_analog(linuxraw->joypad,
joypad_info, port, idx, id, binds[port]);
return ret;
}
break;
ret = linuxraw_analog_pressed(linuxraw, binds[port], idx, id);
if (!ret && binds[port])
ret = input_joypad_analog(linuxraw->joypad,
joypad_info, port, idx, id, binds[port]);
return ret;
}
return 0;

View File

@ -655,29 +655,24 @@ static int16_t udev_input_state(void *data,
const struct retro_keybind **binds,
unsigned port, unsigned device, unsigned idx, unsigned id)
{
int16_t ret = 0;
udev_input_t *udev = (udev_input_t*)data;
switch (device)
{
case RETRO_DEVICE_JOYPAD:
{
int16_t ret = BIT_GET(udev_key_state,
rarch_keysym_lut[binds[port][id].key]);
if (!ret)
ret = input_joypad_pressed(udev->joypad,
joypad_info, port, binds[port], id);
return ret;
}
ret = BIT_GET(udev_key_state,
rarch_keysym_lut[binds[port][id].key]);
if (!ret)
ret = input_joypad_pressed(udev->joypad,
joypad_info, port, binds[port], id);
return ret;
case RETRO_DEVICE_ANALOG:
if (binds[port])
{
int16_t ret = udev_analog_pressed(binds[port], idx, id);
if (!ret)
ret = input_joypad_analog(udev->joypad,
joypad_info, port, idx, id, binds[port]);
return ret;
}
break;
ret = udev_analog_pressed(binds[port], idx, id);
if (!ret && binds[port])
ret = input_joypad_analog(udev->joypad,
joypad_info, port, idx, id, binds[port]);
return ret;
case RETRO_DEVICE_KEYBOARD:
return id < RETROK_LAST && BIT_GET(udev_key_state,
rarch_keysym_lut[(enum retro_key)id]);

View File

@ -222,40 +222,36 @@ static int16_t x_input_state(void *data,
const struct retro_keybind **binds, unsigned port,
unsigned device, unsigned idx, unsigned id)
{
int16_t ret = 0;
x11_input_t *x11 = (x11_input_t*)data;
switch (device)
{
case RETRO_DEVICE_JOYPAD:
{
int16_t ret = 0;
int keycode = XKeysymToKeycode(x11->display,
rarch_keysym_lut[(enum retro_key)binds[port][id].key]);
ret = x11->state[keycode >> 3] & (1 << (keycode & 7));
if (!ret)
ret = input_joypad_pressed(x11->joypad,
joypad_info, port, binds[port], id);
return ret;
}
return ret;
case RETRO_DEVICE_KEYBOARD:
if (id < RETROK_LAST)
{
int keycode = XKeysymToKeycode(x11->display,
rarch_keysym_lut[(enum retro_key)id]);
return x11->state[keycode >> 3] & (1 << (keycode & 7));
ret = x11->state[keycode >> 3] & (1 << (keycode & 7));
}
break;
return ret;
case RETRO_DEVICE_ANALOG:
if (binds[port])
{
int16_t ret = x_pressed_analog(x11, binds[port], idx, id);
if (!ret)
ret = input_joypad_analog(x11->joypad, joypad_info,
port, idx,
id, binds[port]);
return ret;
}
break;
ret = x_pressed_analog(x11, binds[port], idx, id);
if (!ret && binds[port])
ret = input_joypad_analog(x11->joypad, joypad_info,
port, idx,
id, binds[port]);
return ret;
case RETRO_DEVICE_MOUSE:
return x_mouse_state(x11, id);
case RARCH_DEVICE_MOUSE_SCREEN: