r-c-f / waynergy

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

Issue: [raw-keymap] cannot unbind left arrow key from system shutdown #73

Open moghingold opened 1 year ago

moghingold commented 1 year ago

Host: Mac OS Client: Arch linux with KDE

Reproduction steps:

Expected result:

Actual result:

Mitigations attempted:

Mitigations not attempted:

r-c-f commented 1 year ago

When using a hardware keyboard, what is the key code registered by xev/wev for normal (ie not shutting down) left arrow?

moghingold commented 1 year ago

When you say hardware keyboard, do you mean plugging this USB keyboard directly into my Linux box or do you mean the Linux box's built-in keyboard (since it's a laptop)? I'll try both and hope you wanted at least one of them:

Plugging the keyboard directly into the laptop:

[14:     wl_keyboard] key: serial: 13284; time: 21200041; key: 113; state: 1 (pressed)
                      sym: Left         (65361), utf8: ''
[14:     wl_keyboard] key: serial: 13285; time: 21200110; key: 113; state: 0 (released)
                      sym: Left         (65361), utf8: ''

The laptop's own left arrow key:

[14:     wl_keyboard] key: serial: 13645; time: 21297606; key: 113; state: 1 (pressed)
                      sym: Left         (65361), utf8: ''
[14:     wl_keyboard] key: serial: 13646; time: 21297675; key: 113; state: 0 (released)
                      sym: Left         (65361), utf8: ''
r-c-f commented 1 year ago

Could you post the waynergy output with -L debug when this happens, as well as the full keymap that waynergy-mapper generated?

moghingold commented 1 year ago

Where does waynergy write its logs so I can send you the output after the computer shuts down? Should I just redirect it eg: waynergy -L debug > foo.txt 2>&1? Unless directed otherwise before my kernel finishes building that is what I will try, and report back.

moghingold commented 1 year ago

Before I make my laptop shut down, here is the raw keymap that is currently in config.ini. Please pay no attention to the numlock and kp_enter entries, that's another issue.

[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
57 = 50
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
59 = 64
50 = 65
58 = 66
123 = 67
121 = 68
100 = 69
119 = 70
97 = 71
98 = 72
77 = 104
72 = 77
99 = 73
101 = 74
102 = 75
110 = 76
108 = 78
90 = 79
92 = 80
93 = 81
79 = 82
87 = 83
88 = 84
89 = 85
70 = 86
84 = 87
85 = 88
86 = 89
83 = 90
66 = 91
104 = 95
112 = 96
60 = 105
76 = 106
106 = 107
59 = 108
116 = 110
127 = 111
125 = 114
120 = 115
126 = 116
115 = 118
118 = 119
0 = 121
0 = 122
0 = 123
114 = 127
56 = 133
56 = 134
111 = 135
113 = 113
moghingold commented 1 year ago

Running waynergy with the following command:

/usr/bin/waynergy -b kde -e -t -L debug 2>&1 | tee /home/moghingold/.config/waynergy/waynergy-debug.log

I get the following debug output right before the computer shuts down:

298.874354896: [DEBUG] Modifiers: depressed: 0 latched: 0 locked: 0 group: 0
298.874371047: [DEBUG] Keycode: 124, state 1
298.933081293: [DEBUG] Modifiers: depressed: 0 latched: 0 locked: 0 group: 0
298.933096482: [DEBUG] Keycode: 124, state 0
300.452811456: [DEBUG] Got CALV

So it looks like the 'left' arrow key is being mapped to 124 instead of 113 when it's coming over Barrier from on the Mac. Unsurprisingly, waynergy-mapper reports that key 124 is the POWR key and maps to XF86PowerOff. Appending 124 = 113 to the end of the raw-keymap section of config.ini fixed this issue.

r-c-f commented 1 year ago

I'm thinking that the actual resolution of this will be a change such that waynergy-mapper operates at the network level rather than as a simple wayland client. That would prevent any unfortunate erroneous bindings from being triggered in the compositor.