libratbag / piper

GTK application to configure gaming devices
GNU General Public License v2.0
4.74k stars 176 forks source link

Trying to bind acute (´) crashes the application #455

Open Olindholm opened 4 years ago

Olindholm commented 4 years ago

Information

Describe the bug When trying to bind certain keys (acute) the application crashes immediately.

To Reproduce

Steps to reproduce the behavior:

  1. Go to 'Buttons'
  2. Click on a button to bind.
  3. Scroll down to the bottom and choose 'Send Keystroke' image
  4. Press acute (´) button. If you do not have this button immediate on your keyboard. You can run sleep 2 && xdotool key acute in the terminal and quickly switch back to piper. (OBS this requires xdotool)
  5. The application will have crashed by now.

Logs ¯\(ツ)

stephanlachnit commented 4 years ago

Can't test it right now, but sounds interesting. Which keyboard layout do you use, meaning is your acute maybe a dead key? That could be a problem. Can you try to set the macro with ratbagctl?

Also what mouse do you use?

Olindholm commented 4 years ago

Use the terminal command for acute. I have a Logitech G600 Mouse.

I don't know how to use ratbagctl. But I can give you this report. kk

stephanlachnit commented 4 years ago

Thanks for the traceback. I understand the error, so basically the key with number 84 is not defined in linux/input-event-codes.h, that's why there is the error. However, I don't know why the key is missing. Can you do it maybe differently? Like setting a layout with acute (like for example the US one) and try it again, or use ratbagctl and copy acute from somewhere.

Olindholm commented 4 years ago

Well, it seems here is the limitation.

From what I work out from this site, I'd have to run this command, which would've been fine if it were not that the <macro> should consist of as you stated before, code names from linux/input-event-codes.h.

ratbagctl <device> button <N> action set <macro>

As you said, and as far as I can see, the acute button is not defined there anywhere. Thus I couldn't set it using the terminal. I suggest the bug should be fixed by a small popup window saying the pressed key is invalid.

stephanlachnit commented 4 years ago

I checked again and I think ` should be KEY_GRAVE (43), can you try it again with that?

But checking if the button is invalid seems like a good idea, will look into it.

Olindholm commented 4 years ago

It works but doesn't produce the expected character. That is, binding it with ratbagctl worked fine, but it produces a section sign (§ this character). I have this character on my keyboard, so I tried binding that through piper which works fine too. But it's not the button i'd like to bind.

stephanlachnit commented 4 years ago

Hm that's weird, grave should be `. I don't know enough about the input stack, @whot knows more here, but maybe it does depend on your xkb layout, meaning is § the character produced when you press the button left of the 1?

FFY00 commented 4 years ago

Can you run libinput record --show-keycodes and press the target key on your device? This way we can verify if KEY_GRAVE is really being sent.

Olindholm commented 4 years ago

Yes @stephanlachnit. This is correct. I have the swedish QWERTY layout.

Swedish QWERTY

I did previously considering reporting another bug, but I haven't checked whether or not it's known already. Seems like it should. That is, the buttons that piper thinks I have bound, is not always the right buttons. But it works nonetheless so.. ¯\(ツ)/¯. So looking back at my original post, you see I have bound MINUS and EQUAL. This isn't accurate, I've actually bound the two buttons right of 0, which in my layout should be PLUS and ACUTE. However, pressing this ACUTE button doesn't work in all games. An issue I never experience with Windows. But sending the acute button via terminal xdotool key acute all games pick it up, like they should. So clearly my acute button is not the same as sending it with xdotool.

@FFY00 In this sequence, I press section sign (§) (key left of 1) followed by acute (´) (key left of backspace).

