instead of using the MP_KEY events (Int32) and using a logical OR to generate a key event for the mpv core, use the cocoa event type for key states and pass those to the the function. in the function we properly map those events to the right MP_KEY events.
Unified · Split
| @@ -29,7 +29,7 @@ extension RemoteCommandCenter { · 28 unmodified lines | |||
| 29 | struct Config { | 29 | struct Config { |
| 30 | let key: Int32 | 30 | let key: Int32 |
| 31 | let type: KeyType | 31 | let type: KeyType |
| 32 | var state: UInt32 = 0 | 32 | var state: NSEvent.EventType = .applicationDefined |
| 33 | let handler: ConfigHandler | 33 | let handler: ConfigHandler |
| 34 | 34 | ||
| 35 | init(key: Int32 = 0, type: KeyType = .normal, handler: @escaping ConfigHandler = { event in return .commandFailed }) { | 35 | init(key: Int32 = 0, type: KeyType = .normal, handler: @escaping ConfigHandler = { event in return .commandFailed }) { |
| @@ -165,11 +165,10 @@ class RemoteCommandCenter: EventSubscriber { · 129 unmodified lines | |||
| 165 | 165 | ||
| 166 | var state = config.state | 166 | var state = config.state |
| 167 | if config.type == .repeatable { | 167 | if config.type == .repeatable { |
| 168 | state = config.state == MP_KEY_STATE_DOWN ? MP_KEY_STATE_UP : MP_KEY_STATE_DOWN | 168 | state = config.state == .keyDown ? .keyUp : .keyDown |
| 169 | self.configs[event.command]?.state = state | 169 | self.configs[event.command]?.state = state |
| 170 | } | 170 | } |
| 171 | 171 | self.input.put(key: config.key, type: state) | |
| 172 | self.input.put(key: config.key | Int32(state)) | ||
| 173 | 172 | ||
| 174 | return .success | 173 | return .success |
| 175 | } | 174 | } |