ソースを参照

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
pull/1306/head
raysan5 4年前
コミット
7199dd570f
1個のファイルの変更10行の追加19行の削除
  1. +10
    -19
      src/core.c

+ 10
- 19
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;

読み込み中…
キャンセル
保存