Skip to content

Commit a9df6fb

Browse files
committed
fix matching unknown keys
1 parent 412fe1f commit a9df6fb

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

sources/libengine/keybinds.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -645,23 +645,23 @@ namespace cage
645645
{
646646
using T = std::decay_t<decltype(a)>;
647647
if constexpr (std::is_same_v<T, KeyboardMatcher>)
648-
return Stringizer() + "key " + a.key + " " + (uint32)a.requiredFlags + " " + (uint32)~a.forbiddenFlags;
648+
return Stringizer() + "key " + a.key + " " + (sint32)a.requiredFlags + " " + (sint32)a.forbiddenFlags;
649649
if constexpr (std::is_same_v<T, ModifiersMatcher>)
650-
return Stringizer() + "mods " + (uint32)a.requiredFlags + " " + (uint32)~a.forbiddenFlags;
650+
return Stringizer() + "mods " + (sint32)a.requiredFlags + " " + (sint32)a.forbiddenFlags;
651651
if constexpr (std::is_same_v<T, MouseMatcher>)
652-
return Stringizer() + "mouse " + (uint32)a.button + " " + (uint32)a.requiredFlags + " " + (uint32)~a.forbiddenFlags;
652+
return Stringizer() + "mouse " + (sint32)a.button + " " + (sint32)a.requiredFlags + " " + (sint32)a.forbiddenFlags;
653653
if constexpr (std::is_same_v<T, WheelMatcher>)
654-
return Stringizer() + "wheel " + a.direction + " " + (uint32)a.requiredFlags + " " + (uint32)~a.forbiddenFlags;
654+
return Stringizer() + "wheel " + a.direction + " " + (sint32)a.requiredFlags + " " + (sint32)a.forbiddenFlags;
655655
return "";
656656
},
657657
mt);
658658
}
659659

660660
MatcherBase baseFromString(String &s)
661661
{
662-
const uint32 r = toUint32(split(s));
663-
const uint32 f = toUint32(split(s));
664-
return MatcherBase{ (ModifiersFlags)r, ~(ModifiersFlags)f };
662+
const sint32 r = toSint32(split(s));
663+
const sint32 f = toSint32(split(s));
664+
return MatcherBase{ (ModifiersFlags)r, (ModifiersFlags)f };
665665
}
666666

667667
Matcher fromString(const String &str)
@@ -681,12 +681,12 @@ namespace cage
681681
}
682682
else if (type == "mouse")
683683
{
684-
const uint32 b = toUint32(split(s));
684+
const sint32 b = toSint32(split(s));
685685
return MouseMatcher{ baseFromString(s), (MouseButtonsFlags)b };
686686
}
687687
else if (type == "wheel")
688688
{
689-
const sint32 d = toUint32(split(s));
689+
const sint32 d = toSint32(split(s));
690690
return WheelMatcher{ baseFromString(s), d };
691691
}
692692
else

sources/libengine/window/window.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,9 @@ namespace cage
262262

263263
void windowKeyCallback(GLFWwindow *w, int key, int, int action, int mods)
264264
{
265+
if (key == GLFW_KEY_UNKNOWN)
266+
return;
267+
265268
WindowImpl *impl = (WindowImpl *)glfwGetWindowUserPointer(w);
266269
ModifiersFlags ms = getKeyModifiers(mods);
267270

0 commit comments

Comments
 (0)