Commit Graph

9180 Commits

Author SHA1 Message Date
Cameron Gutman
f14fb979c1 Remove legacy SDL2 input grab API 2024-03-24 16:53:23 -07:00
Mykola Rubets
fc053fb499 Fix OpenFolder dialog behavior on Windows 2024-03-24 11:44:16 -07:00
Sam Lantinga
13933222ee Fixed string comparison (thanks @meyraud705!) 2024-03-24 11:37:03 -07:00
Anonymous Maarten
beb52ed54a pen: remove stray '#include <stdio.h>' 2024-03-24 16:58:59 +01:00
Sam Lantinga
36e73bdda4 Updated to version 3.1.0 for the preview release 2024-03-24 06:16:02 -07:00
Frank Praznik
9e460ce6a6 wayland: Pass the keyboard ID through to repeat events 2024-03-24 08:49:29 -04:00
Christoph Reichenbach
615c7efd98 Fix #9279: Memory leak in pen name handling
- Fixes a leak in pen name allocation that would trigger
  for both X11 and Wayland for some non-pen input devices
  when new devices are added/removed.
- SDL_PenQuit() now deallocates and resets the table of known pens
- testautomation_pen.c now uses PenInit and PenQuit as setup and
  teardown, respectively

testautomation_pen.c was already triggering the leak, and it is
visible with --trackmem, so no new tests are added.
2024-03-24 05:04:53 -07:00
Sam Lantinga
c83d0d87c2 Revert "Added virtual keyboard support for Xbox (thanks @ts-13512)"
This reverts commit b5d4206b30.

@nkrapivin already implemented GDK virtual keyboard support in https://github.com/libsdl-org/SDL/pull/7728
2024-03-23 16:47:59 -07:00
Anonymous Maarten
f030533580 SDL_blit: remove SDL_BLIT_CPU_FEATURES override 2024-03-23 16:36:44 -07:00
Anonymous Maarten
1aa9ef7213 cpuinfo: reset cpu features on SDL_Quit 2024-03-23 16:36:44 -07:00
Anonymous Maarten
64465653b4 audio: always build fallback scalar converters 2024-03-23 16:36:44 -07:00
Anonymous Maarten
1d0e5286aa Limit CPU features through a hint 2024-03-23 16:36:44 -07:00
Sam Lantinga
b5d4206b30 Added virtual keyboard support for Xbox (thanks @ts-13512) 2024-03-23 16:34:43 -07:00
Sam Lantinga
7852a6c307 Added device name for evdev mice and keyboards 2024-03-23 16:31:00 -07:00
Frank Praznik
87714ce5b9 wayland: Set the keyboard and mouse names to match XWayland 2024-03-23 16:31:00 -07:00
Sam Lantinga
72fc6f86e5 Text input is no longer automatically enabled when initializing video.
Fixes https://github.com/libsdl-org/SDL/issues/9309
Fixes https://github.com/libsdl-org/SDL/issues/9268
2024-03-23 16:31:00 -07:00
Sam Lantinga
361b7190df Track unique button states between different mice
We were already halfway doing this, but now we make that information available to the Windows driver so it can cache the button state per-mouse
2024-03-23 16:31:00 -07:00
Sam Lantinga
35756593d6 Use the correct device ID (global or default or specific) based on context 2024-03-23 16:31:00 -07:00
Sam Lantinga
c0f4565552 Added SDL_GetKeyboardName() and SDL_GetMouseName() 2024-03-23 16:31:00 -07:00
Sam Lantinga
20a860c876 Use the specific pointer device ID for X11 button and motion events 2024-03-23 16:31:00 -07:00
Sam Lantinga
476245564c Use the real device IDs for the X11 master keyboard and pointer
These always exist so they don't really help detect whether a keyboard/mouse is attached. Looking at the slave devices isn't that helpful either, as they're very permissive in what they might send.

For example, on my system with a single mouse and keyboard attached, xinput -list shows:
 Virtual core pointer                    	id=2	[master pointer  (3)]
   - Virtual core XTEST pointer              	id=4	[slave  pointer  (2)]
   - Generic USB Mouse                       	id=10	[slave  pointer  (2)]
   - Generic USB Consumer Control            	id=11	[slave  pointer  (2)]
   - KINESIS CORPORATION KB800HM Kinesis Freestyle2 for Mac	id=18	[slave  pointer  (2)]
   - Logitech Gaming Mouse G502 Consumer Control	id=15	[slave  pointer  (2)]
   - Logitech Gaming Mouse G502              	id=17	[slave  pointer  (2)]
 Virtual core keyboard                   	id=3	[master keyboard (2)]
   - Virtual core XTEST keyboard             	id=5	[slave  keyboard (3)]
   - Power Button                            	id=6	[slave  keyboard (3)]
   - Power Button                            	id=7	[slave  keyboard (3)]
   - Sleep Button                            	id=8	[slave  keyboard (3)]
   - Generic USB                             	id=9	[slave  keyboard (3)]
   - Generic USB System Control              	id=12	[slave  keyboard (3)]
   - Generic USB Consumer Control            	id=19	[slave  keyboard (3)]
   - KINESIS CORPORATION KB800HM Kinesis Freestyle2 for Mac	id=20	[slave  keyboard (3)]
   - KINESIS CORPORATION KB800HM Kinesis Freestyle2 for Mac	id=21	[slave  keyboard (3)]
   - Logitech Gaming Mouse G502 Keyboard     	id=13	[slave  keyboard (3)]
   - Logitech Gaming Mouse G502 System Control	id=14	[slave  keyboard (3)]
   - Logitech Gaming Mouse G502 Consumer Control	id=16	[slave  keyboard (3)]
2024-03-23 16:31:00 -07:00
Sam Lantinga
d1eb4adb16 Be explicit about the event mouse and keyboard ID 2024-03-23 16:31:00 -07:00
Frank Praznik
1c54455353 wayland: Send keyboard and mouse added/removed events
Send keyboard and mouse added/removed events when seat capabilities change. Note that Wayland only supports one global keyboard and mouse object per seat, so events coming from different keyboards and mice on the same seat can't be distinguished.
2024-03-23 16:31:00 -07:00
Sam Lantinga
2fe1a6a279 Initial support for hotplugging mice and keyboards 2024-03-23 16:31:00 -07:00
Sam Lantinga
c33e4c998d Clear the subsystem ref count when shutting down subsystems in the main quit
This prevents dependent subsystems from being deinitialized multiple times
2024-03-23 16:31:00 -07:00
Frank Praznik
297f8e41af wayland: Factor out the general SHM buffer allocation/free functions from the cursor code
It will be necessary for a forthcoming toplevel icon setting protocol that will likely soon call for implementations, and is cleaner in general.
2024-03-23 14:17:13 -04:00
Sam Lantinga
3d96c2426f PSP: improve performance counter res to us granularity (thanks @rofl0r!) 2024-03-23 09:34:07 -07:00
Marcel Hild
67e425bcf8 Add support for MadCatz Saitek Side Panel Control Deck
Signed-off-by: Marcel Hild <hild@b4mad.net>
2024-03-22 09:15:39 -07:00
Sam Lantinga
05b57f6c2c Simplified SDL_SYS_RemovePath()
If we get ENOENT we call that success. If the parent directory doesn't exist, that's fine, other operations on it will fail if it matters to the application.
2024-03-21 21:16:14 -07:00
Anonymous Maarten
2521ba47fe jack: set error message when failing to open jack client 2024-03-22 01:22:39 +01:00
Mark Delk
dd4636e3fd SDL_sysmutex.c: fix void return compile error 2024-03-21 13:25:01 -07:00
Sam Lantinga
70b0d33106 Poll for the initial controller state when using DirectInput
This fixes getting a deflected axis as the first buffered input reading on a generic USB controller (G-Shark GS-GP702)
2024-03-20 10:45:11 -07:00
Frank Praznik
4a7e3beeb9 filesystem: Use high-res file times on more platforms
Some POSIX platforms don't define macros to note the presence of the POSIX.1-2008 st_*tim timespec members of the stat struct, so check if this member exists during CMake configuration and conditionally enable it.

Apple platforms use st_*timespec naming, which is supported as of OSX 10.6. SDL3 requires 10.9+, so no fallback is needed.

Android only supports the POSIX.1-2008 semantics as of API version 26 or higher, so this has to be conditionally enabled in the makefile build via an API version definition check.

