From 92fd2938e737cf044d2da781cf0f4b4b4de4463f Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Mon, 10 Jul 2023 09:42:12 -0700
Subject: [PATCH] Minor cleanup
---
src/core/linux/SDL_evdev.c | 62 ++++++++++++++++++--------------------
1 file changed, 29 insertions(+), 33 deletions(-)
diff --git a/src/core/linux/SDL_evdev.c b/src/core/linux/SDL_evdev.c
index 4822ece844d0..f5e713a5734f 100644
--- a/src/core/linux/SDL_evdev.c
+++ b/src/core/linux/SDL_evdev.c
@@ -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) {