Skip to content

Getting started with JInput

Endolf edited this page Apr 2, 2019 · 3 revisions
  • Go here and download the latest JInput jar and natives-all.jar.
  • Unpack the natives-all.jar file somewhere temporarily. You should get a dist folder, and in there,
    • jinput-dx8.dll
    • jinput-raw.dll
    • jinput-test.jar
    • jinput-wintab.dll
    • jinput.jar
    • libjinput-osx.jnilib
  • Copy jinput.jar and the dlls, so, or jnilib to somewhere handy and add the natives to your java.library.path.

The jinput-test.jar contains 3 test applications, one to dump the name and details of each controller, one to open up a gui to show the values of each of the components on each of the controllers, and a rumble test for any rumbling controllers.

You can run the tests in the dist folder by running

java -Djava.library.path=. -cp jinput.jar:jinput-test.jar
java -Djava.library.path=. -cp jinput.jar:jinput-test.jar
java -Djava.library.path=. -cp jinput.jar:jinput-test.jar

On windows you'll need to change the :'s to ;'s

Without reproducing the javadoc here, the basic principle is that you ask the DefaultControllerEnvironment for a list of controllers. Controllers are things, a joystick, the keyboard etc. Each controller potentially has subcontrollers, but for most devices, these are not used. Each controller also has a list of components, buttons and axis. Components have a value and a bunch of information about it, relative or absolute, normalised (values are between -1 and +1).

A detailed instruction on how to setup JInput on Mac OS X using Eclipse is available here.

You can’t perform that action at this time.