mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-29 07:59:11 +00:00
emscripten: Pass canvas id to request_pointer_lock
Fixes pointer lock with DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1
This commit is contained in:
parent
287772f5e9
commit
babf010c60
2 changed files with 13 additions and 2 deletions
|
@ -28,6 +28,7 @@
|
|||
#include <emscripten/html5.h>
|
||||
|
||||
#include "SDL_emscriptenmouse.h"
|
||||
#include "SDL_emscriptenvideo.h"
|
||||
|
||||
#include "../../events/SDL_mouse_c.h"
|
||||
#include "SDL_assert.h"
|
||||
|
@ -236,9 +237,19 @@ Emscripten_WarpMouse(SDL_Window* window, int x, int y)
|
|||
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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue