Skip to content
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: For SDL2, in keycode mode, allow remapping of modifier keys #28

Closed
rakslice opened this issue Feb 5, 2020 · 4 comments

Comments

@rakslice
Copy link

rakslice commented Feb 5, 2020

In SDL2 keyboard handling, for the case where keycodes is enabled, host modifier keys are specifically excluded from the cases that provided mapping:

if (use_keycodes && !is_modifier_key(event.key)) {

if (use_keycodes && !is_modifier_key(event.key)) {

This prevents re-mapping of modifier keys. This is inconvenient.

This was put in for SDL in b6e1e6e , at the same time as some SDL Mac OS X keyboard fixes, so perhaps the modifier change is for SDL on Mac OS X also? Is it necessary to avoid a problem of some kind?

Is this also true for SDL2?

If the exception for modifiers is not needed for SDL2 it could simply be removed.

Alternatively, if it is necessary to handle modifiers as keysyms for whatever reason, another approach would be to add logic that infers the keysym remappings for modifiers from the keycodes table and applies them on the keysyms side.

@rakslice rakslice changed the title Feature request: For SDL2, in keycode mode, allow mapping of modifier keys Feature request: For SDL2, in keycode mode, allow remapping of modifier keys Feb 5, 2020
@kanjitalk755
Copy link
Owner

I don't understand the intention of excluding modifier keys from customizing keymaps.
So, I tried to be able to define modifier keys in the keymap file.

Please test:
https://github.com/kanjitalk755/macemu/tree/test_keymap

@rakslice
Copy link
Author

rakslice commented Feb 9, 2020

I tested this branch in Mac OS X 10.12 and Linux, working around #29, and the keyboard remapping works fine.

@kanjitalk755
Copy link
Owner

Merged to the master.

@BloodyMess
Copy link

BloodyMess commented Oct 3, 2020

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:

  • elementary OS 5.1.7 Hera (with all current updates) based on Ubuntu 18.04LTS
  • Linux Kernel 5.4.0-48-generic
  • GTK 3.22.30
  • SheepShaver built from a current snapshot of master branch from this repository.

HARDWARE:

  • Ryzen 3900X
  • Radeon RX590
  • 128GB RAM
  • Matias Tactile Pro Keyboard for Mac

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 the opt_down and cmd_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:

  1. At the Finder Desktop, Press command-N to create a new folder. This creates a folder presenting the "untitled" text for you to edit.
  2. WITHOUT pressing any other keys or clicking the mouse anywhere, press command-I to open the Get Info window.
  3. You'll see that the name of the folder has been changed to an "i" and THEN the Get Info window was opened for the folder.
  4. Pressing command-w to close the Get Info window will again change the folder name, this time to "w", before acting on the command-w press to close the window.

The order that these key events happens in can be verified like this:

  1. In the Finder (at Desktop or with a folder window active, it doesn't matter) with nothing selected, press command-i.
  2. The Finder will process the plain "i" keypress by selecting the icon with the closest matching name, and then opening the Get Info window.

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.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants