@@ -76,6 +76,47 @@ TEST_CASE("[InputEventKey] Key correctly stores and retrieves keycode with modif
7676 CHECK (key.get_physical_keycode_with_modifiers () != Key::SPACE);
7777}
7878
79+ TEST_CASE (" [InputEventKey] keycode and modifier matches" ) {
80+ InputEventKey spaceKeyAction;
81+ InputEventKey shiftKeyAction;
82+ InputEventKey shiftSpaceKeyAction;
83+
84+ spaceKeyAction.set_keycode (Key::SPACE);
85+ shiftKeyAction.set_keycode (Key::SHIFT);
86+ shiftKeyAction.set_shift_pressed (true );
87+ shiftSpaceKeyAction.set_keycode (Key::SPACE);
88+ shiftSpaceKeyAction.set_shift_pressed (true );
89+
90+ InputEventKey key;
91+ bool p_exact_match = false ;
92+ float deadzone = 0.5 ;
93+ bool r_pressed = false ;
94+ float r_strength = 0.0 ;
95+ float r_raw_strength = 0.0 ;
96+
97+ Ref<InputEventKey> p_event;
98+
99+ p_event = key.create_reference (Key::SPACE);
100+ p_event->set_pressed (true );
101+ CHECK (spaceKeyAction.action_match (p_event, p_exact_match, deadzone, &r_pressed, &r_strength, &r_raw_strength) == true );
102+
103+ p_event = key.create_reference (Key::SHIFT | KeyModifierMask::SHIFT);
104+ p_event->set_pressed (true );
105+ CHECK (shiftKeyAction.action_match (p_event, p_exact_match, deadzone, &r_pressed, &r_strength, &r_raw_strength) == true );
106+
107+ p_event = key.create_reference (Key::SPACE | KeyModifierMask::SHIFT);
108+ p_event->set_pressed (true );
109+ CHECK (shiftSpaceKeyAction.action_match (p_event, p_exact_match, deadzone, &r_pressed, &r_strength, &r_raw_strength) == true );
110+
111+ p_event = key.create_reference (Key::SHIFT | KeyModifierMask::SHIFT);
112+ p_event->set_pressed (false );
113+ CHECK (shiftKeyAction.action_match (p_event, p_exact_match, deadzone, &r_pressed, &r_strength, &r_raw_strength) == true );
114+
115+ p_event = key.create_reference (Key::SPACE);
116+ p_event->set_pressed (false );
117+ CHECK (spaceKeyAction.action_match (p_event, p_exact_match, deadzone, &r_pressed, &r_strength, &r_raw_strength) == true );
118+ }
119+
79120TEST_CASE (" [InputEventKey] Key correctly stores and retrieves unicode" ) {
80121 InputEventKey key;
81122
0 commit comments