Skip to content

Commit

Permalink
Warn the user if the 'enable access for assistive devices' option is off
Browse files Browse the repository at this point in the history
  • Loading branch information
sdeken committed Mar 19, 2009
1 parent ab0f77a commit 30486c8
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions KCKeyboardTap.m
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -111,7 +111,21 @@ -(id) init
static BOOL tapInstalled = NO; static BOOL tapInstalled = NO;
if (!tapInstalled) 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( 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, kCGSessionEventTap,
kCGHeadInsertEventTap, kCGHeadInsertEventTap,
kCGEventTapOptionListenOnly, kCGEventTapOptionListenOnly,
Expand Down

0 comments on commit 30486c8

Please sign in to comment.