summaryrefslogtreecommitdiff
path: root/core/input
diff options
context:
space:
mode:
authorHakim <hakim.rouatbi@gmail.com>2023-04-07 17:44:36 +0200
committerYuri Sizov <yuris@humnom.net>2023-04-07 17:44:36 +0200
commitb17f0f593e136ca67e2de1e845d194069fa23318 (patch)
tree6b7a3b1677cae49e6b2c4409ae8f984e32f3205f /core/input
parent4762303f182e65c5293db8d22a4ce88521eba445 (diff)
Use physical shortcuts for freelook navigation in the editor
(cherry picked from commit 52de40310a9d98496aa3de5aaf457a7e60959b77)
Diffstat (limited to 'core/input')
-rw-r--r--core/input/input_event.cpp9
-rw-r--r--core/input/input_event.h2
2 files changed, 8 insertions, 3 deletions
diff --git a/core/input/input_event.cpp b/core/input/input_event.cpp
index a6c1bb168c..9d5d84a508 100644
--- a/core/input/input_event.cpp
+++ b/core/input/input_event.cpp
@@ -474,10 +474,15 @@ String InputEventKey::to_string() {
return vformat("InputEventKey: keycode=%s, mods=%s, physical=%s, pressed=%s, echo=%s", kc, mods, physical, p, e);
}
-Ref<InputEventKey> InputEventKey::create_reference(Key p_keycode) {
+Ref<InputEventKey> InputEventKey::create_reference(Key p_keycode, bool p_physical) {
Ref<InputEventKey> ie;
ie.instantiate();
- ie->set_keycode(p_keycode & KeyModifierMask::CODE_MASK);
+ if (p_physical) {
+ ie->set_physical_keycode(p_keycode & KeyModifierMask::CODE_MASK);
+ } else {
+ ie->set_keycode(p_keycode & KeyModifierMask::CODE_MASK);
+ }
+
ie->set_unicode(char32_t(p_keycode & KeyModifierMask::CODE_MASK));
if ((p_keycode & KeyModifierMask::SHIFT) != Key::NONE) {
diff --git a/core/input/input_event.h b/core/input/input_event.h
index eff8d479db..4be42d0bd2 100644
--- a/core/input/input_event.h
+++ b/core/input/input_event.h
@@ -195,7 +195,7 @@ public:
virtual String as_text() const override;
virtual String to_string() override;
- static Ref<InputEventKey> create_reference(Key p_keycode_with_modifier_masks);
+ static Ref<InputEventKey> create_reference(Key p_keycode_with_modifier_masks, bool p_physical = false);
InputEventKey() {}
};