Skip to content
This repository has been archived by the owner on Mar 30, 2021. It is now read-only.

Commit

Permalink
Tweak event tap creation to somehow fix a problem (fixes #40)
Browse files Browse the repository at this point in the history
  • Loading branch information
kbhomes committed Mar 9, 2014
1 parent 235a11b commit 440cd20
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions google-music-mac/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
eventTap = CGEventTapCreate(kCGSessionEventTap,
kCGHeadInsertEventTap,
kCGEventTapOptionDefault,
CGEventMaskBit(NX_SYSDEFINED),
kCGEventMaskForAllEvents,
event_tap_callback,
(__bridge void *)(self));
if (!eventTap) {
Expand Down Expand Up @@ -195,11 +195,12 @@ static CGEventRef event_tap_callback(CGEventTapProxy proxy,
return event;
}

if (!(type == NX_SYSDEFINED) || (type == NX_KEYDOWN))
if ((type != NX_SYSDEFINED) && (type != NX_KEYDOWN))
return event;

NSEvent* keyEvent = [NSEvent eventWithCGEvent: event];
if (keyEvent.type != NSSystemDefined || keyEvent.subtype != 8) return event;
if (keyEvent.type != NSSystemDefined || keyEvent.subtype != 8)
return event;

int keyCode = (([keyEvent data1] & 0xFFFF0000) >> 16);
int keyFlags = ([keyEvent data1] & 0x0000FFFF);
Expand Down

0 comments on commit 440cd20

Please sign in to comment.