import { DualShock4 } from './index' ; import { hslToRgb } from './util/colorConversion' ; /**
 * Stores and manages the lightbar state.
 */ export default class DualShock4Lightbar { ignore constructor ( private controller ) { } ignore private _r = 0 ; ignore private _g = 0 ; ignore private _b = 0 ; ignore updateLightbar ( ) { if ( ! this . controller . device ) { throw new Error ( 'Controller not initialized. You must call .init() first!' ) ; } return this . controller . sendLocalState ( ) ; } /** Red Color Intensity (0-255) */ get r ( ) { return this . _r ; } set r ( value ) { this . _r = Math . min ( 255 , Math . max ( 0 , value ) ) ; this . updateLightbar ( ) ; } /** Green Color Intensity (0-255) */ get g ( ) { return this . _g ; } set g ( value ) { this . _g = Math . min ( 255 , Math . max ( 0 , value ) ) ; this . updateLightbar ( ) ; } /** Blue Color Intensity (0-255) */ get b ( ) { return this . _b ; } set b ( value ) { this . _b = Math . min ( 255 , Math . max ( 0 , value ) ) ; this . updateLightbar ( ) ; } param r param g param b async setColorRGB ( r , g , b ) { this . _r = Math . min ( 255 , Math . max ( 0 , r ) ) ; this . _g = Math . min ( 255 , Math . max ( 0 , g ) ) ; this . _b = Math . min ( 255 , Math . max ( 0 , b ) ) ; return this . updateLightbar ( ) ; } param h param s param l async setColorHSL ( h , s , l ) { const color = hslToRgb ( h , s , l ) ; return this . setColorRGB ( color . r , color . g , color . b ) ; } }