mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-10 17:42:29 +01:00
Rename members of InputDeviceKind
This commit is contained in:
@@ -435,7 +435,7 @@ public:
|
|||||||
|
|
||||||
{
|
{
|
||||||
InputEvent ie;
|
InputEvent ie;
|
||||||
ie.DeviceKind = InputDeviceKind::Mouse;
|
ie.DeviceKind = InputDeviceKind::mouse;
|
||||||
ie.Modifiers = SDL_GetModState();
|
ie.Modifiers = SDL_GetModState();
|
||||||
ie.Button = e.button.button;
|
ie.Button = e.button.button;
|
||||||
ie.State = InputEventState::Down;
|
ie.State = InputEventState::Down;
|
||||||
@@ -471,7 +471,7 @@ public:
|
|||||||
|
|
||||||
{
|
{
|
||||||
InputEvent ie;
|
InputEvent ie;
|
||||||
ie.DeviceKind = InputDeviceKind::Mouse;
|
ie.DeviceKind = InputDeviceKind::mouse;
|
||||||
ie.Modifiers = SDL_GetModState();
|
ie.Modifiers = SDL_GetModState();
|
||||||
ie.Button = e.button.button;
|
ie.Button = e.button.button;
|
||||||
ie.State = InputEventState::Release;
|
ie.State = InputEventState::Release;
|
||||||
@@ -1040,7 +1040,7 @@ private:
|
|||||||
InputEvent GetInputEventFromSDLEvent(const SDL_Event& e)
|
InputEvent GetInputEventFromSDLEvent(const SDL_Event& e)
|
||||||
{
|
{
|
||||||
InputEvent ie;
|
InputEvent ie;
|
||||||
ie.DeviceKind = InputDeviceKind::Keyboard;
|
ie.DeviceKind = InputDeviceKind::keyboard;
|
||||||
ie.Modifiers = e.key.keysym.mod;
|
ie.Modifiers = e.key.keysym.mod;
|
||||||
ie.Button = e.key.keysym.sym;
|
ie.Button = e.key.keysym.sym;
|
||||||
|
|
||||||
|
|||||||
@@ -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)
|
|| e.caxis.axis == SDL_CONTROLLER_AXIS_RIGHTX || e.caxis.axis == SDL_CONTROLLER_AXIS_RIGHTY)
|
||||||
{
|
{
|
||||||
InputEvent ie;
|
InputEvent ie;
|
||||||
ie.DeviceKind = InputDeviceKind::JoyAxis;
|
ie.DeviceKind = InputDeviceKind::joyAxis;
|
||||||
ie.Modifiers = SDL_GetModState();
|
ie.Modifiers = SDL_GetModState();
|
||||||
ie.Button = e.caxis.axis;
|
ie.Button = e.caxis.axis;
|
||||||
ie.State = InputEventState::Down;
|
ie.State = InputEventState::Down;
|
||||||
@@ -62,7 +62,7 @@ void InputManager::QueueInputEvent(const SDL_Event& e)
|
|||||||
if (e.jhat.value != SDL_HAT_CENTERED)
|
if (e.jhat.value != SDL_HAT_CENTERED)
|
||||||
{
|
{
|
||||||
InputEvent ie;
|
InputEvent ie;
|
||||||
ie.DeviceKind = InputDeviceKind::JoyHat;
|
ie.DeviceKind = InputDeviceKind::joyHat;
|
||||||
ie.Modifiers = SDL_GetModState();
|
ie.Modifiers = SDL_GetModState();
|
||||||
ie.Button = e.jhat.value;
|
ie.Button = e.jhat.value;
|
||||||
ie.State = InputEventState::Down;
|
ie.State = InputEventState::Down;
|
||||||
@@ -75,7 +75,7 @@ void InputManager::QueueInputEvent(const SDL_Event& e)
|
|||||||
case SDL_JOYBUTTONDOWN:
|
case SDL_JOYBUTTONDOWN:
|
||||||
{
|
{
|
||||||
InputEvent ie;
|
InputEvent ie;
|
||||||
ie.DeviceKind = InputDeviceKind::JoyButton;
|
ie.DeviceKind = InputDeviceKind::joyButton;
|
||||||
ie.Modifiers = SDL_GetModState();
|
ie.Modifiers = SDL_GetModState();
|
||||||
ie.Button = e.cbutton.button;
|
ie.Button = e.cbutton.button;
|
||||||
ie.State = InputEventState::Down;
|
ie.State = InputEventState::Down;
|
||||||
@@ -87,7 +87,7 @@ void InputManager::QueueInputEvent(const SDL_Event& e)
|
|||||||
case SDL_JOYBUTTONUP:
|
case SDL_JOYBUTTONUP:
|
||||||
{
|
{
|
||||||
InputEvent ie;
|
InputEvent ie;
|
||||||
ie.DeviceKind = InputDeviceKind::JoyButton;
|
ie.DeviceKind = InputDeviceKind::joyButton;
|
||||||
ie.Modifiers = SDL_GetModState();
|
ie.Modifiers = SDL_GetModState();
|
||||||
ie.Button = e.cbutton.button;
|
ie.Button = e.cbutton.button;
|
||||||
ie.State = InputEventState::Release;
|
ie.State = InputEventState::Release;
|
||||||
@@ -326,7 +326,7 @@ void InputManager::ProcessEvents()
|
|||||||
void InputManager::Process(const InputEvent& e)
|
void InputManager::Process(const InputEvent& e)
|
||||||
{
|
{
|
||||||
auto& shortcutManager = GetShortcutManager();
|
auto& shortcutManager = GetShortcutManager();
|
||||||
if (e.DeviceKind == InputDeviceKind::Keyboard)
|
if (e.DeviceKind == InputDeviceKind::keyboard)
|
||||||
{
|
{
|
||||||
auto& console = GetInGameConsole();
|
auto& console = GetInGameConsole();
|
||||||
if (console.IsOpen())
|
if (console.IsOpen())
|
||||||
@@ -344,7 +344,7 @@ void InputManager::Process(const InputEvent& e)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.DeviceKind == InputDeviceKind::Keyboard)
|
if (e.DeviceKind == InputDeviceKind::keyboard)
|
||||||
{
|
{
|
||||||
auto* windowMgr = GetWindowManager();
|
auto* windowMgr = GetWindowManager();
|
||||||
|
|
||||||
@@ -392,7 +392,7 @@ void InputManager::Process(const InputEvent& e)
|
|||||||
|
|
||||||
void InputManager::ProcessInGameConsole(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;
|
auto input = ConsoleInput::None;
|
||||||
switch (e.Button)
|
switch (e.Button)
|
||||||
@@ -427,7 +427,7 @@ void InputManager::ProcessInGameConsole(const InputEvent& e)
|
|||||||
|
|
||||||
void InputManager::ProcessChat(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;
|
auto input = ChatInput::None;
|
||||||
switch (e.Button)
|
switch (e.Button)
|
||||||
@@ -508,7 +508,7 @@ bool InputManager::GetState(const ShortcutInput& shortcut) const
|
|||||||
{
|
{
|
||||||
switch (shortcut.Kind)
|
switch (shortcut.Kind)
|
||||||
{
|
{
|
||||||
case InputDeviceKind::Mouse:
|
case InputDeviceKind::mouse:
|
||||||
{
|
{
|
||||||
if (_mouseState & (1 << shortcut.Button))
|
if (_mouseState & (1 << shortcut.Button))
|
||||||
{
|
{
|
||||||
@@ -516,7 +516,7 @@ bool InputManager::GetState(const ShortcutInput& shortcut) const
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case InputDeviceKind::Keyboard:
|
case InputDeviceKind::keyboard:
|
||||||
{
|
{
|
||||||
auto scanCode = static_cast<size_t>(SDL_GetScancodeFromKey(shortcut.Button));
|
auto scanCode = static_cast<size_t>(SDL_GetScancodeFromKey(shortcut.Button));
|
||||||
if (scanCode < _keyboardState.size() && _keyboardState[scanCode])
|
if (scanCode < _keyboardState.size() && _keyboardState[scanCode])
|
||||||
@@ -525,7 +525,7 @@ bool InputManager::GetState(const ShortcutInput& shortcut) const
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case InputDeviceKind::JoyButton:
|
case InputDeviceKind::joyButton:
|
||||||
{
|
{
|
||||||
for (auto* gameController : _gameControllers)
|
for (auto* gameController : _gameControllers)
|
||||||
{
|
{
|
||||||
@@ -538,7 +538,7 @@ bool InputManager::GetState(const ShortcutInput& shortcut) const
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case InputDeviceKind::JoyHat:
|
case InputDeviceKind::joyHat:
|
||||||
{
|
{
|
||||||
for (auto* gameController : _gameControllers)
|
for (auto* gameController : _gameControllers)
|
||||||
{
|
{
|
||||||
@@ -559,7 +559,7 @@ bool InputManager::GetState(const ShortcutInput& shortcut) const
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case InputDeviceKind::JoyAxis:
|
case InputDeviceKind::joyAxis:
|
||||||
{
|
{
|
||||||
// analogue axes don't have a simple "pressed" state like buttons
|
// analogue axes don't have a simple "pressed" state like buttons
|
||||||
// Return false for shortcuts on analogue axes as they're handled differently
|
// Return false for shortcuts on analogue axes as they're handled differently
|
||||||
|
|||||||
@@ -23,11 +23,11 @@ namespace OpenRCT2::Ui
|
|||||||
|
|
||||||
enum class InputDeviceKind
|
enum class InputDeviceKind
|
||||||
{
|
{
|
||||||
Mouse,
|
mouse,
|
||||||
Keyboard,
|
keyboard,
|
||||||
JoyButton,
|
joyButton,
|
||||||
JoyHat,
|
joyHat,
|
||||||
JoyAxis,
|
joyAxis,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class InputEventState
|
enum class InputEventState
|
||||||
|
|||||||
@@ -125,25 +125,25 @@ ShortcutInput::ShortcutInput(std::string_view value)
|
|||||||
rem = rem.substr(4);
|
rem = rem.substr(4);
|
||||||
if (String::equals(rem, "LEFT"))
|
if (String::equals(rem, "LEFT"))
|
||||||
{
|
{
|
||||||
Kind = InputDeviceKind::JoyHat;
|
Kind = InputDeviceKind::joyHat;
|
||||||
Modifiers = modifiers;
|
Modifiers = modifiers;
|
||||||
Button = SDL_HAT_LEFT;
|
Button = SDL_HAT_LEFT;
|
||||||
}
|
}
|
||||||
else if (String::equals(rem, "RIGHT"))
|
else if (String::equals(rem, "RIGHT"))
|
||||||
{
|
{
|
||||||
Kind = InputDeviceKind::JoyHat;
|
Kind = InputDeviceKind::joyHat;
|
||||||
Modifiers = modifiers;
|
Modifiers = modifiers;
|
||||||
Button = SDL_HAT_RIGHT;
|
Button = SDL_HAT_RIGHT;
|
||||||
}
|
}
|
||||||
else if (String::equals(rem, "UP"))
|
else if (String::equals(rem, "UP"))
|
||||||
{
|
{
|
||||||
Kind = InputDeviceKind::JoyHat;
|
Kind = InputDeviceKind::joyHat;
|
||||||
Modifiers = modifiers;
|
Modifiers = modifiers;
|
||||||
Button = SDL_HAT_UP;
|
Button = SDL_HAT_UP;
|
||||||
}
|
}
|
||||||
else if (String::equals(rem, "DOWN"))
|
else if (String::equals(rem, "DOWN"))
|
||||||
{
|
{
|
||||||
Kind = InputDeviceKind::JoyHat;
|
Kind = InputDeviceKind::joyHat;
|
||||||
Modifiers = modifiers;
|
Modifiers = modifiers;
|
||||||
Button = SDL_HAT_DOWN;
|
Button = SDL_HAT_DOWN;
|
||||||
}
|
}
|
||||||
@@ -152,7 +152,7 @@ ShortcutInput::ShortcutInput(std::string_view value)
|
|||||||
auto number = String::Parse<int32_t>(rem);
|
auto number = String::Parse<int32_t>(rem);
|
||||||
if (number.has_value())
|
if (number.has_value())
|
||||||
{
|
{
|
||||||
Kind = InputDeviceKind::JoyButton;
|
Kind = InputDeviceKind::joyButton;
|
||||||
Modifiers = modifiers;
|
Modifiers = modifiers;
|
||||||
Button = number.value() - 1;
|
Button = number.value() - 1;
|
||||||
}
|
}
|
||||||
@@ -164,26 +164,26 @@ ShortcutInput::ShortcutInput(std::string_view value)
|
|||||||
auto number = String::Parse<int32_t>(rem);
|
auto number = String::Parse<int32_t>(rem);
|
||||||
if (number)
|
if (number)
|
||||||
{
|
{
|
||||||
Kind = InputDeviceKind::Mouse;
|
Kind = InputDeviceKind::mouse;
|
||||||
Modifiers = modifiers;
|
Modifiers = modifiers;
|
||||||
Button = *number - 1;
|
Button = *number - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (String::iequals(rem, "LMB"))
|
else if (String::iequals(rem, "LMB"))
|
||||||
{
|
{
|
||||||
Kind = InputDeviceKind::Mouse;
|
Kind = InputDeviceKind::mouse;
|
||||||
Modifiers = modifiers;
|
Modifiers = modifiers;
|
||||||
Button = 0;
|
Button = 0;
|
||||||
}
|
}
|
||||||
else if (String::iequals(rem, "RMB"))
|
else if (String::iequals(rem, "RMB"))
|
||||||
{
|
{
|
||||||
Kind = InputDeviceKind::Mouse;
|
Kind = InputDeviceKind::mouse;
|
||||||
Modifiers = modifiers;
|
Modifiers = modifiers;
|
||||||
Button = 1;
|
Button = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Kind = InputDeviceKind::Keyboard;
|
Kind = InputDeviceKind::keyboard;
|
||||||
Modifiers = modifiers;
|
Modifiers = modifiers;
|
||||||
Button = ParseKey(rem);
|
Button = ParseKey(rem);
|
||||||
}
|
}
|
||||||
@@ -288,7 +288,7 @@ std::string ShortcutInput::ToString(bool localised) const
|
|||||||
AppendModifier(result, KMOD_LALT, KMOD_RALT, localised);
|
AppendModifier(result, KMOD_LALT, KMOD_RALT, localised);
|
||||||
AppendModifier(result, KMOD_LGUI, KMOD_RGUI, localised);
|
AppendModifier(result, KMOD_LGUI, KMOD_RGUI, localised);
|
||||||
|
|
||||||
if (Kind == InputDeviceKind::Keyboard)
|
if (Kind == InputDeviceKind::keyboard)
|
||||||
{
|
{
|
||||||
if (Button != 0)
|
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)
|
switch (Button)
|
||||||
{
|
{
|
||||||
@@ -326,11 +326,11 @@ std::string ShortcutInput::ToString(bool localised) const
|
|||||||
break;
|
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);
|
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)
|
if (Button & SDL_HAT_LEFT)
|
||||||
result += localised ? LanguageGetString(STR_SHORTCUT_JOY_LEFT) : "JOY LEFT";
|
result += localised ? LanguageGetString(STR_SHORTCUT_JOY_LEFT) : "JOY LEFT";
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ bool RegisteredShortcut::IsSuitableInputEvent(const InputEvent& e) const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.DeviceKind == InputDeviceKind::Mouse)
|
if (e.DeviceKind == InputDeviceKind::mouse)
|
||||||
{
|
{
|
||||||
// Do not allow LMB or RMB to be shortcut
|
// Do not allow LMB or RMB to be shortcut
|
||||||
if (e.Button == 0 || e.Button == 1)
|
if (e.Button == 0 || e.Button == 1)
|
||||||
@@ -72,7 +72,7 @@ bool RegisteredShortcut::IsSuitableInputEvent(const InputEvent& e) const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (e.DeviceKind == InputDeviceKind::Keyboard)
|
else if (e.DeviceKind == InputDeviceKind::keyboard)
|
||||||
{
|
{
|
||||||
// Do not allow modifier keys alone
|
// Do not allow modifier keys alone
|
||||||
switch (e.Button)
|
switch (e.Button)
|
||||||
@@ -242,7 +242,7 @@ std::optional<ShortcutInput> ShortcutManager::ConvertLegacyBinding(uint16_t bind
|
|||||||
}
|
}
|
||||||
|
|
||||||
ShortcutInput result;
|
ShortcutInput result;
|
||||||
result.Kind = InputDeviceKind::Keyboard;
|
result.Kind = InputDeviceKind::keyboard;
|
||||||
if (binding & kShift)
|
if (binding & kShift)
|
||||||
result.Modifiers |= KMOD_SHIFT;
|
result.Modifiers |= KMOD_SHIFT;
|
||||||
if (binding & kCtrl)
|
if (binding & kCtrl)
|
||||||
|
|||||||
Reference in New Issue
Block a user