src/core/linux/SDL_evdev.c


Log

Author Commit Date CI Message
Pierre Wendling d0bbfdbf 2022-12-01T16:07:03 Clang-Tidy fixes (#6725) (cherry picked from commit 3c501b963dd8f0605a6ce7978882df39ba76f9cd)
Sylvain 09ee811f 2022-12-01T09:39:08 Small format changed (using clang-format 15.0.2-1) (cherry picked from commit 778b8926b4808f0642a331ed84a9e8e19899b6db)
Sam Lantinga b8d85c69 2022-11-30T12:51:59 Update for SDL3 coding style (#6717) I updated .clang-format and ran clang-format 14 over the src and test directories to standardize the code base. In general I let clang-format have it's way, and added markup to prevent formatting of code that would break or be completely unreadable if formatted. The script I ran for the src directory is added as build-scripts/clang-format-src.sh This fixes: #6592 #6593 #6594 (cherry picked from commit 5750bcb174300011b91d1de20edb288fcca70f8c)
Sylvain Becker fb0ce375 2022-11-27T17:38:43 Cleanup add brace (#6545) * Add braces after if conditions * More add braces after if conditions * Add braces after while() conditions * Fix compilation because of macro being modified * Add braces to for loop * Add braces after if/goto * Move comments up * Remove extra () in the 'return ...;' statements * More remove extra () in the 'return ...;' statements * More remove extra () in the 'return ...;' statements after merge * Fix inconsistent patterns are xxx == NULL vs !xxx * More "{}" for "if() break;" and "if() continue;" * More "{}" after if() short statement * More "{}" after "if () return;" statement * More fix inconsistent patterns are xxx == NULL vs !xxx * Revert some modificaion on SDL_RLEaccel.c * SDL_RLEaccel: no short statement * Cleanup 'if' where the bracket is in a new line * Cleanup 'while' where the bracket is in a new line * Cleanup 'for' where the bracket is in a new line * Cleanup 'else' where the bracket is in a new line (cherry picked from commit 6a2200823c66e53bd3cda4a25f0206b834392652 to reduce conflicts merging between SDL2 and SDL3)
Sam Lantinga 99f2a503 2022-10-13T22:40:24 X11 scancode mapping cleanup * Consolidated scancode mapping tables into a single location for all backends * Verified that the xfree86_scancode_table2 is largely identical to the Linux scancode table * Updated the Linux scancode table with the latest kernel keycodes (still unmapped) * Route X11 keysym -> scancode mapping through the linux scancode table (which a few hand-written exceptions), which will allow mappings to automatically get picked up as they are added in the Linux scancode table * Disabled verbose reporting of missing keysym mappings, we have enough data for now
Adam Butcher 8f5932dc 2022-06-23T16:10:39 evdev: Support user-provided devices via SDL_EVDEV_DEVICES in non-udev mode.
Cameron Gutman a10c57df 2022-07-31T14:18:33 evdev: Report touchpad events with the correct device type
Cameron Gutman 9a33c62e 2022-07-31T14:06:59 evdev: Use SDL_bool for boolean types
Cameron Gutman f9d1f34b 2022-07-31T13:10:43 evdev: Report a unique ID for each mouse device
Cameron Gutman 574db63c 2022-07-31T12:36:11 evdev: Batch mouse axis updates until SYN_REPORT This is necessary for consistent position reports with absolute mice and improves application performance with relative mice by cutting the number of reported mouse motion events roughly in half.
Sam Lantinga 120c76c8 2022-01-03T09:40:00 Updated copyright for 2022
Cameron Gutman 2d673e5b 2021-12-06T22:07:33 evdev: Add support for REL_WHEEL_HI_RES and REL_HWHEEL_HI_RES If supported, these come alongside the regular REL_WHEEL and REL_HWHEEL events so it's important that we only process one or the other.
Sam Lantinga 373216ae 2021-10-07T18:14:16 Added support for touchpads in the Linux evdev code (thanks Francisco!)
Sam Lantinga bf97c5a2 2021-09-08T14:47:40 Make sure SDL file descriptors don't leak into child processes
Sam Lantinga 2f72535c 2021-01-08T09:54:55 Fixed joysticks generating SDL mouse events
Sam Lantinga 9130f7c3 2021-01-02T10:25:38 Updated copyright for 2021
Sam Lantinga cb361896 2020-12-09T07:16:22 Fixed bug 5235 - All internal sources should include SDL_assert.h Ryan C. Gordon We should really stick this in SDL_internal.h or something so it's always available.
Simon McVittie 8db3171b 2020-11-11T19:14:34 udev: Factor out SDL_EVDEV_GuessDeviceClass This works on capability bitfields that can either come from udev or from ioctls, so it is equally applicable to both udev and non-udev input device detection. Signed-off-by: Simon McVittie <smcv@collabora.com>
Sam Lantinga a8780c6a 2020-01-16T20:49:25 Updated copyright date for 2020
Sam Lantinga 2bfcf5cd 2019-11-18T14:08:05 Added Linux controller mapping for the Xbox One Elite Series 2 controller in Bluetooth mode
Alex Szpakowski 109cbd6e 2019-08-04T16:56:40 Fix touch-related compile errors on Linux.
Alex Szpakowski d5ec735a 2019-08-01T18:22:12 Add a windowID field to SDL_TouchFingerEvent (bug #4331). This is unimplemented on some platforms and will cause compile errors when building those platform backends for now.
Sam Lantinga 67bb882e 2019-07-03T15:57:55 Fixed bug 4707 - SDL_SetRelativeMouseMode fails on Vivante Cameron Gutman The bugfix in https://hg.libsdl.org/SDL/rev/ca9417a52f18 caused SDL_SetRelativeMouseMode() to begin failing on Vivante (Steam Link). Even though Vivante doesn't have a SetRelativeMouseMode() or WarpMouse() function, it's in relative mode already (because it uses evdev) so the function was actually working as intended. I think providing a no-op SetRelativeMouseMode() function for Vivante is a reasonable fix. Since it's already getting relative events through evdev, it really is a no-op to "enter relative mode". In fact, this is probably the right thing to do for all backends that use evdev (vivante, raspberry, and kmsdrm). Raspberry and kmsdrm both have WarpMouse() implementations so SDL_SetRelativeMouseMode() isn't failing there, but it still seems to make sense not to have to do the fake warping if they're evdev-based anyway.
Sam Lantinga d01150ab 2019-06-12T07:55:48 Fixed bug 4665 - Add support for single touch evdev devices Jan Martin Mikkelsen The attached patch adds support for single-touch evdev devices. These devices report ABS_X, ABS_Y and BTN_TOUCH events. This patch sets them up as MT devices with a single slot and handles the appropriate messages.
Sam Lantinga 23569362 2019-06-05T12:01:26 Use SDL sized types
Sam Lantinga 3e329464 2019-06-05T08:54:07 Fixed bug 4656 - SDL_evdev.c uses Linux specific integer types Jan Martin Mikkelsen The file src/core/linux/SDL_evdev.c uses the Linux specific types __u32 and __s32. This breaks things on FreeBSD when building with evdev.
Sylvain Becker ab03892d 2019-04-04T15:19:00 Bug 4576: track both FingerId and TrackId
Sylvain Becker 6bc2d9de 2019-04-02T17:03:58 Bug 4576: remove touch/mouse duplication for linux/EVDEV
Ryan C. Gordon 861a21f9 2019-01-14T19:43:25 evdev: don't debug log on a BTN_TOUCH from a non-touch device.
Ryan C. Gordon 2755a505 2019-01-14T19:36:54 evdev: Add touchscreen mouse emulation and pressure support (thanks, Zach!). This also solves reports of this log message: "INFO: The key you just pressed is not recognized by SDL. To help get this fixed, please report this to the SDL forums/mailing list <https://discourse.libsdl.org/> EVDEV KeyCode 330" (EVDEV KeyCode 330 is BTN_TOUCH.) Fixes Bugzilla #4147.
Sam Lantinga 5e13087b 2019-01-04T22:01:14 Updated copyright for 2019
Alex Szpakowski 5029d50e 2018-11-10T16:15:48 Add SDL_TouchDeviceType enum and SDL_GetTouchDeviceType(SDL_TouchID id). Touch device types include SDL_TOUCH_DEVICE_DIRECT (a touch screen with window-relative coordinates for touches), SDL_TOUCH_DEVICE_INDIRECT_ABSOLUTE (a trackpad-style device with absolute device coordinates), and SDL_TOUCH_DEVICE_INDIRECT_RELATIVE (a trackpad-style device with screen cursor-relative coordinates). Phone screens are an example of a direct device type. Mac trackpads are the indirect-absolute touch device type. The Apple TV remote is an indirect-relative touch device type.
Ozkan Sezer b6aaefc7 2018-08-29T11:04:02 SDL_evdev.c: undefine _THIS before redefining it. src/core/linux/SDL_evdev.c:104:1: warning: "_THIS" redefined In file included from src/core/linux/../../events/SDL_events_c.h:26, from src/core/linux/SDL_evdev.c:45: src/core/linux/../../events/../video/SDL_sysvideo.h:146:1: warning: this is the location of the previous definition
Sam Lantinga e3cc5b2c 2018-01-03T10:03:25 Updated copyright for 2018
Philipp Wiesemann 22c221f3 2017-06-11T22:30:58 linux: Changed internal functions to be static.
Philipp Wiesemann 90ed3daa 2017-05-26T22:45:52 Changed messages about not recognized keys to include discourse link.
Sam Lantinga e0a40fb6 2017-01-09T02:54:42 Implemented full evdev keyboard text support This is based on the Linux kernel driver, and has fallback mapping tables in case we aren't connected to a virtual terminal.
Sam Lantinga 49292705 2017-01-08T20:03:18 Fixed bug 3545 - SDL_EVDEV_do_text_input() may be too eager to find error cases Rob I've ran into an issue where I successfully receive SDL_KEY[UP,DOWN] events but not SDL_TEXTINPUT or SDL_TEXTEDITING. In my case the code in SDL_EVDEV_do_text_input() is returning early (on error) prior to calling SDL_SendKeyboardText(). I'm running on the RaspberryPi 3, without X11. In SDL_EVDEV_do_text_input() there is a condition to check keysyms with a type value below 0xf0, then subtract 0xf0 from type. Without understanding the purpose of this code, I disabled it, recompiled, and I'm getting correct SDL_TEXTINPUT events. I'm going to guess that my hack/fix is going to be problematic in some other environment, but after some initial testing it looks like everything is running fine in my setup.
Sam Lantinga 7b66295e 2017-01-08T19:04:38 Removed console check, let the kernel decide whether muting is appropriate on this terminal. We don't fail the init if we can't mute the terminal (we might be running from ssh, or on a system without virtual terminals, etc.)
Sam Lantinga b8ab4eb9 2017-01-08T10:15:22 SDL_evdev.c: fix building against old kernel headers (K_OFF may not be defined.)
Sam Lantinga 7e505b0d 2017-01-07T16:49:23 Don't fail if we can't open the tty, this can be a legitimate use case.
Sam Lantinga e9c2dcda 2017-01-07T10:13:04 Fixed bug 3469 - Keypresses leak to the console with 2.0.5 tvc I believe this patch should fix it, instead of looping through all the tty's and seemingly selecting the wrong one and corrupting the console I've just made SDL open /dev/tty which is the console attached to the current process anyway.
Sam Lantinga 41be9756 2017-01-05T23:26:13 Fixed bug 3546 - SDL_EVDEV_is_console() uses type of wrong size when calling ioctl Rob When calling ioctl(fd, KDGKBTYPE, &type) in SDL_EVDEV_is_console(), we declare type as an 'int'. This should be a 'char'. The subsequent syscall, and kernel code, only writes the lower byte of the word. See: http://lxr.free-electrons.com/source/drivers/tty/vt/vt_ioctl.c?v=4.4#L399 ucval = KB_101; ret = put_user(ucval, (char __user *)arg); I've observed intermittent behavior related to this, and I can force an error condition by using an int initialized to 0xFFFFFFFF. The resulting ioctl will set type to 0XFFFFFF02, and the conditional return in SDL_EVDEV_is_console() will fail. Recommend changing to char, or masking off unused bits.
Sam Lantinga 45b774e3 2017-01-01T18:33:28 Updated copyright for 2017
Sam Lantinga 539afc5d 2016-11-01T10:33:44 Fixed bug 3473 - can't build on linux with an old kernel
Sam Lantinga ac7d1174 2016-10-01T15:04:13 Fixed build on older Raspberry Pi environments
Sam Lantinga a0d3e0d6 2016-10-01T14:56:53 Fixed warning and code style in SDL_evdev.c
Sam Lantinga 1a31bbe2 2016-10-01T13:51:56 Fixed bug 3157 - Rudimentary touchscreen support in SDL_evdev (supports Raspberry Pi) tvc I've spent the last few days implementing touchscreen support in core/linux/SDL_evdev.c. It's fairly rudimentary at the moment, as can be seen from the multiple TODO's and FIXME's littered throughout, but I'm mainly submitting this patch for review. I've tested this patch on my Raspberry Pi 2 with the official touchscreen and it works fantastically, reporting all 10 multitouch points. I'm happy to work on this further, the evdev logic also needs a bit of a cleanup I think (I may have included a few changes). But if it's good enough in its current state to be committed then I'm sure there'd be plenty of people pleased, as currently the only other framework/library that supports touchscreens on the Raspberry Pi is Kivy.
Sam Lantinga 42065e78 2016-01-02T10:10:34 Updated copyright to 2016
Sam Lantinga 82eec4b6 2015-06-24T17:55:38 Fixed whitespace in SDL_evdev.c
Sam Lantinga 9f50d63d 2015-06-24T17:54:39 Fixed an issue with mouse/keyboard removal Sometimes, on removal SDL_EVDEV_udev_callback() gets called with zero udev_class. This in turn seems to be caused the SDL_udev.c:guess_device_class() failing to find the attributes of the parent device. Apparently this is normal, attributes are not guaranteed to be in place during removal, depending on timing. This lack of attributes causes guess_device_class() to return zero. This fix mimics the code in linux/SDL_sysjoystick.c:joystick_udev_callback() which effectively has the same fix already in place.
Philipp Wiesemann 0e45984f 2015-06-21T17:33:46 Fixed crash if initialization of EGL failed but was tried again later. The internal function SDL_EGL_LoadLibrary() did not delete and remove a mostly uninitialized data structure if loading the library first failed. A later try to use EGL then skipped initialization and assumed it was previously successful because the data structure now already existed. This led to at least one crash in the internal function SDL_EGL_ChooseConfig() because a NULL pointer was dereferenced to make a call to eglBindAPI().
Ryan C. Gordon 71468742 2015-06-12T11:58:31 Make some string literals "const char *", not "char *" (thanks, Martin!). Fixes Bugzilla #3007.
Sam Lantinga 2c4a6ea0 2015-05-26T06:27:46 Updated the copyright year to 2015
Ryan C. Gordon b72938c8 2015-04-20T12:22:44 Windows: Always set the system timer resolution to 1ms by default. An existing hint lets apps that don't need the timer resolution changed avoid this, to save battery, etc, but this fixes several problems in timing, audio callbacks not firing fast enough, etc. Fixes Bugzilla #2944.
Alex Szpakowski fe6c797c 2015-04-10T23:30:31 Fixed an iOS view orientation issue when SDL_GL_CreateContext or SDL_CreateRenderer is called.
Edward Rudd b88ca1b4 2015-02-10T16:28:56 the last parameter of XChangeProperty is the number of elements.. and when the element format is 32.. the element is "long" so we have 5 long elements here. Yes this seems confusing as on mac+linux Long is either 32 or 64bits depending on the architecture, but this is how the X11 protocol is defined. Thus 5 is the correct value for the nelts here. Not 5 or 10 depending on the architecture. More info on the confusion https://bugs.freedesktop.org/show_bug.cgi?id=16802
Philipp Wiesemann b48e54aa 2015-01-26T22:00:29 Fixed bug 2802 - [patch] Fix android build compiling in wrong filesystem implementation Jonas Kulla The configure script didn't differentiate between Linux and Android, unconditionally compiling in the unix implementation of SDL_sysfilesystem.c. I'm probably one of the very few people building SDL for android using classic configure + standalone toolchain, so this has gone undetected all along.
David Ludwig 70438be2 2014-12-03T10:55:23 WinRT: fixed bug whereby SDL would override an app's default orientation WinRT apps can set a default, preferred orientation via a .appxmanifest file. SDL was overriding this on app startup, and making the app use all possible orientations (landscape and portrait). Thanks to Eric Wing for the heads up on this!
Edward Rudd 5b5823ee 2014-11-23T21:09:54 add in support for passing down the "natural" (or flipped) scrolling direction in the MouseWheelEvent event
Philipp Wiesemann 9c398852 2014-11-22T22:20:40 Corrected header file documentation comment.
Sam Lantinga 639b39c4 2014-10-15T09:09:57 Fixed crash if the event subsystem didn't initialize properly
Pierre-Loup A. Griffais 24c86b55 2014-09-11T19:24:42 [X11] Reconcile logical keyboard state with physical state on FocusIn since the window system doesn't do it for us like other platforms. This prevents sticky keys and missed keys when going in and out of focus, for example Alt would appear to stick if switching away from an SDL app with Alt-Tab and had to be pressed again. CR: Sam
David Ludwig 3dcb451f 2014-04-09T21:29:19 Added a README file regarding WinRT support To note, this file is currently formatted with CRLF line endings, rather than LF, to allow the file to be viewed with Notepad.
Sam Lantinga 58edac3e 2014-02-02T00:53:27 Fixed bug 2374 - Update copyright for 2014... Is it that time already??
Gabriel Jacobo f848adff 2013-11-29T10:06:08 Improve Android pause/resume behavior.
Ryan C. Gordon 7e1289af 2013-11-24T23:56:17 Make internal SDL sources include SDL_internal.h instead of SDL_config.h The new header will include SDL_config.h, but allows for other global stuff.
Sam Lantinga 4e1ee557 2013-11-16T12:02:09 Fixed bug 2231 - Move src/input/evdev into src/core/linux Ryan C. Gordon To keep the directory layout sane, we should probably move this one piece of source to the linux catch-all directory, instead of making it look like this is part of an SDL "input" subsystem.