noccylabs / joystick
Joystick access via /dev/input (linux only)
Installs: 31
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 1
Open Issues: 0
pkg:composer/noccylabs/joystick
This package is auto-updated.
Last update: 2025-10-07 09:36:15 UTC
README
This is a small library to read connected gamepads via /dev/input/js0
etc. As
it uses /dev/input
it only supports Linux. It can be used to create configs
with keybindings for games, xboxdrv etc.
Install
For development version:
$ composer require noccylabs/joystick:dev-master
Examples
Example 1: Using raw events
$js = new \NoccyLabs\Joystick\Joystick(0);
echo "Press a button on joystick 0 ... ";
while (true) {
$raw = $js->getRawEvent();
if ($raw['type'] & JS_EVENT_BUTTON) {
echo "Thank you!\n";
break;
}
}
Example 2: Using the JoystickState
$js = new \NoccyLabs\Joystick\Joystick(0);
echo "Press button 1 on joystick 0 ... ";
while ($state = $js->update()) {
if ($state->getButton(1)) {
echo "Thank you!\n";
break;
}
}