| | |
| | | /* |
| | | Simple DirectMedia Layer |
| | | Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> |
| | | Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org> |
| | | |
| | | This software is provided 'as-is', without any express or implied |
| | | warranty. In no event will the authors be held liable for any damages |
| | |
| | | |
| | | ++numjoysticks; |
| | | |
| | | SDL_PrivateJoystickAdded(numjoysticks - 1); |
| | | SDL_PrivateJoystickAdded(item->device_instance); |
| | | |
| | | #ifdef DEBUG_JOYSTICK |
| | | SDL_Log("Number of joysticks is %d", numjoysticks); |
| | |
| | | EmscriptenGamepadEvent gamepadState; |
| | | |
| | | numjoysticks = 0; |
| | | numjs = emscripten_get_num_gamepads(); |
| | | |
| | | retval = emscripten_sample_gamepad_data(); |
| | | |
| | | /* 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"); |
| | | } |
| | | |
| | | numjs = emscripten_get_num_gamepads(); |
| | | |
| | | /* handle already connected gamepads */ |
| | | if (numjs > 0) { |
| | |
| | | return -1; |
| | | } |
| | | |
| | | static void |
| | | EMSCRIPTEN_JoystickSetDevicePlayerIndex(int device_index, int player_index) |
| | | { |
| | | } |
| | | |
| | | static SDL_JoystickID |
| | | EMSCRIPTEN_JoystickGetDeviceInstanceID(int device_index) |
| | | { |
| | |
| | | EmscriptenGamepadEvent gamepadState; |
| | | SDL_joylist_item *item = (SDL_joylist_item *) joystick->hwdata; |
| | | int i, result, buttonState; |
| | | |
| | | emscripten_sample_gamepad_data(); |
| | | |
| | | if (item) { |
| | | result = emscripten_get_gamepad_status(item->index, &gamepadState); |
| | |
| | | } |
| | | |
| | | static int |
| | | EMSCRIPTEN_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms) |
| | | EMSCRIPTEN_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) |
| | | { |
| | | return SDL_Unsupported(); |
| | | } |
| | |
| | | EMSCRIPTEN_JoystickDetect, |
| | | EMSCRIPTEN_JoystickGetDeviceName, |
| | | EMSCRIPTEN_JoystickGetDevicePlayerIndex, |
| | | EMSCRIPTEN_JoystickSetDevicePlayerIndex, |
| | | EMSCRIPTEN_JoystickGetDeviceGUID, |
| | | EMSCRIPTEN_JoystickGetDeviceInstanceID, |
| | | EMSCRIPTEN_JoystickOpen, |