@mesmotronic/xpad
Version:
Simplified Gamepad API for Xbox 360 and Xbox One controllers
85 lines (84 loc) • 1.81 kB
JavaScript
import { ConbineEvent } from "conbine";
export class XpadEvent extends ConbineEvent {
constructor(type, index, data) {
super(type, data);
Object.defineProperty(this, "index", {
enumerable: true,
configurable: true,
writable: true,
value: index
});
}
}
/**
* Xpad is connected and ready to use
*/
Object.defineProperty(XpadEvent, "CONNECT", {
enumerable: true,
configurable: true,
writable: true,
value: "connect"
});
/**
* Xpad is disconnected
*/
Object.defineProperty(XpadEvent, "DISCONNECT", {
enumerable: true,
configurable: true,
writable: true,
value: "disconnect"
});
/**
* Xpad button is pressed
*/
Object.defineProperty(XpadEvent, "BUTTON_DOWN", {
enumerable: true,
configurable: true,
writable: true,
value: "buttonDown"
});
/**
* Xpad button is released
*/
Object.defineProperty(XpadEvent, "BUTTON_UP", {
enumerable: true,
configurable: true,
writable: true,
value: "buttonUp"
});
/**
* Xpad button state has changed
*/
Object.defineProperty(XpadEvent, "BUTTON_CHANGE", {
enumerable: true,
configurable: true,
writable: true,
value: "buttonChange"
});
/**
* Xpad stick is active (not in center)
*/
Object.defineProperty(XpadEvent, "STICK_ACTIVE", {
enumerable: true,
configurable: true,
writable: true,
value: "stickActive"
});
/**
* Xpad stick is inactive (in center)
*/
Object.defineProperty(XpadEvent, "STICK_INACTIVE", {
enumerable: true,
configurable: true,
writable: true,
value: "stickInactive"
});
/**
* Xpad stick state has changed
*/
Object.defineProperty(XpadEvent, "STICK_CHANGE", {
enumerable: true,
configurable: true,
writable: true,
value: "stickChange"
});