Search code examples
javajoystickgamepadvibration

Is there any way to make my ps4 control vibrate/rumble? With java


Maybe a library can do this? ;)

I have been searching the internet but can't find anything :(

I use glfw.


Solution

  • Dualshock 4 is tricky because it doesn't do rumble in a standard way. But, it's a HID device and you can send HID output reports that will cause it to rumble.

    The easiest cross-platform way to send HID reports is to use the signal11/hidapi library. From Java, you'll want a wrapper for this library like hid4java, or you can take a look at what was suggested when this was asked previously.

    Once you can access the device from Java and send reports, send a 0x11 output report to tell the device to rumble.

    As an alternative, since you're on Windows, you can use a third-party driver to make the DS4 look like an XInput device, and then send rumble commands through the XInput API. I would recommend getting Ryochan's fork of the DS4Windows driver since the original version hasn't been updated in a while. See here for how to use the XInput API from Java.