mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-10 09:32:29 +01:00
Rename members of InputEvent
This commit is contained in:
@@ -435,10 +435,10 @@ public:
|
||||
|
||||
{
|
||||
InputEvent ie;
|
||||
ie.DeviceKind = InputDeviceKind::mouse;
|
||||
ie.Modifiers = SDL_GetModState();
|
||||
ie.Button = e.button.button;
|
||||
ie.State = InputEventState::down;
|
||||
ie.deviceKind = InputDeviceKind::mouse;
|
||||
ie.modifiers = SDL_GetModState();
|
||||
ie.button = e.button.button;
|
||||
ie.state = InputEventState::down;
|
||||
_inputManager.QueueInputEvent(std::move(ie));
|
||||
}
|
||||
break;
|
||||
@@ -471,10 +471,10 @@ public:
|
||||
|
||||
{
|
||||
InputEvent ie;
|
||||
ie.DeviceKind = InputDeviceKind::mouse;
|
||||
ie.Modifiers = SDL_GetModState();
|
||||
ie.Button = e.button.button;
|
||||
ie.State = InputEventState::release;
|
||||
ie.deviceKind = InputDeviceKind::mouse;
|
||||
ie.modifiers = SDL_GetModState();
|
||||
ie.button = e.button.button;
|
||||
ie.state = InputEventState::release;
|
||||
_inputManager.QueueInputEvent(std::move(ie));
|
||||
}
|
||||
break;
|
||||
@@ -544,14 +544,14 @@ public:
|
||||
#endif
|
||||
_textComposition.HandleMessage(&e);
|
||||
auto ie = GetInputEventFromSDLEvent(e);
|
||||
ie.State = InputEventState::down;
|
||||
ie.state = InputEventState::down;
|
||||
_inputManager.QueueInputEvent(std::move(ie));
|
||||
break;
|
||||
}
|
||||
case SDL_KEYUP:
|
||||
{
|
||||
auto ie = GetInputEventFromSDLEvent(e);
|
||||
ie.State = InputEventState::release;
|
||||
ie.state = InputEventState::release;
|
||||
_inputManager.QueueInputEvent(std::move(ie));
|
||||
break;
|
||||
}
|
||||
@@ -1040,20 +1040,20 @@ private:
|
||||
InputEvent GetInputEventFromSDLEvent(const SDL_Event& e)
|
||||
{
|
||||
InputEvent ie;
|
||||
ie.DeviceKind = InputDeviceKind::keyboard;
|
||||
ie.Modifiers = e.key.keysym.mod;
|
||||
ie.Button = e.key.keysym.sym;
|
||||
ie.deviceKind = InputDeviceKind::keyboard;
|
||||
ie.modifiers = e.key.keysym.mod;
|
||||
ie.button = e.key.keysym.sym;
|
||||
|
||||
// Handle dead keys
|
||||
if (ie.Button == (SDLK_SCANCODE_MASK | 0))
|
||||
if (ie.button == (SDLK_SCANCODE_MASK | 0))
|
||||
{
|
||||
switch (e.key.keysym.scancode)
|
||||
{
|
||||
case SDL_SCANCODE_APOSTROPHE:
|
||||
ie.Button = '\'';
|
||||
ie.button = '\'';
|
||||
break;
|
||||
case SDL_SCANCODE_GRAVE:
|
||||
ie.Button = '`';
|
||||
ie.button = '`';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -48,11 +48,11 @@ 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.Modifiers = SDL_GetModState();
|
||||
ie.Button = e.caxis.axis;
|
||||
ie.State = InputEventState::down;
|
||||
ie.AxisValue = e.caxis.value;
|
||||
ie.deviceKind = InputDeviceKind::joyAxis;
|
||||
ie.modifiers = SDL_GetModState();
|
||||
ie.button = e.caxis.axis;
|
||||
ie.state = InputEventState::down;
|
||||
ie.axisValue = e.caxis.value;
|
||||
QueueInputEvent(std::move(ie));
|
||||
}
|
||||
break;
|
||||
@@ -62,11 +62,11 @@ void InputManager::QueueInputEvent(const SDL_Event& e)
|
||||
if (e.jhat.value != SDL_HAT_CENTERED)
|
||||
{
|
||||
InputEvent ie;
|
||||
ie.DeviceKind = InputDeviceKind::joyHat;
|
||||
ie.Modifiers = SDL_GetModState();
|
||||
ie.Button = e.jhat.value;
|
||||
ie.State = InputEventState::down;
|
||||
ie.AxisValue = 0;
|
||||
ie.deviceKind = InputDeviceKind::joyHat;
|
||||
ie.modifiers = SDL_GetModState();
|
||||
ie.button = e.jhat.value;
|
||||
ie.state = InputEventState::down;
|
||||
ie.axisValue = 0;
|
||||
QueueInputEvent(std::move(ie));
|
||||
}
|
||||
break;
|
||||
@@ -75,11 +75,11 @@ void InputManager::QueueInputEvent(const SDL_Event& e)
|
||||
case SDL_JOYBUTTONDOWN:
|
||||
{
|
||||
InputEvent ie;
|
||||
ie.DeviceKind = InputDeviceKind::joyButton;
|
||||
ie.Modifiers = SDL_GetModState();
|
||||
ie.Button = e.cbutton.button;
|
||||
ie.State = InputEventState::down;
|
||||
ie.AxisValue = 0;
|
||||
ie.deviceKind = InputDeviceKind::joyButton;
|
||||
ie.modifiers = SDL_GetModState();
|
||||
ie.button = e.cbutton.button;
|
||||
ie.state = InputEventState::down;
|
||||
ie.axisValue = 0;
|
||||
QueueInputEvent(std::move(ie));
|
||||
break;
|
||||
}
|
||||
@@ -87,11 +87,11 @@ void InputManager::QueueInputEvent(const SDL_Event& e)
|
||||
case SDL_JOYBUTTONUP:
|
||||
{
|
||||
InputEvent ie;
|
||||
ie.DeviceKind = InputDeviceKind::joyButton;
|
||||
ie.Modifiers = SDL_GetModState();
|
||||
ie.Button = e.cbutton.button;
|
||||
ie.State = InputEventState::release;
|
||||
ie.AxisValue = 0;
|
||||
ie.deviceKind = InputDeviceKind::joyButton;
|
||||
ie.modifiers = SDL_GetModState();
|
||||
ie.button = e.cbutton.button;
|
||||
ie.state = InputEventState::release;
|
||||
ie.axisValue = 0;
|
||||
QueueInputEvent(std::move(ie));
|
||||
break;
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
@@ -352,9 +352,9 @@ void InputManager::Process(const InputEvent& e)
|
||||
auto w = windowMgr->FindByClass(WindowClass::textinput);
|
||||
if (w != nullptr)
|
||||
{
|
||||
if (e.State == InputEventState::release)
|
||||
if (e.state == InputEventState::release)
|
||||
{
|
||||
OpenRCT2::Ui::Windows::WindowTextInputKey(w, e.Button);
|
||||
OpenRCT2::Ui::Windows::WindowTextInputKey(w, e.button);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -363,9 +363,9 @@ void InputManager::Process(const InputEvent& e)
|
||||
w = windowMgr->FindByClass(WindowClass::loadsaveOverwritePrompt);
|
||||
if (w != nullptr)
|
||||
{
|
||||
if (e.State == InputEventState::release)
|
||||
if (e.state == InputEventState::release)
|
||||
{
|
||||
OpenRCT2::Ui::Windows::WindowLoadSaveOverwritePromptInputKey(w, e.Button);
|
||||
OpenRCT2::Ui::Windows::WindowLoadSaveOverwritePromptInputKey(w, e.button);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -374,9 +374,9 @@ void InputManager::Process(const InputEvent& e)
|
||||
w = windowMgr->FindByClass(WindowClass::loadsave);
|
||||
if (w != nullptr)
|
||||
{
|
||||
if (e.State == InputEventState::release)
|
||||
if (e.state == InputEventState::release)
|
||||
{
|
||||
OpenRCT2::Ui::Windows::WindowLoadSaveInputKey(w, e.Button);
|
||||
OpenRCT2::Ui::Windows::WindowLoadSaveInputKey(w, e.button);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -392,10 +392,10 @@ 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)
|
||||
switch (e.button)
|
||||
{
|
||||
case SDLK_ESCAPE:
|
||||
input = ConsoleInput::LineClear;
|
||||
@@ -427,10 +427,10 @@ 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)
|
||||
switch (e.button)
|
||||
{
|
||||
case SDLK_ESCAPE:
|
||||
input = ChatInput::Close;
|
||||
|
||||
@@ -38,11 +38,11 @@ namespace OpenRCT2::Ui
|
||||
|
||||
struct InputEvent
|
||||
{
|
||||
InputDeviceKind DeviceKind;
|
||||
uint32_t Modifiers;
|
||||
uint32_t Button;
|
||||
InputEventState State;
|
||||
int16_t AxisValue; // For analogue stick values (-32768 to 32767)
|
||||
InputDeviceKind deviceKind;
|
||||
uint32_t modifiers;
|
||||
uint32_t button;
|
||||
InputEventState state;
|
||||
int16_t axisValue{}; // For analogue stick values (-32768 to 32767)
|
||||
};
|
||||
|
||||
enum class ModifierKey : uint8_t
|
||||
|
||||
@@ -399,9 +399,9 @@ static bool CompareModifiers(uint32_t shortcut, uint32_t actual)
|
||||
|
||||
bool ShortcutInput::Matches(const InputEvent& e) const
|
||||
{
|
||||
if (CompareModifiers(Modifiers, e.Modifiers))
|
||||
if (CompareModifiers(Modifiers, e.modifiers))
|
||||
{
|
||||
if (e.DeviceKind == Kind && Button == e.Button)
|
||||
if (e.deviceKind == Kind && Button == e.button)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -412,7 +412,7 @@ bool ShortcutInput::Matches(const InputEvent& e) const
|
||||
std::optional<ShortcutInput> ShortcutInput::FromInputEvent(const InputEvent& e)
|
||||
{
|
||||
// Assume any side modifier (more specific configurations can be done by manually editing config file)
|
||||
auto modifiers = e.Modifiers & kUsefulModifiers;
|
||||
auto modifiers = e.modifiers & kUsefulModifiers;
|
||||
for (auto mod : { KMOD_CTRL, KMOD_SHIFT, KMOD_ALT, KMOD_GUI })
|
||||
{
|
||||
if (modifiers & mod)
|
||||
@@ -422,8 +422,8 @@ std::optional<ShortcutInput> ShortcutInput::FromInputEvent(const InputEvent& e)
|
||||
}
|
||||
|
||||
ShortcutInput result;
|
||||
result.Kind = e.DeviceKind;
|
||||
result.Kind = e.deviceKind;
|
||||
result.Modifiers = modifiers;
|
||||
result.Button = e.Button;
|
||||
result.Button = e.button;
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -59,23 +59,23 @@ bool RegisteredShortcut::Matches(const InputEvent& e) const
|
||||
bool RegisteredShortcut::IsSuitableInputEvent(const InputEvent& e) const
|
||||
{
|
||||
// Do not intercept button releases
|
||||
if (e.State == InputEventState::release)
|
||||
if (e.state == InputEventState::release)
|
||||
{
|
||||
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)
|
||||
if (e.button == 0 || e.button == 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (e.DeviceKind == InputDeviceKind::keyboard)
|
||||
else if (e.deviceKind == InputDeviceKind::keyboard)
|
||||
{
|
||||
// Do not allow modifier keys alone
|
||||
switch (e.Button)
|
||||
switch (e.button)
|
||||
{
|
||||
case SDLK_LCTRL:
|
||||
case SDLK_RCTRL:
|
||||
|
||||
Reference in New Issue
Block a user