input4j

Lightweight, cross-platform Java library for unified gamepad and joystick input handling

The modern solution for java gamepad input and java joystick input - no native dependencies required.

🪟 Windows 🐧 Linux 🍎 macOS
Java 22+ No Native Dependencies MIT License

Quick Start

Add input4j to your project and start handling gamepad input in minutes.

Gradle
dependencies {
    implementation 'de.gurkenlabs:input4j:1.1.1'
}
Maven
<dependency>
    <groupId>de.gurkenlabs</groupId>
    <artifactId>input4j</artifactId>
    <version>1.1.1</version>
</dependency>
Java - Initialize
try (var devices = InputDevices.init()) {
    for (var device : devices.getAll()) {
        System.out.println("Found: " + device.getName());
    }
}
Java - Handle Events
device.onButtonPressed(XInput.Button.A, () -> 
    System.out.println("A pressed!"));

device.onAxisChanged(XInput.Axis.LEFT_X, value -> 
    System.out.println("Left X: " + value));

Features

100%
Java Native
0
Native Dependencies
3
Platforms
MIT
Open Source

Why Use input4j?

🌍

Cross-Platform

Works seamlessly on Windows, Linux, and macOS. Single API for all platforms with zero platform-specific code required.

Modern Java API

Leverages the Foreign Function & Memory API (Java 22+) for high-performance native access without JNI complexity.

🎮

Unified Input API

Single consistent java game controller API for gamepads, joysticks, and other input devices. Supports XInput, DirectInput, evdev, and IOKit/HID - the ultimate java controller library solution.

🔌

No Native Dependencies

No .dll, .so, or .dylib files to manage. Simply add the JAR and start coding. Perfect for distribution. The cleanest way to add java joystick input to your game.

📡

Event-Based & Polling

Flexible input handling with both event-driven callbacks and polling modes. Choose what fits your architecture.

🛠️

Lightweight

Minimal footprint with no external dependencies. Designed for games, simulations, and applications.

Supported Platforms

🪟

Windows

Full support for XInput (Xbox controllers) and DirectInput (legacy gamepads).

🐧

Linux

Native evdev integration via /dev/input interface for all HID-compliant gamepads.

🍎

macOS

IOKit HID framework integration for reliable gamepad detection on Apple Silicon and Intel Macs.