From 840657180428b6e25813e6670a387b294d02eb47 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Fri, 4 Aug 2023 18:48:10 +1000 Subject: [PATCH] Separate gamepad Start/Select from Enter/Escape keys --- src/ClassiCube.vcxproj | 3 ++ src/ClassiCube.vcxproj.filters | 9 ++++++ src/Input.c | 41 ++++++++++++------------- src/Input.h | 55 ++++++++++++++++++---------------- src/LScreens.c | 4 +-- src/LWidgets.c | 2 +- src/Menus.c | 6 ++-- src/Screens.c | 6 ++-- src/Window_3DS.c | 8 ++--- src/Window_Carbon.c | 2 +- src/Window_GCWii.c | 8 ++--- src/Window_PSP.c | 6 ++-- src/Window_SDL.c | 6 ++-- src/Window_Web.c | 8 ++--- src/Window_Win.c | 4 +-- src/Window_X11.c | 2 +- src/_WindowBase.h | 6 ++-- src/interop_cocoa.m | 2 +- 18 files changed, 97 insertions(+), 81 deletions(-) diff --git a/src/ClassiCube.vcxproj b/src/ClassiCube.vcxproj index 64a28ed51..a03c51db9 100644 --- a/src/ClassiCube.vcxproj +++ b/src/ClassiCube.vcxproj @@ -446,8 +446,10 @@ + + @@ -465,6 +467,7 @@ + diff --git a/src/ClassiCube.vcxproj.filters b/src/ClassiCube.vcxproj.filters index 4a1c2e848..249e97c6f 100644 --- a/src/ClassiCube.vcxproj.filters +++ b/src/ClassiCube.vcxproj.filters @@ -620,6 +620,15 @@ Source Files\Platform + + Source Files\Graphics + + + Source Files\Graphics + + + Source Files\Graphics + diff --git a/src/Input.c b/src/Input.c index f96b7afe2..f48b0db84 100644 --- a/src/Input.c +++ b/src/Input.c @@ -25,6 +25,7 @@ #include "AxisLinesRenderer.h" #include "Picking.h" +struct _InputState Input; static cc_bool input_buttonsDown[3]; static int input_pickingId = -1; static TimeMS input_lastClick; @@ -88,7 +89,7 @@ static cc_bool TryUpdateTouch(long id, int x, int y) { for (i = 0; i < Pointers_Count; i++) { if (touches[i].id != id || !touches[i].type) continue; - if (Input_RawMode && (touches[i].type & TOUCH_TYPE_CAMERA)) { + if (Input.RawMode && (touches[i].type & TOUCH_TYPE_CAMERA)) { /* If the pointer hasn't been locked to gui or block yet, moving a bit */ /* should cause the pointer to get locked to camera movement. */ if (touches[i].type == TOUCH_TYPE_ALL && MovedFromBeg(i, x, y)) { @@ -179,8 +180,6 @@ static void ClearTouches(void) { } /*########################################################################################################################* *-----------------------------------------------------------Key-----------------------------------------------------------* *#########################################################################################################################*/ -cc_bool Input_Pressed[INPUT_COUNT]; - #define Key_Function_Names \ "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10",\ "F11", "F12", "F13", "F14", "F15", "F16", "F17", "F18", "F19", "F20",\ @@ -191,9 +190,11 @@ cc_bool Input_Pressed[INPUT_COUNT]; "U", "V", "W", "X", "Y", "Z" #define Pad_Names \ "PAD_A", "PAD_B", "PAD_X", "PAD_Y", "PAD_L", "PAD_R", \ -"PAD_LEFT", "PAD_RIGHT", "PAD_UP", "PAD_DOWN", +"PAD_LEFT", "PAD_RIGHT", "PAD_UP", "PAD_DOWN", \ +"PAD_START", "PAD_SELECT" -const char* const Input_StorageNames[INPUT_COUNT] = { +/* Names for each input button when stored to disc */ +static const char* const storageNames[INPUT_COUNT] = { "None", Key_Function_Names, "Tilde", "Minus", "Plus", "BracketLeft", "BracketRight", "Slash", @@ -240,8 +241,8 @@ const char* const Input_DisplayNames[INPUT_COUNT] = { }; void Input_SetPressed(int key) { - cc_bool wasPressed = Input_Pressed[key]; - Input_Pressed[key] = true; + cc_bool wasPressed = Input.Pressed[key]; + Input.Pressed[key] = true; Event_RaiseInput(&InputEvents.Down, key, wasPressed); if (key == 'C' && Input_IsActionPressed()) Event_RaiseInput(&InputEvents.Down, INPUT_CLIPBOARD_COPY, 0); @@ -253,8 +254,8 @@ void Input_SetPressed(int key) { } void Input_SetReleased(int key) { - if (!Input_Pressed[key]) return; - Input_Pressed[key] = false; + if (!Input.Pressed[key]) return; + Input.Pressed[key] = false; Event_RaiseInt(&InputEvents.Up, key); if (key == CCMOUSE_L) Pointer_SetPressed(0, false); @@ -270,7 +271,7 @@ void Input_Set(int key, int pressed) { void Input_SetNonRepeatable(int key, int pressed) { if (pressed) { - if (Input_Pressed[key]) return; + if (Input.Pressed[key]) return; Input_SetPressed(key); } else { Input_SetReleased(key); @@ -279,8 +280,9 @@ void Input_SetNonRepeatable(int key, int pressed) { void Input_Clear(void) { int i; - for (i = 0; i < INPUT_COUNT; i++) { - if (Input_Pressed[i]) Input_SetReleased(i); + for (i = 0; i < INPUT_COUNT; i++) + { + if (Input.Pressed[i]) Input_SetReleased(i); } /* TODO: Properly release instead of just clearing */ ClearTouches(); @@ -291,7 +293,6 @@ void Input_Clear(void) { *----------------------------------------------------------Mouse----------------------------------------------------------* *#########################################################################################################################*/ struct Pointer Pointers[INPUT_MAX_POINTERS]; -cc_bool Input_RawMode; void Pointer_SetPressed(int idx, cc_bool pressed) { if (pressed) { @@ -350,7 +351,7 @@ static const char* const keybindNames[KEYBIND_COUNT] = { "Hotbar7", "Hotbar8", "Hotbar9" }; -cc_bool KeyBind_IsPressed(KeyBind binding) { return Input_Pressed[KeyBinds[binding]]; } +cc_bool KeyBind_IsPressed(KeyBind binding) { return Input.Pressed[KeyBinds[binding]]; } static void KeyBind_Load(void) { cc_string name; char nameBuffer[STRING_SIZE + 1]; @@ -363,7 +364,7 @@ static void KeyBind_Load(void) { String_Format1(&name, "key-%c", keybindNames[i]); name.buffer[name.length] = '\0'; - mapping = Options_GetEnum(name.buffer, KeyBind_Defaults[i], Input_StorageNames, INPUT_COUNT); + mapping = Options_GetEnum(name.buffer, KeyBind_Defaults[i], storageNames, INPUT_COUNT); if (mapping != CCKEY_ESCAPE) KeyBinds[i] = mapping; } } @@ -374,7 +375,7 @@ void KeyBind_Set(KeyBind binding, int key) { String_InitArray(name, nameBuffer); String_Format1(&name, "key-%c", keybindNames[binding]); - value = String_FromReadonly(Input_StorageNames[key]); + value = String_FromReadonly(storageNames[key]); Options_SetString(&name, &value); KeyBinds[binding] = key; } @@ -521,7 +522,7 @@ static void StoredHotkey_Parse(cc_string* key, cc_string* value) { if (!String_UNSAFE_Separate(key, '&', &strKey, &strMods)) return; if (!String_UNSAFE_Separate(value, '&', &strMore, &strText)) return; - trigger = Utils_ParseEnum(&strKey, INPUT_NONE, Input_StorageNames, INPUT_COUNT); + trigger = Utils_ParseEnum(&strKey, INPUT_NONE, storageNames, INPUT_COUNT); if (trigger == INPUT_NONE) return; if (!Convert_ParseUInt8(&strMods, &modifiers)) return; if (!Convert_ParseBool(&strMore, &more)) return; @@ -546,7 +547,7 @@ void StoredHotkeys_Load(int trigger, cc_uint8 modifiers) { cc_string key, value; char keyBuffer[STRING_SIZE]; String_InitArray(key, keyBuffer); - String_Format2(&key, "hotkey-%c&%b", Input_StorageNames[trigger], &modifiers); + String_Format2(&key, "hotkey-%c&%b", storageNames[trigger], &modifiers); key.buffer[key.length] = '\0'; /* TODO: Avoid this null terminator */ Options_UNSAFE_Get(key.buffer, &value); @@ -557,7 +558,7 @@ void StoredHotkeys_Remove(int trigger, cc_uint8 modifiers) { cc_string key; char keyBuffer[STRING_SIZE]; String_InitArray(key, keyBuffer); - String_Format2(&key, "hotkey-%c&%b", Input_StorageNames[trigger], &modifiers); + String_Format2(&key, "hotkey-%c&%b", storageNames[trigger], &modifiers); Options_SetString(&key, NULL); } @@ -567,7 +568,7 @@ void StoredHotkeys_Add(int trigger, cc_uint8 modifiers, cc_bool moreInput, const String_InitArray(key, keyBuffer); String_InitArray(value, valueBuffer); - String_Format2(&key, "hotkey-%c&%b", Input_StorageNames[trigger], &modifiers); + String_Format2(&key, "hotkey-%c&%b", storageNames[trigger], &modifiers); String_Format2(&value, "%t&%s", &moreInput, text); Options_SetString(&key, &value); } diff --git a/src/Input.h b/src/Input.h index 366847805..bbdea8889 100644 --- a/src/Input.h +++ b/src/Input.h @@ -47,6 +47,7 @@ enum InputButtons { CCPAD_A, CCPAD_B, CCPAD_X, CCPAD_Y, CCPAD_L, CCPAD_R, CCPAD_LEFT, CCPAD_RIGHT, CCPAD_UP, CCPAD_DOWN, + CCPAD_START, CCPAD_SELECT, INPUT_COUNT, @@ -54,33 +55,15 @@ enum InputButtons { INPUT_CLIPBOARD_PASTE = 1002 }; -/* Names for each input button when stored to disc */ -extern const char* const Input_StorageNames[INPUT_COUNT]; -/* Simple display names for each input button */ extern const char* const Input_DisplayNames[INPUT_COUNT]; -#define Input_IsWinPressed() (Input_Pressed[CCKEY_LWIN] || Input_Pressed[CCKEY_RWIN]) -#define Input_IsAltPressed() (Input_Pressed[CCKEY_LALT] || Input_Pressed[CCKEY_RALT]) -#define Input_IsCtrlPressed() (Input_Pressed[CCKEY_LCTRL] || Input_Pressed[CCKEY_RCTRL]) -#define Input_IsShiftPressed() (Input_Pressed[CCKEY_LSHIFT] || Input_Pressed[CCKEY_RSHIFT]) +extern struct _InputState { + /* Pressed state of each input button. Use Input_Set to change */ + cc_bool Pressed[INPUT_COUNT]; + /* Whether raw mouse/touch input is currently being listened for */ + cc_bool RawMode; +} Input; -#define Input_IsUpButton(btn) ((btn) == CCKEY_UP || (btn) == CCPAD_UP) -#define Input_IsDownButton(btn) ((btn) == CCKEY_DOWN || (btn) == CCPAD_DOWN) -#define Input_IsLeftButton(btn) ((btn) == CCKEY_LEFT || (btn) == CCPAD_LEFT) -#define Input_IsRightButton(btn) ((btn) == CCKEY_RIGHT || (btn) == CCPAD_RIGHT) - -#if defined CC_BUILD_HAIKU -/* Haiku uses ALT instead of CTRL for clipboard and stuff */ -#define Input_IsActionPressed() Input_IsAltPressed() -#elif defined CC_BUILD_DARWIN -/* macOS uses CMD instead of CTRL for clipboard and stuff */ -#define Input_IsActionPressed() Input_IsWinPressed() -#else -#define Input_IsActionPressed() Input_IsCtrlPressed() -#endif - -/* Pressed state of each input button. Use Input_Set to change. */ -extern cc_bool Input_Pressed[INPUT_COUNT]; /* Sets Input_Pressed[key] to true and raises InputEvents.Down */ void Input_SetPressed(int key); /* Sets Input_Pressed[key] to false and raises InputEvents.Up */ @@ -91,8 +74,28 @@ void Input_SetNonRepeatable(int key, int pressed); /* Resets all input buttons to released state. (Input_SetReleased) */ void Input_Clear(void); -/* Whether raw mouse/touch input is currently being listened for. */ -extern cc_bool Input_RawMode; + +#define Input_IsWinPressed() (Input.Pressed[CCKEY_LWIN] || Input.Pressed[CCKEY_RWIN]) +#define Input_IsAltPressed() (Input.Pressed[CCKEY_LALT] || Input.Pressed[CCKEY_RALT]) +#define Input_IsCtrlPressed() (Input.Pressed[CCKEY_LCTRL] || Input.Pressed[CCKEY_RCTRL]) +#define Input_IsShiftPressed() (Input.Pressed[CCKEY_LSHIFT] || Input.Pressed[CCKEY_RSHIFT]) + +#define Input_IsUpButton(btn) ((btn) == CCKEY_UP || (btn) == CCPAD_UP) +#define Input_IsDownButton(btn) ((btn) == CCKEY_DOWN || (btn) == CCPAD_DOWN) +#define Input_IsLeftButton(btn) ((btn) == CCKEY_LEFT || (btn) == CCPAD_LEFT) +#define Input_IsRightButton(btn) ((btn) == CCKEY_RIGHT || (btn) == CCPAD_RIGHT) +#define Input_IsEnterButton(btn) ((btn) == CCKEY_ENTER || (btn) == CCPAD_START || (btn) == CCKEY_KP_ENTER) +#define Input_IsEscapeButton(btn) ((btn) == CCKEY_ESCAPE || (btn) == CCPAD_SELECT) + +#if defined CC_BUILD_HAIKU +/* Haiku uses ALT instead of CTRL for clipboard and stuff */ +#define Input_IsActionPressed() Input_IsAltPressed() +#elif defined CC_BUILD_DARWIN +/* macOS uses CMD instead of CTRL for clipboard and stuff */ +#define Input_IsActionPressed() Input_IsWinPressed() +#else +#define Input_IsActionPressed() Input_IsCtrlPressed() +#endif #ifdef CC_BUILD_TOUCH #define INPUT_MAX_POINTERS 32 diff --git a/src/LScreens.c b/src/LScreens.c index 83c07c3cc..5d2918f7c 100644 --- a/src/LScreens.c +++ b/src/LScreens.c @@ -81,7 +81,7 @@ static void LScreen_CycleSelected(struct LScreen* s, int dir) { } static void LScreen_KeyDown(struct LScreen* s, int key, cc_bool was) { - if (key == CCKEY_ENTER || key == CCKEY_KP_ENTER) { + if (Input_IsEnterButton(key)) { /* Shouldn't multi click when holding down Enter */ if (was) return; @@ -106,7 +106,7 @@ static void LScreen_KeyDown(struct LScreen* s, int key, cc_bool was) { LScreen_CycleSelected(s, -1); } else if (Input_IsDownButton(key)) { LScreen_CycleSelected(s, 1); - } else if (key == CCKEY_ESCAPE && s->onEscapeWidget) { + } else if (Input_IsEscapeButton(key) && s->onEscapeWidget) { s->onEscapeWidget->OnClick(s->onEscapeWidget); } } diff --git a/src/LWidgets.c b/src/LWidgets.c index 6da5fdf7c..278e96e51 100644 --- a/src/LWidgets.c +++ b/src/LWidgets.c @@ -257,7 +257,7 @@ static cc_bool LInput_KeyDown(void* widget, int key, cc_bool was) { if (w->text.length) Clipboard_SetText(&w->text); } else if (key == INPUT_CLIPBOARD_PASTE) { LInput_CopyFromClipboard(w); - } else if (key == CCKEY_ESCAPE) { + } else if (Input_IsEscapeButton(key)) { if (w->text.length) LInput_SetString(w, &String_Empty); } else if (Input_IsLeftButton(key)) { LInput_AdvanceCaretPos(w, false); diff --git a/src/Menus.c b/src/Menus.c index 7a0700ce2..81db45e1e 100644 --- a/src/Menus.c +++ b/src/Menus.c @@ -166,7 +166,7 @@ static int Menu_InputDown(void* screen, int key) { Menu_CycleSelected(s, -1); } else if (Input_IsDownButton(key)) { Menu_CycleSelected(s, +1); - } else if (key == CCKEY_ENTER) { + } else if (Input_IsEnterButton(key)) { Menu_ClickSelected(s); } return Screen_InputDown(screen, key); @@ -1876,7 +1876,7 @@ static int KeyBindsScreen_KeyDown(void* screen, int key) { if (s->curI == -1) return Menu_InputDown(s, key); bind = s->binds[s->curI]; - if (key == CCKEY_ESCAPE) key = KeyBind_Defaults[bind]; + if (Input_IsEscapeButton(key)) key = KeyBind_Defaults[bind]; KeyBind_Set(bind, key); idx = s->curI; @@ -2144,7 +2144,7 @@ static int MenuInputOverlay_KeyDown(void* screen, int key) { struct MenuInputOverlay* s = (struct MenuInputOverlay*)screen; if (Elem_HandlesKeyDown(&s->input.base, key)) return true; - if (key == CCKEY_ENTER || key == CCKEY_KP_ENTER) { + if (Input_IsEnterButton(key)) { MenuInputOverlay_EnterInput(s); return true; } return Menu_InputDown(screen, key); diff --git a/src/Screens.c b/src/Screens.c index eb39d4d7c..d1059e8ac 100644 --- a/src/Screens.c +++ b/src/Screens.c @@ -1228,8 +1228,8 @@ static int ChatScreen_KeyDown(void* screen, int key) { if (key == KeyBinds[KEYBIND_SEND_CHAT] || key == CCKEY_KP_ENTER) { ChatScreen_EnterChatInput(s, false); #else - if (key == KeyBinds[KEYBIND_SEND_CHAT] || key == CCKEY_KP_ENTER || key == CCKEY_ESCAPE) { - ChatScreen_EnterChatInput(s, key == CCKEY_ESCAPE); + if (key == KeyBinds[KEYBIND_SEND_CHAT] || key == CCKEY_KP_ENTER || Input_IsEscapeButton(key)) { + ChatScreen_EnterChatInput(s, Input_IsEscapeButton(key)); #endif } else if (key == CCKEY_PAGEUP) { ChatScreen_ScrollChatBy(s, -Gui.Chatlines); @@ -1597,7 +1597,7 @@ static int InventoryScreen_KeyDown(void* screen, int key) { if (key == KeyBinds[KEYBIND_INVENTORY] && s->releasedInv) { Gui_Remove((struct Screen*)s); - } else if (key == CCKEY_ENTER && table->selectedIndex != -1) { + } else if (Input_IsEnterButton(key) && table->selectedIndex != -1) { Inventory_SetSelectedBlock(table->blocks[table->selectedIndex]); Gui_Remove((struct Screen*)s); } else if (Elem_HandlesKeyDown(table, key)) { diff --git a/src/Window_3DS.c b/src/Window_3DS.c index 78aa4ffb7..67e1a111f 100644 --- a/src/Window_3DS.c +++ b/src/Window_3DS.c @@ -155,13 +155,13 @@ void Window_ProcessEvents(double delta) { touchBegY = touch.py; } - if (Input_RawMode) { + if (Input.RawMode) { circlePosition pos; hidCircleRead(&pos); ProcessJoystickInput(&pos); } - if (Input_RawMode && irrst_result == 0) { + if (Input.RawMode && irrst_result == 0) { circlePosition pos; irrstScanInput(); irrstCstickRead(&pos); @@ -171,8 +171,8 @@ void Window_ProcessEvents(double delta) { void Cursor_SetPosition(int x, int y) { } // Makes no sense for 3DS -void Window_EnableRawMouse(void) { Input_RawMode = true; } -void Window_DisableRawMouse(void) { Input_RawMode = false; } +void Window_EnableRawMouse(void) { Input.RawMode = true; } +void Window_DisableRawMouse(void) { Input.RawMode = false; } void Window_UpdateRawMouse(void) { if (!touchActive) return; diff --git a/src/Window_Carbon.c b/src/Window_Carbon.c index e6e5e18bd..1405a4c73 100644 --- a/src/Window_Carbon.c +++ b/src/Window_Carbon.c @@ -270,7 +270,7 @@ static OSStatus Window_ProcessMouseEvent(EventRef inEvent) { Logger_Abort2(res, "Getting mouse position"); } - if (Input_RawMode) { + if (Input.RawMode) { raw.x = 0; raw.y = 0; GetEventParameter(inEvent, kEventParamMouseDelta, typeHIPoint, NULL, sizeof(HIPoint), NULL, &raw); Event_RaiseRawMove(&PointerEvents.RawMoved, raw.x, raw.y); diff --git a/src/Window_GCWii.c b/src/Window_GCWii.c index 8722d2486..0f51d72b9 100644 --- a/src/Window_GCWii.c +++ b/src/Window_GCWii.c @@ -110,7 +110,7 @@ static void ProcessPAD_Game(PADStatus* pad) { int dx = pad->substickX; int dy = pad->substickY; - if (Input_RawMode) { + if (Input.RawMode) { // May not be exactly 0 on actual hardware if (Math_AbsI(dx) <= 8) dx = 0; if (Math_AbsI(dy) <= 8) dy = 0; @@ -270,7 +270,7 @@ static void ProcessClassic_Game(void) { Input_SetNonRepeatable(KeyBinds[KEYBIND_BACK], mods & CLASSIC_CTRL_BUTTON_DOWN); Input_SetNonRepeatable(CCPAD_DOWN, mods & CLASSIC_CTRL_BUTTON_DOWN); - if (Input_RawMode) { + if (Input.RawMode) { ProcessClassic_Joystick(&ctrls.ljs); ProcessClassic_Joystick(&ctrls.rjs); } @@ -368,8 +368,8 @@ void Window_UpdateRawMouse(void) { } void Cursor_SetPosition(int x, int y) { } // No point in GameCube/Wii // TODO: Display cursor on Wii when not raw mode -void Window_EnableRawMouse(void) { Input_RawMode = true; } -void Window_DisableRawMouse(void) { Input_RawMode = false; } +void Window_EnableRawMouse(void) { Input.RawMode = true; } +void Window_DisableRawMouse(void) { Input.RawMode = false; } /*########################################################################################################################* diff --git a/src/Window_PSP.c b/src/Window_PSP.c index 71f779929..110df0a55 100644 --- a/src/Window_PSP.c +++ b/src/Window_PSP.c @@ -60,7 +60,7 @@ void Window_ProcessEvents(double delta) { int dx = pad.Lx - 127; int dy = pad.Ly - 127; - if (Input_RawMode && (Math_AbsI(dx) > 1 || Math_AbsI(dy) > 1)) { + if (Input.RawMode && (Math_AbsI(dx) > 1 || Math_AbsI(dy) > 1)) { //Platform_Log2("RAW: %i, %i", &dx, &dy); Event_RaiseRawMove(&PointerEvents.RawMoved, dx / 32.0f, dy / 32.0f); } @@ -162,12 +162,12 @@ void Window_CloseKeyboard(void) { /* TODO implement */ } void Window_EnableRawMouse(void) { RegrabMouse(); - Input_RawMode = true; + Input.RawMode = true; } void Window_UpdateRawMouse(void) { CentreMousePosition(); } void Window_DisableRawMouse(void) { RegrabMouse(); - Input_RawMode = false; + Input.RawMode = false; } #endif diff --git a/src/Window_SDL.c b/src/Window_SDL.c index c247d3d64..f1ff58f85 100644 --- a/src/Window_SDL.c +++ b/src/Window_SDL.c @@ -243,7 +243,7 @@ void Window_ProcessEvents(double delta) { break; case SDL_MOUSEMOTION: Pointer_SetPosition(0, e.motion.x, e.motion.y); - if (Input_RawMode) Event_RaiseRawMove(&PointerEvents.RawMoved, e.motion.xrel, e.motion.yrel); + if (Input.RawMode) Event_RaiseRawMove(&PointerEvents.RawMoved, e.motion.xrel, e.motion.yrel); break; case SDL_TEXTINPUT: OnTextEvent(&e); break; @@ -339,14 +339,14 @@ void Window_CloseKeyboard(void) { SDL_StopTextInput(); } void Window_EnableRawMouse(void) { RegrabMouse(); SDL_SetRelativeMouseMode(true); - Input_RawMode = true; + Input.RawMode = true; } void Window_UpdateRawMouse(void) { CentreMousePosition(); } void Window_DisableRawMouse(void) { RegrabMouse(); SDL_SetRelativeMouseMode(false); - Input_RawMode = false; + Input.RawMode = false; } diff --git a/src/Window_Web.c b/src/Window_Web.c index ae361aed2..8ffc96614 100644 --- a/src/Window_Web.c +++ b/src/Window_Web.c @@ -39,7 +39,7 @@ static void SetFullscreenBounds(void) { /* Browser only allows pointer lock requests in response to user input */ static void DeferredEnableRawMouse(void) { EmscriptenPointerlockChangeEvent status; - if (!Input_RawMode) return; + if (!Input.RawMode) return; status.isActive = false; emscripten_get_pointerlock_status(&status); @@ -92,7 +92,7 @@ static EM_BOOL OnMouseMove(int type, const EmscriptenMouseEvent* ev, void* data) x = ev->targetX; y = ev->targetY; RescaleXY(&x, &y); Pointer_SetPosition(0, x, y); - if (Input_RawMode) Event_RaiseRawMove(&PointerEvents.RawMoved, ev->movementX, ev->movementY); + if (Input.RawMode) Event_RaiseRawMove(&PointerEvents.RawMoved, ev->movementX, ev->movementY); return true; } @@ -632,14 +632,14 @@ void Window_CloseKeyboard(void) { void Window_EnableRawMouse(void) { RegrabMouse(); /* defer pointerlock request until next user input */ - Input_RawMode = true; + Input.RawMode = true; } void Window_UpdateRawMouse(void) { } void Window_DisableRawMouse(void) { RegrabMouse(); emscripten_exit_pointerlock(); - Input_RawMode = false; + Input.RawMode = false; } diff --git a/src/Window_Win.c b/src/Window_Win.c index a8d8d1d58..cf80228e8 100644 --- a/src/Window_Win.c +++ b/src/Window_Win.c @@ -102,7 +102,7 @@ static void RefreshWindowBounds(void) { static void GrabCursor(void) { RECT rect; - if (!grabCursor || !Input_RawMode) return; + if (!grabCursor || !Input.RawMode) return; GetWindowRect(win_handle, &rect); ClipCursor(&rect); @@ -209,7 +209,7 @@ static LRESULT CALLBACK Window_Procedure(HWND handle, UINT message, WPARAM wPara dy = absY - prevPosY; prevPosY = absY; } else { break; } - if (Input_RawMode) Event_RaiseRawMove(&PointerEvents.RawMoved, (float)dx, (float)dy); + if (Input.RawMode) Event_RaiseRawMove(&PointerEvents.RawMoved, (float)dx, (float)dy); } break; case WM_KEYDOWN: diff --git a/src/Window_X11.c b/src/Window_X11.c index 7cf3d2594..0554448bb 100644 --- a/src/Window_X11.c +++ b/src/Window_X11.c @@ -1161,7 +1161,7 @@ static void HandleGenericEvent(XEvent* e) { if (!rawMouseSupported || e->xcookie.extension != xiOpcode) return; if (!XGetEventData(win_display, &e->xcookie)) return; - if (e->xcookie.evtype == XI_RawMotion && Input_RawMode) { + if (e->xcookie.evtype == XI_RawMotion && Input.RawMode) { ev = (XIRawEvent*)e->xcookie.data; values = ev->raw_values; diff --git a/src/_WindowBase.h b/src/_WindowBase.h index e6e1796fc..75dc2fd61 100644 --- a/src/_WindowBase.h +++ b/src/_WindowBase.h @@ -41,7 +41,7 @@ static void RegrabMouse(void) { } static void DefaultEnableRawMouse(void) { - Input_RawMode = true; + Input.RawMode = true; RegrabMouse(); Cursor_SetVisible(false); } @@ -54,7 +54,7 @@ static void DefaultUpdateRawMouse(void) { } static void DefaultDisableRawMouse(void) { - Input_RawMode = false; + Input.RawMode = false; RegrabMouse(); Cursor_SetVisible(true); } @@ -63,7 +63,7 @@ static void DefaultDisableRawMouse(void) { static void ShowDialogCore(const char* title, const char* msg); void Window_ShowDialog(const char* title, const char* msg) { /* Ensure cursor is usable while showing message box */ - cc_bool rawMode = Input_RawMode; + cc_bool rawMode = Input.RawMode; if (rawMode) Window_DisableRawMouse(); ShowDialogCore(title, msg); diff --git a/src/interop_cocoa.m b/src/interop_cocoa.m index 2a63ce711..94634648c 100644 --- a/src/interop_cocoa.m +++ b/src/interop_cocoa.m @@ -527,7 +527,7 @@ void Window_ProcessEvents(double delta) { case 27: // NSOtherMouseDragged if (GetMouseCoords(&x, &y)) Pointer_SetPosition(0, x, y); - if (Input_RawMode) { + if (Input.RawMode) { dx = [ev deltaX]; dy = [ev deltaY]; Event_RaiseRawMove(&PointerEvents.RawMoved, dx, dy);