Sam Lantinga
bf27269952
Re-enable full controller reports for Joy-Con controllers
...
When they are in simple report mode, the thumbstick gets turned into a digital hat, so let's use them in full report mode.
2024-06-12 23:36:16 -07:00
Sam Lantinga
6619de8f24
Try to guess the type of a Nintendo Switch controller if we can't read the device info
2024-06-12 23:22:44 -07:00
Sam Lantinga
5ee9a840b1
Ignore spurious reply packets when reading Nintendo Switch controller reports
2024-06-12 23:03:50 -07:00
Sam Lantinga
fcd2a3a6ad
Fixed mapping for Joy-Con controllers in simple report mode
2024-06-12 22:28:47 -07:00
Sam Lantinga
a87fa020ac
Don't enable enhanced report mode for Bluetooth Nintendo Switch controllers by default
...
This breaks applications using them in DirectInput mode, which isn't worth just getting battery status. We'll turn on enhanced mode if the application enables sensors.
2024-05-10 12:17:28 -07:00
Sam Lantinga
8847b35244
Separate joystick power state into battery status and percentage
...
This allows you to see battery percentage while the controller is charging
2024-04-01 13:59:00 -07:00
Sam Lantinga
f66fe7e221
Replaced SDL_GetJoystickCaps() with joystick properties
...
Fixes https://github.com/libsdl-org/SDL/issues/8927
2024-01-27 15:11:52 -08:00
Sam Lantinga
cd231a65f6
Added SDL_GetJoystickCaps() and SDL_GetGamepadCaps() to get the capabilities of controllers
...
Also added SDL_GAMEPAD_CAP_PLAYER_LED to let the application know if the controller has a visible player LED
2024-01-22 19:23:42 -08:00
Sam Lantinga
5b3ee51c6c
Updated copyright for 2024
2024-01-01 13:15:26 -08:00
Sam Lantinga
dce626f469
Fixed warning C4244: 'function': conversion from 'int' to 'Uint16', possible loss of data
2023-12-29 09:24:52 -08:00
Sam Lantinga
70ba3f2830
Report the D-Pad for HIDAPI gamepads as a hat
...
This makes it easier for games that don't use the gamepad API to handle D-Pad navigation, and is consistent with many other non-HIDAPI mappings.
Fixes https://github.com/libsdl-org/SDL/issues/8754
2023-12-28 14:14:51 -08:00
Sam Lantinga
c3d84c3342
Record the initial input report mode and only restore simple mode if that's what we started with
...
Fixes https://github.com/libsdl-org/SDL/issues/8108
Closes https://github.com/libsdl-org/SDL/pull/8115
2023-12-24 08:12:14 -08:00
Ryan C. Gordon
447b508a77
error: SDL's allocators now call SDL_OutOfMemory on error.
...
This means the allocator's caller doesn't need to use SDL_OutOfMemory directly
if the allocation fails.
This applies to the usual allocators: SDL_malloc, SDL_calloc, SDL_realloc
(all of these regardless of if the app supplied a custom allocator or we're
using system malloc() or an internal copy of dlmalloc under the hood),
SDL_aligned_alloc, SDL_small_alloc, SDL_strdup, SDL_asprintf, SDL_wcsdup...
probably others. If it returns something you can pass to SDL_free, it should
work.
The caller might still need to use SDL_OutOfMemory if something that wasn't
SDL allocated the memory: operator new in C++ code, Objective-C's alloc
message, win32 GlobalAlloc, etc.
Fixes #8642 .
2023-11-30 00:14:27 -05:00
Sam Lantinga
09d1e9defb
Only update the battery status for Bluetooth Switch Pro controllers
...
Controllers that are plugged in are in the wired state
2023-11-10 17:09:39 -08:00
Sam Lantinga
d98e1bdfe1
Use the standard gamepad type for Switch Pro controllers using the GameCube form factor
2023-11-10 16:39:32 -08:00
Sam Lantinga
2991b9f6ac
SDL now represents gamepad buttons as positional elements with a separate label
...
This gives applications and binding systems a clearer view of what the hardware is so they can make intelligent decisions about how to present things to the user.
Gamepad mappings continue to use abxy for the face buttons for simplicity and compatibility with earlier versions of SDL, however the "SDL_GAMECONTROLLER_USE_BUTTON_LABELS" hint no longer has any effect.
Fixes https://github.com/libsdl-org/SDL/issues/6117
2023-11-10 12:21:43 -08:00
Sylvain
d8600f717e
Pointer as bool (libsdl-org#7214)
2023-11-09 14:18:36 -08:00
Sam Lantinga
f3261fedcc
Code cleanup now that SDL_bool is equivalent to a C boolean expression
2023-11-03 09:54:04 -07:00
Simon McVittie
efe15588d5
Relabel back paddles as left or right
...
The sequence order of the four paddles is not obvious, with SDL and Xbox
controllers swapping the order of P2 and P3 relative to each other.
If we group them into left and right, then it becomes more obvious.
Signed-off-by: Simon McVittie <smcv@collabora.com >
2023-08-09 11:03:30 -07:00
Sam Lantinga
b271e92c6e
Added the ability to specify a gamepad type in the mapping
...
Also renamed most cases of SDL_GAMEPAD_TYPE_UNKNOWN to SDL_GAMEPAD_TYPE_STANDARD, and SDL_GetGamepadType() will return SDL_GAMEPAD_TYPE_UNKNOWN only if the gamepad is invalid.
2023-07-17 12:59:56 -07:00
luzpaz
37e567994d
Fix remaining typos ( #7921 )
...
* Fix remaining typos
Found via `codespell -q 3 -S *.hex,*.pdf,./src/libm,./src/hidapi,./src/stdlib/SDL_malloc.c,./src/video/x11/edid.h -L caf,currenty,datas,einstance,fo,hda,lod,mata,parm,parms,pevent,pevents,pixelx,requestor,ser,statics,te,texturers,thid,uscaled,windowz`
2023-07-03 12:46:47 -07:00
Sam Lantinga
baa9c57581
Added support for the Nintendo Online Famicom controllers
2023-06-28 19:15:43 -07:00
Sam Lantinga
9ee1200e6f
Fixed Nintendo Switch Pro controllers that don't have readable user calibration
2023-06-27 07:48:42 -07:00
Narr the Reg
425062c123
hidapi: switch: Handle MCU input reports
2023-06-26 10:01:49 -07:00
Sam Lantinga
214d5daa3c
Removed 100 ms hitch when querying third party Nintendo Switch controllers that don't respond to request for info
...
Also take advantage of the fact that we know whether the device is connected over Bluetooth now.
2023-06-21 12:14:50 -07:00
Sam Lantinga
3694dabe7c
Use default sensor calibration if we can't read it from the Nintendo Switch controller
...
Fixes https://github.com/libsdl-org/SDL/issues/7830
2023-06-21 10:28:45 -07:00
Sam Lantinga
f168f9c813
Added support for the GameSir G4 Pro
...
We can't read device info or IMU calibration from this controller, and it has no gyro or accelerometer, but is otherwise perfectly functional.
2023-06-17 12:42:55 -07:00
Sam Lantinga
0c16f4faf0
Fixed third-party Nintendo Switch Pro controllers shutting down when we try to set the home LED.
...
This fixes the PDP Afterglow Wireless Deluxe Controller.
2023-06-14 10:15:06 -07:00
Sam Lantinga
23e007d3b7
Fixed third party Nintendo Switch Pro Controller resetting when being sent an unsupported command to set the Home LED
...
Tested with the PowerA Fusion Pro Wireless Controller in Bluetooth mode
2023-06-14 00:02:32 -07:00
Sam Lantinga
8c95bd814b
Allow switching licensed Nintendo Switch Pro controllers into gyro input mode
2023-06-13 22:40:51 -07:00
Sam Lantinga
cdfc0c5a33
Added support for the PowerA Fusion Pro Wireless Controller in Bluetooth mode
...
This controller shows up with a VID/PID of 0, but has full functionality over Bluetooth
2023-06-13 22:20:58 -07:00
Sam Lantinga
5490873daa
Fixed querying device info on the MOBAPAD M073
...
The query packet needs to contain valid rumble data in order to be accepted by the controller.
Fixes https://github.com/libsdl-org/SDL/issues/7788
2023-06-09 18:41:21 -07:00
Sam Lantinga
9837653b9d
Allow the application to send commands to Nintendo Switch controllers
2023-06-02 15:52:56 -07:00
Sam Lantinga
ddbdd73258
Updated source to match SDL function prototype style
2023-05-23 11:29:41 -07:00
Sam Lantinga
28f891ad0a
Allow the application to send rumble packets to Nintendo Switch controllers
2023-05-09 17:08:47 -07:00
Sam Lantinga
308bcbbe76
Fixed Visual Studio warning 4244
2023-03-30 14:04:32 -07:00
Sam Lantinga
c6443d86c9
Code style: changed "sizeof foo" to "sizeof(foo)" (thanks @sezero!)
2023-03-09 15:10:44 -08:00
Sam Lantinga
1a15d506a6
Removed duplicated conditional
2023-02-20 18:24:52 -08:00
Sam Lantinga
02cea5fca1
Fixed rumble caps for the Nintendo Joy-Con controllers
2023-02-20 17:14:18 -08:00
Sam Lantinga
b7c6fec10a
Make sure we synchronously re-enable USB reporting mode for Switch controllers (thanks @SortaCore!)
...
Fixes https://github.com/libsdl-org/SDL/issues/3450
2023-02-08 14:22:39 -08:00
Narr the Reg
9fa55d9cab
hidapi: switch: Add user calibration support
2023-01-09 18:07:54 -08:00
Sam Lantinga
fde78d12f2
Updated copyright for 2023
2023-01-09 09:41:41 -08:00
Sam Lantinga
36d4395c97
SDL API renaming: internal functions
2022-12-27 15:05:51 -08:00
Sam Lantinga
659abc721a
SDL API renaming: SDL_gamecontroller.h
...
SDL_gamecontroller.h has been renamed SDL_gamepad.h, and all APIs have been renamed to match.
Fixes https://github.com/libsdl-org/SDL/issues/6885
2022-12-27 09:47:24 -08:00
Sam Lantinga
fc478c1bc0
SDL API renaming: SDL_joystick.h
...
Fixes https://github.com/libsdl-org/SDL/issues/6881
2022-12-27 05:50:46 -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
5c29b58e95
Added support for clang thread-safety analysis
...
The annotations have been added to SDL_mutex.h and have been made public so applications can enable this for their own code.
Clang assumes that locking and unlocking can't fail, but SDL has the concept of a NULL mutex, so the mutex functions have been changed not to report errors if a mutex hasn't been initialized. We do have mutexes that might be accessed when they are NULL, notably in the event system, so this is an important change.
This commit cleans up a bunch of rare race conditions in the joystick and game controller code so now everything should be completely protected by the joystick lock.
To test this, change the compiler to "clang -Wthread-safety -Werror=thread-safety -DSDL_THREAD_SAFETY_ANALYSIS"
2022-12-14 09:53:39 -08:00
Sam Lantinga
b8760a3ffe
The timestamp_us member of the sensor events has been renamed sensor_timestamp and now represents nanoseconds.
2022-12-04 09:29:28 -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
8121bbd083
Convert ticks to 64-bit, added nanosecond precision to the API
...
Fixes https://github.com/libsdl-org/SDL/issues/5512
Fixes https://github.com/libsdl-org/SDL/issues/6731
2022-12-02 12:37:41 -08:00