Skip to content

Commit

Permalink
Made compatible with older versions of Windows.
Browse files Browse the repository at this point in the history
In C89 all block-local variables need to be declared at the beginning
of your functions.
  • Loading branch information
octalmage committed Nov 20, 2015
1 parent e6a4369 commit d99f3bb
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/keypress.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d99f3bb

Please sign in to comment.