sudo libinput record --show-keycodes
Available devices:
/dev/input/event0:  Sleep Button
/dev/input/event1:  Power Button
/dev/input/event2:  Power Button
/dev/input/event3:  Logitech Logitech G933 Gaming Wireless Headset Consumer Control
/dev/input/event4:  Logitech Logitech G933 Gaming Wireless Headset
/dev/input/event5:  Logitech Logitech G933 Gaming Wireless Headset
/dev/input/event6:  Logitech Gaming Mouse G600
/dev/input/event7:  Logitech Gaming Mouse G600 Keyboard
/dev/input/event8:  Logitech Gaming Mouse G600
/dev/input/event9:  Logitech G510 Gaming Keyboard
/dev/input/event10: Logitech G510 Gaming Keyboard Consumer Control
/dev/input/event11: HDA ATI HDMI HDMI/DP,pcm=3
/dev/input/event12: HDA ATI HDMI HDMI/DP,pcm=7
/dev/input/event13: HDA ATI HDMI HDMI/DP,pcm=8
/dev/input/event14: HDA ATI HDMI HDMI/DP,pcm=9
/dev/input/event15: HDA ATI HDMI HDMI/DP,pcm=10
/dev/input/event16: HDA ATI HDMI HDMI/DP,pcm=11
/dev/input/event17: HDA Intel PCH Front Mic
/dev/input/event18: HDA Intel PCH Rear Mic
/dev/input/event19: HDA Intel PCH Line
/dev/input/event20: HDA Intel PCH Line Out Front
/dev/input/event21: HDA Intel PCH Line Out Surround
/dev/input/event22: HDA Intel PCH Line Out CLFE
/dev/input/event23: HDA Intel PCH Front Headphone
Select the device event number: 9
Recording to 'stdout'.
version: 1
ndevices: 1
libinput:
  version: "1.14.1"
  git: "unknown"
system:
  kernel: "5.3.0-26-generic"
  dmi: "dmi:bvnAmericanMegatrendsInc.:bvrB.A0:bd04/24/2017:svnMSI:pnMS-7978:pvr2.0:rvnMSI:rnB150GAMINGM3(MS-7978):rvr2.0:cvnMSI:ct3:cvr2.0:"
