-
Notifications
You must be signed in to change notification settings - Fork 0
PUIGamepadController
Elijah Cobb edited this page May 15, 2021
·
1 revision
This controller allows you to attach event handlers to specific button presses or actions taken by a user using a Gamepad. This will support ANY major gamepad. This API gives you access to all buttons, joysticks, and triggers. As you can see below, you can very quickly and easily use a gamepad with a PUI app.
import {PUIGamepadButton, PUIGamepadController} from "@pstdl/ui;
const gamepadController = new PUIGamepadController();
gamepadController.on("leftJoystickMove", (x, y) => {
console.log(`Left joystick moved to: (${x}, ${y}).`)
});
gamepadController.on("rightJoystickMove", (x, y) => {
console.log(`Right joystick moved to: (${x}, ${y}).`)
});
gamepadController.on("leftTrigger", v => {
console.log(`Left trigger is depressed ${v}.`);
});
gamepadController.on("rightTrigger", v => {
console.log(`Right trigger is depressed ${v}.`);
});
gamepadController.on("buttonDown", button => {
if (button === PUIGamepadButton.A) console.log("A is down!");
else console.log("Another button is down.")
});
gamepadController.on("buttonUp", button => {
if (button === PUIGamepadButton.START) console.log("START button was let go.");
else console.log("Another button was let go.")
});
gamepadController.on("buttonChange", (button, pressed) => {
console.log(`Button '${button}' is ${pressed ? "pressed" : "not-pressed"}.`);
});Created by Elijah Cobb at the Planetary Surface Technology Development Lab located at Michigan Technological University
- PUIGage
- PUIImmutableBinaryStatus
- PUIImmutableNumericStatus
- PUILog
- PUIMutableBinaryStatus
- PUIMutableNumericStatus
- PUIPicker
- PUISegmentedPicker
- PUIAlert
- PUIToast
- PUICard
- PUITopBar
- PUIAppController
- PUIKeyboardController
- PUIGamepadController
- PUIHookAlert
- PUIHookLog
- PUIHookState
- PUIHookToast
- PUIApp
- PUIColor
- PUIContext