UNPKG

dualsense-ts

Version:

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

102 lines 3.58 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PowerSaveControl = void 0; const command_1 = require("../hid/command"); /** * Controls per-subsystem power save flags on the DualSense controller. * * Disabling a subsystem tells the controller to stop processing that input * or output entirely, conserving battery. This is distinct from the * per-channel audio mutes on {@link Audio}, which silence individual * outputs without powering down the processor. * * All subsystems are enabled by default. */ class PowerSaveControl { constructor() { /** Bitfield of active PowerSave disable/mute flags */ this._mask = 0; } /** Whether touch processing is enabled */ get touch() { return (this._mask & command_1.PowerSave.DisableTouch) === 0; } /** Enable or disable touch processing */ set touch(enabled) { if (enabled) this._mask &= ~command_1.PowerSave.DisableTouch; else this._mask |= command_1.PowerSave.DisableTouch; } /** Whether motion sensor (IMU) processing is enabled */ get motion() { return (this._mask & command_1.PowerSave.DisableMotion) === 0; } /** Enable or disable motion sensor processing */ set motion(enabled) { if (enabled) this._mask &= ~command_1.PowerSave.DisableMotion; else this._mask |= command_1.PowerSave.DisableMotion; } /** Whether the haptic processor is enabled */ get haptics() { return (this._mask & command_1.PowerSave.DisableHaptics) === 0; } /** Enable or disable the haptic processor */ set haptics(enabled) { if (enabled) this._mask &= ~command_1.PowerSave.DisableHaptics; else this._mask |= command_1.PowerSave.DisableHaptics; } /** Whether the audio processor is enabled */ get audio() { return (this._mask & command_1.PowerSave.DisableAudio) === 0; } /** Enable or disable the audio processor */ set audio(enabled) { if (enabled) this._mask &= ~command_1.PowerSave.DisableAudio; else this._mask |= command_1.PowerSave.DisableAudio; } /** Whether haptic output is muted (processor still runs) */ get hapticsMuted() { return (this._mask & command_1.PowerSave.MuteHaptics) !== 0; } /** Mute or unmute haptic output without disabling the processor */ set hapticsMuted(muted) { if (muted) this._mask |= command_1.PowerSave.MuteHaptics; else this._mask &= ~command_1.PowerSave.MuteHaptics; } /** Set multiple subsystem states at once */ set(options) { if (options.touch !== undefined) this.touch = options.touch; if (options.motion !== undefined) this.motion = options.motion; if (options.haptics !== undefined) this.haptics = options.haptics; if (options.audio !== undefined) this.audio = options.audio; if (options.muteHaptics !== undefined) this.hapticsMuted = options.muteHaptics; } /** Reset all subsystems to their default (enabled/unmuted) state */ reset() { this._mask = 0; } /** Raw power save flags byte for the output loop */ get flags() { return this._mask; } /** Change-detection key for the output loop */ toKey() { return String(this._mask); } } exports.PowerSaveControl = PowerSaveControl; //# sourceMappingURL=power_save.js.map