From 2025dcffbd4d937afbac757931891172c4465614 Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Sun, 29 Oct 2023 00:25:38 +0200 Subject: [PATCH] Revert "Don't trigger a key event if a key with the same associated char was pressed (#13773)" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This partially reverts commit d57c936b080f404df0b544561242b0c45c57f04d. 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> --- src/client/keycode.h | 4 +--- src/unittest/test_keycode.cpp | 7 ------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/src/client/keycode.h b/src/client/keycode.h index 1abaa97bc..7036705d1 100644 --- a/src/client/keycode.h +++ b/src/client/keycode.h @@ -38,9 +38,7 @@ public: 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; diff --git a/src/unittest/test_keycode.cpp b/src/unittest/test_keycode.cpp index 4a3b59ecd..3398626fa 100644 --- a/src/unittest/test_keycode.cpp +++ b/src/unittest/test_keycode.cpp @@ -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))); }