mirror of
https://github.com/mpv-player/mpv
synced 2025-02-11 09:27:26 +00:00
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:
parent
70eba5e831
commit
2cbb13db9e
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user