History

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.

der richter committed 2 years ago

Commit 2cbb13d1 parent 70eba5e1 file · +3 −4Browse files

Unified · Split

osdep/mac/remote_command_center.swift+3−4
@@ -29,7 +29,7 @@ extension RemoteCommandCenter { · 28 unmodified lines
29 struct Config {29 struct Config {
30 let key: Int3230 let key: Int32
31 let type: KeyType31 let type: KeyType
32 var state: UInt32 = 032 var state: NSEvent.EventType = .applicationDefined
33 let handler: ConfigHandler33 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.state166 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_DOWN168 state = config.state == .keyDown ? .keyUp : .keyDown
169 self.configs[event.command]?.state = state169 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 .success173 return .success
175 }174 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t