mirror of https://github.com/encounter/SDL.git
Emscripten: call emscripten_sample_gamepad_data
This commit is contained in:
parent
8dab9c956f
commit
aacb1091df
|
@ -189,13 +189,16 @@ EMSCRIPTEN_JoystickInit(void)
|
||||||
EmscriptenGamepadEvent gamepadState;
|
EmscriptenGamepadEvent gamepadState;
|
||||||
|
|
||||||
numjoysticks = 0;
|
numjoysticks = 0;
|
||||||
numjs = emscripten_get_num_gamepads();
|
|
||||||
|
retval = emscripten_sample_gamepad_data();
|
||||||
|
|
||||||
/* Check if gamepad is supported by browser */
|
/* Check if gamepad is supported by browser */
|
||||||
if (numjs == EMSCRIPTEN_RESULT_NOT_SUPPORTED) {
|
if (retval == EMSCRIPTEN_RESULT_NOT_SUPPORTED) {
|
||||||
return SDL_SetError("Gamepads not supported");
|
return SDL_SetError("Gamepads not supported");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
numjs = emscripten_get_num_gamepads();
|
||||||
|
|
||||||
/* handle already connected gamepads */
|
/* handle already connected gamepads */
|
||||||
if (numjs > 0) {
|
if (numjs > 0) {
|
||||||
for(i = 0; i < numjs; i++) {
|
for(i = 0; i < numjs; i++) {
|
||||||
|
@ -335,6 +338,8 @@ EMSCRIPTEN_JoystickUpdate(SDL_Joystick * joystick)
|
||||||
SDL_joylist_item *item = (SDL_joylist_item *) joystick->hwdata;
|
SDL_joylist_item *item = (SDL_joylist_item *) joystick->hwdata;
|
||||||
int i, result, buttonState;
|
int i, result, buttonState;
|
||||||
|
|
||||||
|
emscripten_sample_gamepad_data();
|
||||||
|
|
||||||
if (item) {
|
if (item) {
|
||||||
result = emscripten_get_gamepad_status(item->index, &gamepadState);
|
result = emscripten_get_gamepad_status(item->index, &gamepadState);
|
||||||
if( result == EMSCRIPTEN_RESULT_SUCCESS) {
|
if( result == EMSCRIPTEN_RESULT_SUCCESS) {
|
||||||
|
|
Loading…
Reference in New Issue