Permalink
Browse files
Improve keyboard type handling
- Loading branch information...
|
|
@@ -294,6 +294,10 @@ EOD; |
|
|
return KeyboardLayoutType{$type};
|
|
|
}
|
|
|
|
|
|
+- (UInt8)macKbdType {
|
|
|
+ return {$id};
|
|
|
+}
|
|
|
+
|
|
|
- (CGSize)size {
|
|
|
return {$size};
|
|
|
}
|
|
|
|
|
|
@@ -20,6 +20,10 @@ - (KeyboardLayoutType)type { |
|
|
return KeyboardLayoutTypeANSI;
|
|
|
}
|
|
|
|
|
|
+- (UInt8)macKbdType {
|
|
|
+ return 58;
|
|
|
+}
|
|
|
+
|
|
|
- (CGSize)size {
|
|
|
return CGSizeMake(290, 113);
|
|
|
}
|
|
|
|
|
|
@@ -20,6 +20,10 @@ - (KeyboardLayoutType)type { |
|
|
return KeyboardLayoutTypeISO;
|
|
|
}
|
|
|
|
|
|
+- (UInt8)macKbdType {
|
|
|
+ return 59;
|
|
|
+}
|
|
|
+
|
|
|
- (CGSize)size {
|
|
|
return CGSizeMake(290, 113);
|
|
|
}
|
|
|
|
|
|
@@ -20,6 +20,10 @@ - (KeyboardLayoutType)type { |
|
|
return KeyboardLayoutTypeJIS;
|
|
|
}
|
|
|
|
|
|
+- (UInt8)macKbdType {
|
|
|
+ return 60;
|
|
|
+}
|
|
|
+
|
|
|
- (CGSize)size {
|
|
|
return CGSizeMake(290, 113);
|
|
|
}
|
|
|
|
|
|
@@ -25,6 +25,7 @@ typedef NS_ENUM(NSInteger, KeyboardLayoutType) { |
|
|
|
|
|
@interface KeyboardLayout : NSObject
|
|
|
@property (nonatomic, readonly) KeyboardLayoutType type;
|
|
|
+@property (nonatomic, readonly) UInt8 macKbdType;
|
|
|
@property (nonatomic, readonly) CGSize size;
|
|
|
@property (nonatomic, readonly) NSUInteger numberOfKeys;
|
|
|
- (KeyCode)keyCodeForKeyIndex:(NSUInteger)keyIndex;
|
|
|
|
|
|
@@ -14,6 +14,10 @@ - (KeyboardLayoutType)type { |
|
|
return KeyboardLayoutTypeUnknown;
|
|
|
}
|
|
|
|
|
|
+- (UInt8)macKbdType {
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
- (CGSize)size {
|
|
|
return CGSizeZero;
|
|
|
}
|
|
|
|
|
|
@@ -109,7 +109,7 @@ - (NSString *)interfaceBuilderKeyCaptionForKeyCode:(KeyCode)keyCode { |
|
|
case 0x1D: return @"0"; // kVK_ANSI_0
|
|
|
case 0x1B: return @"-"; // kVK_ANSI_Minus
|
|
|
case 0x5D: return @"¥"; // kVK_JIS_Yen
|
|
|
- case 0x5E: return @""; // kVK_JIS_Underscore
|
|
|
+ case 0x5E: return @"_"; // kVK_JIS_Underscore
|
|
|
case 0x18: return _layout.type == KeyboardLayoutTypeJIS ? @"^" : @"="; // kVK_ANSI_Equal
|
|
|
case 0x2A: return _layout.type == KeyboardLayoutTypeJIS ? @"]" : @"\\"; // kVK_ANSI_Backslash
|
|
|
case 0x1E: return _layout.type == KeyboardLayoutTypeJIS ? @"[" : @"]"; // kVK_ANSI_RightBracket
|
|
|
|
|
|
@@ -93,7 +93,8 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { |
|
|
_keyboardLayout = [KeyboardLayoutANSI new];
|
|
|
break;
|
|
|
}
|
|
|
-
|
|
|
+ _keyboardType = _keyboardLayout.macKbdType;
|
|
|
+
|
|
|
GlobalEventApplication *app = [NSApplication sharedApplication];
|
|
|
app.globalEventMask = NSKeyDownMask | NSKeyUpMask | NSFlagsChangedMask |
|
|
|
NSLeftMouseDownMask | NSLeftMouseUpMask |
|
|
|
|
0 comments on commit
2e9e82c