Skip to content

Commit 3652109

Browse files
committed
Do not show Physical in the special key names.
1 parent 63e14e1 commit 3652109

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

core/input/input_event.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,10 @@ String InputEventKey::as_text() const {
475475
} else if (keycode != Key::NONE) {
476476
kc = keycode_get_string(keycode);
477477
} else if (physical_keycode != Key::NONE) {
478-
kc = keycode_get_string(physical_keycode) + " - " + RTR("Physical");
478+
kc = keycode_get_string(physical_keycode);
479+
if ((physical_keycode & Key::SPECIAL) != Key::SPECIAL) {
480+
kc += " - " + RTR("Physical");
481+
}
479482
} else {
480483
kc = "(" + RTR("unset") + ")";
481484
}

tests/core/input/test_input_event_key.h

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,26 +123,43 @@ TEST_CASE("[InputEventKey] Key correctly converts itself to text") {
123123

124124
// Key is None WITH a physical key AND modifiers.
125125
none_key.set_physical_keycode(Key::ENTER);
126-
CHECK(none_key.as_text() == "Ctrl+Enter - Physical");
126+
CHECK(none_key.as_text() == "Ctrl+Enter");
127+
128+
none_key.set_physical_keycode(Key::W);
129+
CHECK(none_key.as_text() == "Ctrl+W - Physical");
127130

128131
// Key is None WITH a physical key AND multiple modifiers, checks for correct ordering.
132+
none_key.set_physical_keycode(Key::ENTER);
129133
none_key.set_alt_pressed(true);
130134
none_key.set_shift_pressed(true);
131135
#ifdef MACOS_ENABLED
132-
CHECK(none_key.as_text() != "Ctrl+Shift+Option+Enter - Physical");
133-
CHECK(none_key.as_text() == "Ctrl+Option+Shift+Enter - Physical");
136+
CHECK(none_key.as_text() != "Ctrl+Shift+Option+Enter");
137+
CHECK(none_key.as_text() == "Ctrl+Option+Shift+Enter");
138+
#else
139+
CHECK(none_key.as_text() != "Ctrl+Shift+Alt+Enter");
140+
CHECK(none_key.as_text() == "Ctrl+Alt+Shift+Enter");
141+
#endif
142+
none_key.set_physical_keycode(Key::W);
143+
#ifdef MACOS_ENABLED
144+
CHECK(none_key.as_text() != "Ctrl+Shift+Option+W - Physical");
145+
CHECK(none_key.as_text() == "Ctrl+Option+Shift+W - Physical");
134146
#else
135-
CHECK(none_key.as_text() != "Ctrl+Shift+Alt+Enter - Physical");
136-
CHECK(none_key.as_text() == "Ctrl+Alt+Shift+Enter - Physical");
147+
CHECK(none_key.as_text() != "Ctrl+Shift+Alt+W - Physical");
148+
CHECK(none_key.as_text() == "Ctrl+Alt+Shift+W - Physical");
137149
#endif
138150

139151
InputEventKey none_key2;
140152

141153
// Key is None without modifiers with a physical key.
154+
none_key2.set_keycode(Key::NONE);
155+
none_key2.set_physical_keycode(Key::W);
156+
157+
CHECK(none_key2.as_text() == "W - Physical");
158+
142159
none_key2.set_keycode(Key::NONE);
143160
none_key2.set_physical_keycode(Key::ENTER);
144161

145-
CHECK(none_key2.as_text() == "Enter - Physical");
162+
CHECK(none_key2.as_text() == "Enter");
146163

147164
InputEventKey key;
148165

0 commit comments

Comments
 (0)