Fix HTML5 gamepad input

(cherry picked from commit cd7c0f67b9)
This commit is contained in:
Leon Krause 2018-08-30 02:23:06 +02:00 committed by Rémi Verschelde
parent 272c31c837
commit 701683e557
1 changed files with 5 additions and 2 deletions

View File

@ -866,8 +866,11 @@ void OS_JavaScript::process_joypads() {
int joy_count = emscripten_get_num_gamepads(); int joy_count = emscripten_get_num_gamepads();
for (int i = 0; i < joy_count; i++) { for (int i = 0; i < joy_count; i++) {
EmscriptenGamepadEvent state; EmscriptenGamepadEvent state;
emscripten_get_gamepad_status(i, &state); EMSCRIPTEN_RESULT query_result = emscripten_get_gamepad_status(i, &state);
if (state.connected) { // 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_buttons = MIN(state.numButtons, 18);
int num_axes = MIN(state.numAxes, 8); int num_axes = MIN(state.numAxes, 8);