mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-18 12:05:14 -04:00
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:
parent
273473c922
commit
5245c317ee
@ -395,7 +395,7 @@ static void PrintRegisters(String* str, void* ctx) {
|
||||
Dump_X64()
|
||||
#elif defined _M_ARM
|
||||
#define REG_GNUM(num) &r->R ## num
|
||||
#define REG_GET(ign,reg) &r-> ## reg
|
||||
#define REG_GET(ign, reg) &r-> ## reg
|
||||
#define REG_GET_FP() &r->R11
|
||||
#define REG_GET_IP() &r->R12
|
||||
Dump_ARM32()
|
||||
@ -466,7 +466,7 @@ static void PrintRegisters(String* str, void* ctx) {
|
||||
Dump_ARM64()
|
||||
#elif defined __arm__
|
||||
#define REG_GNUM(num) &r.arm_r##num
|
||||
#define REG_GET(reg,ign) &r.arm_##reg
|
||||
#define REG_GET(reg, ign) &r.arm_##reg
|
||||
#define REG_GET_FP() &r.arm_fp
|
||||
#define REG_GET_IP() &r.arm_ip
|
||||
Dump_ARM32()
|
||||
|
20
src/Window.c
20
src/Window.c
@ -3210,10 +3210,8 @@ static int MapNativeKey(int k) {
|
||||
return KEY_NONE;
|
||||
}
|
||||
|
||||
static EM_BOOL OnKey(int type, const EmscriptenKeyboardEvent* ev , void* data) {
|
||||
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,25 +3220,29 @@ 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;
|
||||
|
||||
|
||||
/* If holding down Ctrl or Alt, keys aren't going to generate a KeyPress event anyways. */
|
||||
/* This intercepts Ctrl+S etc. Ctrl+C and Ctrl+V are not intercepted for clipboard. */
|
||||
if (Key_IsAltPressed() || Key_IsWinPressed()) return true;
|
||||
if (Key_IsControlPressed() && key != 'C' && key != 'V') return true;
|
||||
|
||||
|
||||
/* Must not intercept KeyDown for regular keys, otherwise KeyPress doesn't get raised. */
|
||||
/* However, do want to prevent browser's behaviour on F11, F5, home etc. */
|
||||
/* e.g. not preventing F11 means browser makes page fullscreen instead of just canvas */
|
||||
return (key >= KEY_F1 && key <= KEY_F24) || (key >= KEY_UP && key <= KEY_RIGHT) ||
|
||||
return (key >= KEY_F1 && key <= KEY_F24) || (key >= KEY_UP && key <= KEY_RIGHT) ||
|
||||
(key >= KEY_INSERT && key <= KEY_MENU) || (key >= KEY_ENTER && key <= KEY_NUMLOCK && key != KEY_SPACE);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user