@@ -2066,39 +2066,34 @@ var LibraryHTML5 = {
2066
2066
return JSEvents . registerOrRemoveHandler ( eventHandler ) ;
2067
2067
} ,
2068
2068
2069
- $disableGamepadApiIfItThrows__docs : '/** @suppress {checkTypes} */' ,
2070
- $disableGamepadApiIfItThrows : ( ) = > {
2071
- try {
2072
- navigator . getGamepads ( ) ;
2073
- } catch ( e ) {
2074
- #if ASSERTIONS
2075
- err ( `navigator.getGamepads() exists, but failed to execute with exception ${ e } . Disabling Gamepad access.` ) ;
2076
- #endif
2077
- navigator . getGamepads = null ; // Disable getGamepads() so that other functions will not attempt to use it.
2078
- return 1 ;
2079
- }
2080
- } ,
2081
-
2082
2069
emscripten_set_gamepadconnected_callback_on_thread__proxy : 'sync ',
2083
- emscripten_set_gamepadconnected_callback_on_thread__deps : [ '$registerGamepadEventCallback' , '$disableGamepadApiIfItThrows ' ] ,
2070
+ emscripten_set_gamepadconnected_callback_on_thread__deps : [ '$registerGamepadEventCallback' , 'emscripten_sample_gamepad_data ' ] ,
2084
2071
emscripten_set_gamepadconnected_callback_on_thread : ( userData , useCapture , callbackfunc , targetThread ) = > {
2085
- if ( ! navigator . getGamepads || disableGamepadApiIfItThrows ( ) ) return { { { cDefs . EMSCRIPTEN_RESULT_NOT_SUPPORTED } } } ;
2072
+ if ( _emscripten_sample_gamepad_data ( ) ) return { { { cDefs . EMSCRIPTEN_RESULT_NOT_SUPPORTED } } } ;
2086
2073
return registerGamepadEventCallback ( { { { cDefs . EMSCRIPTEN_EVENT_TARGET_WINDOW } } } , userData, useCapture, callbackfunc, { { { cDefs . EMSCRIPTEN_EVENT_GAMEPADCONNECTED } } } , "gamepadconnected" , targetThread) ;
2087
2074
} ,
2088
2075
2089
2076
emscripten_set_gamepaddisconnected_callback_on_thread__proxy : 'sync' ,
2090
- emscripten_set_gamepaddisconnected_callback_on_thread__deps : [ '$registerGamepadEventCallback' , '$disableGamepadApiIfItThrows ' ] ,
2077
+ emscripten_set_gamepaddisconnected_callback_on_thread__deps : [ '$registerGamepadEventCallback' , 'emscripten_sample_gamepad_data ' ] ,
2091
2078
emscripten_set_gamepaddisconnected_callback_on_thread : ( userData , useCapture , callbackfunc , targetThread ) => {
2092
- if ( ! navigator . getGamepads || disableGamepadApiIfItThrows ( ) ) return { { { cDefs . EMSCRIPTEN_RESULT_NOT_SUPPORTED } } } ;
2079
+ if ( _emscripten_sample_gamepad_data ( ) ) return { { { cDefs . EMSCRIPTEN_RESULT_NOT_SUPPORTED } } } ;
2093
2080
return registerGamepadEventCallback ( { { { cDefs . EMSCRIPTEN_EVENT_TARGET_WINDOW } } } , userData , useCapture, callbackfunc, { { { cDefs . EMSCRIPTEN_EVENT_GAMEPADDISCONNECTED } } } , "gamepaddisconnected" , targetThread) ;
2094
2081
} ,
2095
2082
2083
+ emscripten_sample_gamepad_data__docs : '/** @suppress {checkTypes} */' , // We assign null to navigator.getGamepads, which Closure would like to complain about.
2096
2084
emscripten_sample_gamepad_data__proxy : 'sync' ,
2097
- emscripten_sample_gamepad_data__deps : [ '$JSEvents' , '$disableGamepadApiIfItThrows' ] ,
2085
+ emscripten_sample_gamepad_data__deps : [ '$JSEvents' ] ,
2098
2086
emscripten_sample_gamepad_data : ( ) => {
2099
- if ( ! navigator . getGamepads || disableGamepadApiIfItThrows ( ) ) return { { { cDefs . EMSCRIPTEN_RESULT_NOT_SUPPORTED } } } ;
2100
- return ( JSEvents . lastGamepadState = navigator . getGamepads ( ) )
2101
- ? { { { cDefs . EMSCRIPTEN_RESULT_SUCCESS } } } : { { { cDefs . EMSCRIPTEN_RESULT_NOT_SUPPORTED } } } ;
2087
+ try {
2088
+ if ( navigator . getGamepads ) return ( JSEvents . lastGamepadState = navigator . getGamepads ( ) )
2089
+ ? { { { cDefs . EMSCRIPTEN_RESULT_SUCCESS } } } : { { { cDefs . EMSCRIPTEN_RESULT_NOT_SUPPORTED } } } ;
2090
+ } catch ( e ) {
2091
+ #if ASSERTIONS
2092
+ err ( `navigator.getGamepads() exists, but failed to execute with exception ${ e } . Disabling Gamepad access.` ) ;
2093
+ #endif
2094
+ navigator . getGamepads = null ; // Disable getGamepads() so that it won't be attempted to be used again.
2095
+ }
2096
+ return { { { cDefs . EMSCRIPTEN_RESULT_NOT_SUPPORTED } } } ;
2102
2097
} ,
2103
2098
2104
2099
emscripten_get_num_gamepads__proxy : 'sync' ,
0 commit comments