Respecting settings for command and control swap

This commit is contained in:
michael starke
2014-12-14 16:12:07 +01:00
parent f65fc31408
commit af8743b5cc
2 changed files with 13 additions and 2 deletions

View File

@@ -93,7 +93,7 @@ static CGKeyCode kMPFunctionKeyCodes[] = { kVK_F1, kVK_F2, kVK_F3, kVK_F4, kVK_F
dispatch_once(&onceToken, ^{
modifierCommands = @{
kKPKAutotypeAlt : @(kCGEventFlagMaskAlternate),
kKPKAutotypeControl : @(kCGEventFlagMaskCommand),
kKPKAutotypeControl : @(kCGEventFlagMaskControl),
kKPKAutotypeShift : @(kCGEventFlagMaskShift)
};
});

View File

@@ -7,14 +7,25 @@
//
#import "MPAutotypeKeyPress.h"
#import "MPFlagsHelper.h"
#import "MPKeyMapper.h"
#import "MPSettingsHelper.h"
@implementation MPAutotypeKeyPress
static CGEventFlags _updateModifierMaskForCurrentDefaults(CGEventFlags modifiers) {
BOOL sendCommand = [[NSUserDefaults standardUserDefaults] boolForKey:kMPSettingsKeySendCommandForControlKey];
if(sendCommand && MPIsFlagSetInOptions(kCGEventFlagMaskControl, modifiers)) {
return (modifiers ^ kCGEventFlagMaskControl) | kCGEventFlagMaskCommand;
}
return modifiers;
}
- (instancetype)initWithModifierMask:(CGEventFlags)modiferMask keyCode:(CGKeyCode)code {
self = [super init];
if(self) {
_modifierMask = modiferMask;
_modifierMask = _updateModifierMaskForCurrentDefaults(modiferMask);
_keyCode = code;
}
return self;