We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4323 - Haptic: SDL_SYS_HapticOpenFromJoystick failed on macOS mojave 10.14
Summary: Haptic: SDL_SYS_HapticOpenFromJoystick failed on macOS mojave 10.14
Status: RESOLVED WONTFIX
Alias: None
Product: SDL
Classification: Unclassified
Component: haptic (show other bugs)
Version: 2.0.9
Hardware: x86_64 Other
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords: target-2.0.14
Depends on:
Blocks:
 
Reported: 2018-10-18 03:09 UTC by haxpor
Modified: 2020-06-28 17:53 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description haxpor 2018-10-18 03:09:24 UTC
Use haptic sample here https://github.com/haxpor/lazyfoo-sdl2c/tree/master/20_forcefeedback, then just `make` and run `./haptic.out`. Connect gamepad then try to hit button A to let it provides force feedback.

But it failed as it shouts out error

... Haptic: SDL_SYS_HapticOpenFromJoystick failed.

Tested with xbox360 controller.
Comment 1 haxpor 2018-11-02 19:09:08 UTC
Update: Tested with official release of 2.0.9, and the issue is still there.
Comment 2 maxime.leblanc 2019-12-20 15:27:14 UTC
Using SDL 2.0.11 on macOS Catalina we are having the same issue.

Just running the `testhaptic` or `testrumble` returns 

```
2019-12-20 16:26:10.491 testrumble[6730:34686] INFO: 0 Haptic devices detected.
2019-12-20 16:26:10.491 testrumble[6730:34686] ERROR: No Haptic devices found!
```

This is with an Xbox One S Bluetooth gamepad.

This gamepad works well when testing through https://html5gamepad.com/ and it has vibrations.
Comment 3 Mathieu Eyraud 2019-12-21 13:52:47 UTC
On Windows, SDL_HapticOpenFromJoystick does not work on joysticks that use hidapi driver. I think it is the same on other platform.

Try using SDL_JoystickRumble instead.
Comment 4 Cameron Gutman 2019-12-22 22:13:57 UTC
(In reply to meyraud705 from comment #3)
> On Windows, SDL_HapticOpenFromJoystick does not work on joysticks that use
> hidapi driver. I think it is the same on other platform.
> 
> Try using SDL_JoystickRumble instead.

I also encountered this issue (and addressed it by using the new SDL_GameControllerRumble() function). However, I don't think this is a real fix.

Breaking SDL_HapticOpenFromJoystick() for HIDAPI joysticks results in a de facto regression from 2.0.8 to 2.0.9+, since many common joysticks that were previously handled using native drivers with SDL_Haptic support are now using HIDAPI by default. That means we will break haptics for games that update to the latest SDL (or worse, games that simply get built against the latest SDL downstream in a Linux distro or something, where the version of SDL used is outside of the game developer's control).

I think the proper solution is to write a HIDAPI haptics driver that uses SDL_JoystickRumble() on the backend. I'll look into that if nobody beats me to it.
Comment 5 maxime.leblanc 2019-12-23 09:26:36 UTC
Even using HIDAPI, which is no by default available on macOS, it does not get the controller to rumble.

I have run some more testes and it appears that the controller rumbles only when wired and using the controller360 driver. 

When in bluetooth, I cannot get it to rumble even though it should work since I get it to rumble when on this page : https://html5gamepad.com/
Comment 6 Ryan C. Gordon 2020-06-28 17:53:14 UTC
Ok, I downloaded all 10 gigabytes of Chromium source to see how this works (firefox, fwiw, doesn't rumble a bluetooth Xbox One controller on a Mac on html5gamepad.com, either, but it did work with Chrome!), and they appear to be talking to it as a raw HID device.

In SDL, the Haptic API uses macOS's force feedback API, and these controllers just do not report themselves as able to vibrate under that API, so it fails.

SDL_JoystickRumble() (and the equivalent SDL_GameControllerRumble) _do_ work when used with hidapi, the same way this works in Chrome.

I intend to remove the haptic API in 2.1, leaving just SDL_JoystickRumble(), and I don't intend to change the existing haptic code in 2.0, so I'm marking this as WONTFIX.

If you need it on a Mac in the meantime, use SDL_JoystickRumble and build with hidapi support.

--ryan.