UNPKG

dualsense-ts

Version:

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

44 lines 1.56 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Lightbar = void 0; const hid_1 = require("../hid"); /** Controls the RGB light bar at the top of the controller */ class Lightbar { constructor() { this._color = { r: 0, g: 0, b: 255 }; /** One-shot pulse effect to send on the next output cycle */ this._pendingPulse = hid_1.PulseOptions.Off; } /** Get the current color */ get color() { return { ...this._color }; } /** Set the light bar color (0–255 per channel) */ set(color) { this._color = { r: Math.round(Math.max(0, Math.min(255, color.r))), g: Math.round(Math.max(0, Math.min(255, color.g))), b: Math.round(Math.max(0, Math.min(255, color.b))), }; } /** Fade the light bar to Sony blue and hold. Use fadeOut() to return to your set color. */ fadeBlue() { this._pendingPulse = hid_1.PulseOptions.FadeBlue; } /** Fade the light bar to black, then return to the set color. */ fadeOut() { this._pendingPulse = hid_1.PulseOptions.FadeOut; } /** Consume and return pending pulse (used by the output loop) */ consumePulse() { const pulse = this._pendingPulse; this._pendingPulse = hid_1.PulseOptions.Off; return pulse; } /** Returns a string key for change detection */ toKey() { return `${this._color.r},${this._color.g},${this._color.b}`; } } exports.Lightbar = Lightbar; //# sourceMappingURL=lightbar.js.map