Skip to content

Commit

Permalink
Check accepted keyCodes before app running check
Browse files Browse the repository at this point in the history
Fixes #46
  • Loading branch information
aonez committed Jun 11, 2018
1 parent 14f321c commit 8d14890
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions HighSierraMediaKeyEnabler/AppDelegate.m
Expand Up @@ -89,6 +89,17 @@ static CGEventRef tapEventCallback(CGEventTapProxy proxy, CGEventType type, CGEv
return event;
}

int keyCode = (([nsEvent data1] & 0xFFFF0000) >> 16);

if (keyCode != NX_KEYTYPE_PLAY &&
keyCode != NX_KEYTYPE_FAST &&
keyCode != NX_KEYTYPE_REWIND &&
keyCode != NX_KEYTYPE_PREVIOUS &&
keyCode != NX_KEYTYPE_NEXT)
{
return event;
}

iTunesApplication *iTunes = [SBApplication applicationWithBundleIdentifier:@"com.apple.iTunes"];
SpotifyApplication *spotify = [SBApplication applicationWithBundleIdentifier:@"com.spotify.client"];

Expand All @@ -105,17 +116,6 @@ static CGEventRef tapEventCallback(CGEventTapProxy proxy, CGEventType type, CGEv
}
}

int keyCode = (([nsEvent data1] & 0xFFFF0000) >> 16);

if (keyCode != NX_KEYTYPE_PLAY &&
keyCode != NX_KEYTYPE_FAST &&
keyCode != NX_KEYTYPE_REWIND &&
keyCode != NX_KEYTYPE_PREVIOUS &&
keyCode != NX_KEYTYPE_NEXT)
{
return event;
}

int keyFlags = ([nsEvent data1] & 0x0000FFFF);
BOOL keyIsPressed = (((keyFlags & 0xFF00) >> 8)) == 0xA;

Expand Down

0 comments on commit 8d14890

Please sign in to comment.