Mednafen Members Members   Search Search   Help Help   Register Register   Login Login   Home Home
Home » Mednafen » Development » SDL2 rumble patch
Show: Today's Messages  :: Show Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
SDL2 rumble patch [message #4183] Tue, 08 September 2015 04:07 Go to next message
athei  [PM]
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 Smile
Re: SDL2 rumble patch [message #4184 is a reply to message #4183 ] Fri, 11 September 2015 02:57 Go to previous messageGo to next message
Administrator  [PM]
Does it support dual motors properly?
Re: SDL2 rumble patch [message #4185 is a reply to message #4184 ] Fri, 11 September 2015 03:02 Go to previous messageGo to next message
athei  [PM]
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 #4186 is a reply to message #4185 ] Fri, 11 September 2015 16:45 Go to previous messageGo to next message
Administrator  [PM]
SDL2 has an API for it seemingly at least: http://wiki.libsdl.org/SDL_HapticLeftRight?highlight=%28\bCategoryStruct\b%29|%28CategoryForceFeedback%29
Re: SDL2 rumble patch [message #4187 is a reply to message #4183 ] Fri, 11 September 2015 17:48 Go to previous messageGo to next message
athei  [PM]
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 Go to previous messageGo to next message
Administrator  [PM]
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 Go to previous messageGo to next message
Administrator  [PM]
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 Go to previous message
athei  [PM]
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]

  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic:djgpp compile?
Next Topic:swap input.port1 and input.port2
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ ]

Current Time: Sat May 18 11:53:19 CDT 2024
.:: Contact :: Home ::.

Powered by FUDforum.
Copyright © FUDforum Bulletin Board Software