|
@@ -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 {
|