| | |
| | | /* |
| | | 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 |
| | |
| | | misrepresented as being the original software. |
| | | 3. This notice may not be removed or altered from any source distribution. |
| | | */ |
| | | |
| | | |
| | | #include "../../SDL_internal.h" |
| | | |
| | | #if SDL_VIDEO_DRIVER_EMSCRIPTEN |
| | |
| | | #include <emscripten/html5.h> |
| | | |
| | | #include "SDL_emscriptenmouse.h" |
| | | #include "SDL_emscriptenvideo.h" |
| | | |
| | | #include "../../events/SDL_mouse_c.h" |
| | | #include "SDL_assert.h" |
| | | |
| | | static SDL_Cursor* |
| | | Emscripten_CreateCursorFromString(const char* cursor_str, SDL_bool is_custom) |
| | |
| | | if(curdata->system_cursor) { |
| | | EM_ASM_INT({ |
| | | if (Module['canvas']) { |
| | | Module['canvas'].style['cursor'] = Module['Pointer_stringify']($0); |
| | | Module['canvas'].style['cursor'] = UTF8ToString($0); |
| | | } |
| | | return 0; |
| | | }, curdata->system_cursor); |
| | |
| | | static int |
| | | Emscripten_SetRelativeMouseMode(SDL_bool enabled) |
| | | { |
| | | SDL_Window *window; |
| | | SDL_WindowData *window_data; |
| | | |
| | | /* TODO: pointer lock isn't actually enabled yet */ |
| | | if(enabled) { |
| | | if(emscripten_request_pointerlock(NULL, 1) >= EMSCRIPTEN_RESULT_SUCCESS) { |
| | | window = SDL_GetMouseFocus(); |
| | | if (window == NULL) { |
| | | return -1; |
| | | } |
| | | |
| | | window_data = (SDL_WindowData *) window->driverdata; |
| | | |
| | | if(emscripten_request_pointerlock(window_data->canvas_id, 1) >= EMSCRIPTEN_RESULT_SUCCESS) { |
| | | return 0; |
| | | } |
| | | } else { |