SDL2 rumble patch [message #4183] |
Tue, 08 September 2015 04:07 |
|
Because I want Rumble for OS X I applied this http://pastebin.com/GCbqbkes SDL2 patch.
After that I added some code to Joystick_SDL.cpp to enable rumble for SDL2 joysticks: http://pastebin.com/dw5yjv2U
Works fine with my XBOX360 gamepad and this driver: https://github.com/d235j/360Controller
Please consider porting to SDL2
|
|
Re: SDL2 rumble patch [message #4184 is a reply to message #4183 ] |
Fri, 11 September 2015 02:57 |
|
Does it support dual motors properly?
|
|
Re: SDL2 rumble patch [message #4185 is a reply to message #4184 ] |
Fri, 11 September 2015 03:02 |
|
As far as I see it there is no way to do this right. There is no API in SDL or even the Apple Force Feedback framework explicitly account for setting 2 motors to different values since it is for all kind of devices.
There is a way to set the direction of the force which is for actual force feedback and not vibration I guess. I can test if it would actually make it possible to differentiate between the motors.
|
|
Re: SDL2 rumble patch [message #4187 is a reply to message #4183 ] |
Fri, 11 September 2015 17:48 |
|
You are right. I totally overlooked this. I tried and it is like expected. This effect is not supported ( SDL_HapticQuery(sdl_haptic) & SDL_HAPTIC_LEFTRIGHT == 0 ).
The Apple Force Feedback framework simply does not support to differentiate between the two motors.
So there is no way to get this working on OS X. We need to take what we can get.
On the bright site: You can drop your different implementations for linux and windows since sdl2 can be used there for rumble (sdl2 uses xinput, too).
|
|
Re: SDL2 rumble patch [message #4188 is a reply to message #4187 ] |
Fri, 11 September 2015 18:24 |
|
I'm not going to include rumble support for OS X if it's going to be half-broken because of poor API design.
Regardless, the Windows and Linux joystick code will not be dropped; it's been well-tested and works fine, and I like having fewer dependencies on SDL since I've been burned by SDL's limitations in the past.
|
|
Re: SDL2 rumble patch [message #4189 is a reply to message #4188 ] |
Sat, 12 September 2015 05:25 |
|
Is it possible to access a game controller at a lower-level on OS X via a HID or USB API?
|
|
Re: SDL2 rumble patch [message #4190 is a reply to message #4189 ] |
Sat, 12 September 2015 06:10 |
|
Yes it makes sense to stick with the linux/windows implementations. I see that.
As for your last question: OS X has no dedicated joystick or game controller API. You discover your joystick by iterating over the device tree and looking for HID devices. Then you read the USB data fields to look for a device that says it is a joystick/gamepad. Then you can read the elements (buttons etc.) of that device.
The force feedback framework directly operates on a IOKit service node. You just feed it a pointer to a device and if it supports the force feedback framework you can use it's functions. For a device to support the force feedback framework it has to ship a force feedback plugin in it's driver kext. The Xbox360 Pad driver I use does this.
My point is: As long as the device registers itself as a standard HID device we can't do anything but use the IOKit HID / Force Feedback APIs to access it (which do not offer dual motor rumble as mentioned).
We can make it possible though. But we have to modify the driver to support things that are not in the specification. The problem with that is of course that it gets inherently device dependent. I don't think this a big problem because the 360 and playstation3 pads are the only ones we had to support because I don't think there are other pads in use (which have drivers for OS X and a dual motor).
My proposal is:
Add a new undocumented constant recognized by this function:
https://developer.apple.com/library/mac/documentation/ForceFeedback/Reference/ForceFeedback_header_reference/index.html#//apple_ref/c/func/FFDeviceCreateEffect
The second problem is that we won't get SDL2 to support undocumented behavior. We had to do OS X joystick handling ourselves which is kind of ugly. Much easier would be to just enumerate hid devices check if they have force feedback and match them to a controller already discovered by SDL(1.2) and do only the force feedback natively. That would be something that could be implemented right away without migrating to SDL2. The xbox360 pad driver is open source so we could just implement this behavior and test it.
[Updated on: Sat, 12 September 2015 06:13]
|
|