Skip to content

Commit

Permalink
Fix CGEventTap event mask. Turns out I was using a completely wrong m…
Browse files Browse the repository at this point in the history
…ask.
  • Loading branch information
Bensge committed Mar 1, 2017
1 parent 274357b commit 49f7a73
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions NativeDisplayBrightness/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ CGEventRef keyboardCGEventCallback(CGEventTapProxy proxy,
CGEventRef event,
void *refcon)
{
//Surpress the brightness key events to prevent other applications from catching it
//Surpress the F1/F2 key events to prevent other applications from catching it or playing beep sound
if (type == NX_KEYDOWN || type == NX_KEYUP || type == NX_FLAGSCHANGED)
{
int64_t keyCode = CGEventGetIntegerValueField(event, kCGKeyboardEventKeycode);
Expand Down Expand Up @@ -123,8 +123,7 @@ - (void)_registerGlobalKeyboardEvents
}];

CFRunLoopRef runloop = (CFRunLoopRef)CFRunLoopGetCurrent();

CGEventMask interestedEvents = kCGEventKeyDown | NSKeyUp;
CGEventMask interestedEvents = NX_KEYDOWNMASK | NX_KEYUPMASK | NX_FLAGSCHANGEDMASK;
CFMachPortRef eventTap = CGEventTapCreate(kCGAnnotatedSessionEventTap, kCGHeadInsertEventTap,
kCGEventTapOptionDefault, interestedEvents, keyboardCGEventCallback, (__bridge void * _Nullable)(self));
// by passing self as last argument, you can later send events to this class instance
Expand Down

0 comments on commit 49f7a73

Please sign in to comment.