summaryrefslogtreecommitdiffhomepage
path: root/src/core.c
diff options
context:
space:
mode:
authorraysan5 <[email protected]>2020-07-10 18:23:17 +0200
committerraysan5 <[email protected]>2020-07-10 18:23:17 +0200
commit7199dd570f8d8ef2f4cb9235cf0ab6c76195e8ab (patch)
tree089ed61dc4e2140a650e256d8651244484d9cb08 /src/core.c
parent3f4c6fee11f6b2121066c6e366c7af8b02a1d232 (diff)
downloadraylib-7199dd570f8d8ef2f4cb9235cf0ab6c76195e8ab.tar.gz
raylib-7199dd570f8d8ef2f4cb9235cf0ab6c76195e8ab.zip
REVIEW: Pointer lock emscripten API does not work #1241
It seems some internals change recently due to web security reasons and some emscripten HTML5 funtionalities like pointerLock or fullscreen modes behave very weird or just don't work as expected
Diffstat (limited to 'src/core.c')
-rw-r--r--src/core.c29
1 files changed, 10 insertions, 19 deletions
diff --git a/src/core.c b/src/core.c
index 737d2935..91ce0ca3 100644
--- a/src/core.c
+++ b/src/core.c
@@ -406,9 +406,7 @@ typedef struct CoreData {
bool cursorHidden; // Track if cursor is hidden
bool cursorOnScreen; // Tracks if cursor is inside client area
-#if defined(PLATFORM_WEB)
- bool cursorLockRequired; // Ask for cursor pointer lock on next click
-#endif
+
char currentButtonState[3]; // Registers current mouse button state
char previousButtonState[3]; // Registers previous mouse button state
int currentWheelMove; // Registers current mouse wheel variation
@@ -1301,9 +1299,6 @@ void EnableCursor(void)
#if defined(PLATFORM_DESKTOP)
glfwSetInputMode(CORE.Window.handle, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
#endif
-#if defined(PLATFORM_WEB)
- CORE.Input.Mouse.cursorLockRequired = true;
-#endif
#if defined(PLATFORM_UWP)
UWPGetMouseUnlockFunc()();
#endif
@@ -1316,9 +1311,6 @@ void DisableCursor(void)
#if defined(PLATFORM_DESKTOP)
glfwSetInputMode(CORE.Window.handle, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
#endif
-#if defined(PLATFORM_WEB)
- CORE.Input.Mouse.cursorLockRequired = true;
-#endif
#if defined(PLATFORM_UWP)
UWPGetMouseLockFunc()();
#endif
@@ -4226,20 +4218,19 @@ static EM_BOOL EmscriptenKeyboardCallback(int eventType, const EmscriptenKeyboar
static EM_BOOL EmscriptenMouseCallback(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData)
{
// Lock mouse pointer when click on screen
- if ((eventType == EMSCRIPTEN_EVENT_CLICK) && CORE.Input.Mouse.cursorLockRequired)
+ if ((eventType == EMSCRIPTEN_EVENT_CLICK))
{
EmscriptenPointerlockChangeEvent plce;
emscripten_get_pointerlock_status(&plce);
+
+ int result = emscripten_request_pointerlock("#canvas", 1); // TODO: It does not work!
+
+ // result -> EMSCRIPTEN_RESULT_DEFERRED
+ // The requested operation cannot be completed now for web security reasons,
+ // and has been deferred for completion in the next event handler. --> but it never happens!
- if (!plce.isActive) emscripten_request_pointerlock(0, 1);
- else
- {
- emscripten_exit_pointerlock();
- emscripten_get_pointerlock_status(&plce);
- //if (plce.isActive) TRACELOG(LOG_WARNING, "Pointer lock exit did not work!");
- }
-
- CORE.Input.Mouse.cursorLockRequired = false;
+ //if (!plce.isActive) emscripten_request_pointerlock(0, 1);
+ //else emscripten_exit_pointerlock();
}
return 0;