MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / create_reference

Method create_reference

core/input/input_event.cpp:528–563  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

526}
527
528Ref<InputEventKey> InputEventKey::create_reference(Key p_keycode, bool p_physical) {
529 Ref<InputEventKey> ie;
530 ie.instantiate();
531 if (p_physical) {
532 ie->set_physical_keycode(p_keycode & KeyModifierMask::CODE_MASK);
533 } else {
534 ie->set_keycode(p_keycode & KeyModifierMask::CODE_MASK);
535 }
536
537 char32_t ch = char32_t(p_keycode & KeyModifierMask::CODE_MASK);
538 if (ch < 0xd800 || (ch > 0xdfff && ch <= 0x10ffff)) {
539 ie->set_unicode(ch);
540 }
541
542 if ((p_keycode & KeyModifierMask::SHIFT) != Key::NONE) {
543 ie->set_shift_pressed(true);
544 }
545 if ((p_keycode & KeyModifierMask::ALT) != Key::NONE) {
546 ie->set_alt_pressed(true);
547 }
548 if ((p_keycode & KeyModifierMask::CMD_OR_CTRL) != Key::NONE) {
549 ie->set_command_or_control_autoremap(true);
550 if ((p_keycode & KeyModifierMask::CTRL) != Key::NONE || (p_keycode & KeyModifierMask::META) != Key::NONE) {
551 WARN_PRINT("Invalid Key Modifiers: Command or Control autoremapping is enabled, Meta and Control values are ignored!");
552 }
553 } else {
554 if ((p_keycode & KeyModifierMask::CTRL) != Key::NONE) {
555 ie->set_ctrl_pressed(true);
556 }
557 if ((p_keycode & KeyModifierMask::META) != Key::NONE) {
558 ie->set_meta_pressed(true);
559 }
560 }
561
562 return ie;
563}
564
565bool InputEventKey::action_match(const Ref<InputEvent> &p_event, bool p_exact_match, float p_deadzone, bool *r_pressed, float *r_strength, float *r_raw_strength) const {
566 Ref<InputEventKey> key = p_event;

Callers 1

Calls 12

set_physical_keycodeMethod · 0.80
set_keycodeMethod · 0.80
set_unicodeMethod · 0.80
set_shift_pressedMethod · 0.80
set_alt_pressedMethod · 0.80
set_meta_pressedMethod · 0.80
set_axis_valueMethod · 0.80
set_button_indexMethod · 0.80
instantiateMethod · 0.45
set_ctrl_pressedMethod · 0.45
set_axisMethod · 0.45

Tested by

no test coverage detected