devices:
- node: /dev/input/event9
  evdev:
    # Name: Logitech G510 Gaming Keyboard
    # ID: bus 0x3 vendor 0x46d product 0xc22d version 0x111
    # Supported Events:
    # Event type 0 (EV_SYN)
    # Event type 1 (EV_KEY)
    #   Event code 1 (KEY_ESC)
    #   Event code 2 (KEY_1)
    #   Event code 3 (KEY_2)
    #   Event code 4 (KEY_3)
    #   Event code 5 (KEY_4)
    #   Event code 6 (KEY_5)
    #   Event code 7 (KEY_6)
    #   Event code 8 (KEY_7)
    #   Event code 9 (KEY_8)
    #   Event code 10 (KEY_9)
    #   Event code 11 (KEY_0)
    #   Event code 12 (KEY_MINUS)
    #   Event code 13 (KEY_EQUAL)
    #   Event code 14 (KEY_BACKSPACE)
    #   Event code 15 (KEY_TAB)
    #   Event code 16 (KEY_Q)
    #   Event code 17 (KEY_W)
    #   Event code 18 (KEY_E)
    #   Event code 19 (KEY_R)
    #   Event code 20 (KEY_T)
    #   Event code 21 (KEY_Y)
    #   Event code 22 (KEY_U)
    #   Event code 23 (KEY_I)
    #   Event code 24 (KEY_O)
    #   Event code 25 (KEY_P)
    #   Event code 26 (KEY_LEFTBRACE)
    #   Event code 27 (KEY_RIGHTBRACE)
    #   Event code 28 (KEY_ENTER)
    #   Event code 29 (KEY_LEFTCTRL)
    #   Event code 30 (KEY_A)
    #   Event code 31 (KEY_S)
    #   Event code 32 (KEY_D)
    #   Event code 33 (KEY_F)
    #   Event code 34 (KEY_G)
    #   Event code 35 (KEY_H)
    #   Event code 36 (KEY_J)
    #   Event code 37 (KEY_K)
    #   Event code 38 (KEY_L)
    #   Event code 39 (KEY_SEMICOLON)
    #   Event code 40 (KEY_APOSTROPHE)
    #   Event code 41 (KEY_GRAVE)
    #   Event code 42 (KEY_LEFTSHIFT)
    #   Event code 43 (KEY_BACKSLASH)
    #   Event code 44 (KEY_Z)
    #   Event code 45 (KEY_X)
    #   Event code 46 (KEY_C)
    #   Event code 47 (KEY_V)
    #   Event code 48 (KEY_B)
    #   Event code 49 (KEY_N)
    #   Event code 50 (KEY_M)
    #   Event code 51 (KEY_COMMA)
    #   Event code 52 (KEY_DOT)
    #   Event code 53 (KEY_SLASH)
    #   Event code 54 (KEY_RIGHTSHIFT)
    #   Event code 55 (KEY_KPASTERISK)
    #   Event code 56 (KEY_LEFTALT)
    #   Event code 57 (KEY_SPACE)
    #   Event code 58 (KEY_CAPSLOCK)
    #   Event code 59 (KEY_F1)
    #   Event code 60 (KEY_F2)
    #   Event code 61 (KEY_F3)
    #   Event code 62 (KEY_F4)
    #   Event code 63 (KEY_F5)
    #   Event code 64 (KEY_F6)
    #   Event code 65 (KEY_F7)
    #   Event code 66 (KEY_F8)
    #   Event code 67 (KEY_F9)
    #   Event code 68 (KEY_F10)
    #   Event code 69 (KEY_NUMLOCK)
    #   Event code 70 (KEY_SCROLLLOCK)
    #   Event code 71 (KEY_KP7)
    #   Event code 72 (KEY_KP8)
    #   Event code 73 (KEY_KP9)
    #   Event code 74 (KEY_KPMINUS)
    #   Event code 75 (KEY_KP4)
    #   Event code 76 (KEY_KP5)
    #   Event code 77 (KEY_KP6)
    #   Event code 78 (KEY_KPPLUS)
    #   Event code 79 (KEY_KP1)
    #   Event code 80 (KEY_KP2)
    #   Event code 81 (KEY_KP3)
    #   Event code 82 (KEY_KP0)
    #   Event code 83 (KEY_KPDOT)
    #   Event code 85 (KEY_ZENKAKUHANKAKU)
    #   Event code 86 (KEY_102ND)
    #   Event code 87 (KEY_F11)
    #   Event code 88 (KEY_F12)
    #   Event code 89 (KEY_RO)
    #   Event code 90 (KEY_KATAKANA)
    #   Event code 91 (KEY_HIRAGANA)
    #   Event code 92 (KEY_HENKAN)
    #   Event code 93 (KEY_KATAKANAHIRAGANA)
    #   Event code 94 (KEY_MUHENKAN)
    #   Event code 95 (KEY_KPJPCOMMA)
    #   Event code 96 (KEY_KPENTER)
    #   Event code 97 (KEY_RIGHTCTRL)
    #   Event code 98 (KEY_KPSLASH)
    #   Event code 99 (KEY_SYSRQ)
    #   Event code 100 (KEY_RIGHTALT)
    #   Event code 102 (KEY_HOME)
    #   Event code 103 (KEY_UP)
    #   Event code 104 (KEY_PAGEUP)
    #   Event code 105 (KEY_LEFT)
    #   Event code 106 (KEY_RIGHT)
    #   Event code 107 (KEY_END)
    #   Event code 108 (KEY_DOWN)
    #   Event code 109 (KEY_PAGEDOWN)
    #   Event code 110 (KEY_INSERT)
    #   Event code 111 (KEY_DELETE)
    #   Event code 113 (KEY_MUTE)
    #   Event code 114 (KEY_VOLUMEDOWN)
    #   Event code 115 (KEY_VOLUMEUP)
    #   Event code 116 (KEY_POWER)
    #   Event code 117 (KEY_KPEQUAL)
    #   Event code 119 (KEY_PAUSE)
    #   Event code 121 (KEY_KPCOMMA)
    #   Event code 122 (KEY_HANGEUL)
    #   Event code 123 (KEY_HANJA)
    #   Event code 124 (KEY_YEN)
    #   Event code 125 (KEY_LEFTMETA)
    #   Event code 126 (KEY_RIGHTMETA)
    #   Event code 127 (KEY_COMPOSE)
    #   Event code 128 (KEY_STOP)
    #   Event code 129 (KEY_AGAIN)
    #   Event code 130 (KEY_PROPS)
    #   Event code 131 (KEY_UNDO)
    #   Event code 132 (KEY_FRONT)
    #   Event code 133 (KEY_COPY)
    #   Event code 134 (KEY_OPEN)
    #   Event code 135 (KEY_PASTE)
    #   Event code 136 (KEY_FIND)
    #   Event code 137 (KEY_CUT)
    #   Event code 138 (KEY_HELP)
    #   Event code 140 (KEY_CALC)
    #   Event code 142 (KEY_SLEEP)
    #   Event code 150 (KEY_WWW)
    #   Event code 152 (KEY_COFFEE)
    #   Event code 158 (KEY_BACK)
    #   Event code 159 (KEY_FORWARD)
    #   Event code 161 (KEY_EJECTCD)
    #   Event code 163 (KEY_NEXTSONG)
    #   Event code 164 (KEY_PLAYPAUSE)
    #   Event code 165 (KEY_PREVIOUSSONG)
    #   Event code 166 (KEY_STOPCD)
    #   Event code 173 (KEY_REFRESH)
    #   Event code 176 (KEY_EDIT)
    #   Event code 177 (KEY_SCROLLUP)
    #   Event code 178 (KEY_SCROLLDOWN)
    #   Event code 179 (KEY_KPLEFTPAREN)
    #   Event code 180 (KEY_KPRIGHTPAREN)
    #   Event code 183 (KEY_F13)
    #   Event code 184 (KEY_F14)
    #   Event code 185 (KEY_F15)
    #   Event code 186 (KEY_F16)
    #   Event code 187 (KEY_F17)
    #   Event code 188 (KEY_F18)
    #   Event code 189 (KEY_F19)
    #   Event code 190 (KEY_F20)
    #   Event code 191 (KEY_F21)
    #   Event code 192 (KEY_F22)
    #   Event code 193 (KEY_F23)
    #   Event code 194 (KEY_F24)
    #   Event code 240 (KEY_UNKNOWN)
    # Event type 4 (EV_MSC)
    #   Event code 4 (MSC_SCAN)
    # Event type 17 (EV_LED)
    #   Event code 0 (LED_NUML)
    #       State 1
    #   Event code 1 (LED_CAPSL)
    #       State 0
    #   Event code 2 (LED_SCROLLL)
    #       State 0
    #   Event code 3 (LED_COMPOSE)
    #       State 0
    #   Event code 4 (LED_KANA)
    #       State 0
    # Event type 20 (EV_REP)
    #   Event code 0 (REP_DELAY)
    #   Event code 1 (REP_PERIOD)
    # Properties:
    name: "Logitech G510 Gaming Keyboard"
    id: [3, 1133, 49709, 273]
    codes:
      0: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] # EV_SYN
      1: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 113, 114, 115, 116, 117, 119, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 140, 142, 150, 152, 158, 159, 161, 163, 164, 165, 166, 173, 176, 177, 178, 179, 180, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 240] # EV_KEY
      4: [4] # EV_MSC
      17: [0, 1, 2, 3, 4] # EV_LED
      20: [0, 1] # EV_REP
    properties: []
  hid: [5, 1, 9, 6, 161, 1, 117, 1, 149, 8, 5, 7, 25, 224, 41, 231, 21, 0, 37, 1, 129, 2, 149, 1, 117, 8, 129, 1, 149, 5, 117, 1, 5, 8, 25, 1, 41, 5, 145, 2, 149, 1, 117, 3, 145, 1, 149, 6, 117, 8, 21, 0, 38, 255, 0, 5, 7, 25, 0, 42, 255, 0, 129, 0, 192 ]
  udev:
    properties:
    - ID_INPUT=1
    - ID_INPUT_KEY=1
    - ID_INPUT_KEYBOARD=1
    - LIBINPUT_DEVICE_GROUP=3/46d/c22d:usb-0000:00:14.0-10
  quirks:
  events:
  - evdev:
    - [  0,      0,   4,   4, 458792] # EV_MSC / MSC_SCAN             458792
    - [  0,      0,   1,  28,      0] # EV_KEY / KEY_ENTER                 0
    - [  0,      0,   0,   0,      0] # ------------ SYN_REPORT (0) ---------- +0ms
  - evdev:
    - [  2,  99968,   4,   4, 458805] # EV_MSC / MSC_SCAN             458805
    - [  2,  99968,   1,  41,      1] # EV_KEY / KEY_GRAVE                 1
    - [  2,  99968,   0,   0,      0] # ------------ SYN_REPORT (0) ---------- +2099ms
