mac/remote: use event type as key state for proper mapping in function

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.
This commit is contained in:
der richter 2024-04-03 20:48:21 +02:00
parent 70eba5e831
commit 2cbb13db9e
1 changed files with 3 additions and 4 deletions

View File

@ -29,7 +29,7 @@ extension RemoteCommandCenter {
struct Config {
let key: Int32
let type: KeyType
var state: UInt32 = 0
var state: NSEvent.EventType = .applicationDefined
let handler: ConfigHandler
init(key: Int32 = 0, type: KeyType = .normal, handler: @escaping ConfigHandler = { event in return .commandFailed }) {
@ -165,11 +165,10 @@ class RemoteCommandCenter: EventSubscriber {
var state = config.state
if config.type == .repeatable {
state = config.state == MP_KEY_STATE_DOWN ? MP_KEY_STATE_UP : MP_KEY_STATE_DOWN
state = config.state == .keyDown ? .keyUp : .keyDown
self.configs[event.command]?.state = state
}
self.input.put(key: config.key | Int32(state))
self.input.put(key: config.key, type: state)
return .success
}