Hi all,
a slight change to anyone using the Gamepad API and the functions
emscripten_get_num_gamepads() and emscripten_get_gamepad_status() to
poll gamepad state. Previously these functions had intelligent logic
built into them to avoid re-sampling gamepad state multiple times per
frame. This was nice, since it provided a simple API to obtain gamepad
state; however it resulted in increased code size, and subtle bugs
with respect to connecting gamepads and asynchronous page load
sequence, so this abstraction has now been removed.
In new form, when sampling gamepad state, the functions
emscripten_get_num_gamepads() and emscripten_get_gamepad_status()
still exist, but instead of those functions automatically sampling
gamepad state, the sampling is now changed to be explicit, via
function emscripten_sample_gamepad_data() that developer should call
before calling either of emscripten_get_num_gamepads() and
emscripten_get_gamepad_status(). This simplifies the implementation
logic and reduces code size (also for users who were not using gamepad
api in the first place!)
For details on the change, see
https://github.com/kripken/emscripten/pull/7673
The new behavior will be part of Emscripten 1.38.22. To verify your
gamepad code is following the expected API usage, test with a debug
build with -s ASSERTIONS=1 enabled.
Cheers,
Jukka