§  - evdev:
    - [  2, 171977,   4,   4, 458805] # EV_MSC / MSC_SCAN             458805
    - [  2, 171977,   1,  41,      0] # EV_KEY / KEY_GRAVE                 0
    - [  2, 171977,   0,   0,      0] # ------------ SYN_REPORT (0) ---------- +72ms
  - evdev:
    - [  2, 751971,   4,   4, 458798] # EV_MSC / MSC_SCAN             458798
    - [  2, 751971,   1,  13,      1] # EV_KEY / KEY_EQUAL                 1
    - [  2, 751971,   0,   0,      0] # ------------ SYN_REPORT (0) ---------- +580ms
  - evdev:
    - [  2, 819923,   4,   4, 458798] # EV_MSC / MSC_SCAN             458798
    - [  2, 819923,   1,  13,      0] # EV_KEY / KEY_EQUAL                 0
    - [  2, 819923,   0,   0,      0] # ------------ SYN_REPORT (0) ---------- +68ms
FFY00 commented 4 years ago

Then you want to remap to KEY_EQUAL as it is the equivalent of grave in your layout.

stephanlachnit commented 4 years ago

The problem with european layouts is that keys like acute are dead keys and XKB is just horrible for anything that is not the US layout. Pressing your ` isn't like a normal button press, it waits for another button to be pressed to do stuff like an è, which causes your troubles. Basically, you can't bind acute if it isn't on your keyboard if I get it right, and the default swedish keyboard only has a dead acute. However, you can use the swedish layout without dead keys, then it should work.

Olindholm commented 4 years ago

No, it isn't right. Just to try it out, I quickly switched to an american layout. The application still crashes when trying to bind acute.

I don't have any problems binding the dead keys. However, they will still be dead keys then, which is not what I want. I wanted it to make an acute symbol.

Something interesting I found. If I try to bind using this terminal command sleep 2 && xdotool key equal. It will show up as LEFTSHIFT DOWN, 0, LEFTSHIFT UP. Which is how I'd make an equal sign. However, it is really unpreferable to have the shift operation etc, because spamming this key now, and another key will result in the other key because capitalized due to the shift operation.

Anyway more on that, writing... sleep 2 && xdotool key mu will also crash the application. Whilst pressing ALTGR, m, ALTGR will bind just fine. Though it has same issue as with the shift.

Why is it, we cannot simply bind the keys to any symbol we want? Clearly somehow the application interprets the 2 different ways of making mu different, so one succeeds and one fails. However, it figures out how to make the equal sign with the keyboard layout, why couldn't it figure out how to make mu (µ)?

Also, when binding using sleep 2 && xdotool key grave, it instead binds the section sign (§), why doesn't it bind to SHIFT, acute because that is how I'd make the grave sign.

Ughh, this is getting stranger by the hour. Anyway, like I stated before. I don't think it's worthwhile to look into why these odd buttons aren't working unless someone really dislikes sleep. The most critical is just to prevent the application from crashing by catching the exception.

stephanlachnit commented 4 years ago

Hm weird that it doesn't work even if you swith to the american layout, have to try it out myself once I can access to my mouse again. Anyway, I don't think it's a good idea that libratbag binds to libinput keys since it's not what the user actually does (kinda), but XKB is such a mess that I don't even know if there's a better way. Linux definitely needs a replacement for XKB, but that's a different topic.

stephanlachnit commented 4 years ago

Sorry for the long delay. I tried it, and I don't get a crash using an American keyboard layout.

Olindholm commented 4 years ago

That is very peculiar. Is it possible that an update of libratbag has fixed this? or there is some other dependency that makes this possible / not possible?

stephanlachnit commented 4 years ago

There was an update but we didn't change anything on the input side of things afaik. If switching to an American layout also crashes the application, I don't know what could be the cause.