Skip to content

Commit c4724e6

Browse files
committed
upd to previous the commit
1 parent b69cdd5 commit c4724e6

14 files changed

+318
-60
lines changed

MTMR.xcodeproj/project.pbxproj

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
B082B271205C7D8000BC04DC /* MTMRUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B082B270205C7D8000BC04DC /* MTMRUITests.swift */; };
1919
B0A7E9AA205D6AA400EEF070 /* KeyPress.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0A7E9A9205D6AA400EEF070 /* KeyPress.swift */; };
2020
B0C1CFCA205C97D30021C862 /* WindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0C1CFC9205C97D30021C862 /* WindowController.swift */; };
21+
B0F8771A207AC1EA00D6E430 /* TouchBarSupport.m in Sources */ = {isa = PBXBuildFile; fileRef = B0F87719207AC1EA00D6E430 /* TouchBarSupport.m */; };
22+
B0F8771D207AD35400D6E430 /* battery.scpt in Resources */ = {isa = PBXBuildFile; fileRef = B0F8771C207AD35400D6E430 /* battery.scpt */; };
2123
/* End PBXBuildFile section */
2224

2325
/* Begin PBXContainerItemProxy section */
@@ -58,6 +60,9 @@
5860
B082B272205C7D8000BC04DC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
5961
B0A7E9A9205D6AA400EEF070 /* KeyPress.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyPress.swift; sourceTree = "<group>"; };
6062
B0C1CFC9205C97D30021C862 /* WindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WindowController.swift; sourceTree = "<group>"; };
63+
B0F87719207AC1EA00D6E430 /* TouchBarSupport.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TouchBarSupport.m; sourceTree = "<group>"; };
64+
B0F8771B207AC92700D6E430 /* TouchBarSupport.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TouchBarSupport.h; sourceTree = "<group>"; };
65+
B0F8771C207AD35400D6E430 /* battery.scpt */ = {isa = PBXFileReference; lastKnownFileType = text; path = battery.scpt; sourceTree = "<group>"; };
6166
/* End PBXFileReference section */
6267

6368
/* Begin PBXFrameworksBuildPhase section */
@@ -130,6 +135,9 @@
130135
B082B258205C7D8000BC04DC /* Main.storyboard */,
131136
B082B25B205C7D8000BC04DC /* Info.plist */,
132137
B082B25C205C7D8000BC04DC /* MTMR.entitlements */,
138+
B0F87719207AC1EA00D6E430 /* TouchBarSupport.m */,
139+
B0F8771B207AC92700D6E430 /* TouchBarSupport.h */,
140+
B0F8771C207AD35400D6E430 /* battery.scpt */,
133141
);
134142
path = MTMR;
135143
sourceTree = "<group>";
@@ -215,12 +223,17 @@
215223
isa = PBXProject;
216224
attributes = {
217225
LastSwiftUpdateCheck = 0920;
218-
LastUpgradeCheck = 0920;
226+
LastUpgradeCheck = 0930;
219227
ORGANIZATIONNAME = "Anton Palgunov";
220228
TargetAttributes = {
221229
B082B24E205C7D8000BC04DC = {
222230
CreatedOnToolsVersion = 9.2;
223231
ProvisioningStyle = Automatic;
232+
SystemCapabilities = {
233+
com.apple.Sandbox = {
234+
enabled = 0;
235+
};
236+
};
224237
};
225238
B082B260205C7D8000BC04DC = {
226239
CreatedOnToolsVersion = 9.2;
@@ -261,6 +274,7 @@
261274
files = (
262275
B082B257205C7D8000BC04DC /* Assets.xcassets in Resources */,
263276
B082B25A205C7D8000BC04DC /* Main.storyboard in Resources */,
277+
B0F8771D207AD35400D6E430 /* battery.scpt in Resources */,
264278
);
265279
runOnlyForDeploymentPostprocessing = 0;
266280
};
@@ -288,6 +302,7 @@
288302
B059D622205E03F5006E6B86 /* TouchBarController.swift in Sources */,
289303
B082B255205C7D8000BC04DC /* ViewController.swift in Sources */,
290304
B0C1CFCA205C97D30021C862 /* WindowController.swift in Sources */,
305+
B0F8771A207AC1EA00D6E430 /* TouchBarSupport.m in Sources */,
291306
B082B253205C7D8000BC04DC /* AppDelegate.swift in Sources */,
292307
B059D624205E04F3006E6B86 /* TouchBarItems.swift in Sources */,
293308
B0A7E9AA205D6AA400EEF070 /* KeyPress.swift in Sources */,
@@ -351,13 +366,15 @@
351366
CLANG_WARN_BOOL_CONVERSION = YES;
352367
CLANG_WARN_COMMA = YES;
353368
CLANG_WARN_CONSTANT_CONVERSION = YES;
369+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
354370
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
355371
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
356372
CLANG_WARN_EMPTY_BODY = YES;
357373
CLANG_WARN_ENUM_CONVERSION = YES;
358374
CLANG_WARN_INFINITE_RECURSION = YES;
359375
CLANG_WARN_INT_CONVERSION = YES;
360376
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
377+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
361378
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
362379
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
363380
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
@@ -408,13 +425,15 @@
408425
CLANG_WARN_BOOL_CONVERSION = YES;
409426
CLANG_WARN_COMMA = YES;
410427
CLANG_WARN_CONSTANT_CONVERSION = YES;
428+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
411429
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
412430
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
413431
CLANG_WARN_EMPTY_BODY = YES;
414432
CLANG_WARN_ENUM_CONVERSION = YES;
415433
CLANG_WARN_INFINITE_RECURSION = YES;
416434
CLANG_WARN_INT_CONVERSION = YES;
417435
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
436+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
418437
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
419438
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
420439
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
@@ -447,7 +466,6 @@
447466
isa = XCBuildConfiguration;
448467
buildSettings = {
449468
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
450-
CODE_SIGN_ENTITLEMENTS = MTMR/MTMR.entitlements;
451469
CODE_SIGN_STYLE = Automatic;
452470
COMBINE_HIDPI_IMAGES = YES;
453471
DEVELOPMENT_TEAM = D6D8BR2QNB;
@@ -468,7 +486,6 @@
468486
isa = XCBuildConfiguration;
469487
buildSettings = {
470488
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
471-
CODE_SIGN_ENTITLEMENTS = MTMR/MTMR.entitlements;
472489
CODE_SIGN_STYLE = Automatic;
473490
COMBINE_HIDPI_IMAGES = YES;
474491
DEVELOPMENT_TEAM = D6D8BR2QNB;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>

MTMR/AppDelegate.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ class AppDelegate: NSObject, NSApplicationDelegate {
1616
func applicationDidFinishLaunching(_ aNotification: Notification) {
1717
TouchBarController.shared.setupControlStripPresence()
1818
// Insert code here to initialize your application
19-
2019
}
2120

2221
func applicationWillTerminate(_ aNotification: Notification) {

MTMR/KeyPress.swift

Lines changed: 61 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,73 @@
88

99
import Foundation
1010

11+
protocol KeyPress {
12+
var keyCode: CGKeyCode { get }
13+
func send()
14+
}
15+
16+
extension KeyPress {
17+
func send () {
18+
let src = CGEventSource(stateID: .hidSystemState)
19+
let keyDown = CGEvent(keyboardEventSource: src, virtualKey: keyCode, keyDown: true)
20+
let keyUp = CGEvent(keyboardEventSource: src, virtualKey: keyCode, keyDown: false)
1121

12-
func KeyPress (keyCode: CGKeyCode) {
13-
let keyDown = CGEvent(keyboardEventSource: nil, virtualKey: keyCode, keyDown: true)
14-
let keyUp = CGEvent(keyboardEventSource: nil, virtualKey: keyCode, keyDown: false)
22+
let loc: CGEventTapLocation = .cghidEventTap
23+
keyDown?.post(tap: loc)
24+
keyUp?.post(tap: loc)
25+
}
26+
}
1527

16-
keyDown?.post(tap: .cghidEventTap)
17-
keyUp?.post(tap: .cghidEventTap)
28+
struct ESCKeyPress: KeyPress {
29+
let keyCode: CGKeyCode = 53
1830
}
1931

20-
func ESCKeyPress() {
21-
KeyPress(keyCode: 53)
32+
struct BrightnessUpPress: KeyPress {
33+
let keyCode: CGKeyCode = 107
2234
}
2335

24-
func BrightnessUpPress() {
25-
KeyPress(keyCode: 107)
36+
struct BrightnessDownPress: KeyPress {
37+
let keyCode: CGKeyCode = 113
2638
}
2739

28-
func BrightnessDownPress() {
29-
KeyPress(keyCode: 113)
40+
41+
func doKey(_ key: Int, down: Bool) {
42+
let flags = NSEvent.ModifierFlags(rawValue: down ? 0xa00 : 0xb00)
43+
let data1 = (key << 16) | ((down ? 0xa : 0xb) << 8)
44+
45+
let ev = NSEvent.otherEvent(
46+
with: NSEvent.EventType.systemDefined,
47+
location: NSPoint(x:0.0, y:0.0),
48+
modifierFlags: flags,
49+
timestamp: TimeInterval(0),
50+
windowNumber: 0,
51+
context: nil,
52+
// context: 0,
53+
subtype: 8,
54+
data1: data1,
55+
data2: -1
56+
)
57+
let cev = ev!.cgEvent!
58+
cev.post(tap: CGEventTapLocation(rawValue: 0)!)
3059
}
60+
61+
func HIDPostAuxKey(_ key: Int) {
62+
doKey(key, down: true)
63+
doKey(key, down: false)
64+
}
65+
66+
67+
// hidsystem/ev_keymap.h
68+
let NX_KEYTYPE_SOUND_UP = 0
69+
let NX_KEYTYPE_SOUND_DOWN = 1
70+
71+
let NX_KEYTYPE_BRIGHTNESS_UP = 2
72+
let NX_KEYTYPE_BRIGHTNESS_DOWN = 3
73+
74+
let NX_KEYTYPE_PLAY = 16
75+
let NX_KEYTYPE_NEXT = 17
76+
let NX_KEYTYPE_PREVIOUS = 18
77+
78+
79+
80+

MTMR/MTMR.entitlements

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
4-
<dict>
5-
<key>com.apple.security.app-sandbox</key>
6-
<true/>
7-
<key>com.apple.security.files.user-selected.read-only</key>
8-
<true/>
9-
</dict>
4+
<dict/>
105
</plist>

0 commit comments

Comments
 (0)