mirror of
https://github.com/libretro/RetroArch
synced 2025-02-07 12:39:54 +00:00
Further cleanups/standardizations to analog_pressed
This commit is contained in:
parent
97319d4f98
commit
e119d3c98e
@ -342,9 +342,6 @@ static int16_t dinput_pressed_analog(
|
||||
id_minus_key = binds[id_minus].key;
|
||||
id_plus_key = binds[id_plus].key;
|
||||
|
||||
if (!id_minus_valid || !id_plus_valid)
|
||||
return 0;
|
||||
|
||||
if (id_plus_valid && id_plus_key < RETROK_LAST)
|
||||
{
|
||||
unsigned sym = rarch_keysym_lut[(enum retro_key)id_plus_key];
|
||||
|
@ -72,7 +72,7 @@ static void *linuxraw_input_init(const char *joypad_driver)
|
||||
return linuxraw;
|
||||
}
|
||||
|
||||
static int16_t linuxraw_analog_pressed(linuxraw_input_t *linuxraw,
|
||||
static int16_t linuxraw_pressed_analog(linuxraw_input_t *linuxraw,
|
||||
const struct retro_keybind *binds, unsigned idx, unsigned id)
|
||||
{
|
||||
int id_minus_key = 0;
|
||||
@ -90,9 +90,6 @@ static int16_t linuxraw_analog_pressed(linuxraw_input_t *linuxraw,
|
||||
id_minus_key = binds[id_minus].key;
|
||||
id_plus_key = binds[id_plus].key;
|
||||
|
||||
if (!id_minus_valid || !id_plus_valid)
|
||||
return 0;
|
||||
|
||||
if (id_plus_valid && id_plus_key < RETROK_LAST)
|
||||
{
|
||||
unsigned sym = rarch_keysym_lut[(enum retro_key)id_plus_key];
|
||||
@ -164,7 +161,7 @@ static int16_t linuxraw_input_state(
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
if (binds[port])
|
||||
return linuxraw_analog_pressed(
|
||||
return linuxraw_pressed_analog(
|
||||
linuxraw, binds[port], idx, id);
|
||||
break;
|
||||
}
|
||||
|
@ -262,23 +262,19 @@ static EM_BOOL rwebinput_keyboard_cb(int event_type,
|
||||
static EM_BOOL rwebinput_mouse_cb(int event_type,
|
||||
const EmscriptenMouseEvent *mouse_event, void *user_data)
|
||||
{
|
||||
rwebinput_input_t *rwebinput = (rwebinput_input_t*)user_data;
|
||||
rwebinput_input_t *rwebinput = (rwebinput_input_t*)user_data;
|
||||
|
||||
uint8_t mask = 1 << mouse_event->button;
|
||||
uint8_t mask = 1 << mouse_event->button;
|
||||
|
||||
rwebinput->mouse.x = mouse_event->targetX;
|
||||
rwebinput->mouse.y = mouse_event->targetY;
|
||||
rwebinput->mouse.x = mouse_event->targetX;
|
||||
rwebinput->mouse.y = mouse_event->targetY;
|
||||
rwebinput->mouse.pending_delta_x += mouse_event->movementX;
|
||||
rwebinput->mouse.pending_delta_y += mouse_event->movementY;
|
||||
|
||||
if (event_type == EMSCRIPTEN_EVENT_MOUSEDOWN)
|
||||
{
|
||||
rwebinput->mouse.buttons |= mask;
|
||||
}
|
||||
else if (event_type == EMSCRIPTEN_EVENT_MOUSEUP)
|
||||
{
|
||||
rwebinput->mouse.buttons &= ~mask;
|
||||
}
|
||||
|
||||
return EM_TRUE;
|
||||
}
|
||||
@ -286,8 +282,7 @@ static EM_BOOL rwebinput_mouse_cb(int event_type,
|
||||
static EM_BOOL rwebinput_wheel_cb(int event_type,
|
||||
const EmscriptenWheelEvent *wheel_event, void *user_data)
|
||||
{
|
||||
rwebinput_input_t *rwebinput = (rwebinput_input_t*)user_data;
|
||||
(void)event_type;
|
||||
rwebinput_input_t *rwebinput = (rwebinput_input_t*)user_data;
|
||||
|
||||
rwebinput->mouse.pending_scroll_x += wheel_event->deltaX;
|
||||
rwebinput->mouse.pending_scroll_y += wheel_event->deltaY;
|
||||
@ -496,7 +491,7 @@ static int16_t rwebinput_is_pressed(
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int16_t rwebinput_analog_pressed(
|
||||
static int16_t rwebinput_pressed_analog(
|
||||
rwebinput_input_t *rwebinput,
|
||||
const input_device_driver_t *joypad,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
@ -518,9 +513,6 @@ static int16_t rwebinput_analog_pressed(
|
||||
id_minus_key = binds[id_minus].key;
|
||||
id_plus_key = binds[id_plus].key;
|
||||
|
||||
if (!id_minus_valid || !id_plus_valid)
|
||||
return 0;
|
||||
|
||||
if (id_plus_valid && id_plus_key < RETROK_LAST)
|
||||
{
|
||||
if (rwebinput_is_pressed(rwebinput,
|
||||
@ -583,7 +575,7 @@ static int16_t rwebinput_input_state(
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
if (binds[port])
|
||||
return rwebinput_analog_pressed(
|
||||
return rwebinput_pressed_analog(
|
||||
rwebinput, joypad, joypad_info, binds[port],
|
||||
idx, id);
|
||||
break;
|
||||
|
@ -79,7 +79,7 @@ static bool sdl_key_pressed(int key)
|
||||
return keymap[sym];
|
||||
}
|
||||
|
||||
static int16_t sdl_analog_pressed(
|
||||
static int16_t sdl_pressed_analog(
|
||||
sdl_input_t *sdl,
|
||||
const struct retro_keybind *binds,
|
||||
unsigned idx, unsigned id)
|
||||
@ -99,9 +99,6 @@ static int16_t sdl_analog_pressed(
|
||||
id_minus_key = binds[id_minus].key;
|
||||
id_plus_key = binds[id_plus].key;
|
||||
|
||||
if (!id_minus_valid || !id_plus_valid)
|
||||
return 0;
|
||||
|
||||
if (id_plus_valid && id_plus_key < RETROK_LAST)
|
||||
{
|
||||
unsigned sym = rarch_keysym_lut[(enum retro_key)id_plus_key];
|
||||
@ -262,7 +259,7 @@ static int16_t sdl_input_state(
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
if (binds[port])
|
||||
return sdl_analog_pressed(sdl, binds[port], idx, id);
|
||||
return sdl_pressed_analog(sdl, binds[port], idx, id);
|
||||
break;
|
||||
case RETRO_DEVICE_MOUSE:
|
||||
if (config_get_ptr()->uints.input_mouse_index[ port ] == 0)
|
||||
|
@ -932,7 +932,7 @@ static bool udev_mouse_button_pressed(
|
||||
return false;
|
||||
}
|
||||
|
||||
static int16_t udev_analog_pressed(
|
||||
static int16_t udev_pressed_analog(
|
||||
udev_input_t *udev,
|
||||
const struct retro_keybind *binds,
|
||||
unsigned idx, unsigned id)
|
||||
@ -952,9 +952,6 @@ static int16_t udev_analog_pressed(
|
||||
id_minus_key = binds[id_minus].key;
|
||||
id_plus_key = binds[id_plus].key;
|
||||
|
||||
if (!id_minus_valid || !id_plus_valid)
|
||||
return 0;
|
||||
|
||||
if (id_plus_valid && id_plus_key < RETROK_LAST)
|
||||
{
|
||||
unsigned sym = rarch_keysym_lut[(enum retro_key)id_plus_key];
|
||||
@ -1085,7 +1082,7 @@ static int16_t udev_input_state(
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
if (binds[port])
|
||||
return udev_analog_pressed(udev, binds[port], idx, id);
|
||||
return udev_pressed_analog(udev, binds[port], idx, id);
|
||||
break;
|
||||
case RETRO_DEVICE_KEYBOARD:
|
||||
return (id < RETROK_LAST) && udev_keyboard_pressed(udev, id);
|
||||
|
@ -104,9 +104,6 @@ static int16_t uwp_pressed_analog(uwp_input_t *uwp,
|
||||
id_minus_key = binds[id_minus].key;
|
||||
id_plus_key = binds[id_plus].key;
|
||||
|
||||
if (!id_minus_valid || !id_plus_valid)
|
||||
return 0;
|
||||
|
||||
if (id_plus_valid && id_plus_key < RETROK_LAST)
|
||||
{
|
||||
if (uwp_keyboard_pressed(bind_plus_key))
|
||||
|
@ -154,7 +154,7 @@ static void input_wl_poll(void *data)
|
||||
input_wl_touch_pool(wl);
|
||||
}
|
||||
|
||||
static int16_t input_wl_analog_pressed(
|
||||
static int16_t input_wl_pressed_analog(
|
||||
input_ctx_wayland_data_t *wl,
|
||||
const struct retro_keybind *binds,
|
||||
unsigned idx, unsigned id)
|
||||
@ -174,17 +174,16 @@ static int16_t input_wl_analog_pressed(
|
||||
id_minus_key = binds[id_minus].key;
|
||||
id_plus_key = binds[id_plus].key;
|
||||
|
||||
if (!id_minus_valid || !id_plus_valid)
|
||||
return 0;
|
||||
|
||||
if (id_plus_valid && id_plus_key < RETROK_LAST)
|
||||
{
|
||||
if (BIT_GET(wl->key_state, rarch_keysym_lut[(enum retro_key)id_plus_key]))
|
||||
unsigned sym = rarch_keysym_lut[(enum retro_key)id_plus_key];
|
||||
if (BIT_GET(wl->key_state, sym))
|
||||
ret = 0x7fff;
|
||||
}
|
||||
if (id_minus_valid && id_minus_key < RETROK_LAST)
|
||||
{
|
||||
if (BIT_GET(wl->key_state, rarch_keysym_lut[(enum retro_key)id_minus_key]))
|
||||
unsigned sym = rarch_keysym_lut[(enum retro_key)id_minus_key];
|
||||
if (BIT_GET(wl->key_state, sym))
|
||||
ret += -0x7fff;
|
||||
}
|
||||
|
||||
@ -352,7 +351,7 @@ static int16_t input_wl_state(
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
if (binds[port])
|
||||
return input_wl_analog_pressed(wl, binds[port], idx, id);
|
||||
return input_wl_pressed_analog(wl, binds[port], idx, id);
|
||||
break;
|
||||
case RETRO_DEVICE_KEYBOARD:
|
||||
return input_wl_state_kb(wl, binds, port, device, idx, id);
|
||||
|
@ -122,16 +122,12 @@ static int16_t x_pressed_analog(x11_input_t *x11,
|
||||
id_minus_key = binds[id_minus].key;
|
||||
id_plus_key = binds[id_plus].key;
|
||||
|
||||
if (!id_minus_valid || !id_plus_valid)
|
||||
return 0;
|
||||
|
||||
if (id_plus_valid && id_plus_key < RETROK_LAST)
|
||||
{
|
||||
unsigned sym = rarch_keysym_lut[(enum retro_key)id_plus_key];
|
||||
if (x11->state[sym >> 3] & (1 << (sym & 7)))
|
||||
ret = 0x7fff;
|
||||
}
|
||||
|
||||
if (id_minus_valid && id_minus_key < RETROK_LAST)
|
||||
{
|
||||
unsigned sym = rarch_keysym_lut[(enum retro_key)id_minus_key];
|
||||
|
Loading…
x
Reference in New Issue
Block a user