0

I am working on Java map project. I use the Logitech extreme 3D pro Joystick and JInput library. I want to write text to the console when the buttons on the joystick are clicked. But I can't do that, can anyone help?

MWiesner
  • 8,868
  • 11
  • 36
  • 70
  • 1
    Please consider adding what you have already tried / your research to your question. Have you looked at the API's? Do you need help with choosing one of a handful of API calls? The more specific you are the more likely you are to get answers. – Prashant Aug 07 '20 at 10:46

1 Answers1

0

You can adapt the JInput example found here which shows "how to read the values in a polling loop for the first mouse". In line 28 simply change the controller type to STICK, as it is defined in the Controller class of that library:

/**
 * Stick controller, such as a joystick or flightstick.
 */
public static final Type STICK = new Type("Stick");

If you execute the example you will retrieve "the components of the controller" (see line 46, /* Get all the axis and buttons */).

With those components at hand, you can retrieve properties or data from the connected (joystick) controller, in your case not a mouse but a joystick.

Hint: Before modifying the example, you can just start to experiment with the "first mouse" connected to your machine.

Dharman
  • 30,962
  • 25
  • 85
  • 135
MWiesner
  • 8,868
  • 11
  • 36
  • 70