ballistica icon indicating copy to clipboard operation
ballistica copied to clipboard

Feature Request: Haptic Feedback (force feedback, rumble)

Open Areopagitics opened this issue 3 years ago • 9 comments

Hi Eric,

Your game would be great with force feedback. I lfound that sdl2, the one you are using, has force feedback.

https://wiki.libsdl.org/CategoryForceFeedback

Let me know if I could help in some way. I have a bit of experience with python, not too much with C++ but wouldn't mind getting my hands a bit dirty ... would love to help if it's not too complicated.

Areopagitics avatar Sep 01 '20 06:09 Areopagitics

It looks like you would just need to call SDL_HapticRumbleSupported on the controller to check if it has rumble (when it connects), and then SDL_HapticRumblePlay triggered by events (for example when receiving punches, bombs, or snowballs).

Areopagitics avatar Dec 28 '20 20:12 Areopagitics

I would be all for adding something like this, though its low on my priority list at the moment. If anyone wants to help out, the first step would be adding some sort of haptic events to the InputDevice class (perhaps virtual functions that by default do nothing). Then the Joystick class could override those to talk to SDL's functionality as you mention above. One could test it by simply having joysticks rumble when buttons are pressed on them/etc. but after that we would want to wire it up to be controlled by game events coming from the python layer.

efroemling avatar Dec 28 '20 22:12 efroemling

Interesting. Let me see if I can help you get this to work!

ritiek avatar Dec 29 '20 23:12 ritiek

@ritiek let me know if I can do any testing. I have both USB and Bluetooth controllers with vibration.

Areopagitics avatar Dec 30 '20 08:12 Areopagitics

@Areopagitics Thanks! I only have a Dualshock 4 controller which can be used both as wired and wireless. It'd be nice to see what happens with other controllers too.

I made a very experimental change on my fork in ritiek/ballistica@joystick-rumble-support. The controller should vibrate a little whenever you press the punch button in-game.

ritiek avatar Dec 30 '20 12:12 ritiek

sweet! I'll do a pull of your fork and try building on my Windows for the first time soon. I finally found the instructions ; they're great.

Areopagitics avatar Dec 30 '20 19:12 Areopagitics

@ritiek I'm guessing I would need to do a full clean build from source. I tried your repo using the prefab command for windows; I was able to build it with some errors and then run, but no luck getting the rumble to work. I tested the rumble on USB controller configuration settings though, and it's working fine.

Any suggestions on how to build your repo on a WSL 2 setup on windows?

Areopagitics avatar Dec 30 '20 22:12 Areopagitics