@@ -6,17 +6,22 @@ public protocol CGEventObserverType {
66 @discardableResult
77 func activateIfPossible( ) -> Bool
88 func deactivate( )
9- var stream : AsyncStream < Void > { get }
9+ var stream : AsyncStream < CGEventType > { get }
1010 var isEnabled : Bool { get }
1111}
1212
1313final class CGEventObserver : CGEventObserverType {
14- let stream : AsyncStream < Void >
14+ let stream : AsyncStream < CGEventType >
1515 var isEnabled : Bool { port != nil }
1616
17- private var continuation : AsyncStream < Void > . Continuation
17+ private var continuation : AsyncStream < CGEventType > . Continuation
1818 private var port : CFMachPort ?
19- private let eventsOfInterest : Set < CGEventType > = [ . keyUp]
19+ private let eventsOfInterest : Set < CGEventType > = [
20+ . keyUp,
21+ . keyDown,
22+ . rightMouseDown,
23+ . leftMouseDown,
24+ ]
2025 private let tapLocation : CGEventTapLocation = . cghidEventTap
2126 private let tapPlacement : CGEventTapPlacement = . tailAppendEventTap
2227 private let tapOptions : CGEventTapOptions = . listenOnly
@@ -28,7 +33,7 @@ final class CGEventObserver: CGEventObserverType {
2833 }
2934
3035 init ( ) {
31- var continuation : AsyncStream < Void > . Continuation !
36+ var continuation : AsyncStream < CGEventType > . Continuation !
3237 stream = AsyncStream { c in
3338 continuation = c
3439 }
@@ -66,9 +71,9 @@ final class CGEventObserver: CGEventObserverType {
6671 }
6772
6873 if let continuation = continuationPointer?
69- . assumingMemoryBound ( to: AsyncStream < Void > . Continuation. self)
74+ . assumingMemoryBound ( to: AsyncStream < CGEventType > . Continuation. self)
7075 {
71- continuation. pointee. yield ( ( ) )
76+ continuation. pointee. yield ( eventType )
7277 }
7378
7479 return . passRetained( event)
0 commit comments