Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/lebogoo/linux-joystick

A simple package to get joystick/gamepad information via linux device files, without any dependencies and prebuilt binaries.
https://github.com/lebogoo/linux-joystick

Last synced: about 2 months ago
JSON representation

A simple package to get joystick/gamepad information via linux device files, without any dependencies and prebuilt binaries.

Awesome Lists containing this project

README

        

# linux-joystick

A simple package to get joystick/gamepad information via linux device files, without any dependencies and prebuilt binaries.

## Installation

```
npm install linux-joystick
```

## Usage

```js
const { JoystickDevice, listDevices } = require("linux-joystick");

const devicePath = listDevices()[0];
const joystick = new JoystickDevice(devicePath);

joystick.on("button_pressed", (event) => {
console.log("Pressed button:", event);
});
```

### Methods:

- getButton(number)
- getAxis(number)

### Events:

- button_changed
- axis_changed
- button_pressed
- button_released
- button_init
- axis_init

### Helper functions

- listDevices() -> Returns an array with all joystick/gamepad devices.