r-c-f / waynergy

A synergy client for Wayland compositors
MIT License
394 stars 17 forks source link

Can't get key combos to register #84

Closed dat-gitto-kid closed 1 year ago

dat-gitto-kid commented 1 year ago

Hello,

I've been having an issue with Waynergy that I'm quite sure is user error but I can't see any way to fix it from my limited troubleshooting knowledge.

Any time I use my external keyboard directly connected to the Arch client, I can use SUPER as my modifier and work normally. When connected to the macOS host and then being controlled via waynergy, the SUPER modifier does not seem to do anything (although the keys are getting passed along according to wev). All the individual keys (i.e. the xkb keycodes/mapping) seem to work fine

If anybody sees anything wrong with my config or has any ideas to figure out a solution I'd be more than grateful!

.config/waynergy/config.ini

#Example configuration (in INI format)

host = 192.168.2.223
#port = 28400
name = LINUX
width = 5760
height = 1080
xkb_key_offset = 7
wl_keyboard_map = false
syn_raw_key_codes = true

[screensaver]
#start = pkill -SIGUSR1 #swayidle
#stop = pkill swaylock

[idle-inhibit]
method = key
keyname = HYPR

[tls]
enable = true
tofu = true

[log]
level = 4
mode = a
path = /tmp/waynergy.log

.config/waynergy/xkb_keymap

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

.config/xkb/keycodes/mxk4bw

xkb_keycodes "mxk4bw" {
    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;
    <HOME> = 123;
    <PGUP> = 124;
    <NMLK> = 79;
    <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;
    <DELE> = 125;
    <END>  = 127;
    <PGDN> = 129;
    <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> = 68;
    <LCTL> = 67;
    <LWIN> = 66;
    <LALT> = 63;
    <SPCE> = 57;
    <RALT> = 62;
    <RCTL> = 69;
    <KPEN> = 84;
    <LEFT> = 131;
    <RGHT> = 132;
    <DOWN> = 133;
    <UP>   = 134;
};

Thanks! :)

EDIT:

Including some wev output for the SUPER+Q (Launch Terminal bind)

[14:     wl_keyboard] key: serial: 15695; time: 13669113; key: 66; state: 1 (pressed)
                      sym: Super_L      (65515), utf8: ''
[14:     wl_keyboard] modifiers: serial: 0; group: 0
                      depressed: 00000040: Mod4 
                      latched: 00000000
                      locked: 00000000
[14:     wl_keyboard] key: serial: 15697; time: 13669308; key: 20; state: 1 (pressed)
                      sym: q            (113), utf8: 'q'
[14:     wl_keyboard] key: serial: 15698; time: 13669444; key: 20; state: 0 (released)
                      sym: q            (113), utf8: ''
[14:     wl_keyboard] key: serial: 15699; time: 13669645; key: 66; state: 0 (released)
                      sym: Super_L      (65515), utf8: ''
[14:     wl_keyboard] modifiers: serial: 0; group: 0
                      depressed: 00000000
                      latched: 00000000
                      locked: 00000000
r-c-f commented 1 year ago

Which compositor are you using? This is weird indeed.

dat-gitto-kid commented 1 year ago

Hyprland

I did some more testing and short of any other ideas, I might try with raw-keymaps instead of the xkb map for the Ctrl/Alt/Super keys

On Tue, Jun 27, 2023, 09:49 r-c-f @.***> wrote:

Which compositor are you using? This is weird indeed.

— Reply to this email directly, view it on GitHub https://github.com/r-c-f/waynergy/issues/84#issuecomment-1609661288, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALCPQ5LTTNK55BAC56DS4X3XNLXHJANCNFSM6AAAAAAZSU2OVM . You are receiving this because you authored the thread.Message ID: @.***>

dat-gitto-kid commented 1 year ago

After more playing around, I tried specifying raw keymaps (which seem to work okay), but I've now thoroughly confused myself.

From left to right, these are the keycodes I see (confirmed in wev) when I press the following keys, keyboard directly connected to the Linux client: Control_L -> 37 Super_L -> 133 Alt_L -> 64

When connected via the macOS host, however (and specified in a raw keymap with no offset) I get different symbols for the same keycodes: 0 -> 37 Down -> 133 Shift_L -> 64

I guess my question is, which keycodes/keymap does wev look at and is there a way to tell what it thinks the right keycode is for the 3 little problem keys I'm trying to fix?

One odd thing I also found was that the macOS host was sending one code while it was offset by 1 in the Waynergy log (despite my 0 offset being set in the config): [macOS synergy 1 sent as] -> [received by waynergy as] 59 -> 60 58 -> 59 55 -> 56

Current config.ini

#Example configuration (in INI format)

host = 192.168.2.223
#port = 28400
name = LINUX
width = 5760
height = 1080
xkb_key_offset = 7
wl_keyboard_map = false
syn_raw_key_codes = true

