-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Multiple fixes to key binding parsing #3887
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
iina/KeyCodeHelper.swift
Outdated
case META_KEY: modifiers.insert(.command) | ||
case CTRL_KEY: modifiers.insert(.control) | ||
case ALT_KEY: modifiers.insert(.option) | ||
case SHIFT_KEY: modifiers.insert(.shift) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the space
I made another commit based on more recent code - this was a little out of date - and fixed typos. The only significant change was that it needed a check for the special line |
Ack - found a bug - and just committed the fix. It incorrectly parsed if the rawKey included ended in the minus key ( |
1e6c52b
to
3de6687
Compare
…and change use to one or the other appropriately. Improve and expand logic for normalizing MPV key sequences. Add logic to skip over "default bindings start" and ignore bindings which specify non-default input sections.
3de6687
to
756739d
Compare
Found one more corner case with key sequences that wasn't handled ( I cleaned up the dash checks in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding the mpv key sequence part: It's great to handle key sequences (and we probably should add support for them later), but since IINA doesn't support key sequences, perhaps currently we should filter them out before displaying/setting the key bindings?
iina/AppData.swift
Outdated
static let iinaInputConfListChanged = Notification.Name("IINAInputConfListChanged") | ||
static let iinaCurrentInputConfChanged = Notification.Name("IINACurrentInputConfChanged") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two notifications are unused?
iina/AppData.swift
Outdated
static let iinaInputConfListChanged = Notification.Name("IINAInputConfListChanged") | ||
static let iinaCurrentInputConfChanged = Notification.Name("IINACurrentInputConfChanged") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These names are unused?
iina/PlayerCore.swift
Outdated
if $0.rawKey == "default-bindings" && $0.action.count == 1 && $0.action[0] == "start" { | ||
Logger.log("Skipping line: \"default-bindings start\"", level: .verbose) | ||
} else { | ||
if let kb = filterSectionBindings($0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be } else if let kb = ... {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't test for the issues linked, hopefully that has been done by someone else. Just some suggestions based on the code.
iina/KeyMapping.swift
Outdated
normalizedKey += "+" | ||
var confFileFormat: String { | ||
get { | ||
let iinaCommandString = isIINACommand ? "#@iina " : "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider making "#@iina" a constant instead of writing literals every time?
iina/KeyCodeHelper.swift
Outdated
var normalizedList: [String] = [] | ||
for keystroke in keystrokesList { | ||
normalizedList.append(normalizeSingleMpvKeystroke(keystroke)) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var normalizedList: [String] = [] | |
for keystroke in keystrokesList { | |
normalizedList.append(normalizeSingleMpvKeystroke(keystroke)) | |
} | |
let normalizedList = keystrokesList.map({ normalizeSingleMpvKeystroke($0) }) |
iina/KeyCodeHelper.swift
Outdated
} | ||
|
||
/* | ||
MPV accepts several forms for the same keystroke. This ensures that it is reduced to a single standardized form |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MPV accepts several forms for the same keystroke. This ensures that it is reduced to a single standardized form | |
mpv accepts several forms for the same keystroke. This ensures that it is reduced to a single standardized form |
I pushed a new commit, non-forced so you can see the changes.
I agree it's not pretty to put it here, but it's hard to find another place to put it. If we drop the line while parsing the file, we'll end up removing it from the file the first time the user makes any other changes to it, because of the way config files are handled. It's one thing to strip the comments out of a file, but it's bigger thing to strip valid lines out of it, and I'd rather avoid doing that (and this is basically a section start token, so the consequences would be big). There are apparently some users who use the same config files for both IINA and mpv, and they would be adversely affected by it.
Fair point. I've updated the normalization code to just pass back anything with more than one |
b9911f8
to
997af49
Compare
…and change use to one or the other appropriately. Improve and expand logic for normalizing MPV keys. Add logic to skip over "default bindings start" and ignore bindings which specify non-default input sections.
997af49
to
a0e5354
Compare
Now I see that changes are still retained either way, so I force pushed against the original commit, for tidiness. |
Multiple keys bound to the same menu item results in a random key being chosen #3831
Cannot Quit with Q-Key #3881
Using different forms of uppercase letters can cause wrong key binding to be set #3851
Description:
This patch is a subset of (and is actually back-ported from) #3847, and contains only the changes to parsing and mapping key bindings. It is the successor to #3833: it fixes a loophole in that logic which result in unused duplicate entries being stored, while also adding other fixes which couldn't be merged separately.
It does the following
KeyMapping
'skey
field into rawKey andnormalizedMpvKey
, similar to how itsaction
field has raw & parsed version.KeyMapping
constructor and intoKeyCodeHelper
.-
(minus) key are properly parseddefault-bindings begin
, rather than binding it to a ke{section_name}
(section name in curly braces): if it is "default" then strip the section and include the binding; for other section names do not include the binding (fixes Cannot Quit with Q-Key #3881)