mirror of
https://github.com/Ryujinx/SDL.git
synced 2025-03-06 18:39:50 +00:00
Minor cleanup
This commit is contained in:
parent
9cd7cbe134
commit
92fd2938e7
|
@ -448,7 +448,7 @@ void SDL_EVDEV_Poll(void)
|
|||
switch (events[i].code) {
|
||||
case SYN_REPORT:
|
||||
/* Send mouse axis changes together to ensure consistency and reduce event processing overhead */
|
||||
if (item->relative_mouse) {
|
||||
if (item->relative_mouse) {
|
||||
if (item->mouse_x != 0 || item->mouse_y != 0) {
|
||||
SDL_SendMouseMotion(mouse->focus, (SDL_MouseID)item->fd, item->relative_mouse, item->mouse_x, item->mouse_y);
|
||||
item->mouse_x = item->mouse_y = 0;
|
||||
|
@ -457,8 +457,8 @@ void SDL_EVDEV_Poll(void)
|
|||
/* TODO: test with multiple display scenarios */
|
||||
SDL_DisplayMode mode;
|
||||
SDL_GetCurrentDisplayMode(0, &mode);
|
||||
SDL_SendMouseMotion(mouse->focus, (SDL_MouseID)item->fd, item->relative_mouse,
|
||||
(item->mouse_x - item->min_x) * mode.w / item->range_x,
|
||||
SDL_SendMouseMotion(mouse->focus, (SDL_MouseID)item->fd, item->relative_mouse,
|
||||
(item->mouse_x - item->min_x) * mode.w / item->range_x,
|
||||
(item->mouse_y - item->min_y) * mode.h / item->range_y);
|
||||
}
|
||||
|
||||
|
@ -552,6 +552,32 @@ static SDL_Scancode SDL_EVDEV_translate_keycode(int keycode)
|
|||
return scancode;
|
||||
}
|
||||
|
||||
static int SDL_EVDEV_init_mouse(SDL_evdevlist_item *item, int udev_class)
|
||||
{
|
||||
int ret;
|
||||
struct input_absinfo abs_info;
|
||||
|
||||
ret = ioctl(item->fd, EVIOCGABS(ABS_X), &abs_info);
|
||||
if (ret < 0) {
|
||||
// no absolute mode info, continue
|
||||
return 0;
|
||||
}
|
||||
item->min_x = abs_info.minimum;
|
||||
item->max_x = abs_info.maximum;
|
||||
item->range_x = abs_info.maximum - abs_info.minimum;
|
||||
|
||||
ret = ioctl(item->fd, EVIOCGABS(ABS_Y), &abs_info);
|
||||
if (ret < 0) {
|
||||
// no absolute mode info, continue
|
||||
return 0;
|
||||
}
|
||||
item->min_y = abs_info.minimum;
|
||||
item->max_y = abs_info.maximum;
|
||||
item->range_y = abs_info.maximum - abs_info.minimum;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int SDL_EVDEV_init_touchscreen(SDL_evdevlist_item *item, int udev_class)
|
||||
{
|
||||
int ret, i;
|
||||
|
@ -653,36 +679,6 @@ static int SDL_EVDEV_init_touchscreen(SDL_evdevlist_item *item, int udev_class)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int SDL_EVDEV_init_mouse(SDL_evdevlist_item *item, int udev_class)
|
||||
{
|
||||
int ret;
|
||||
struct input_absinfo abs_info;
|
||||
|
||||
if (item->is_touchscreen) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = ioctl(item->fd, EVIOCGABS(ABS_X), &abs_info);
|
||||
if (ret < 0) {
|
||||
// no absolute mode info, continue
|
||||
return 0;
|
||||
}
|
||||
item->min_x = abs_info.minimum;
|
||||
item->max_x = abs_info.maximum;
|
||||
item->range_x = abs_info.maximum - abs_info.minimum;
|
||||
|
||||
ret = ioctl(item->fd, EVIOCGABS(ABS_Y), &abs_info);
|
||||
if (ret < 0) {
|
||||
// no absolute mode info, continue
|
||||
return 0;
|
||||
}
|
||||
item->min_y = abs_info.minimum;
|
||||
item->max_y = abs_info.maximum;
|
||||
item->range_y = abs_info.maximum - abs_info.minimum;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void SDL_EVDEV_destroy_touchscreen(SDL_evdevlist_item *item)
|
||||
{
|
||||
if (!item->is_touchscreen) {
|
||||
|
|
Loading…
Reference in a new issue