diff --git a/src/openrct2-ui/UiContext.cpp b/src/openrct2-ui/UiContext.cpp index cb42b5335e..54cc054b2e 100644 --- a/src/openrct2-ui/UiContext.cpp +++ b/src/openrct2-ui/UiContext.cpp @@ -435,7 +435,7 @@ public: { InputEvent ie; - ie.DeviceKind = InputDeviceKind::Mouse; + ie.DeviceKind = InputDeviceKind::mouse; ie.Modifiers = SDL_GetModState(); ie.Button = e.button.button; ie.State = InputEventState::Down; @@ -471,7 +471,7 @@ public: { InputEvent ie; - ie.DeviceKind = InputDeviceKind::Mouse; + ie.DeviceKind = InputDeviceKind::mouse; ie.Modifiers = SDL_GetModState(); ie.Button = e.button.button; ie.State = InputEventState::Release; @@ -1040,7 +1040,7 @@ private: InputEvent GetInputEventFromSDLEvent(const SDL_Event& e) { InputEvent ie; - ie.DeviceKind = InputDeviceKind::Keyboard; + ie.DeviceKind = InputDeviceKind::keyboard; ie.Modifiers = e.key.keysym.mod; ie.Button = e.key.keysym.sym; diff --git a/src/openrct2-ui/input/InputManager.cpp b/src/openrct2-ui/input/InputManager.cpp index f7b6168dff..080f289a6c 100644 --- a/src/openrct2-ui/input/InputManager.cpp +++ b/src/openrct2-ui/input/InputManager.cpp @@ -48,7 +48,7 @@ void InputManager::QueueInputEvent(const SDL_Event& e) || e.caxis.axis == SDL_CONTROLLER_AXIS_RIGHTX || e.caxis.axis == SDL_CONTROLLER_AXIS_RIGHTY) { InputEvent ie; - ie.DeviceKind = InputDeviceKind::JoyAxis; + ie.DeviceKind = InputDeviceKind::joyAxis; ie.Modifiers = SDL_GetModState(); ie.Button = e.caxis.axis; ie.State = InputEventState::Down; @@ -62,7 +62,7 @@ void InputManager::QueueInputEvent(const SDL_Event& e) if (e.jhat.value != SDL_HAT_CENTERED) { InputEvent ie; - ie.DeviceKind = InputDeviceKind::JoyHat; + ie.DeviceKind = InputDeviceKind::joyHat; ie.Modifiers = SDL_GetModState(); ie.Button = e.jhat.value; ie.State = InputEventState::Down; @@ -75,7 +75,7 @@ void InputManager::QueueInputEvent(const SDL_Event& e) case SDL_JOYBUTTONDOWN: { InputEvent ie; - ie.DeviceKind = InputDeviceKind::JoyButton; + ie.DeviceKind = InputDeviceKind::joyButton; ie.Modifiers = SDL_GetModState(); ie.Button = e.cbutton.button; ie.State = InputEventState::Down; @@ -87,7 +87,7 @@ void InputManager::QueueInputEvent(const SDL_Event& e) case SDL_JOYBUTTONUP: { InputEvent ie; - ie.DeviceKind = InputDeviceKind::JoyButton; + ie.DeviceKind = InputDeviceKind::joyButton; ie.Modifiers = SDL_GetModState(); ie.Button = e.cbutton.button; ie.State = InputEventState::Release; @@ -326,7 +326,7 @@ void InputManager::ProcessEvents() void InputManager::Process(const InputEvent& e) { auto& shortcutManager = GetShortcutManager(); - if (e.DeviceKind == InputDeviceKind::Keyboard) + if (e.DeviceKind == InputDeviceKind::keyboard) { auto& console = GetInGameConsole(); if (console.IsOpen()) @@ -344,7 +344,7 @@ void InputManager::Process(const InputEvent& e) return; } - if (e.DeviceKind == InputDeviceKind::Keyboard) + if (e.DeviceKind == InputDeviceKind::keyboard) { auto* windowMgr = GetWindowManager(); @@ -392,7 +392,7 @@ void InputManager::Process(const InputEvent& e) void InputManager::ProcessInGameConsole(const InputEvent& e) { - if (e.DeviceKind == InputDeviceKind::Keyboard && e.State == InputEventState::Release) + if (e.DeviceKind == InputDeviceKind::keyboard && e.State == InputEventState::Release) { auto input = ConsoleInput::None; switch (e.Button) @@ -427,7 +427,7 @@ void InputManager::ProcessInGameConsole(const InputEvent& e) void InputManager::ProcessChat(const InputEvent& e) { - if (e.DeviceKind == InputDeviceKind::Keyboard && e.State == InputEventState::Down) + if (e.DeviceKind == InputDeviceKind::keyboard && e.State == InputEventState::Down) { auto input = ChatInput::None; switch (e.Button) @@ -508,7 +508,7 @@ bool InputManager::GetState(const ShortcutInput& shortcut) const { switch (shortcut.Kind) { - case InputDeviceKind::Mouse: + case InputDeviceKind::mouse: { if (_mouseState & (1 << shortcut.Button)) { @@ -516,7 +516,7 @@ bool InputManager::GetState(const ShortcutInput& shortcut) const } break; } - case InputDeviceKind::Keyboard: + case InputDeviceKind::keyboard: { auto scanCode = static_cast(SDL_GetScancodeFromKey(shortcut.Button)); if (scanCode < _keyboardState.size() && _keyboardState[scanCode]) @@ -525,7 +525,7 @@ bool InputManager::GetState(const ShortcutInput& shortcut) const } break; } - case InputDeviceKind::JoyButton: + case InputDeviceKind::joyButton: { for (auto* gameController : _gameControllers) { @@ -538,7 +538,7 @@ bool InputManager::GetState(const ShortcutInput& shortcut) const } break; } - case InputDeviceKind::JoyHat: + case InputDeviceKind::joyHat: { for (auto* gameController : _gameControllers) { @@ -559,7 +559,7 @@ bool InputManager::GetState(const ShortcutInput& shortcut) const } break; } - case InputDeviceKind::JoyAxis: + case InputDeviceKind::joyAxis: { // analogue axes don't have a simple "pressed" state like buttons // Return false for shortcuts on analogue axes as they're handled differently diff --git a/src/openrct2-ui/input/InputManager.h b/src/openrct2-ui/input/InputManager.h index cbcece0b78..3399ee8dc2 100644 --- a/src/openrct2-ui/input/InputManager.h +++ b/src/openrct2-ui/input/InputManager.h @@ -23,11 +23,11 @@ namespace OpenRCT2::Ui enum class InputDeviceKind { - Mouse, - Keyboard, - JoyButton, - JoyHat, - JoyAxis, + mouse, + keyboard, + joyButton, + joyHat, + joyAxis, }; enum class InputEventState diff --git a/src/openrct2-ui/input/ShortcutInput.cpp b/src/openrct2-ui/input/ShortcutInput.cpp index c9b09b136e..2544eb7831 100644 --- a/src/openrct2-ui/input/ShortcutInput.cpp +++ b/src/openrct2-ui/input/ShortcutInput.cpp @@ -125,25 +125,25 @@ ShortcutInput::ShortcutInput(std::string_view value) rem = rem.substr(4); if (String::equals(rem, "LEFT")) { - Kind = InputDeviceKind::JoyHat; + Kind = InputDeviceKind::joyHat; Modifiers = modifiers; Button = SDL_HAT_LEFT; } else if (String::equals(rem, "RIGHT")) { - Kind = InputDeviceKind::JoyHat; + Kind = InputDeviceKind::joyHat; Modifiers = modifiers; Button = SDL_HAT_RIGHT; } else if (String::equals(rem, "UP")) { - Kind = InputDeviceKind::JoyHat; + Kind = InputDeviceKind::joyHat; Modifiers = modifiers; Button = SDL_HAT_UP; } else if (String::equals(rem, "DOWN")) { - Kind = InputDeviceKind::JoyHat; + Kind = InputDeviceKind::joyHat; Modifiers = modifiers; Button = SDL_HAT_DOWN; } @@ -152,7 +152,7 @@ ShortcutInput::ShortcutInput(std::string_view value) auto number = String::Parse(rem); if (number.has_value()) { - Kind = InputDeviceKind::JoyButton; + Kind = InputDeviceKind::joyButton; Modifiers = modifiers; Button = number.value() - 1; } @@ -164,26 +164,26 @@ ShortcutInput::ShortcutInput(std::string_view value) auto number = String::Parse(rem); if (number) { - Kind = InputDeviceKind::Mouse; + Kind = InputDeviceKind::mouse; Modifiers = modifiers; Button = *number - 1; } } else if (String::iequals(rem, "LMB")) { - Kind = InputDeviceKind::Mouse; + Kind = InputDeviceKind::mouse; Modifiers = modifiers; Button = 0; } else if (String::iequals(rem, "RMB")) { - Kind = InputDeviceKind::Mouse; + Kind = InputDeviceKind::mouse; Modifiers = modifiers; Button = 1; } else { - Kind = InputDeviceKind::Keyboard; + Kind = InputDeviceKind::keyboard; Modifiers = modifiers; Button = ParseKey(rem); } @@ -288,7 +288,7 @@ std::string ShortcutInput::ToString(bool localised) const AppendModifier(result, KMOD_LALT, KMOD_RALT, localised); AppendModifier(result, KMOD_LGUI, KMOD_RGUI, localised); - if (Kind == InputDeviceKind::Keyboard) + if (Kind == InputDeviceKind::keyboard) { if (Button != 0) { @@ -310,7 +310,7 @@ std::string ShortcutInput::ToString(bool localised) const } } } - else if (Kind == InputDeviceKind::Mouse) + else if (Kind == InputDeviceKind::mouse) { switch (Button) { @@ -326,11 +326,11 @@ std::string ShortcutInput::ToString(bool localised) const break; } } - else if (Kind == InputDeviceKind::JoyButton) + else if (Kind == InputDeviceKind::joyButton) { result += localised ? FormatStringID(STR_SHORTCUT_JOY_NUMBER, Button + 1) : "JOY " + std::to_string(Button + 1); } - else if (Kind == InputDeviceKind::JoyHat) + else if (Kind == InputDeviceKind::joyHat) { if (Button & SDL_HAT_LEFT) result += localised ? LanguageGetString(STR_SHORTCUT_JOY_LEFT) : "JOY LEFT"; diff --git a/src/openrct2-ui/input/ShortcutManager.cpp b/src/openrct2-ui/input/ShortcutManager.cpp index 7c28c2eb95..f3ddf66423 100644 --- a/src/openrct2-ui/input/ShortcutManager.cpp +++ b/src/openrct2-ui/input/ShortcutManager.cpp @@ -64,7 +64,7 @@ bool RegisteredShortcut::IsSuitableInputEvent(const InputEvent& e) const return false; } - if (e.DeviceKind == InputDeviceKind::Mouse) + if (e.DeviceKind == InputDeviceKind::mouse) { // Do not allow LMB or RMB to be shortcut if (e.Button == 0 || e.Button == 1) @@ -72,7 +72,7 @@ bool RegisteredShortcut::IsSuitableInputEvent(const InputEvent& e) const return false; } } - else if (e.DeviceKind == InputDeviceKind::Keyboard) + else if (e.DeviceKind == InputDeviceKind::keyboard) { // Do not allow modifier keys alone switch (e.Button) @@ -242,7 +242,7 @@ std::optional ShortcutManager::ConvertLegacyBinding(uint16_t bind } ShortcutInput result; - result.Kind = InputDeviceKind::Keyboard; + result.Kind = InputDeviceKind::keyboard; if (binding & kShift) result.Modifiers |= KMOD_SHIFT; if (binding & kCtrl)