Force feedback in libretro (with Linux and Windows support atm)

I’ve just added experimental rumble support to libretro. It is a very simple interface which should hopefully be enough for at least PlayStation 1. You have control over a weak motor and a strong motor.

The Linux gamepad driver we used sadly cannot support rumble, so I’ve written a new gamepad driver for linux, “udev”. It uses the more modern /dev/input/event* interface, plus libudev to discover joypad devices and hotplugging. To avoid breaking stuff, udev is not the primary driver atm, although I expect it to become the default driver as it matures. Also, /dev/input/event*'s buttons don’t match up exactly with linuxraw joypad API in some cases, so configuring from Phoenix can break (just like xinput now). To use udev, you must set input_joypad_driver = udev in the config. You also need to compile with libudev available.

To set up autoconfigs with retroarch-joyconfig, add -d udev to force the udev driver.

I’ve added rumble support to the libretro-test/ core. Start button activates strong rumble, Select activates the weak rumble.

You should see something like this in verbose log:


RetroArch: [udev]: Plugged pad: ACRUX USB GAMEPAD 8116 on port #0.
RetroArch: Joypad port #0 (ACRUX USB GAMEPAD 8116) configured.
RetroArch: [udev]: Pad #0 (/dev/input/event20) supports force feedback.
RetroArch: [udev]: Pad #0 (/dev/input/event20) supports 16 force feedback effects.

TODO: Xinput should get rumble as well. Rumble should be implemented in Mednafen PSX.

EDIT: Xinput now has rumble support thanks to pinumbernumber. I’ve also pushed rumble support to Mednafen PSX. You have to use Joypad w/ Analog input type to get rumble for now. We’ve noticed some issues with swapping between regular gamepad and dualshock, so if you get issues with rumble make sure you start the game with dualshock on. We might have to find a way to have dualshock enabled at all times, but use the analog “button” on the dualshock instead.

After discussing on IRC, I figured out we needed variable strength rumble, so changed the libretro API to reflect this.

Thank you. This is really nice.

This seems to have broke my controller auto detection on linux. I build the new retroarch and the a new mednafen with the rumble support. Edited my controller auto config file which i keep in a directory “~/RetroArch/configs” to change to udev, didn’t change my .retroarch.cfg AT ALL (still set up to auto detect input and pointing to correct directory) and now it won’t auto detect my controller config. Can’t understand why. I had this same issue in Windows before and couldn’t figure it out but never in linux. Am I just missing something or is this a bug?

edit

fixed it. I had to add input_joypad_driver instead of input_driver in .retroarch.cfg. Dunno how I missed that one. Can’t seem to get it working in mednafen. I will try the test core to see if it is working at all

okay I figured out my gamepad had two versions one of which has no rumble which is probably why i got confused, but I just bought a new gamepad today and this one is clear and you can actually see the rumble motors and yet the force feedback is still not working. This is all I get.


RetroArch: [udev]: Plugged pad: Afterglow Gamepad for PS3 on port #0.
RetroArch: Joypad port #0 (Afterglow Gamepad for PS3) configured.
RetroArch: [udev]: Pad #0 (/dev/input/event1) supports 0 force feedback effects.

are only the the official ps3 controllers supporting rumble ATM or what might be the problem?

I guess it means the drivers do not support rumble for that pad. :\ It works fine with my 360 pad at least and some crappy no-name pad.

Ahh man, I was so pumped to check out the rumble. If I knew enough to add the support myself I would, but I have a feeling it is out of my experiential range. You mean the udev linux driver for the pad right, not your udev driver? Maybe I can find the code and at least take a look.

Driver for the pad in the kernel, yes.