mirror of
https://github.com/minetest/minetest.git
synced 2025-03-06 20:48:40 +01:00
Don't trigger a key event if a key with the same associated char was pressed (#13773)
This commit is contained in:
parent
9f47e123d2
commit
d57c936b08
2 changed files with 11 additions and 2 deletions
|
@ -38,7 +38,9 @@ public:
|
||||||
|
|
||||||
bool operator==(const KeyPress &o) const
|
bool operator==(const KeyPress &o) const
|
||||||
{
|
{
|
||||||
return (Char > 0 && Char == o.Char) || (valid_kcode(Key) && Key == o.Key);
|
if (valid_kcode(Key) && valid_kcode(o.Key))
|
||||||
|
return Key == o.Key;
|
||||||
|
return Char > 0 && Char == o.Char;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *sym() const;
|
const char *sym() const;
|
||||||
|
|
|
@ -111,7 +111,7 @@ void TestKeycode::testCompare()
|
||||||
{
|
{
|
||||||
// Basic comparison
|
// Basic comparison
|
||||||
UASSERT(KeyPress("5") == KeyPress("KEY_KEY_5"));
|
UASSERT(KeyPress("5") == KeyPress("KEY_KEY_5"));
|
||||||
UASSERT(!(KeyPress("5") == KeyPress("KEY_NUMPAD_5")));
|
UASSERT(!(KeyPress("5") == KeyPress("KEY_NUMPAD5")));
|
||||||
|
|
||||||
// Matching char suffices
|
// Matching char suffices
|
||||||
// note: This is a real-world example, Irrlicht maps XK_equal to irr::KEY_PLUS on Linux
|
// note: This is a real-world example, Irrlicht maps XK_equal to irr::KEY_PLUS on Linux
|
||||||
|
@ -126,4 +126,11 @@ void TestKeycode::testCompare()
|
||||||
in.Char = L'\0';
|
in.Char = L'\0';
|
||||||
in2.Char = L';';
|
in2.Char = L';';
|
||||||
UASSERT(KeyPress(in) == KeyPress(in2));
|
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)));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue