diff --git a/Sources/CapswitchApp/MacOSInputController.swift b/Sources/CapswitchApp/MacOSInputController.swift index 0e0d5ff..53b712a 100644 --- a/Sources/CapswitchApp/MacOSInputController.swift +++ b/Sources/CapswitchApp/MacOSInputController.swift @@ -165,13 +165,13 @@ final class MacOSInputController { let eventMask = CGEventMask(1 << CGEventType.flagsChanged.rawValue) let refcon = Unmanaged.passUnretained(self).toOpaque() - guard let tap = CGEventTapCreate( - .cgSessionEventTap, - .headInsertEventTap, - .defaultTap, - eventMask, - Self.eventTapCallback, - refcon + guard let tap = CGEvent.tapCreate( + tap: .cgSessionEventTap, + place: .headInsertEventTap, + options: .defaultTap, + eventsOfInterest: eventMask, + callback: Self.eventTapCallback, + userInfo: refcon ) else { throw InputControllerError.eventTapUnavailable } @@ -191,14 +191,14 @@ final class MacOSInputController { ) } - CGEventTapEnable(tap, true) + CGEvent.tapEnable(tap: tap, enable: true) resetGestureState() onStateChanged?() } func stop() { if let eventTap { - CGEventTapEnable(eventTap, false) + CGEvent.tapEnable(tap: eventTap, enable: false) } if let runLoopSource { @@ -255,7 +255,7 @@ final class MacOSInputController { if type == .tapDisabledByTimeout || type == .tapDisabledByUserInput { resetGestureState() if let eventTap { - CGEventTapEnable(eventTap, true) + CGEvent.tapEnable(tap: eventTap, enable: true) } return Unmanaged.passUnretained(event) } diff --git a/Taskfile.yml b/Taskfile.yml index 4859584..5477366 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -55,6 +55,10 @@ tasks: - test -f Sources/CapswitchApp/MacOSInputController.swift - grep -q "LSUIElement" Resources/Info.plist - grep -q ".flagsChanged" Sources/CapswitchApp/MacOSInputController.swift + - grep -q "CGEvent.tapCreate" Sources/CapswitchApp/MacOSInputController.swift + - grep -q "CGEvent.tapEnable" Sources/CapswitchApp/MacOSInputController.swift + - test "$(grep -c "CGEventTapCreate" Sources/CapswitchApp/MacOSInputController.swift || true)" -eq 0 + - test "$(grep -c "CGEventTapEnable" Sources/CapswitchApp/MacOSInputController.swift || true)" -eq 0 - grep -q "TISSelectInputSource" Sources/CapswitchApp/MacOSInputController.swift - grep -q "switchToNextInputSource" Sources/Capswitch/CapsGestureMachine.swift