Skip to content

Commit f7d44f3

Browse files
committed
fix vanilla crash on macos with special keys
1 parent 077304f commit f7d44f3

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

loader/src/hooks/AddExtraKeys.mm

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,23 @@ void keyDownExecHook(EAGLView* self, SEL sel, NSEvent* event) {
147147
bool extraKey = isExtraKey(event);
148148
bool numpad = isKeyNumpad(event);
149149
if (!extraKey && !numpad) {
150+
if ([[event characters] length] == 0) {
151+
// really dumb workaround for a really dumb crash
152+
// basically the game tries to read the 1st character on every keydown
153+
// but rob uses this instead of ignoring modifiers or whatever so sometimes there is no 1st character!!
154+
// hopefully fixed in 2.208 :(
155+
return;
156+
}
157+
150158
GEODE_MACOS([self performSelector:sel withObject:event]);
151159
return;
152160
}
153161
if (CCIMEDispatcher::sharedDispatcher()->hasDelegate()) {
162+
if ([[event characters] length] == 0) {
163+
// we need this for every original call to keyDown btw
164+
return;
165+
}
166+
154167
GEODE_MACOS([self performSelector:sel withObject:event]);
155168
return;
156169
}

0 commit comments

Comments
 (0)