Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Warn the user if the 'enable access for assistive devices' option is off

  • Loading branch information...
commit 30486c8bd9a0d9561676efe67499a32668cd7cca 1 parent ab0f77a
@sdeken sdeken authored
Showing with 14 additions and 0 deletions.
  1. +14 −0 KCKeyboardTap.m
View
14 KCKeyboardTap.m
@@ -111,10 +111,24 @@ -(id) init
static BOOL tapInstalled = NO;
if (!tapInstalled)
{
+ // We have to try to tap the keydown event independently because CGEventTapCreate will succeed if it can
+ // install the event tap for the flags changed event, which apparently doesn't require universal access
+ // to be enabled. Thus, the call would succeed but KeyCastr would be, um, useless.
CFMachPortRef tap = CGEventTapCreate(
kCGSessionEventTap,
kCGHeadInsertEventTap,
kCGEventTapOptionListenOnly,
+ CGEventMaskBit(kCGEventKeyDown),
+ eventTapCallback,
+ self
+ );
+ FAIL_LOUDLY( tap == NULL, @"Could not create event tap. Make sure 'Enable Access for Assistive Devices' is checked in the Universal Access preferences." );
+ CFRelease( tap );
+
+ tap = CGEventTapCreate(
+ kCGSessionEventTap,
+ kCGHeadInsertEventTap,
+ kCGEventTapOptionListenOnly,
CGEventMaskBit(kCGEventKeyDown) | CGEventMaskBit(kCGEventFlagsChanged),
eventTapCallback,
self
Please sign in to comment.
Something went wrong with that request. Please try again.