mirror of
https://github.com/libretro/RetroArch
synced 2025-03-19 16:21:30 +00:00
(input drivers) More simplifications
This commit is contained in:
parent
ceecf4751a
commit
51365ed387
@ -856,10 +856,9 @@ static bool udev_keyboard_pressed(udev_input_t *udev, unsigned key)
|
|||||||
return BIT_GET(udev_key_state,bit);
|
return BIT_GET(udev_key_state,bit);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool udev_mbutton_pressed(udev_input_t *udev, unsigned port, unsigned key)
|
static bool udev_mouse_button_pressed(
|
||||||
|
udev_input_t *udev, unsigned port, unsigned key)
|
||||||
{
|
{
|
||||||
bool result;
|
|
||||||
|
|
||||||
udev_input_mouse_t *mouse = udev_get_mouse(udev, port);
|
udev_input_mouse_t *mouse = udev_get_mouse(udev, port);
|
||||||
|
|
||||||
if (!mouse)
|
if (!mouse)
|
||||||
@ -867,26 +866,24 @@ static bool udev_mbutton_pressed(udev_input_t *udev, unsigned port, unsigned key
|
|||||||
|
|
||||||
switch ( key )
|
switch ( key )
|
||||||
{
|
{
|
||||||
|
case RETRO_DEVICE_ID_MOUSE_LEFT:
|
||||||
case RETRO_DEVICE_ID_MOUSE_LEFT:
|
return mouse->l;
|
||||||
return mouse->l;
|
case RETRO_DEVICE_ID_MOUSE_RIGHT:
|
||||||
case RETRO_DEVICE_ID_MOUSE_RIGHT:
|
return mouse->r;
|
||||||
return mouse->r;
|
case RETRO_DEVICE_ID_MOUSE_MIDDLE:
|
||||||
case RETRO_DEVICE_ID_MOUSE_MIDDLE:
|
return mouse->m;
|
||||||
return mouse->m;
|
case RETRO_DEVICE_ID_MOUSE_BUTTON_4:
|
||||||
case RETRO_DEVICE_ID_MOUSE_BUTTON_4:
|
return mouse->b4;
|
||||||
return mouse->b4;
|
case RETRO_DEVICE_ID_MOUSE_BUTTON_5:
|
||||||
case RETRO_DEVICE_ID_MOUSE_BUTTON_5:
|
return mouse->b5;
|
||||||
return mouse->b5;
|
case RETRO_DEVICE_ID_MOUSE_WHEELUP:
|
||||||
case RETRO_DEVICE_ID_MOUSE_WHEELUP:
|
return mouse->wu;
|
||||||
return mouse->wu;
|
case RETRO_DEVICE_ID_MOUSE_WHEELDOWN:
|
||||||
case RETRO_DEVICE_ID_MOUSE_WHEELDOWN:
|
return mouse->wd;
|
||||||
return mouse->wd;
|
case RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELUP:
|
||||||
case RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELUP:
|
return mouse->whu;
|
||||||
return mouse->whu;
|
case RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELDOWN:
|
||||||
case RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELDOWN:
|
return mouse->whd;
|
||||||
return mouse->whd;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -905,7 +902,7 @@ static bool udev_is_pressed(udev_input_t *udev,
|
|||||||
|
|
||||||
if (binds && binds[id].valid)
|
if (binds && binds[id].valid)
|
||||||
{
|
{
|
||||||
if (udev_mbutton_pressed(udev, port, bind->mbutton))
|
if (udev_mouse_button_pressed(udev, port, bind->mbutton))
|
||||||
return true;
|
return true;
|
||||||
if (input_joypad_pressed(udev->joypad, joypad_info, port, binds, id))
|
if (input_joypad_pressed(udev->joypad, joypad_info, port, binds, id))
|
||||||
return true;
|
return true;
|
||||||
|
@ -127,19 +127,6 @@ static void wiiu_input_poll(void *data)
|
|||||||
wiiu->joypad->poll();
|
wiiu->joypad->poll();
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool wiiu_key_pressed(int key)
|
|
||||||
{
|
|
||||||
bool ret = false;
|
|
||||||
|
|
||||||
if (key >= RETROK_LAST)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (keyboardState[key] && (keyboardChannel > 0))
|
|
||||||
ret = true;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int16_t wiiu_input_state(void *data,
|
static int16_t wiiu_input_state(void *data,
|
||||||
rarch_joypad_info_t joypad_info,
|
rarch_joypad_info_t joypad_info,
|
||||||
const struct retro_keybind **binds,
|
const struct retro_keybind **binds,
|
||||||
@ -157,7 +144,9 @@ static int16_t wiiu_input_state(void *data,
|
|||||||
return input_joypad_pressed(wiiu->joypad,
|
return input_joypad_pressed(wiiu->joypad,
|
||||||
joypad_info, port, binds[port], id);
|
joypad_info, port, binds[port], id);
|
||||||
case RETRO_DEVICE_KEYBOARD:
|
case RETRO_DEVICE_KEYBOARD:
|
||||||
return wiiu_key_pressed(id);
|
if (id < RETROK_LAST && keyboardState[id] && (keyboardChannel > 0))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
case RETRO_DEVICE_ANALOG:
|
case RETRO_DEVICE_ANALOG:
|
||||||
if (binds[port])
|
if (binds[port])
|
||||||
return input_joypad_analog(wiiu->joypad,
|
return input_joypad_analog(wiiu->joypad,
|
||||||
|
@ -246,60 +246,58 @@ static bool winraw_set_mouse_input(HWND window, bool grab)
|
|||||||
static int16_t winraw_lightgun_aiming_state(winraw_input_t *wr,
|
static int16_t winraw_lightgun_aiming_state(winraw_input_t *wr,
|
||||||
unsigned port, unsigned id)
|
unsigned port, unsigned id)
|
||||||
{
|
{
|
||||||
const int edge_detect = 32700;
|
const int edge_detect = 32700;
|
||||||
struct video_viewport vp;
|
struct video_viewport vp;
|
||||||
bool inside = false;
|
bool inside = false;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
winraw_mouse_t *mouse = NULL;
|
winraw_mouse_t *mouse = NULL;
|
||||||
int16_t res_x = 0;
|
int16_t res_x = 0;
|
||||||
int16_t res_y = 0;
|
int16_t res_y = 0;
|
||||||
int16_t res_screen_x = 0;
|
int16_t res_screen_x = 0;
|
||||||
int16_t res_screen_y = 0;
|
int16_t res_screen_y = 0;
|
||||||
|
|
||||||
if (port >= MAX_USERS)
|
if (port >= MAX_USERS)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
for (i = 0; i < g_mouse_cnt; ++i)
|
for (i = 0; i < g_mouse_cnt; ++i)
|
||||||
{
|
{
|
||||||
if (i == settings->uints.input_mouse_index[port])
|
if (i == settings->uints.input_mouse_index[port])
|
||||||
{
|
{
|
||||||
mouse = &wr->mice[i];
|
mouse = &wr->mice[i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mouse)
|
if (!mouse)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
vp.x = 0;
|
vp.x = 0;
|
||||||
vp.y = 0;
|
vp.y = 0;
|
||||||
vp.width = 0;
|
vp.width = 0;
|
||||||
vp.height = 0;
|
vp.height = 0;
|
||||||
vp.full_width = 0;
|
vp.full_width = 0;
|
||||||
vp.full_height = 0;
|
vp.full_height = 0;
|
||||||
|
|
||||||
if ( !( video_driver_translate_coord_viewport_wrap(
|
if ( !( video_driver_translate_coord_viewport_wrap(
|
||||||
&vp, mouse->x, mouse->y, &res_x, &res_y, &res_screen_x, &res_screen_y ) ) )
|
&vp, mouse->x, mouse->y, &res_x, &res_y, &res_screen_x, &res_screen_y ) ) )
|
||||||
{
|
return 0;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
inside = (res_x >= -edge_detect) && (res_y >= -edge_detect) && (res_x <= edge_detect) && (res_y <= edge_detect);
|
inside = (res_x >= -edge_detect) && (res_y >= -edge_detect) && (res_x <= edge_detect) && (res_y <= edge_detect);
|
||||||
|
|
||||||
switch ( id )
|
switch ( id )
|
||||||
{
|
{
|
||||||
case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X:
|
case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X:
|
||||||
return inside ? res_x : 0;
|
return inside ? res_x : 0;
|
||||||
case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y:
|
case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y:
|
||||||
return inside ? res_y : 0;
|
return inside ? res_y : 0;
|
||||||
case RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN:
|
case RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN:
|
||||||
return !inside;
|
return !inside;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int16_t winraw_mouse_state(winraw_input_t *wr,
|
static int16_t winraw_mouse_state(winraw_input_t *wr,
|
||||||
@ -349,13 +347,10 @@ static int16_t winraw_mouse_state(winraw_input_t *wr,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool winraw_keyboard_pressed(winraw_input_t *wr, unsigned key)
|
#define winraw_keyboard_pressed(wr, key) (wr->keyboard.keys[rarch_keysym_lut[(enum retro_key)(key)]])
|
||||||
{
|
|
||||||
unsigned k = rarch_keysym_lut[(enum retro_key)key];
|
|
||||||
return wr->keyboard.keys[k];
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool winraw_mbutton_pressed(winraw_input_t *wr, unsigned port, unsigned key)
|
static bool winraw_mouse_button_pressed(
|
||||||
|
winraw_input_t *wr, unsigned port, unsigned key)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
winraw_mouse_t *mouse = NULL;
|
winraw_mouse_t *mouse = NULL;
|
||||||
@ -410,7 +405,7 @@ static bool winraw_is_pressed(winraw_input_t *wr,
|
|||||||
return true;
|
return true;
|
||||||
if (binds && binds[id].valid)
|
if (binds && binds[id].valid)
|
||||||
{
|
{
|
||||||
if (winraw_mbutton_pressed(wr, port, bind->mbutton))
|
if (winraw_mouse_button_pressed(wr, port, bind->mbutton))
|
||||||
return true;
|
return true;
|
||||||
if (input_joypad_pressed(wr->joypad, joypad_info, port, binds, id))
|
if (input_joypad_pressed(wr->joypad, joypad_info, port, binds, id))
|
||||||
return true;
|
return true;
|
||||||
|
@ -79,7 +79,8 @@ static bool x_keyboard_pressed(x11_input_t *x11, unsigned key)
|
|||||||
return x11->state[keycode >> 3] & (1 << (keycode & 7));
|
return x11->state[keycode >> 3] & (1 << (keycode & 7));
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool x_mbutton_pressed(x11_input_t *x11, unsigned port, unsigned key)
|
static bool x_mouse_button_pressed(
|
||||||
|
x11_input_t *x11, unsigned port, unsigned key)
|
||||||
{
|
{
|
||||||
bool result;
|
bool result;
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
@ -137,7 +138,7 @@ static bool x_is_pressed(x11_input_t *x11,
|
|||||||
|
|
||||||
if (binds && binds[id].valid)
|
if (binds && binds[id].valid)
|
||||||
{
|
{
|
||||||
if (x_mbutton_pressed(x11, port, bind->mbutton))
|
if (x_mouse_button_pressed(x11, port, bind->mbutton))
|
||||||
return true;
|
return true;
|
||||||
if (input_joypad_pressed(x11->joypad, joypad_info, port, binds, id))
|
if (input_joypad_pressed(x11->joypad, joypad_info, port, binds, id))
|
||||||
return true;
|
return true;
|
||||||
|
@ -66,21 +66,19 @@ static int16_t xenon360_input_state(void *data,
|
|||||||
{
|
{
|
||||||
unsigned user = port;
|
unsigned user = port;
|
||||||
uint64_t button = binds[user][id].joykey;
|
uint64_t button = binds[user][id].joykey;
|
||||||
int16_t retval = 0;
|
|
||||||
|
|
||||||
if(user < MAX_PADS)
|
if (user >= MAX_PADS)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
switch (device)
|
||||||
{
|
{
|
||||||
switch (device)
|
case RETRO_DEVICE_JOYPAD:
|
||||||
{
|
return (state[user] & button) ? 1 : 0;
|
||||||
case RETRO_DEVICE_JOYPAD:
|
default:
|
||||||
retval = (state[user] & button) ? 1 : 0;
|
break;
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return retval;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xenon360_input_free_input(void *data)
|
static void xenon360_input_free_input(void *data)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user