Commit Graph

10534 Commits (9e3c4b9f328bb3738ee8a8ec20055d7191702164)

Author SHA1 Message Date
Sam Lantinga 046aaa2d21 Use auto calibration for the Wii Nunchuk thumbstick axis values 2022-09-01 21:37:26 -07:00
Sam Lantinga 8381e008ea Handle hotplugging of Wii controller extensions 2022-09-01 21:13:16 -07:00
Sam Lantinga 396411c090 Added mapping for the Wii Nunchuk extension 2022-09-01 20:27:34 -07:00
Sam Lantinga e19b36d871 Initial support for the Wii Remote with Nunchuk extension 2022-09-01 19:29:20 -07:00
Sam Lantinga c887cb02af Added the hint SDL_HINT_JOYSTICK_HIDAPI_WII_PLAYER_LED to control whether the player LED should be lit on the Nintendo Wii controllers
Also fixed the Y axes on the Wii U Pro controller, and various formatting cleanup
2022-09-01 16:30:55 -07:00
Ozkan Sezer 0ffaf5b871 SDL_hidapi_wii.c: fix build in c89 mode and builds using watcom compiler 2022-09-02 02:04:20 +03:00
Sam Lantinga 397672edfe Added SDL_hidapi_wii.c to the Xcode project 2022-09-01 15:31:03 -07:00
Sam Lantinga c72e14e8f4 Added initial support for Wii controllers (thanks @tellowkrinkle!) 2022-09-01 15:29:41 -07:00
Ozkan Sezer 2847696338 hidapi: really fix dynamic / non-dynamic libusb loading. 2022-09-01 22:55:00 +03:00
Ozkan Sezer 9d77945d36 fixed linkage libusb not dynamicaly loaded after commit 3f89d1704d
build/.libs/SDL_hidapi.o: In function `SDL_EnableGameCubeAdaptors':
src/hidapi/SDL_hidapi.c:1593: undefined reference to `libusb_init'
src/hidapi/SDL_hidapi.c:1594: undefined reference to `libusb_get_device_list'
src/hidapi/SDL_hidapi.c:1596: undefined reference to `libusb_get_device_descriptor'
src/hidapi/SDL_hidapi.c:1604: undefined reference to `libusb_open'
src/hidapi/SDL_hidapi.c:1608: undefined reference to `libusb_kernel_driver_active'
src/hidapi/SDL_hidapi.c:1614: undefined reference to `libusb_claim_interface'
src/hidapi/SDL_hidapi.c:1623: undefined reference to `libusb_close'
src/hidapi/SDL_hidapi.c:1626: undefined reference to `libusb_free_device_list'
src/hidapi/SDL_hidapi.c:1628: undefined reference to `libusb_exit'
src/hidapi/SDL_hidapi.c:1609: undefined reference to `libusb_detach_kernel_driver'
src/hidapi/SDL_hidapi.c:1620: undefined reference to `libusb_attach_kernel_driver'
src/hidapi/SDL_hidapi.c:1615: undefined reference to `libusb_control_transfer'
src/hidapi/SDL_hidapi.c:1616: undefined reference to `libusb_release_interface'
build/.libs/SDL_hidapi.o: In function `SDL_hid_init_REAL':
src/hidapi/SDL_hidapi.c:1086: undefined reference to `libusb_init'
src/hidapi/SDL_hidapi.c:1087: undefined reference to `libusb_exit'
src/hidapi/SDL_hidapi.c:1088: undefined reference to `libusb_get_device_list'
src/hidapi/SDL_hidapi.c:1089: undefined reference to `libusb_free_device_list'
src/hidapi/SDL_hidapi.c:1090: undefined reference to `libusb_get_device_descriptor'
src/hidapi/SDL_hidapi.c:1091: undefined reference to `libusb_get_active_config_descriptor'
src/hidapi/SDL_hidapi.c:1092: undefined reference to `libusb_get_config_descriptor'
src/hidapi/SDL_hidapi.c:1093: undefined reference to `libusb_free_config_descriptor'
src/hidapi/SDL_hidapi.c:1094: undefined reference to `libusb_get_bus_number'
src/hidapi/SDL_hidapi.c:1095: undefined reference to `libusb_get_device_address'
src/hidapi/SDL_hidapi.c:1096: undefined reference to `libusb_open'
src/hidapi/SDL_hidapi.c:1097: undefined reference to `libusb_close'
src/hidapi/SDL_hidapi.c:1098: undefined reference to `libusb_claim_interface'
src/hidapi/SDL_hidapi.c:1099: undefined reference to `libusb_release_interface'
src/hidapi/SDL_hidapi.c:1100: undefined reference to `libusb_kernel_driver_active'
src/hidapi/SDL_hidapi.c:1101: undefined reference to `libusb_detach_kernel_driver'
src/hidapi/SDL_hidapi.c:1102: undefined reference to `libusb_attach_kernel_driver'
src/hidapi/SDL_hidapi.c:1103: undefined reference to `libusb_set_interface_alt_setting'
src/hidapi/SDL_hidapi.c:1104: undefined reference to `libusb_alloc_transfer'
src/hidapi/SDL_hidapi.c:1105: undefined reference to `libusb_submit_transfer'
src/hidapi/SDL_hidapi.c:1106: undefined reference to `libusb_cancel_transfer'
src/hidapi/SDL_hidapi.c:1107: undefined reference to `libusb_free_transfer'
src/hidapi/SDL_hidapi.c:1108: undefined reference to `libusb_control_transfer'
src/hidapi/SDL_hidapi.c:1109: undefined reference to `libusb_interrupt_transfer'
src/hidapi/SDL_hidapi.c:1110: undefined reference to `libusb_handle_events'
src/hidapi/SDL_hidapi.c:1111: undefined reference to `libusb_handle_events_completed'
collect2: ld returned 1 exit status
2022-09-01 21:56:50 +03:00
Ozkan Sezer 5767dc710e regenerated configure script after commit 3f89d1704 2022-09-01 21:56:50 +03:00
Ozkan Sezer 4ebf34857a updated os2 config file after commit 3f89d1704d 2022-09-01 21:56:50 +03:00
Sam Lantinga 3f89d1704d Fixed building with libusb not dynamicaly loaded 2022-09-01 11:30:02 -07:00
Sam Lantinga 7708bf0f8a Try matching game controller mappings on CRC and version and fall back to no CRC and no version, in that order.
We do exact match when adding mappings, but loose matching everywhere else we look up a mapping for a GUID.
2022-09-01 08:18:58 -07:00
Sam Lantinga 6c2c01e0d1 Fixed documentation to match function parameter 2022-08-31 15:04:12 -07:00
Sam Lantinga 7861f924ea Removed debug print statements 2022-08-31 13:34:43 -07:00
Sam Lantinga 62f2379e4c Try up to 20 times to read the controller type
It takes a while for Joy-Cons to initialize when plugged in via the Nintendo Joy-Con Charging Grip.
2022-08-31 13:24:23 -07:00
Sam Lantinga e5f161bda4 Restored accidentally removed code to guess XInput device 2022-08-30 19:12:22 -07:00
Ozkan Sezer 973a677a2d SDL_xinputjoystick.c: commented out GuessXInputDevice()
Not used since commit 277b033e78.
2022-08-31 02:32:28 +03:00
Shawn Hoffman 42d09a8f42 wgi: refcount the delegate objects 2022-08-30 15:01:31 -07:00
Shawn Hoffman ca915b1884 WGI_JoystickUpdate: bounds-check array sizes 2022-08-30 14:59:38 -07:00
Sam Lantinga cdaafcec0d The Kinvoca Joy-Cons are handled by the Joy-Con driver, not the Switch Pro driver. 2022-08-30 14:56:11 -07:00
Sam Lantinga b2c3237b75 Added support for the Kinvoca Joy-Cons
These report their VID/PID as a Nintendo Switch Pro controller, but they are actually left/right Joy-Cons. We'll fix up the joystick GUID so applications can handle them appropriately.
2022-08-30 14:14:38 -07:00
Sam Lantinga 92d3fc4883 Fixed deadlock when shutting down the Windows joystick system 2022-08-30 12:59:02 -07:00
Brad Smith 371735e95b Silence unused variable warning
SDL_x11dyn.c:123:17: warning: unused variable 'i' [-Wunused-variable]
            int i;
                ^
2022-08-30 12:52:01 -07:00
Sam Lantinga 0e4baf1c4e Don't crash if SDL functions are passed a closed joystick or gamecontroller 2022-08-30 12:39:23 -07:00
Sam Lantinga 675d90c708 Revert "wgi: refcount the delegate objects"
This reverts commit ff233fe306.

This doesn't compile cleanly with Visual Studio and I don't want to introduce any subtle issues because we're passing the wrong types of pointers to WGI functions.
2022-08-30 12:09:57 -07:00
SDL Wiki Bot 3fe6768caf Sync SDL wiki -> header 2022-08-30 18:47:15 +00:00
Sam Lantinga 40bd4feedc Revamped joystick locking
This makes the joystick locking more robust by holding the lock while updating joysticks.

The lock should be held when calling any SDL joystick function on a different thread than the one calling SDL_PumpEvents() and SDL_JoystickUpdate().

It is now possible to hold the lock while reinitializing the joystick subsystem, however any open joysticks will become invalid and potentially cause crashes if used afterwards.

Fixes https://github.com/libsdl-org/SDL/issues/6063
2022-08-30 11:42:13 -07:00
Shawn Hoffman ff233fe306 wgi: refcount the delegate objects
assert if calls become unbalanced.
2022-08-30 10:48:10 -07:00
Francisco Javier Trujillo Mata f1e4685806 Adding specific SDL_Hint for the dynamic VSYNC 2022-08-30 07:20:36 -04:00
Sam Lantinga 2f08bf2313 Added the share button to the Linux mapping for the third party Nintendo Switch Pro controllers 2022-08-29 22:15:35 -07:00
Gleb Mazovetskiy 803924b223 CMake: Make SDL_SHARED/STATIC/TEST options
This makes it easier to set these options when SDL is used as a subprojects.
Since CMake v3.13+, one can simply `set(SDL_TEST OFF)` before include the SDL2 subproject because options do not override existing variables. (https://cmake.org/cmake/help/latest/policy/CMP0077.html#policy:CMP0077)
This is also true for `set(CACHE)` commands but only in CMake v3.21+ (https://cmake.org/cmake/help/latest/policy/CMP0126.html).
2022-08-29 17:47:32 -07:00
Sam Lantinga b2ac758f61 Added support for the Hori Fighting Stick Alpha to the HIDAPI driver 2022-08-29 17:33:00 -07:00
Ludovico de Nittis 3c78ba570b dbus: Use xdg-desktop-portal Inhibit when running under Flatpak or Snap
In order to inhibit the screen saver, SDL currently uses
`org.freedesktop.ScreenSaver.Inhibit()` and, as a fallback, a protocol
specific method for X11 or Wayland.

Accessing `org.freedesktop.ScreenSaver` is usually not allowed when
inside a sandbox like Flatpak, unless the permission has been explicitly
granted to the application.

Another issue is that the Wayland protocol "Idle inhibit" is relatively
new and not yet widely adopted. For example Mutter still doesn't support
it.

For those reasons, when running under Flatpak or Snap, we should try to
inhibit the screen saver by using xdg-desktop-portal instead. This
should give us an higher chance of success.

Fixes: https://github.com/libsdl-org/SDL/issues/6075

Signed-off-by: Ludovico de Nittis <ludovico.denittis@collabora.com>
2022-08-29 06:30:40 -07:00
Ludovico de Nittis e8cb4da71f Add utility function to detect if SDL is inside a sandbox
Refactor the previous sandbox check in a standalone function that also
includes Snap support.

Signed-off-by: Ludovico de Nittis <ludovico.denittis@collabora.com>
2022-08-29 06:30:40 -07:00
Ludovico de Nittis a3ce700ded dbus: Add generic internal function to send messages with reply
SDL_DBus_CallWithBasicReply() allows us to send a DBus message and get
its result, if it is a basic type, e.g. integer or string.

With this function we avoid duplicating code.

Signed-off-by: Ludovico de Nittis <ludovico.denittis@collabora.com>
2022-08-29 06:30:40 -07:00
Sam Lantinga 1153aaae0d Fixed compiling with USB_GET_DEVICEINFO on DragonFly BSD
Although the ioctl() currently fails on this platform...
2022-08-29 00:15:56 -07:00
Sam Lantinga 57cbec1095 Added controller mappings for Xbox 360, PS4, and PS5 controllers on OpenBSD
Removed the axis flipping hack for Xbox controllers which would actually apply to any controller with a full 16-bit range.

Fixes https://github.com/libsdl-org/SDL/issues/6143
2022-08-28 23:18:40 -07:00
Sam Lantinga 0b8b321f9e Allow the product version to be different when trying to find a controller mapping
This is in the hope that revving the product version doesn't change the mapping, which is the case for some devices. In cases where it does, we just need to provide a mapping for each version of the product.
2022-08-28 23:01:30 -07:00
Sam Lantinga 761b9d1e49 Use the HID usage for the button as the button number 2022-08-28 22:33:17 -07:00
Sam Lantinga a9d3935a84 Improved code to get the name and guid for joysticks on OpenBSD and NetBSD
Also dynamically allocate joysticks to reduce static memory usage
2022-08-28 18:20:54 -07:00
Sam Lantinga 32700294e2 Don't crash if SDL_CreateJoystickGUID() is passed a NULL name 2022-08-28 18:20:54 -07:00
Sam Lantinga bac8df4abd Fixed memory leak when out of memory 2022-08-28 18:20:54 -07:00
Sam Lantinga ffbad3617c Use the correct type for the device_instance 2022-08-28 18:20:54 -07:00
Sam Lantinga 4a800ae149 Created a consolidated define enabling BSD gameport joystick support 2022-08-28 18:20:54 -07:00
Sam Lantinga 42f90c6292 Removed unused path variable 2022-08-28 18:20:54 -07:00
Cameron Gutman b7c1fbf9f0 WGI: Fix a couple of reference leaks 2022-08-28 17:38:02 -05:00
Sam Lantinga 0db1813049 Applied OpenBSD patch
http://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/ports/devel/sdl2/patches/patch-src_joystick_bsd_SDL_bsdjoystick_c?rev=1.5&content-type=text/plain&hideattic=1
2022-08-28 07:27:01 -07:00
Mathieu Eyraud b8af865f18 Fix candidate list size for Windows IME
Adjust candidate count so list is not draw bigger that needed. This also fix potential uninitialised read of variable `candsize[i]` if `vertical` is false.
2022-08-28 06:27:24 -07:00