File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change 184184 class GamepadBoxSet extends Node {
185185 constructor ( buttonCount , axesCount ) {
186186 super ( ) ;
187+ this . setup_buttons_and_axes ( buttonCount , axesCount ) ;
188+ }
187189
190+ setup_buttons_and_axes ( buttonCount , axesCount ) {
188191 let axesBoxCount = Math . ceil ( axesCount / 2 ) ;
189192 let rowLength = Math . max ( buttonCount , axesBoxCount ) ;
190193
206209 }
207210
208211 update_state ( gamepad ) {
212+ if ( ( gamepad . buttons . length !== this . buttonBoxes . length ) || ( gamepad . axes . length / 2 !== this . axesBoxes . length ) ) {
213+ this . clearNodes ( ) ;
214+ this . buttonBoxes = [ ] ;
215+ this . axesBoxes = [ ] ;
216+ this . setup_buttons_and_axes ( gamepad . buttons . length , gamepad . axes . length ) ;
217+ }
209218 // The boxes associated with any given button will turn green if
210219 // touched and red if pressed. The box height will also scale based
211220 // on the button's value to make it appear like a button being pushed.
You can’t perform that action at this time.
0 commit comments