2017 © Pedro Peláez
 

library joystick

Joystick access via /dev/input (linux only)

image

noccylabs/joystick

Joystick access via /dev/input (linux only)

  • Tuesday, November 4, 2014
  • by noccy80
  • Repository
  • 1 Watchers
  • 1 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

noccylabs/joystick: Joystick access via /dev/input

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., (*1)

Install

For development version:, (*2)

$ composer require noccylabs/joystick:dev-master

Examples

Example 1: Using raw events, (*3)

$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, (*4)

$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;
    }
}

The Versions

04/11 2014

dev-master

9999999-dev

Joystick access via /dev/input (linux only)

  Sources   Download

GPL-3.0

by Christopher Vagnetoft