-
Notifications
You must be signed in to change notification settings - Fork 58
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
Feature Request: Prevent Swapping Command & Option Keys When Using A Mac Keyboard on Linux #59
Comments
One question is: if you leave the If you are modifying the The fact that the keyboard handling has special cases for |
Since SDL2 doesn't tell us anything about the keyboard that generated the keypress, and there's no way to infer it if I understand correctly, I think it may be academic. Maybe the best we could do would be to add a specific settings toggle for it to make it easier to swap than writing an entire keysyms file?
Is that behaviour consistent with not having codes for SDL_KEYUP that are consistent with the ones for SDL_KEYDOWN? |
As a practical matter, do you have your desktop environment configured somehow such that it doesn't intercept whatever key generates |
How about this implementation: |
In Qemu, the windows key is intercepted when the mouse is grabbed. |
Well, there's some improvement: This implementation fixes ignoring the righthand option and command keys. I ran the
CORRECTION: The new prefs option actually does fix the option/command swapping problem. And it still fixes recognizing the righthand option and command keys. It also halfway fixes the funky behaviour of sending the regular character before the command key combo: It works perfectly fine when I use the righthand modifier keys, but it still has the problem when using the lefthand modifier keys. |
I don't know the relevance to this issue. I tested SS under Arch Linux.
All had the same result.
I couldn't reproduce this phenomena.
So there's nothing more we can do with SS code. |
I guess there is some kind of interception of Cmd / Win, a.k.a. what ev calls KEY_LEFTMETA, USB HID key code 125 going on. I wonder if there is a way to convince whatever is doing that in elementaryOS to not do that, or at least get SDL to give some less dumb input when it happens? For the benefit of those trying to reproduce the problem, this is one of those bug reports where perhaps a tedious level precision helps. Testing in elementaryOS Hera x86_64, with option and command swapped:
I would never have thought to release command and press it again except that I was eventually trying with Key Caps open in the emulated Mac, and that gave away the underlying issue: the command key doesn't register when you press it, it only registers when you finish a two key combination. This seems to be because SheepShaver doesn't get a key event when you press left meta until a shortcut with left meta is complete that elementaryOS doesn't want. When SheepShaver does get a key event it gets 3 at once, and 5 altogether: When the meta key is pressed:
When the letter key is pressed:
When the letter key is released:
When left meta key is released:
So in other words if you had kept left meta held down after the first key combination, it continues to register as down and any subsequent key combinations work normally. Right meta doesn't have this problem; it registers right away and pressing a two key combination with it only generates 4 events, one for each key event as expected.
That part I have no clue how you did; I've set command key behaviour to Disabled in System Settings -> Keyboard -> Layout, and scoured all the shortcuts in Shortcuts and in Gnome Tweaks for Cmd W, and didn't find anything, but left meta + W and right meta + W are still captured by ElementaryOS no matter what and make it give an overview of the open windows. |
Testing with |
But using Left meta pressed:
Letter key pressed:
Letter key released:
Left meta released:
|
One thing I'm noticing during this testing is that the host key repeat applying in SheepShaver makes shortcuts repeat in a way that doesn't happen on a real Mac, and unnecessarily duplicates key repeat already being done in software by the emulated Mac on things that should repeat. Actually, of the SDL key events seen for the Left Meta shortcut in this issue:
|
Okay, I see that the elementaryos shortcuts that aren't working properly in the settings GUI yet are modifiable through org.pantheon.desktop.gala in dconf-editor etc. |
In addition to org.pantheon.desktop.gala, change the superkey with org.gnome.mutter.overlay-key. For example: |
Ah, removing Super_L from org.gnome.mutter.overlay-key is sufficient to let SheepShaver see the initial Super_L press by itself, which causes it to be delivered first before the other key in a key combination. I have a code change in a branch to make it so that when consecutive keydown events arrive simultaneously modifiers are delivered first, and also to ignore key repeat events: https://github.com/rakslice/macemu/tree/sdl2_keys |
Do we need to change the handling of key repeats even if the superkey is set properly? |
If you go into the Shortcuts tab of the Keyboard settings panel, select the item with command-w assigned to it, then click on the item's right column to allow reassignment of the shortcut for that item. While it's waiting for you to select a new keyboard shortcut: Simply press the Delete/Backspace key, which will clear the shortcut key assignment and disable the item. |
This might be a clue to something I thought was an entirely different issue with handling keypresses: If you hold down a modifier key for more than a couple of seconds, SheepShaver "forgets" that the modifier key is still pressed. This has tripped me up more times than I care to admit, even when I'm consciously trying to work around it. |
I've used dconf-editor to clear the overlay key string and disable the default, and built your sdl2_keys branch. It seems to be working fine. So far, I've only quickly tested it with the actions listed in this thread, but it looks good so far! |
@kanjitalk755 Sure, when using X11, run SheepShaver, go to the desktop, and press cmd + n and hold them down for 10 seconds. @BloodyMess But like I said there was nothing in the Shortcuts using Cmd + W. I eventually found it in a setting in org.pantheon.desktop.gala in dconf |
I assume that elementary's Keyboard settings panel is a work in progress, because for instance if I click on a Disabled item and it says "New accelerator" and I type a new shortcut, it just goes back to Disabled, it doesn't seem to be able to take an actual setting no matter what combinations I try. |
Yes, I think if you have the command key disabled in the Layout panel, then it just marks things as disabled in the other panels, but apparently doesn't actually change them. I seem to remember having to leave the command key enabled in the Layout panel to let me make changes in the other panels. |
I have confirmed that key repeats should be ignored. One more question. If we set the superkey properly, the event occurrence order of the command key and other keys will be the order in which the user pressed it, so I think that look ahead for keydown events is unnecessary, but how about it? |
Yeah, I don't know any other case where multiple key presses happen at the same time that would need the reordering, and without that it is unnecessary. |
I added a step to ignore key repeat and merged to the master. |
I just built the latest snapshot and it seems to be working well. Even the problem of "forgetting" that a modifier key is being held down for an extended period isn't happening now. |
I went through d-conf looking for any key bindings that might need to be changed on elementaryOS (or any other gnome based system) to let SheepShaver function normally. It might be a good idea to mention in a read-me that users of systems like these might need to do this sort of thing to let SheepShaver react to keypresses correctly. Here are the changes I made on my system:
|
The above settings can be referenced from the top-level readme.md. |
I'm having a problem related to #28, but I'm not sure if it should be under that issue or a new one. So I'm doing both. Feel free to delete whichever one you feel is best.
My system config is this:
SOFTWARE:
HARDWARE:
As you can see above, I'm using a keyboard made for Macs on my Linux system. I'm trying to get my SheepShaver Mac to use the correct command and option keys on my Mac keyboard.
Other builds I've been running previously (from vasi, as posted on the e-maculation forums) have swapped the command and option keys and also would only respond to the left command and option keys, ignoring the right-hand command and option keys.
I ran across issue #28 while searching for a solution, and downloaded a snapshot to see if your SheepShaver was any better. I looked at the code in video_sdl2.cpp and found the places where the keycodes were being swapped unless the
__APPLE__
macro is defined.Since swapping those keys isn't appropriate for the Mac keyboard I'm using, I commented out the
#ifdef __APPLE__
lines and their related#else
blocks, so that just the lines of code that set the keycodes correctly and correctly sets theopt_down
andcmd_down
variables remained. I also unswapped the command and option keycodes in the "sdl x11" section of the "keycodes" file.This mostly worked!
But there is an odd bug that I cant' figure out so far: when I press a command-key combination it seems to be sending the regular keypress first and then immediately follows it with the correct command-key combo that I pressed. For Example:
The order that these key events happens in can be verified like this:
Like i said earlier, I don't know if this should be under issue #28 or in its own issue.
Also, I'm not sure whether it should be a bug or a feature request to not swap the command and option keys when a Mac keyboard is being used regardless of whether the system itself is a Mac.
The text was updated successfully, but these errors were encountered: