6
\$\begingroup\$

The com.badlogic.gdx.controllers.Controllers API only supports getting the input data (which works fine).

Is there a way to make my controller rumble/vibrate, possibly using some other classes?

I tried using the org.lwjgl.input.Controllers class, which supports this, but the controllers don't get indexed there and I can not access them.

\$\endgroup\$
  • 2
    \$\begingroup\$ As far as I know, it is not supported by now: github.com/libgdx/libgdx/issues/2057 But maybe this will work for you github.com/StrikerX3/JXInput ? \$\endgroup\$ – Ello Apr 7 '15 at 15:21
  • 2
    \$\begingroup\$ JXInput worked for me. Once I linked the libraries properly it was just a matter of a few lines of code. Just be aware, there's another Java lib called JXInput out there that's not the same thing. \$\endgroup\$ – Scuba Steve Jun 2 '15 at 4:29
  • 1
    \$\begingroup\$ JXInput is not cross-platform :-( \$\endgroup\$ – Benedikt S. Vogler Jun 4 '15 at 18:10
1
\$\begingroup\$

Is there a way to make my controller rumble/vibrate, possibly using some other classes?

It's not a feature libGDX itself supports, and it seems unlikely (based on the discussion on the issue linked in the comments) to happen any time soon. You'll have to use third-party libraries.

Unfortunately most of those third-party libraries (like JXInput) map to the native XInput API to provide vibration (for 360 controllers), which means they don't function on non-Windows system. Regular JInput seems like it may be hampered by the same issue, and doesn't seem to expose vibration anyhow. There are native libraries like libstem_gamepad you could wrap, but they don't support vibration either.

With the caveat that I haven't really tried it, your best bet might be to use the Java binding for SDL, possibly only for the controller APIs, and try to leverage the haptic feedback API therein.

\$\endgroup\$
0
\$\begingroup\$

For using SDL with libGDX desktop, you can use Jamepad. It supports rumbling. There are wrappers for Jamepad to use it as a drop-in replacement for the libGDX controller implementation, for example gdx-controllerutils.

Now, a problem is that you can't trigger rumbling with the existing implementations: libGDX' controller interface just don't have a method for doing so. The task still to do is:

  • make an own Controller interface extending libGDX' interface with methods for rumbling
  • implement this interface in JamepadController
  • check with instanceof in your core code if you have an Controller implementing your interface and then rumble

Best was if the libGDX' controller interface would be extended. There are other methods lacking as well, for example requesting how many buttons and axis are present. Apparently, there is not much interest in the controller extension by the maintainers, so you are better off with an own solution described above.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.