Avoid requesting pointer lock then exiting pointer lock when pressing escape to open pause menu

This should further reduce chance where cursor gets stuck down
This commit is contained in:
UnknownShadow200 2020-07-04 16:53:13 +10:00
parent 273473c922
commit 5245c317ee
2 changed files with 13 additions and 11 deletions

View File

@ -3212,8 +3212,6 @@ static int MapNativeKey(int k) {
static EM_BOOL OnKey(int type, const EmscriptenKeyboardEvent* ev, void* data) {
int key = MapNativeKey(ev->keyCode);
DeferredEnableRawMouse();
if (!key) return false;
if (ev->location == DOM_KEY_LOCATION_RIGHT) {
switch (key) {
@ -3222,13 +3220,17 @@ static EM_BOOL OnKey(int type, const EmscriptenKeyboardEvent* ev , void* data) {
case KEY_LSHIFT: key = KEY_RSHIFT; break;
case KEY_LWIN: key = KEY_RWIN; break;
}
} else if (ev->location == DOM_KEY_LOCATION_NUMPAD) {
}
else if (ev->location == DOM_KEY_LOCATION_NUMPAD) {
switch (key) {
case KEY_ENTER: key = KEY_KP_ENTER; break;
}
}
Input_SetPressed(key, type == EMSCRIPTEN_EVENT_KEYDOWN);
if (key) Input_SetPressed(key, type == EMSCRIPTEN_EVENT_KEYDOWN);
DeferredEnableRawMouse();
if (!key) return false;
/* KeyUp always intercepted */
if (type != EMSCRIPTEN_EVENT_KEYDOWN) return true;