Sam Lantinga
a9650d440a
Fixed MFI controller being opened while HIDAPI controller was being opened
...
This was the callstack:
frame #3 : 0x00000001004e1930 libSDL3.1.0.0.dylib`IOS_AddJoystickDevice(controller=0x0000600003b0c000, accelerometer=SDL_FALSE) at SDL_mfijoystick.m:528:14
frame #4 : 0x00000001004e1a54 libSDL3.1.0.0.dylib`__IOS_JoystickInit_block_invoke(.block_descriptor=0x0000000100547760, note=@"GCControllerDidConnectNotification") at SDL_mfijoystick.m:673:45
frame #5 : 0x000000018601e578 CoreFoundation`__CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 128
frame #6 : 0x00000001860bc074 CoreFoundation`___CFXRegistrationPost_block_invoke + 88
frame #7 : 0x00000001860bbfbc CoreFoundation`_CFXRegistrationPost + 440
frame #8 : 0x0000000185fefbac CoreFoundation`_CFXNotificationPost + 708
frame #9 : 0x0000000186edc72c Foundation`-[NSNotificationCenter postNotificationName:object:userInfo:] + 88
frame #10 : 0x000000019b054a18 GameController`__60-[_GCControllerManagerAppClient _onqueue_publishController:]_block_invoke + 156
frame #11 : 0x0000000185dc19dc libdispatch.dylib`_dispatch_call_block_and_release + 32
frame #12 : 0x0000000185dc3504 libdispatch.dylib`_dispatch_client_callout + 20
frame #13 : 0x0000000185dd1d1c libdispatch.dylib`_dispatch_main_queue_drain + 928
frame #14 : 0x0000000185dd196c libdispatch.dylib`_dispatch_main_queue_callback_4CF + 44
frame #15 : 0x000000018606ad6c CoreFoundation`__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16
frame #16 : 0x00000001860287ec CoreFoundation`__CFRunLoopRun + 2036
frame #17 : 0x00000001860278a4 CoreFoundation`CFRunLoopRunSpecific + 612
frame #18 : 0x00000001003b1194 libSDL3.1.0.0.dylib`process_pending_events at hid.c:509:9
frame #19 : 0x00000001003aebe8 libSDL3.1.0.0.dylib`PLATFORM_hid_open_path(path="USB_054c_05c4_0x11a104290", bExclusive=0) at hid.c:823:2
frame #20 : 0x00000001003b051c libSDL3.1.0.0.dylib`SDL_hid_open_path_REAL(path="USB_054c_05c4_0x11a104290", bExclusive=0) at SDL_hidapi.c:1419:19
frame #21 : 0x00000001004dabdc libSDL3.1.0.0.dylib`HIDAPI_SetupDeviceDriver(device=0x0000600003518000, removed=0x000000016fdfee3c) at SDL_hidapijoystick.c:399:19
frame #22 : 0x00000001004da890 libSDL3.1.0.0.dylib`HIDAPI_AddDevice(info=0x000060000212c2d0, num_children=0, children=0x0000000000000000) at SDL_hidapijoystick.c:843:5
frame #23 : 0x00000001004d9148 libSDL3.1.0.0.dylib`HIDAPI_UpdateDeviceList at SDL_hidapijoystick.c:1000:21
frame #24 : 0x00000001004d9940 libSDL3.1.0.0.dylib`HIDAPI_JoystickDetect at SDL_hidapijoystick.c:1205:13
frame #25 : 0x00000001003bc6d8 libSDL3.1.0.0.dylib`SDL_UpdateJoysticks_REAL at SDL_joystick.c:1703:9
frame #26 : 0x00000001003a13a8 libSDL3.1.0.0.dylib`SDL_PumpEventsInternal(push_sentinel=SDL_FALSE) at SDL_events.c:855:9
frame #27 : 0x00000001003a1340 libSDL3.1.0.0.dylib`SDL_PumpEvents_REAL at SDL_events.c:879:5
frame #28 : 0x000000010038b380 libSDL3.1.0.0.dylib`SDL_PumpEvents at SDL_dynapi_procs.h:572:1
frame #29 : 0x0000000100004524 testgamepad`loop + 40
frame #30 : 0x00000001000063d8 testgamepad`main + 2140
2023-02-09 12:07:11 -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
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
15a9890919
Added SDL_HINT_HIDAPI_IGNORE_DEVICES to specify devices that should be ignored in SDL_hid_enumerate()
2022-11-05 16:44:52 -07:00
Sam Lantinga
f6b1e028ab
Allow vendor matching for hid_enumerate() on all backends
2022-10-29 10:43:11 -07:00
Sam Lantinga
aa2e2f4843
Make sure HID devices can be opened before making them available to the application
...
This prevents a number of issues where devices are enumerated but not actually able to be opened, like https://github.com/libsdl-org/SDL/issues/5781 .
We currently leave the devices open, allowing us to more easily do controller feature detection, protocol negotiation, detect dropped Bluetooth connections, etc. with the expectation that the application is likely to open the controllers shortly.
2022-09-22 18:27:38 -07:00
Sam Lantinga
99e85cc27b
Accidentally reverted 172865ff13
2022-09-22 10:10:20 -07:00
Sam Lantinga
6cbdc66650
Fixed use of uninitialized 'size' variable (thanks @ozkan!)
2022-09-22 09:05:06 -07:00
Sam Lantinga
910d499c54
Fixed comment typo
2022-09-16 09:19:20 -07:00
Sam Lantinga
172865ff13
Don't enumerate HID devices on macOS if we don't have input monitoring permissions
...
Unfortunately the only way to detect this is to actually try opening a device, so we wait until the application tries, and then stop enumerating afterwards.
Fixes https://github.com/libsdl-org/SDL/issues/5781
2022-09-16 09:16:18 -07:00
Sam Lantinga
679582e702
Fixed crash if there are no devices available
2022-08-25 11:07:20 -07:00
Pierre Wendling
6c536afdb7
Fix C89 declaration for macOS modules.
...
Since Clang 14, `-Wdeclaration-after-statement` is enforced on every
standard.
2022-06-27 15:19:40 -07:00
Ryan C. Gordon
4fe7b2cbd1
static analysis: Fixed several complaints from codechecker.
...
There are still some pending Objective-C specific issues.
Reference issue #4600 .
2022-03-24 11:00:43 -04:00
Sam Lantinga
09b652b70a
Make sure the string properties are actually strings (thanks Nat!)
2022-03-09 13:54:23 -08:00
Sam Lantinga
14db417e12
Reenable getting the serial number on macOS
...
We filter now on game controllers, so we shouldn't hit the crash bug on random devices that this was working around.
2022-03-08 21:32:27 -08:00
Sam Lantinga
c3ca3445bd
Prefer HIDAPI on macOS, as that has extended functionality
2022-03-08 18:56:49 -08:00
Cameron Gutman
343fa61215
hid: fix inconsistent indentation
2021-11-20 13:17:59 -06:00
Cameron Gutman
db60b27188
hid: Only enumerate IOHIDDevices that are likely to be joysticks
...
Touching HID devices with keyboard usages will trigger a keyboard capture
permission prompt on macOS 11+. See #4887
Like the IOKit joystick backend, we accept HID devices that have joystick,
gamepad, or multi-axis controller usages. We also allow the Valve VID for
the Steam Controller, just like the Windows HIDAPI implementation does.
2021-11-20 13:13:17 -06:00
Sam Lantinga
5b646cd19e
Build hidapi code into SDL as a new public API
...
This prevents conflicts with hidapi linked with applications, as well as allowing applications to make use of HIDAPI on Android and other platforms that might not normally have an implementation available.
2021-11-07 23:00:59 -08:00
Sam Lantinga
db18764e41
Use correct relative include path
2021-10-01 16:27:59 -07:00
Sam Lantinga
814285d6e3
Workaround for crash on Apple Mac M1 hardware
2021-06-23 09:19:02 -07:00
Sam Lantinga
6de33c0945
Clarify why we're skipping Game Controller framework supported devices in hid.c
2021-06-03 09:05:33 -07:00
Patrick Hogan
28da6c5ddb
Have HIDAPI skip MFI supported HID devices on macOS to avoid duplicate devices.
2021-06-03 09:03:11 -07:00
Sam Lantinga
1133ea0349
Fixed crash on macOS when AirPods are connected
2021-03-22 19:18:57 -07:00
Sam Lantinga
43aa1fa9e7
Added support for detecting previously unknown Xbox 360 and Xbox One controllers using the HIDAPI driver with libusb and Android
2020-01-18 11:21:14 -08:00
Sam Lantinga
98ce0e50b7
Removed unnecessary setlocale() on Mac
...
240bad3b66
2019-12-30 11:09:03 -08:00
Cameron Gutman
f21e172767
Use IOHIDManagerRegisterDeviceRemovalCallback() to monitor for HID removal
...
The function we currently use, IOHIDDeviceRegisterRemovalCallback(), often
fails on Catalina with a "__CFRunLoopModeFindSourceForMachPort returned NULL"
error message. Once a removal callback is missed, we will eventually crash when
the joystick is closed attempting to use the invalid IOHIDDeviceRef.
https://forums.developer.apple.com/thread/124444
2019-12-20 22:25:49 -08:00
Andrew Eikum
738dff4bbc
hidapi: Update repository URLs
...
Upstream hidapi has been re-homed. Update the repo URLs to help guide folks
where to contribute fixes.
2019-07-25 08:05:13 -05:00
Andrew Eikum
0e9560aea2
hidapi: Zero out new hid_device_info structs
2019-07-23 14:41:00 -05:00
Sam Lantinga
52e62329c8
Fixed build error
2019-07-17 16:47:19 -07:00
Sam Lantinga
1dc24160a1
Add linked list of opened HID devices to prevent accessing already freed devices in device removal callback that is sometimes called even after being unregistered
2019-07-17 16:47:13 -07:00
Sam Lantinga
b08bdc4401
Don't build SDL_JOYSTICK_HIDAPI by default on iOS
...
If you enable this, you'll need to link with CoreBluetooth.framework and add something like this to your Info.plist:
<key>NSBluetoothPeripheralUsageDescription</key>
<string>MyApp would like to remain connected to nearby bluetooth Game Controllers and Game Pads even when you're not using the app.</string>
2018-10-26 09:27:31 -07:00
Sam Lantinga
5dfa4043a3
Fixed warnings building on Mac OS X 64-bit
2018-08-20 21:19:17 -07:00
Sam Lantinga
4f41f07d43
Added missing files from previous commits
2018-08-09 16:05:48 -07:00