mirror of
https://github.com/XProger/OpenLara.git
synced 2025-08-07 13:46:45 +02:00
#15 fix active gamepad detection
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include "game.h"
|
#include "game.h"
|
||||||
|
|
||||||
int lastTime;
|
int lastTime, lastJoy = -1;
|
||||||
EGLDisplay display;
|
EGLDisplay display;
|
||||||
EGLSurface surface;
|
EGLSurface surface;
|
||||||
EGLContext context;
|
EGLContext context;
|
||||||
@@ -65,11 +65,14 @@ void joyUpdate() {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
EmscriptenGamepadEvent state;
|
EmscriptenGamepadEvent state;
|
||||||
for (int i = 0; i < count; i++)
|
if (lastJoy == -1 || emscripten_get_gamepad_status(lastJoy, &state) != EMSCRIPTEN_RESULT_SUCCESS)
|
||||||
if (emscripten_get_gamepad_status(i, &state) == EMSCRIPTEN_RESULT_SUCCESS && state.numButtons >= 12)
|
for (int i = 0; i < count; i++)
|
||||||
break;
|
if (i != lastJoy && emscripten_get_gamepad_status(i, &state) == EMSCRIPTEN_RESULT_SUCCESS && state.numButtons >= 12) {
|
||||||
|
lastJoy = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (state.numButtons < 12)
|
if (lastJoy == -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (int i = 0; i < max(state.numButtons, 12); i++) {
|
for (int i = 0; i < max(state.numButtons, 12); i++) {
|
||||||
|
Reference in New Issue
Block a user