In other cases, file times fall back to the legacy path with second precision.
2024-03-20 11:39:42 -04:00
Sam Lantinga
da027ec3ee Fixed signed/unsigned comparison warning 2024-03-19 17:00:46 -07:00
Pierre Wendling
390fff4ae0 N3DS: Fix locale name and early return.
- The name for simplified Chinese should be `zh_CN`.
- Ensure `cfguExit` is called even if `CFGU_GetSystemLanguage` failed.
2024-03-19 16:54:07 -07:00
Pierre Wendling
8f529d9d16 N3DS: Implement SDL_GetSystemTimeLocalePreferences
The formats are deduced based on the system's current language and region.
2024-03-19 16:52:56 -07:00
Sam Lantinga
478b965e6c Fixed warning C4702: unreachable code
Also switched SDL_IOFromFile() to use SDL_InvalidParamError()
2024-03-19 16:02:54 -07:00
Sam Lantinga
b1215272ad Fixed warning C4244: '=': conversion from '__int64' to 'int', possible loss of data 2024-03-19 16:02:37 -07:00
Sam Lantinga
c582a89f78 Fixed build warning 2024-03-19 14:53:49 -07:00
Ivan Epifanov
2e45568338 PSVita: fix SDL_GetSystemTimeLocalePreferences 2024-03-19 12:32:51 -07:00
Frank Praznik
a6fbf0488c Add time and realtime clock functions
Adds functions to query the system's realtime clock, convert time intervals to/from a calendar date and time in either UTC or the local time, and perform time related calculations.

An SDL_Time type (a time interval represented in nanoseconds), and SDL_DateTime struct (broken down calendar date and time) were added to facilitate this functionality.

Querying the system time results in a value expressed in nanoseconds since the Unix epoch (Jan 1, 1970) in UTC +0000. Conversions to and from the various platform epochs and units are performed when required.

Any direct handling of timezones and DST were intentionally avoided. The offset from UTC is provided when converting from UTC to a local time by calculating the difference between the original UTC and the resulting local time, but no other timezone or DST information is used.

The preferred date formatting and 12/24 hour time for the system locale can be retrieved via global preferences.

Helper functions for obtaining the day of week or day or year for calendar date, and getting the number of days in a month in a given year are provided for convenience. These are simple, but useful for performing various time related calculations.

An automated test for time conversion is included, as is a simple standalone test to display the current system date and time onscreen along with a calendar, the rendering of which demonstrates the use of the utility functions (press up/down to increment or decrement the current month, and keys 1-5 to change the date and time formats).
2024-03-19 10:57:36 -07:00
Sam Lantinga
24ec1c09b9 Renamed SDL_PROP_IOSTREAM_STDIO_HANDLE_POINTER to SDL_PROP_IOSTREAM_STDIO_FILE_POINTER 2024-03-18 21:56:11 -07:00
Cameron Gutman
d3a785e521 Improve event processing latency when gamepad/sensor is open
By using the SDL_WaitEventTimeout_Device() path even when polling is required,
we can still achieve sub-millisecond latency for non-gamepad/sensor events when
a gamepad or sensor is in use by the application.
2024-03-18 21:52:42 -07:00
Anonymous Maarten
009318c5a9 Fix warnings when building with -DSDL_LIBC=OFF on Linux 2024-03-18 21:29:08 +01:00
Anonymous Maarten
f59dbf6a12 cmake: add -Wimplicit-fallthrough warning 2024-03-18 20:34:50 +01:00
Sam Lantinga
086a7a4687 Fixed signed/unsigned comparison warning 2024-03-18 09:48:45 -07:00
Sam Lantinga
491f18eea3 Fixed uninitialized signal_id
Also removed unnecessary SDL_OutOfMemory() calls

Fixes https://github.com/libsdl-org/SDL/issues/9300
2024-03-18 09:12:51 -07:00
Sam Lantinga
90e2551c4f Sort the SDL API symbols
API renames are almost complete, let's prepare for a preview release
2024-03-18 09:03:36 -07:00
Sam Lantinga
92d01ef12a You can pass NULL to SDL_GetPathInfo() and SDL_GetStoragePathInfo() to test for the existence of a file. 2024-03-18 08:56:24 -07:00
Frank Praznik
ebb6582534 wayland: Handle the toplevel export property as a string
xdg-toplevel export handles are strings, so treat the property as one. Avoids the need to manually manage the string pointer.
2024-03-18 11:41:02 -04:00