From d99f3bb8264f6925ac0da2356c55f33f84388e79 Mon Sep 17 00:00:00 2001 From: Jason Stallings Date: Fri, 20 Nov 2015 10:31:10 -0600 Subject: [PATCH] Made compatible with older versions of Windows. In C89 all block-local variables need to be declared at the beginning of your functions. --- src/keypress.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/keypress.c b/src/keypress.c index cb8598df..27e3ff38 100644 --- a/src/keypress.c +++ b/src/keypress.c @@ -70,12 +70,15 @@ void tapKeyCode(MMKeyCode code, MMKeyFlags flags) void toggleKey(char c, const bool down, MMKeyFlags flags) { + int modifiers; + MMKeyCode keyCode = keyCodeForChar(c); + if (isupper(c) && !(flags & MOD_SHIFT)) { flags |= MOD_SHIFT; /* Not sure if this is safe for all layouts. */ } - MMKeyCode keyCode = keyCodeForChar(c); + #if defined(IS_WINDOWS) - int modifiers = keyCode >> 8; // Pull out modifers. + modifiers = keyCode >> 8; // Pull out modifers. if ((modifiers & 1) != 0) flags |= MOD_SHIFT; // Uptdate flags from keycode modifiers. if ((modifiers & 2) != 0) flags |= MOD_CONTROL; if ((modifiers & 4) != 0) flags |= MOD_ALT;