From 78f80a0010929bcb87b097f2cf3b35a906c7b912 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 10 Jul 2026 10:33:53 +0200 Subject: [PATCH] Some tweaks to avoid name collisions in upcoming commits --- Common/GPU/ShaderWriter.h | 2 +- Common/Input/InputState.h | 14 +++++--------- Common/UI/TabHolder.cpp | 4 ++-- Common/UI/View.cpp | 4 ++-- UI/DevScreens.cpp | 12 +++++++----- UI/MainScreen.cpp | 2 +- UI/MiscViews.cpp | 2 +- UI/NativeApp.cpp | 8 ++++---- 8 files changed, 23 insertions(+), 25 deletions(-) diff --git a/Common/GPU/ShaderWriter.h b/Common/GPU/ShaderWriter.h index 4dd3414fb6..7ebe801403 100644 --- a/Common/GPU/ShaderWriter.h +++ b/Common/GPU/ShaderWriter.h @@ -35,7 +35,7 @@ enum class ShaderWriterFlags { }; ENUM_CLASS_BITOPS(ShaderWriterFlags); -// TODO: Somehow merge with StringWriter from Parsers.h +// TODO: Somehow merge with StringWriter from StringWriter.h class ShaderWriter { public: // Extensions are supported for both OpenGL ES and Vulkan (though of course, they're different). diff --git a/Common/Input/InputState.h b/Common/Input/InputState.h index b9aacbbe4a..588af44509 100644 --- a/Common/Input/InputState.h +++ b/Common/Input/InputState.h @@ -165,11 +165,6 @@ struct TouchInput { double timestamp; }; -#undef MOD_CTRL -#undef MOD_ALT -#undef MOD_SHIFT -#undef MOD_META - enum class KeyInputFlags { DOWN = 1 << 0, UP = 1 << 1, @@ -178,16 +173,17 @@ enum class KeyInputFlags { CHAR = 1 << 4, // Unicode character input. Cannot detect keyups of these so KeyInputFlags::DOWN and KeyInputFlags::UP are zero when this is set. // NOTE: These are only available in sync input. - MOD_CTRL = 1 << 5, - MOD_SHIFT = 1 << 6, - MOD_ALT = 1 << 7, - MOD_META = 1 << 8, // Windows key, command key, etc. + ModCtrl = 1 << 5, + ModShift = 1 << 6, + ModAlt = 1 << 7, + ModMeta = 1 << 8, // Windows key, command key, etc. }; ENUM_CLASS_BITOPS(KeyInputFlags); struct KeyInput { KeyInput() {} + // These utility constructors are used a lot in SDL/Qt. KeyInput(InputDeviceID devId, InputKeyCode code, KeyInputFlags fl) : deviceId(devId), keyCode(code), flags(fl) {} KeyInput(InputDeviceID devId, int unicode) : deviceId(devId), unicodeChar(unicode), flags(KeyInputFlags::CHAR) {} InputDeviceID deviceId; diff --git a/Common/UI/TabHolder.cpp b/Common/UI/TabHolder.cpp index 2456a19f14..9c3a2ab0df 100644 --- a/Common/UI/TabHolder.cpp +++ b/Common/UI/TabHolder.cpp @@ -362,8 +362,8 @@ bool ChoiceStrip::Key(const KeyInput &input) { } // Support Ctrl+Tab / Ctrl+Shift+Tab as well, as these are common shortcuts for tab switching even outside of browsers. - if (input.keyCode == NKCODE_TAB && (input.flags & KeyInputFlags::MOD_CTRL)) { - if (input.flags & KeyInputFlags::MOD_SHIFT) { + if (input.keyCode == NKCODE_TAB && (input.flags & KeyInputFlags::ModCtrl)) { + if (input.flags & KeyInputFlags::ModShift) { if (selected_ > 0) { SetSelection(selected_ - 1, true); } else if (!choices_.empty()) { diff --git a/Common/UI/View.cpp b/Common/UI/View.cpp index f9bce6ab57..eb3e9f9237 100644 --- a/Common/UI/View.cpp +++ b/Common/UI/View.cpp @@ -1450,7 +1450,7 @@ bool TextEdit::Key(const KeyInput &input) { break; } - if ((input.flags & KeyInputFlags::MOD_CTRL) || (input.flags & KeyInputFlags::MOD_META)) { + if ((input.flags & KeyInputFlags::ModCtrl) || (input.flags & KeyInputFlags::ModMeta)) { switch (input.keyCode) { case NKCODE_C: // Just copy the entire text contents, until we get selection support. @@ -1501,7 +1501,7 @@ bool TextEdit::Key(const KeyInput &input) { // Process chars. if (input.flags & KeyInputFlags::CHAR) { const int unichar = input.keyCode; - if (unichar >= 0x20 && !(input.flags & KeyInputFlags::MOD_CTRL)) { // Ignore control characters. + if (unichar >= 0x20 && !(input.flags & KeyInputFlags::ModCtrl)) { // Ignore control characters. // Insert it! (todo: do it with a string insert) char buf[8]; buf[u8_wc_toutf8(buf, unichar)] = '\0'; diff --git a/UI/DevScreens.cpp b/UI/DevScreens.cpp index cea1bed935..1751c98312 100644 --- a/UI/DevScreens.cpp +++ b/UI/DevScreens.cpp @@ -474,7 +474,7 @@ int ShaderListScreen::ListShaders(DebugShaderType shaderType, UI::LinearLayout * return count; } -struct { DebugShaderType type; const char *name; } shaderTypes[] = { +static constexpr struct { DebugShaderType type; const char *name; } shaderTypes[] = { { SHADER_TYPE_VERTEX, "Vertex" }, { SHADER_TYPE_FRAGMENT, "Fragment" }, { SHADER_TYPE_VERTEXLOADER, "VertexLoader" }, @@ -729,10 +729,10 @@ bool TouchTestScreen::key(const KeyInput &key) { (key.flags & KeyInputFlags::UP) ? "UP " : "", (key.flags & KeyInputFlags::DOWN) ? "DOWN " : "", (key.flags & KeyInputFlags::CHAR) ? "CHAR " : "", - (key.flags & KeyInputFlags::MOD_CTRL) ? "CTRL " : "", - (key.flags & KeyInputFlags::MOD_SHIFT) ? "SHIFT " : "", - (key.flags & KeyInputFlags::MOD_ALT) ? "ALT " : "", - (key.flags & KeyInputFlags::MOD_META) ? "META " : ""); + (key.flags & KeyInputFlags::ModCtrl) ? "CTRL " : "", + (key.flags & KeyInputFlags::ModShift) ? "SHIFT " : "", + (key.flags & KeyInputFlags::ModAlt) ? "ALT " : "", + (key.flags & KeyInputFlags::ModMeta) ? "META " : ""); keyEventLog_.push_back(buf); UpdateLogView(); return true; @@ -755,6 +755,8 @@ void TouchTestScreen::axis(const AxisInput &axis) { UpdateLogView(); } +#undef DrawText + void TouchTestScreen::DrawForeground(UIContext &dc) { Bounds bounds = GetLayoutBounds(dc); diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index 7eb9540a43..644c90f8cd 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -516,7 +516,7 @@ void MainScreen::CreateViews() { bool MainScreen::key(const KeyInput &key) { if (key.flags & KeyInputFlags::DOWN) { - if (key.keyCode == NKCODE_F && (key.flags & KeyInputFlags::MOD_CTRL) && System_GetPropertyBool(SYSPROP_HAS_TEXT_INPUT_DIALOG)) { + if (key.keyCode == NKCODE_F && (key.flags & KeyInputFlags::ModCtrl) && System_GetPropertyBool(SYSPROP_HAS_TEXT_INPUT_DIALOG)) { auto se = GetI18NCategory(I18NCat::SEARCH); System_InputBoxGetString(GetRequesterToken(), se->T("Search term"), searchFilter_, false, [this](std::string_view value, int) { searchFilter_ = StripSpaces(value); diff --git a/UI/MiscViews.cpp b/UI/MiscViews.cpp index 4d61d0f147..cef4a1b605 100644 --- a/UI/MiscViews.cpp +++ b/UI/MiscViews.cpp @@ -458,7 +458,7 @@ bool ViewSearch::Key(UI::ViewGroup *viewGroup, const KeyInput &input) { } else if (input.flags & KeyInputFlags::DOWN) { if (input.keyCode == NKCODE_DEL) { if (!searchFilter.empty()) { - if (input.flags & KeyInputFlags::MOD_CTRL) { + if (input.flags & KeyInputFlags::ModCtrl) { // Ctrl+Backspace deletes the last word. Delete until the last space. size_t pos = searchFilter.find_last_of(' '); if (pos != searchFilter.npos) { diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 23eb404068..81857bfae1 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -1521,16 +1521,16 @@ bool NativeKey(const KeyInput &key) { KeyInputFlags modifierFlags{}; if (g_modifiersPressed & (KeyModifier::LCTRL | KeyModifier::RCTRL)) { - modifierFlags |= KeyInputFlags::MOD_CTRL; + modifierFlags |= KeyInputFlags::ModCtrl; } if (g_modifiersPressed & (KeyModifier::LSHIFT | KeyModifier::RSHIFT)) { - modifierFlags |= KeyInputFlags::MOD_SHIFT; + modifierFlags |= KeyInputFlags::ModShift; } if (g_modifiersPressed & (KeyModifier::LALT | KeyModifier::RALT)) { - modifierFlags |= KeyInputFlags::MOD_ALT; + modifierFlags |= KeyInputFlags::ModAlt; } if (g_modifiersPressed & (KeyModifier::LMETA | KeyModifier::RMETA)) { - modifierFlags |= KeyInputFlags::MOD_META; + modifierFlags |= KeyInputFlags::ModMeta; } KeyInput modKey = key;