From 701683e5573c3b78678c7b3a4fe6fd53249343bb Mon Sep 17 00:00:00 2001 From: Leon Krause Date: Thu, 30 Aug 2018 02:23:06 +0200 Subject: [PATCH] Fix HTML5 gamepad input (cherry picked from commit cd7c0f67b9f3497ec420da97c6a29c43c68612c2) --- platform/javascript/os_javascript.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp index e878cf3725c..2c40fcc25d0 100644 --- a/platform/javascript/os_javascript.cpp +++ b/platform/javascript/os_javascript.cpp @@ -866,8 +866,11 @@ void OS_JavaScript::process_joypads() { int joy_count = emscripten_get_num_gamepads(); for (int i = 0; i < joy_count; i++) { EmscriptenGamepadEvent state; - emscripten_get_gamepad_status(i, &state); - if (state.connected) { + EMSCRIPTEN_RESULT query_result = emscripten_get_gamepad_status(i, &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 num_buttons = MIN(state.numButtons, 18); int num_axes = MIN(state.numAxes, 8);