declare var joystickObjs ; if ( joystickObjs . length > 0 ) { setInterval ( ( ) => { const gps = navigator . getGamepads ( ) ; let j = 0 ; for ( const gp of gps ) { if ( gp ) { const obj = joystickObjs [ j ] ; const pressed = ( gp . buttons [ 0 ] . pressed ) ? 1 : 0 ; obj . fire . setBitValue ( pressed ) ; const axes = gp . axes ; const axesLen = axes . length ; if ( axesLen >= 2 ) { const lr = axes [ 0 ] ; const ud = axes [ 1 ] ; obj . up . setBitValue ( ( ud < - 0.5 ) ? 1 : 0 ) ; obj . down . setBitValue ( ( ud > 0.5 ) ? 1 : 0 ) ; obj . left . setBitValue ( ( lr < - 0.5 ) ? 1 : 0 ) ; obj . right . setBitValue ( ( lr > 0.5 ) ? 1 : 0 ) ; } j ++ ; } } } , 50 ) ; }