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

Arch Client connecting to MacOS host has incorrect keys #7

Open
hahuang65 opened this issue May 27, 2021 · 17 comments
Open

Arch Client connecting to MacOS host has incorrect keys #7

hahuang65 opened this issue May 27, 2021 · 17 comments

Comments

@hahuang65
Copy link

Connecting from my Arch box to my MacOS box, the keyboard doesn't respond as it should.

If I press a nothing happens, if I press Backspace, it outputs a z.

I took a look at #4 and #3 but I couldn't fully understand it, and neither of those are exactly my problem (I'm on MacOS as host, Arch as client, and I'm not using XWayland.

@r-c-f
Copy link
Owner

r-c-f commented May 27, 2021

It's ultimately similar enough to #4; if I understood their report correctly the macintosh keycodes correspond with what synergy sends, with an offset of 7 to placate X, so you could likely use a keymap of

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

with xkb_key_offset at 7.

@hahuang65
Copy link
Author

I didn't understand where to set this and how to enable it. Does this also interfere with connecting the same keyboard directly to the computer with Bluetooth?

@r-c-f
Copy link
Owner

r-c-f commented May 27, 2021

The quoted xkb_keymap would need to go in ~/.config/waynergy/xkb_keymap, and 7 would go in ~/.config/waynergy/xkb_key_offset. And this will only apply to waynergy's virtual keyboard, not anything else you connect.

@hahuang65
Copy link
Author

Is there anything else to do? I put those files in the mentioned places, and restarted my waynergy client, but still similar results.

Now backspace outputs , and spacebar outputs n though. a still outputs nothing. So I guess somethings did shift.

@hahuang65
Copy link
Author

Okay, if I do 37 as my offset, asdfg are correct... but h outputs g, j seems to output a newline, \ seems to output up arrow. Not sure what to do from here actually.

@r-c-f
Copy link
Owner

r-c-f commented May 28, 2021

In that case I'd try the keycodes from #4, i.e. at ~/.xkb/keycodes/mac use

default xkb_keycodes "mac" {

    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;
};

and for waynergy's xkb_keymap, use

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

and just delete xkb_key_offset.

That's going to be missing a few keys from typical desktop layouts but if it works they'll be easy enough to add.

@hahuang65
Copy link
Author

I'll give that a shot, thanks

@hahuang65
Copy link
Author

That seems to be working for the most part, but only on Chrome for some reason, the asdfghzx keys don't work. They just simply don't output anything. I am running Chrome with --enable-features=UseOzonePlatform --ozone-platform=wayland

