Skip to content

Commit

Permalink
add Capslock flag
Browse files Browse the repository at this point in the history
  • Loading branch information
iMasanari committed Oct 31, 2016
1 parent d39525f commit 78ae40b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions cmd-eikana/Base.lproj/Main.storyboard
Expand Up @@ -845,7 +845,7 @@
<popUpButton identifier="hage" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="dzf-C4-fIi" customClass="MappingMenu" customModule="_英かな" customModuleProvider="target">
<rect key="frame" x="2" y="-2" width="71" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="bevel" title="menu" bezelStyle="regularSquare" image="AB15EF91-E4E0-4388-9933-AE461D4A79B1" imagePosition="left" alignment="center" lineBreakMode="truncatingTail" state="on" identifier="test" inset="2" pullsDown="YES" id="H2F-I4-Cda">
<popUpButtonCell key="cell" type="bevel" title="menu" bezelStyle="regularSquare" image="50498785-5FF6-49B5-B894-B325EE8FF12C" imagePosition="left" alignment="center" lineBreakMode="truncatingTail" state="on" identifier="test" inset="2" pullsDown="YES" id="H2F-I4-Cda">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="menu"/>
<menu key="menu" id="BOb-Li-1q3">
Expand Down Expand Up @@ -1084,7 +1084,7 @@
</scene>
</scenes>
<resources>
<image name="AB15EF91-E4E0-4388-9933-AE461D4A79B1" width="1" height="1">
<image name="50498785-5FF6-49B5-B894-B325EE8FF12C" width="1" height="1">
<mutableData key="keyedArchiveRepresentation">
YnBsaXN0MDDUAQIDBAUGPT5YJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3ASAAGGoK4HCBMU
GR4fIyQrLjE3OlUkbnVsbNUJCgsMDQ4PEBESVk5TU2l6ZVYkY2xhc3NcTlNJbWFnZUZsYWdzVk5TUmVw
Expand Down
3 changes: 2 additions & 1 deletion cmd-eikana/KeyEvent.swift
Expand Up @@ -235,5 +235,6 @@ let modifierMasks: [CGKeyCode: CGEventFlags] = [
62: CGEventFlags.maskControl,
58: CGEventFlags.maskAlternate,
61: CGEventFlags.maskAlternate,
63: CGEventFlags.maskSecondaryFn
63: CGEventFlags.maskSecondaryFn,
57: CGEventFlags.maskAlphaShift
]
11 changes: 9 additions & 2 deletions cmd-eikana/KeyboardShortcut.swift
Expand Up @@ -68,6 +68,10 @@ class KeyboardShortcut: NSObject {
flagString += "(fn)"
}

if isCapslockDown() {
flagString += ""
}

if isCommandDown() {
flagString += ""
}
Expand All @@ -83,7 +87,6 @@ class KeyboardShortcut: NSObject {
if isAlternateDown() {
flagString += ""
}
// capslock ⇪

return flagString + key!
}
Expand All @@ -108,6 +111,10 @@ class KeyboardShortcut: NSObject {
return self.flags.rawValue & CGEventFlags.maskSecondaryFn.rawValue != 0 && keyCode != 63
}

func isCapslockDown() -> Bool {
return self.flags.rawValue & CGEventFlags.maskAlphaShift.rawValue != 0 && keyCode != 57
}

func postEvent() -> Void {
let loc = CGEventTapLocation.cghidEventTap

Expand Down Expand Up @@ -241,7 +248,7 @@ let keyCodeDictionary: Dictionary<CGKeyCode, String> = [
110: "App",
111: "F12",
113: "F15",
114: "HELP",
114: "Help",
115: "Home", // "↖",
116: "PgUp",
117: "",
Expand Down
2 changes: 1 addition & 1 deletion ⌘英かな.xcodeproj/project.pbxproj
Expand Up @@ -153,7 +153,6 @@
isa = PBXGroup;
children = (
6294281A1D387503001BD4E9 /* AppDelegate.swift */,
623E2E061DA60DA800AF163C /* PreferenceWindowController.swift */,
620E0AD61D9E97BA0067F88B /* checkUpdate.swift */,
627265F51D3CC84000703F85 /* KeyEvent.swift */,
6242D4BB1DA2455D00CA80DD /* KeyboardShortcut.swift */,
Expand All @@ -162,6 +161,7 @@
628908ED1DADB0B6008EF46A /* KeyMapping.swift */,
6294281E1D387503001BD4E9 /* Assets.xcassets */,
629428201D387503001BD4E9 /* Main.storyboard */,
623E2E061DA60DA800AF163C /* PreferenceWindowController.swift */,
62BEA2A31DA739B6004409AE /* ShortcutsController.swift */,
62FE51601DC70C5B0037B8D1 /* ExclusionAppsController.swift */,
6294281C1D387503001BD4E9 /* ViewController.swift */,
Expand Down

0 comments on commit 78ae40b

Please sign in to comment.