summaryrefslogtreecommitdiff
path: root/core/input/input.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/input/input.cpp')
-rw-r--r--core/input/input.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/core/input/input.cpp b/core/input/input.cpp
index 0afa004515..1ea9f00fee 100644
--- a/core/input/input.cpp
+++ b/core/input/input.cpp
@@ -93,6 +93,7 @@ void Input::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_anything_pressed"), &Input::is_anything_pressed);
ClassDB::bind_method(D_METHOD("is_key_pressed", "keycode"), &Input::is_key_pressed);
ClassDB::bind_method(D_METHOD("is_physical_key_pressed", "keycode"), &Input::is_physical_key_pressed);
+ ClassDB::bind_method(D_METHOD("is_key_label_pressed", "keycode"), &Input::is_key_label_pressed);
ClassDB::bind_method(D_METHOD("is_mouse_button_pressed", "button"), &Input::is_mouse_button_pressed);
ClassDB::bind_method(D_METHOD("is_joy_button_pressed", "device", "button"), &Input::is_joy_button_pressed);
ClassDB::bind_method(D_METHOD("is_action_pressed", "action", "exact_match"), &Input::is_action_pressed, DEFVAL(false));
@@ -250,6 +251,11 @@ bool Input::is_physical_key_pressed(Key p_keycode) const {
return physical_keys_pressed.has(p_keycode);
}
+bool Input::is_key_label_pressed(Key p_keycode) const {
+ _THREAD_SAFE_METHOD_
+ return key_label_pressed.has(p_keycode);
+}
+
bool Input::is_mouse_button_pressed(MouseButton p_button) const {
_THREAD_SAFE_METHOD_
return mouse_button_mask.has_flag(mouse_button_to_mask(p_button));
@@ -499,6 +505,13 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em
physical_keys_pressed.erase(k->get_physical_keycode());
}
}
+ if (k.is_valid() && !k->is_echo() && k->get_key_label() != Key::NONE) {
+ if (k->is_pressed()) {
+ key_label_pressed.insert(k->get_key_label());
+ } else {
+ key_label_pressed.erase(k->get_key_label());
+ }
+ }
Ref<InputEventMouseButton> mb = p_event;
@@ -919,6 +932,7 @@ void Input::release_pressed_events() {
keys_pressed.clear();
physical_keys_pressed.clear();
+ key_label_pressed.clear();
joy_buttons_pressed.clear();
_joy_axis.clear();