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

Keymap file ignored in XWayland windows (Macbook host / Linux client) #4

Closed
idest opened this issue May 24, 2021 · 3 comments
Closed

Comments

@idest
Copy link

idest commented May 24, 2021

I created a xkb keycodes file to translate from Mac to Linux and it works fine in native wayland windows, but the file is ignored in XWayland windows.

In swaywm/sway#5461 someone suggested that the keymap might be ignored by XWayland if there's errors in the keycodes file, so I ran xkbcomp -xkb -I$HOME/.xkb/ ~/.config/waynergy/xkb_keymap to check and I got the following error and warning:

Error:            Illegal keycode 1 (must be in the range 8-255 inclusive)
                  Value of "minimum" not changed
Warning:          Unsupported maximum keycode 1024, clipping.
                  X11 cannot support keycodes above 255.
Keycodes above 1 (e.g. <AC01>) are not supported by X and are ignored

So the problem is that Mac sends keycodes in a range starting with 1, and X needs the range to start at 8. I think the only way to get this working would be for waynergy to somehow parse the keycodes coming from a Mac by adding 7 to them. This makes sense to me because the file included in /usr/share/X11/xkb/keycodes/macintosh handles it this way, where <AC01> starts with 8 and it goes up from there in the same order as the keycodes file I derived from trial and error.

Here's the contents of ~/.config/waynergy/xkb_keymap:

xkb_keymap {
	xkb_keycodes  { include "macbook+aliases(qwerty)"	};
	xkb_types     { include "complete"	};
	xkb_compat    { include "complete"	};
	xkb_symbols   { include "pc+us+inet(evdev)"	};
	xkb_geometry  { include "pc(pc105)"	};
};

and the contents of ~/.xkb/keycodes/macbook (derived from trial and error):

default xkb_keycodes "macbook" {

    minimum= 1;
    maximum= 1024;

    <ESC> = 54;
    <FK01> = 123;
    <FK02> = 121;
    <FK03> = 100;
    <FK04> = 119;
    <FK05> = 97;
    <FK06> = 98;
    <FK07> = 99;
    <FK08> = 101;
    <FK09> = 102;
    <FK10> = 110;
    <FK11> = 104;
    <FK12> = 112;

    <TLDE> = 51;
    <AE01> = 19;
    <AE02> = 20;
    <AE03> = 21;
    <AE04> = 22;
    <AE05> = 24;
    <AE06> = 23;
    <AE07> = 27;
    <AE08> = 29;
    <AE09> = 26;
    <AE10> = 30;
    <AE11> = 28;
    <AE12> = 25;
    <BKSP> = 52;

    <TAB> = 49;
    <AD01> = 13;
    <AD02> = 14;
    <AD03> = 15;
    <AD04> = 16;
    <AD05> = 18;
    <AD06> = 17;
    <AD07> = 33;
    <AD08> = 35;
    <AD09> = 32;
    <AD10> = 36;
    <AD11> = 34;
    <AD12> = 31;
    <BKSL> = 43;

    <CAPS> = 58;
    <AC01> = 1;
    <AC02> = 2;
    <AC03> = 3;
    <AC04> = 4;
    <AC05> = 6;
    <AC06> = 5;
    <AC07> = 39;
    <AC08> = 41;
    <AC09> = 38;
    <AC10> = 42;
    <AC11> = 40;
    <RTRN> = 37;

    <LFSH> = 57;
    <AB01> = 7;
    <AB02> = 8;
    <AB03> = 9;
    <AB04> = 10;
    <AB05> = 12;
    <AB06> = 46;
    <AB07> = 47;
    <AB08> = 44;
    <AB09> = 48;
    <AB10> = 45;
    <RTSH> = 57;

    <LALT> = 59;
    <LCTL> = 60;
    <SPCE> = 50;
    <RCTL> = 60;
    <RALT> = 59;
    <LWIN> = 56;
    <RWIN> = 56;

    <UP> = 127;
    <LEFT> = 124;
    <DOWN> = 126;
    <RGHT> = 125;
};
r-c-f added a commit that referenced this issue May 24, 2021
Per #4, xwayland gets angry if the minimum key drops below 8, so allow
setting an offset to apply when processing keycodes.
r-c-f added a commit that referenced this issue May 24, 2021
Per #4, xwayland gets angry if the minimum key drops below 8, so allow
setting an offset to apply when processing keycodes.
@r-c-f
Copy link
Owner

r-c-f commented May 24, 2021

@idest

I think the only way to get this working would be for waynergy to somehow parse the keycodes coming from a Mac by adding 7 to them.

#5 should make this possible, does it improve the Xwayland situation on your end?

@idest
Copy link
Author

idest commented May 24, 2021

@r-c-f works perfectly, thank you!

@r-c-f
Copy link
Owner

r-c-f commented May 24, 2021

No problem, glad it works

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

2 participants