diff options
author | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2022-11-14 16:27:26 +0200 |
---|---|---|
committer | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2023-04-11 10:58:54 +0300 |
commit | a5009f4d3cc36974a5897c3c819e61c3e0783b0d (patch) | |
tree | 3321f8bcc561b450f518e93efd682e4d51b2063c /core/input | |
parent | c3ed7af12347aa04a3d3bb91bc726170e894758e (diff) | |
download | redot-engine-a5009f4d3cc36974a5897c3c819e61c3e0783b0d.tar.gz |
[Web] Detect host OS and use macOS keys on mac hosts.
Diffstat (limited to 'core/input')
-rw-r--r-- | core/input/input_event.cpp | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/core/input/input_event.cpp b/core/input/input_event.cpp index 9d5d84a508..46f07fe041 100644 --- a/core/input/input_event.cpp +++ b/core/input/input_event.cpp @@ -33,6 +33,7 @@ #include "core/input/input_map.h" #include "core/input/shortcut.h" #include "core/os/keyboard.h" +#include "core/os/os.h" const int InputEvent::DEVICE_ID_EMULATION = -1; const int InputEvent::DEVICE_ID_INTERNAL = -2; @@ -145,13 +146,13 @@ int64_t InputEventFromWindow::get_window_id() const { void InputEventWithModifiers::set_command_or_control_autoremap(bool p_enabled) { command_or_control_autoremap = p_enabled; if (command_or_control_autoremap) { -#ifdef MACOS_ENABLED - ctrl_pressed = false; - meta_pressed = true; -#else - ctrl_pressed = true; - meta_pressed = false; -#endif + if (OS::get_singleton()->has_feature("macos") || OS::get_singleton()->has_feature("web_macos") || OS::get_singleton()->has_feature("web_ios")) { + ctrl_pressed = false; + meta_pressed = true; + } else { + ctrl_pressed = true; + meta_pressed = false; + } } else { ctrl_pressed = false; meta_pressed = false; @@ -164,11 +165,11 @@ bool InputEventWithModifiers::is_command_or_control_autoremap() const { } bool InputEventWithModifiers::is_command_or_control_pressed() const { -#ifdef MACOS_ENABLED - return meta_pressed; -#else - return ctrl_pressed; -#endif + if (OS::get_singleton()->has_feature("macos") || OS::get_singleton()->has_feature("web_macos") || OS::get_singleton()->has_feature("web_ios")) { + return meta_pressed; + } else { + return ctrl_pressed; + } } void InputEventWithModifiers::set_shift_pressed(bool p_enabled) { @@ -231,11 +232,11 @@ BitField<KeyModifierMask> InputEventWithModifiers::get_modifiers_mask() const { mask.set_flag(KeyModifierMask::META); } if (is_command_or_control_autoremap()) { -#ifdef MACOS_ENABLED - mask.set_flag(KeyModifierMask::META); -#else - mask.set_flag(KeyModifierMask::CTRL); -#endif + if (OS::get_singleton()->has_feature("macos") || OS::get_singleton()->has_feature("web_macos") || OS::get_singleton()->has_feature("web_ios")) { + mask.set_flag(KeyModifierMask::META); + } else { + mask.set_flag(KeyModifierMask::CTRL); + } } return mask; } |