| 526 | } |
| 527 | |
| 528 | Ref<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 | |
| 565 | bool 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; |
no test coverage detected