diff options
author | Leon Krause <lk@leonkrause.com> | 2018-08-30 02:23:06 +0200 |
---|---|---|
committer | Leon Krause <lk@leonkrause.com> | 2018-08-30 03:42:02 +0200 |
commit | cd7c0f67b9f3497ec420da97c6a29c43c68612c2 (patch) | |
tree | 93cc96de69c9114cff20fa363ad408daa3d79728 | |
parent | 9eb4d4ab2d65c7e29b07308c7f18f40b6530f5a2 (diff) |
Fix HTML5 gamepad input
-rw-r--r-- | platform/javascript/os_javascript.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp index 80699b0d32..a7a26411b7 100644 --- a/platform/javascript/os_javascript.cpp +++ b/platform/javascript/os_javascript.cpp @@ -565,8 +565,11 @@ void OS_JavaScript::process_joypads() { int joypad_count = emscripten_get_num_gamepads(); for (int joypad = 0; joypad < joypad_count; joypad++) { EmscriptenGamepadEvent state; - emscripten_get_gamepad_status(joypad, &state); - if (state.connected) { + EMSCRIPTEN_RESULT query_result = emscripten_get_gamepad_status(joypad, &state); + // Chromium reserves gamepads slots, so NO_DATA is an expected result. + ERR_CONTINUE(query_result != EMSCRIPTEN_RESULT_SUCCESS && + query_result != EMSCRIPTEN_RESULT_NO_DATA); + if (query_result == EMSCRIPTEN_RESULT_SUCCESS && state.connected) { int button_count = MIN(state.numButtons, 18); int axis_count = MIN(state.numAxes, 8); |