Skip to content

Commit

Permalink
Implement pointer lock
Browse files Browse the repository at this point in the history
  • Loading branch information
caiiiycuk committed Feb 7, 2024
1 parent 15b049e commit 3492314
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion Source/Game/Runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,20 @@ int SDL_main(int argc, char *argv[])
}

#ifdef GPX
gpx()->sys()->mainReady(true);
static bool gpx_ready = false;
if (!gpx_ready) {
gpx_ready = false;
#ifdef EMSCRIPTEN
EM_ASM(({
if (!document.pointerLockElement) {
Module["canvas"].addEventListener("pointerdown", () => {
Module["canvas"].requestPointerLock().catch((e) => console.error("Can't lock mouse", e));
});
}
}));
#endif
gpx()->sys()->mainReady(true);
}
gpx()->async()->runNextTask();
#ifdef EMSCRIPTEN
emscripten_sleep(0);
Expand Down

0 comments on commit 3492314

Please sign in to comment.