Java library for access to input devices.

View project on GitHub

Maven Central Javadocs

Welcome to the Java Input API Project!

The JInput Project hosts an implementation of an API for game controller discovery and polled input. It is part of a suite of open-source technologies initiated by the Game Technology Group at Sun Microsystems with intention of making the development of high performance games in Java a reality.

The API itself is pure Java and presents a platform-neutral completely portable model of controller discovery and polling. It can handle arbitrary controllers and returns both human and machine understandable descriptions of the inputs available.

The implementation hosted here also includes plug-ins to allow the API to adapt to various specific platforms. These plug-ins often contain a native code portion to interface to the host system.

Getting Started


Include the dependency in your project:


You’ll also need to add the build plugin in your build/plugins section of your pom


A full pom might look like this one

Without maven

The jar file with the java code in should be in maven central, you’ll need the jinput.jar and jinput-natives-all.jar that contains the native binaries.


Add the jinput jar to your classpath, if you are using maven and have the native dependencies plugin working, it will have unpacked the native binaries to target/natives, you must specify the java.library.path property to point to this directy.


java -cp ~/.m2/repository/net/java/jinput/jinput/2.0.9/jinput-2.0.9.jar:target/examples-pom-2.0.9.jar -Djava.library.path=target/natives net.java.games.input.example.ReadFirstMouse

More generally

java -cp <path to jinput.jar>:<your own jars> -Djava.library.path=<path to natives> <main class>


/* Create an event object for the underlying plugin to populate */
Event event = new Event();

/* Get the available controllers */
Controller[] controllers = ControllerEnvironment.getDefaultEnvironment().getControllers();
for (int i = 0; i < controllers.length; i++) {
    /* Remember to poll each one */

    /* Get the controllers event queue */
    EventQueue queue = controllers[i].getEventQueue();

    /* For each object in the queue */
    while (queue.getNextEvent(event)) {
        /* Get event component */
        Component comp = event.getComponent();

        /* Process event (your awesome code) */

More examples here.