Commit graph

62 commits

Author SHA1 Message Date
Sylvain Becker cb6b8b0132
Simplify flags testing (#7220) 2023-02-03 13:08:42 -08:00
Sam Lantinga fde78d12f2 Updated copyright for 2023 2023-01-09 09:41:41 -08:00
Sam Lantinga cefbeb582f Mouse coordinates are floating point
You can get sub-pixel mouse coordinates and motion depending on the platform and display scaling.

Fixes https://github.com/libsdl-org/SDL/issues/2999
2022-12-29 23:12:19 -08:00
Sam Lantinga 63724c113b Removed the vi format comments from the source
Vim users can use the [editorconfig plugin](https://github.com/editorconfig/editorconfig-vim) to automatically set tab spacing for the SDL coding style.

Fixes https://github.com/libsdl-org/SDL/issues/6903
2022-12-26 11:17:23 -08:00
Sam Lantinga 75f1eb9216 Don't assume evdev events and SDL_GetTicks() use the same time source
The evdev events are in the same time base as gettimeofday(), but SDL_GetTicks() might be using clock_gettime()
2022-12-05 10:40:16 -08:00
Sam Lantinga 73f4aeee6a Pass the event timestamp for joystick events
This allows the application to get more fine grained information about controller event timing, and group events that happened together.
2022-12-04 09:29:28 -08:00
Sam Lantinga 0a3262e819 Pass the OS event timestamp for keyboard, mouse, and touch events where possible
Currently implemented for Windows and Apple platforms
2022-12-02 12:37:41 -08:00
Pierre Wendling 3c501b963d
Clang-Tidy fixes (#6725) 2022-12-01 13:07:03 -08:00
Sylvain 778b8926b4
Small format changed (using clang-format 15.0.2-1) 2022-12-01 09:39:08 +01:00
Sam Lantinga 5750bcb174
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
2022-11-30 12:51:59 -08:00
Sam Lantinga c5790359fd
Added precompiled header support for Visual Studio and Xcode (#6710)
Fixes https://github.com/libsdl-org/SDL/issues/6704
2022-11-29 18:34:15 -08:00
Sylvain Becker 6a2200823c
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
2022-11-27 08:38:43 -08:00
Sam Lantinga 0a48abc860 Switch header convention from #include "SDL.h" to #include <SDL3/SDLh>
I ran this script in the include directory:
```sh
sed -i '' -e 's,#include "\(SDL.*\)",#include <SDL3/\1>,' *.h
```

I ran this script in the src directory:
```sh
for i in ../include/SDL3/SDL*.h
do hdr=$(basename $i)
   if [ x"$(echo $hdr | egrep 'SDL_main|SDL_name|SDL_test|SDL_syswm|SDL_opengl|SDL_egl|SDL_vulkan')" != x ]; then
        find . -type f -exec sed -i '' -e 's,#include "\('$hdr'\)",#include <SDL3/\1>,' {} \;
    else
        find . -type f -exec sed -i '' -e '/#include "'$hdr'"/d' {} \;
    fi
done
```

Fixes https://github.com/libsdl-org/SDL/issues/6575
2022-11-26 22:15:18 -08:00
Sam Lantinga e9014ee769 Fixed evdev using standard C functions instead of SDL functions 2022-11-26 05:01:03 -08:00
Sam Lantinga 99f2a50394 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
2022-10-13 22:41:47 -07:00
Adam Butcher 8f5932dc2e evdev: Support user-provided devices via SDL_EVDEV_DEVICES in non-udev mode. 2022-08-07 16:37:07 -07:00
Cameron Gutman a10c57dfe4 evdev: Report touchpad events with the correct device type 2022-07-31 14:18:44 -05:00
Cameron Gutman 9a33c62e13 evdev: Use SDL_bool for boolean types 2022-07-31 14:06:59 -05:00
Cameron Gutman f9d1f34b6c evdev: Report a unique ID for each mouse device 2022-07-31 13:10:43 -05:00
Cameron Gutman 574db63c8e 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.
2022-07-31 12:36:11 -05:00
Sam Lantinga 120c76c84b Updated copyright for 2022 2022-01-03 09:40:21 -08:00
Cameron Gutman 2d673e5b56 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.
2021-12-07 07:00:31 -08:00
Sam Lantinga 373216ae5b Added support for touchpads in the Linux evdev code (thanks Francisco!) 2021-10-07 18:14:16 -07:00
Sam Lantinga bf97c5a22f Make sure SDL file descriptors don't leak into child processes 2021-09-08 14:47:40 -07:00
Sam Lantinga 2f72535c62 Fixed joysticks generating SDL mouse events 2021-01-08 09:54:55 -08:00
Sam Lantinga 9130f7c377 Updated copyright for 2021 2021-01-02 10:25:38 -08:00
Sam Lantinga cb36189692 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.
2020-12-09 07:16:22 -08:00
Simon McVittie 8db3171b98 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>
2020-11-11 19:14:34 -08:00
Sam Lantinga a8780c6a28 Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
Sam Lantinga 2bfcf5cd96 Added Linux controller mapping for the Xbox One Elite Series 2 controller in Bluetooth mode 2019-11-18 14:08:05 -08:00
Alex Szpakowski 109cbd6e8b Fix touch-related compile errors on Linux. 2019-08-04 16:56:40 -03:00
Alex Szpakowski d5ec735a33 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.
2019-08-01 18:22:12 -03:00
Sam Lantinga 67bb882e13 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.
2019-07-03 15:57:55 -07:00
Sam Lantinga d01150abc2 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.
2019-06-12 07:55:48 -07:00
Sam Lantinga 23569362dc Use SDL sized types 2019-06-05 12:01:26 -07:00
Sam Lantinga 3e3294645f 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.
2019-06-05 08:54:07 -07:00
Sylvain Becker ab03892ddf Bug 4576: track both FingerId and TrackId 2019-04-04 15:19:00 +02:00
Sylvain Becker 6bc2d9de1f Bug 4576: remove touch/mouse duplication for linux/EVDEV 2019-04-02 17:03:58 +02:00
Ryan C. Gordon 861a21f98b evdev: don't debug log on a BTN_TOUCH from a non-touch device. 2019-01-14 19:43:25 -05:00
Ryan C. Gordon 2755a505a3 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.
2019-01-14 19:36:54 -05:00
Sam Lantinga 5e13087b0f Updated copyright for 2019 2019-01-04 22:01:14 -08:00
Alex Szpakowski 5029d50ea8 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.
2018-11-10 16:15:48 -04:00
Ozkan Sezer b6aaefc791 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
2018-08-29 11:04:02 +03:00
Sam Lantinga e3cc5b2c6b Updated copyright for 2018 2018-01-03 10:03:25 -08:00
Philipp Wiesemann 22c221f3b0 linux: Changed internal functions to be static. 2017-06-11 22:30:58 +02:00
Philipp Wiesemann 90ed3daa3e Changed messages about not recognized keys to include discourse link. 2017-05-26 22:45:52 +02:00
Sam Lantinga e0a40fb6a9 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.
2017-01-09 02:54:42 -08:00
Sam Lantinga 49292705a9 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.
2017-01-08 20:03:18 -08:00
Sam Lantinga 7b66295e05 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.)
2017-01-08 19:04:38 -08:00
Sam Lantinga b8ab4eb9a8 SDL_evdev.c: fix building against old kernel headers (K_OFF may not be defined.) 2017-01-08 10:15:22 -08:00