Skip to content

Commit 373216a

Browse files
committed
Added support for touchpads in the Linux evdev code (thanks Francisco!)
1 parent 16aeb8d commit 373216a

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

src/core/linux/SDL_evdev.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,11 @@ static void SDL_EVDEV_udev_callback(SDL_UDEV_deviceevent udev_event, int udev_cl
218218

219219
switch(udev_event) {
220220
case SDL_UDEV_DEVICEADDED:
221-
if (!(udev_class & (SDL_UDEV_DEVICE_MOUSE | SDL_UDEV_DEVICE_KEYBOARD |
222-
SDL_UDEV_DEVICE_TOUCHSCREEN)))
221+
if (udev_class & SDL_UDEV_DEVICE_TOUCHPAD) {
222+
udev_class |= SDL_UDEV_DEVICE_TOUCHSCREEN;
223+
}
224+
225+
if (!(udev_class & (SDL_UDEV_DEVICE_MOUSE | SDL_UDEV_DEVICE_KEYBOARD | SDL_UDEV_DEVICE_TOUCHSCREEN)))
223226
return;
224227

225228
if ((udev_class & SDL_UDEV_DEVICE_JOYSTICK))

src/core/linux/SDL_evdev_capabilities.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ SDL_EVDEV_GuessDeviceClass(unsigned long bitmask_ev[NBITS(EV_MAX)],
7878
if (test_bit(BTN_STYLUS, bitmask_key) || test_bit(BTN_TOOL_PEN, bitmask_key)) {
7979
; /* ID_INPUT_TABLET */
8080
} else if (test_bit(BTN_TOOL_FINGER, bitmask_key) && !test_bit(BTN_TOOL_PEN, bitmask_key)) {
81-
; /* ID_INPUT_TOUCHPAD */
81+
devclass |= SDL_UDEV_DEVICE_TOUCHPAD; /* ID_INPUT_TOUCHPAD */
8282
} else if (test_bit(BTN_MOUSE, bitmask_key)) {
8383
devclass |= SDL_UDEV_DEVICE_MOUSE; /* ID_INPUT_MOUSE */
8484
} else if (test_bit(BTN_TOUCH, bitmask_key)) {

src/core/linux/SDL_evdev_capabilities.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ typedef enum
3838
SDL_UDEV_DEVICE_JOYSTICK = 0x0004,
3939
SDL_UDEV_DEVICE_SOUND = 0x0008,
4040
SDL_UDEV_DEVICE_TOUCHSCREEN = 0x0010,
41-
SDL_UDEV_DEVICE_ACCELEROMETER = 0x0020
41+
SDL_UDEV_DEVICE_ACCELEROMETER = 0x0020,
42+
SDL_UDEV_DEVICE_TOUCHPAD = 0x0040
4243
} SDL_UDEV_deviceclass;
4344

4445
#define BITS_PER_LONG (sizeof(unsigned long) * 8)

0 commit comments

Comments
 (0)