UNPKG

dualsense-ts

Version:

The natural interface for your DualSense and DualSense Access controllers, with Typescript

52 lines 1.57 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PlayerLeds = void 0; const command_1 = require("../hid/command"); /** Controls the 5 white player indicator LEDs at the bottom of the controller */ class PlayerLeds { constructor() { this._bitmask = 0; this._brightness = command_1.Brightness.High; } /** Get the current bitmask (5 bits, one per LED) */ get bitmask() { return this._bitmask; } /** Set all 5 LEDs from a bitmask (0–31). PlayerID enum values also work here. */ set(bitmask) { this._bitmask = bitmask & 0x1f; } /** Set a single LED on or off (index 0–4, left to right) */ setLed(index, on) { if (index < 0 || index > 4) return; if (on) { this._bitmask |= 1 << index; } else { this._bitmask &= ~(1 << index); } } /** Get the state of a single LED (index 0–4) */ getLed(index) { return (this._bitmask & (1 << index)) !== 0; } /** Turn all LEDs off */ clear() { this._bitmask = 0; } /** Get the current brightness */ get brightness() { return this._brightness; } /** Set the player LED brightness (High, Medium, Low) */ setBrightness(brightness) { this._brightness = brightness; } /** Returns a string key for change detection */ toKey() { return `${this._bitmask},${this._brightness}`; } } exports.PlayerLeds = PlayerLeds; //# sourceMappingURL=player_leds.js.map