[screensaver]
#start = pkill -SIGUSR1 #swayidle
#stop = pkill swaylock

[idle-inhibit]
method = key
keyname = HYPR

[tls]
enable = true
tofu = true

[log]
level = 4
mode = a
path = /tmp/waynergy.log

[raw-keymap]
offset=0
offset_on_explicit = false
60=37
59=133
56=64
dat-gitto-kid commented 1 year ago

Getting closer! I now have some combos working so I think it's more a Hyprland thing than anything else at the moment.

The key was to keep the modifiers in the xkb_keymap AND in the raw keymap (using waynergy-mapper, no arguments; tried specifying '-r' even though it's the default but it kept giving me an xkb map) section. I'll post configs when I get the chance but it's looking better...

r-c-f commented 1 year ago

(sorry for the delay, real life issues got in the way...)

Generally I'd advise just going for the raw keymap, using waynergy-mapper. That seemed to work well for the last macOS user I spoke to. The one issue would be if the shortcut inhibition protocol isn't supported, but that would have yielded an error.

dat-gitto-kid commented 1 year ago

I completely understand, and appreciate your help!

I took your suggestion and tried going raw keymap for all keys which wound up working beautifully! I now have shortcuts as if I was directly connected to the client.

Thank you very much and I appreciate all that you've done with building Waynergy!

For anyone else, the below config (no xkb_keymap anymore! :) ) should work for a Logitech MX Keys for Business (Bolt Receiver) connected to a macOS host with a Hyprland client on Arch Linux using Synergy 1.14.

~/.config/waynergy/config.ini

#Example configuration (in INI format)

host = 192.168.2.223
#port = 28400
name = LINUX
width = 5760
height = 1080
#xkb_key_offset = 7
wl_keyboard_map = true
syn_raw_key_codes = true

[screensaver]
#start = pkill -SIGUSR1 #swayidle
#stop = pkill swaylock

[idle-inhibit]
method = key
keyname = HYPR

[tls]
enable = true
tofu = true

[log]
level = 4
mode = a
path = /tmp/waynergy.log

[raw-keymap]
54 = 9
19 = 10
20 = 11
21 = 12
22 = 13
24 = 14
23 = 15
27 = 16
29 = 17
26 = 18
30 = 19
28 = 20
25 = 21
52 = 22
49 = 23
13 = 24
14 = 25
15 = 26
16 = 27
18 = 28
17 = 29
33 = 30
35 = 31
36 = 33
31 = 35
37 = 36
60 = 37
1 = 38
2 = 39
3 = 40
4 = 41
6 = 42
5 = 43
39 = 44
41 = 45
38 = 46
42 = 47
40 = 48
51 = 49
43 = 51
7 = 52
8 = 53
9 = 54
10 = 55
12 = 56
46 = 57
47 = 58
44 = 59
48 = 60
45 = 61
57 = 62
68 = 63
56 = 64
50 = 65
58 = 66
123 = 67
121 = 68
100 = 69
119 = 70
97 = 71
98 = 72
99 = 73
101 = 74
102 = 75
110 = 76
72 = 77
90 = 79
92 = 80
93 = 81
79 = 82
87 = 83
88 = 84
89 = 85
70 = 86
84 = 87
85 = 88
86 = 89
83 = 90
69 = 91
104 = 95
112 = 96
77 = 104
76 = 106
116 = 110
127 = 111
117 = 112
124 = 113
125 = 114
120 = 115
126 = 116
122 = 117
118 = 119
59 = 133
simonm commented 10 months ago

Sorry to necro a closed issue, but I wanted to confirm that these raw codes worked well for me. Arch, Hyprland client; macOS server with Keychron external keyboard. This saved me a lot of time and scratching of my head. Thank you @dat-gitto-kid !!

gac3k commented 8 months ago

@dat-gitto-kid Hey, thanks for the config, saved me a lot of hassle :D One question though, since I am using MX Keys as well, in exactly the configuration you provided. And because it's plenty of time passed since you originally posted this, did you also manage to figure out a configuration for a function keys to work? I mean FN + F1-12

dat-gitto-kid commented 8 months ago

@dat-gitto-kid Hey, thanks for the config, saved me a lot of hassle :D One question though, since I am using MX Keys as well, in exactly the configuration you provided. And because it's plenty of time passed since you originally posted this, did you also manage to figure out a configuration for a function keys to work? I mean FN + F1-12

Anytime!

To make a long story short, I never really tried to figure out the function keys, mostly because I never use them on my client machine.

From what I remember though, the FN key is never detected so unless the FN+[whatever] key outputs a different code altogether, they all (1-12) might not work. I think I remember Vol Up outputting a code but like you said, it's been a while.

I'm not in front of my desk until next week, otherwise I'd gen a config for you.

Best of luck!