Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Getting started with JInput
- Go here and download the latest JInput binaries.
- Unpack the zip file somewhere temporarily. You should get a dist folder, and in there,
- 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 net.java.games.input.test.ControllerTextTest java -Djava.library.path=. -cp jinput.jar:jinput-test.jar net.java.games.input.test.ControllerReadTest java -Djava.library.path=. -cp jinput.jar:jinput-test.jar net.java.games.input.test.RumbleTest
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.