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 | 29 | struct Config { |
| 30 | 30 | let key: Int32 |
| 31 | 31 | let type: KeyType |
| 32 | − var state: UInt32 = 0 | |
| 32 | + var state: NSEvent.EventType = .applicationDefined | |
| 33 | 33 | let handler: ConfigHandler |
| 34 | 34 | |
| 35 | 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 | 166 | var state = config.state |
| 167 | 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 | 169 | self.configs[event.command]?.state = state |
| 170 | 170 | } |
| 171 | − | |
| 172 | − self.input.put(key: config.key | Int32(state)) | |
| 171 | + self.input.put(key: config.key, type: state) | |
| 173 | 172 | |
| 174 | 173 | return .success |
| 175 | 174 | } |