I should have mentioned this earlier, but I'm not using a standard 104-key board. I'm using a 60% keyboard with 61-keys, but in standard ANSI layout (it's just missing the Function keys as well as the numpad). I'm not sure that makes a difference since the rest of the keys are standard.

@hahuang65
Copy link
Author

Yeah, a little funky. So xev reads j as s, k as f, l as a... it also doesn't pick up asdfghzx.
But on Chrome using keyboardtester.com, j, k, l work and are recognized as j, k, l, but other keys, even though they output the right character, are recognized differently, for example, ; prints out ; in the text box, but is recognized as a keypress for g. ' prints out ' in the textbox, but is recognized as d.

@r-c-f
Copy link
Owner

r-c-f commented May 28, 2021

xev will be limited by the xwayland keycode limitations, and Chromium is probably assuming they are still in place on Wayland so,
with an xkb_key_offset of 7 and ~/.xkb/keycodes/mac of

default xkb_keycodes "mac" {
	minimum  = 8;
	maximum  = 255;
	<ESC>  = 61;
	<FK01>  = 130;
	<FK02>  = 128;
	<FK03>  = 107;
	<FK04>  = 126;
	<FK05>  = 104;
	<FK06>  = 105;
	<FK07>  = 106;
	<FK08>  = 108;
	<FK09>  = 109;
	<FK10>  = 117;
	<FK11>  = 111;
	<FK12>  = 119;
	<TLDE>  = 58;
	<AE01>  = 26;
	<AE02>  = 27;
	<AE03>  = 28;
	<AE04>  = 29;
	<AE05>  = 31;
	<AE06>  = 30;
	<AE07>  = 34;
	<AE08>  = 36;
	<AE09>  = 33;
	<AE10>  = 37;
	<AE11>  = 35;
	<AE12>  = 32;
	<BKSP>  = 59;
	<TAB>  = 56;
	<AD01>  = 20;
	<AD02>  = 21;
	<AD03>  = 22;
	<AD04>  = 23;
	<AD05>  = 25;
	<AD06>  = 24;
	<AD07>  = 40;
	<AD08>  = 42;
	<AD09>  = 39;
	<AD10>  = 43;
	<AD11>  = 41;
	<AD12>  = 38;
	<BKSL>  = 50;
	<CAPS>  = 65;
	<AC01>  = 8;
	<AC02>  = 9;
	<AC03>  = 10;
	<AC04>  = 11;
	<AC05>  = 13;
	<AC06>  = 12;
	<AC07>  = 46;
	<AC08>  = 48;
	<AC09>  = 45;
	<AC10>  = 49;
	<AC11>  = 47;
	<RTRN>  = 44;
	<LFSH>  = 64;
	<AB01>  = 14;
	<AB02>  = 15;
	<AB03>  = 16;
	<AB04>  = 17;
	<AB05>  = 19;
	<AB06>  = 53;
	<AB07>  = 54;
	<AB08>  = 51;
	<AB09>  = 55;
	<AB10>  = 52;
	<RTSH>  = 64;
	<LALT>  = 66;
	<LCTL>  = 67;
	<SPCE>  = 57;
	<RCTL>  = 67;
	<RALT>  = 66;
	<LWIN>  = 63;
	<RWIN>  = 63;
	<UP>  = 134;
	<LEFT>  = 131;
	<DOWN>  = 133;
	<RGHT>  = 132;
};

you should get vaguely-sensible results.

This should (hopefully) be the last change required; I thank you for being willing to test this, as I (obviously) don't have a Mac myself.

@hahuang65
Copy link
Author

That is indeed working a lot better. I should thank you for bearing with me and my issues. I really appreciate the amazing support you've given me so far.

I have 2 last issues, 1 larger issue, and 1 smaller issue, and both are limited to it happening within Chrome.

a still doesn't work.
\ outputs | no matter if I hold SHIFT or not.

@r-c-f
Copy link
Owner

r-c-f commented May 28, 2021

xkbcomp doesn't like duplicate symbols, so perhaps

default xkb_keycodes "mac" {
	minimum  = 8;
	maximum  = 255;
	<ESC>  = 61;
	<FK01>  = 130;
	<FK02>  = 128;
	<FK03>  = 107;
	<FK04>  = 126;
	<FK05>  = 104;
	<FK06>  = 105;
	<FK07>  = 106;
	<FK08>  = 108;
	<FK09>  = 109;
	<FK10>  = 117;
	<FK11>  = 111;
	<FK12>  = 119;
	<TLDE>  = 58;
	<AE01>  = 26;
	<AE02>  = 27;
	<AE03>  = 28;
	<AE04>  = 29;
	<AE05>  = 31;
	<AE06>  = 30;
	<AE07>  = 34;
	<AE08>  = 36;
	<AE09>  = 33;
	<AE10>  = 37;
	<AE11>  = 35;
	<AE12>  = 32;
	<BKSP>  = 59;
	<TAB>  = 56;
	<AD01>  = 20;
	<AD02>  = 21;
	<AD03>  = 22;
	<AD04>  = 23;
	<AD05>  = 25;
	<AD06>  = 24;
	<AD07>  = 40;
	<AD08>  = 42;
	<AD09>  = 39;
	<AD10>  = 43;
	<AD11>  = 41;
	<AD12>  = 38;
	<BKSL>  = 50;
	<CAPS>  = 65;
	<AC01>  = 8;
	<AC02>  = 9;
	<AC03>  = 10;
	<AC04>  = 11;
	<AC05>  = 13;
	<AC06>  = 12;
	<AC07>  = 46;
	<AC08>  = 48;
	<AC09>  = 45;
	<AC10>  = 49;
	<AC11>  = 47;
	<RTRN>  = 44;
	<LFSH>  = 64;
	<AB01>  = 14;
	<AB02>  = 15;
	<AB03>  = 16;
	<AB04>  = 17;
	<AB05>  = 19;
	<AB06>  = 53;
	<AB07>  = 54;
	<AB08>  = 51;
	<AB09>  = 55;
	<AB10>  = 52;
	<LALT>  = 66;
	<LCTL>  = 67;
	<SPCE>  = 57;
	<LWIN>  = 63;
	<UP>  = 134;
	<LEFT>  = 131;
	<DOWN>  = 133;
	<RGHT>  = 132;
};

will work. If it doesn't, and the output of wev is reasonable, there's likely a Chromium bug to be sorted out.

@hahuang65
Copy link
Author

Yeh, looks like wev is fine. Still having the same issues as above. I'll play around with this a little more and see if I can figure anything out.

@hahuang65
Copy link
Author

hahuang65 commented May 28, 2021

I'm trying to piece together the keycode map you pasted with wev's output. If I have a line:

[14:     wl_keyboard] key: serial: 9837; time: 12141257; key: 38; state: 1 (pressed)
                      sym: a            (97), utf8: 'a'

does that mean that I should map the letter a to keycode 38?

In this case

<AC01>  = 8;

should be

<AC01>  = 38;

?

@hahuang65
Copy link
Author

Oh, I see... the 38 is when I'm directly connected to the laptop with this keyboard. The 8 comes thru when it's with Synergy.
It does look to be a Chrome (at least Chrome-specific) issue. Firefox works flawlessly.

I can live with Firefox, in fact I prefer Firefox. Thank you for all the help! Feel free to close this if you'd like.

@r-c-f
Copy link
Owner

r-c-f commented May 30, 2021

I've updated the readme and included the working keycodes section in the doc directory so that this is less surprising for future users. Thank you again for the report and the testing.

@hahuang65
Copy link
Author

Thank you for your diligence in helping and all your hard work on this project!

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