Skip to content

Commit

Permalink
Revert "Don't trigger a key event if a key with the same associated c…
Browse files Browse the repository at this point in the history
…har was pressed (#13773)"

This partially reverts commit d57c936.

The reverted commit prevented recognition of key combinations.
It correctly changed a test case to no longer use “KEY_NUMPAD_5”.

Several keyboard layouts use a key combination to input a “+” (e.g. Neo2);
therefore some users could no longer input “+” to increase the view range.

Co-authored-by: savilli <78875209+savilli@users.noreply.github.com>
  • Loading branch information
2 people authored and sfan5 committed Oct 30, 2023
1 parent ec7a1f0 commit 2025dcf
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 10 deletions.
4 changes: 1 addition & 3 deletions src/client/keycode.h
Expand Up @@ -38,9 +38,7 @@ class KeyPress

bool operator==(const KeyPress &o) const
{
if (valid_kcode(Key) && valid_kcode(o.Key))
return Key == o.Key;
return Char > 0 && Char == o.Char;
return (Char > 0 && Char == o.Char) || (valid_kcode(Key) && Key == o.Key);
}

const char *sym() const;
Expand Down
7 changes: 0 additions & 7 deletions src/unittest/test_keycode.cpp
Expand Up @@ -126,11 +126,4 @@ void TestKeycode::testCompare()
in.Char = L'\0';
in2.Char = L';';
UASSERT(KeyPress(in) == KeyPress(in2));

// Irrlicht sets chars to the according digit for numpad keys.
// We need to distinguish them in order to bind numpad keys.
irr::SEvent::SKeyInput in3;
in3.Key = irr::KEY_NUMPAD5;
in3.Char = L'5';
UASSERT(!(KeyPress("5") == KeyPress(in3)));
}

0 comments on commit 2025dcf

Please sign in to comment.