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

How to assign multiple keypresses #18

Open
hooliowobbits opened this issue May 25, 2020 · 3 comments
Open

How to assign multiple keypresses #18

hooliowobbits opened this issue May 25, 2020 · 3 comments

Comments

@hooliowobbits
Copy link

Hi mate, thanks heaps for your efforts, I really appreciate what you have done and thanks so much for taking the time to document it and and publish it; it's awesome.

I was able to get ratslap working OK, and If i assign a single button it works fine; here i assign the number 5 key to mouse button 5:

$ ./ratslap --modify F4 --g5 5
RatSlap v0.3.2 (BUILT: 2020-05-25 13:48:43+1000)
Copyright (C) 2016-2020 Todd Harbour
Linux configuration tool for Logitech mice (currently only G300/G300S)
https://gitlab.com/krayon/ratslap/
Found Logitech G300s (046d:c246) @ 0x562f2320dcd0
Detaching kernel driver...
Modifying Mode: F4
    Setting button 5: 5
Saving Mode: F4
Attaching kernel driver...

As per your example I can use the + modifier OK:

./ratslap --modify F4 --g5 LeftCtrl+TAB
RatSlap v0.3.2 (BUILT: 2020-05-25 13:48:43+1000)
Copyright (C) 2016-2020 Todd Harbour
Linux configuration tool for Logitech mice (currently only G300/G300S)
https://gitlab.com/krayon/ratslap/
Found Logitech G300s (046d:c246) @ 0x563cebc8dcd0
Detaching kernel driver...
Modifying Mode: F4
    Setting button 5: LeftCtrl+TAB
Saving Mode: F4
Attaching kernel driver...

However if i use the + syntax to assign both numbers 5 and 6 to mouse button 5 i get an error:

./ratslap --modify F4 --g5 5+6
RatSlap v0.3.2 (BUILT: 2020-05-25 13:48:43+1000)
Copyright (C) 2016-2020 Todd Harbour
Linux configuration tool for Logitech mice (currently only G300/G300S)
https://gitlab.com/krayon/ratslap/
Found Logitech G300s (046d:c246) @ 0x560cb5071cd0
Detaching kernel driver...
Modifying Mode: F4
    Setting button 5: 5+6
20200525T151150+1000 [E]           main.c:01226:set_mode_button ERROR: Invalid modifier (5) specified: 5+6
Saving Mode: F4
Attaching kernel driver...
@krayon
Copy link
Owner

krayon commented May 25, 2020

No problems at all, thank YOU for trying it out and the kind words :)

Unfortunately, you are limited to ONE key with modifiers. The modifiers are hard coded ( as per --listkeys ):

  • LeftCtrl
  • LeftShift
  • LeftAlt
  • Super_L
  • RightCtrl
  • RightShift
  • RightAlt
  • Super_R

Unfortunately this is a limitation of the firmware. The only way around this were if you had a running process that would capture a known combo and then produce the keys.

This could be achieved using xbindkeys(1) to detect the combo, then xdotool to type the keys.

@hooliowobbits
Copy link
Author

hooliowobbits commented May 25, 2020

I had explored xbindkeys + xdotool already and I was able to get them to work (see below); however they did not work within the proton/steam-play game "Grim Dawn.exe". Getting combos/macros working into these games is apparently non trivial. I'm still exploring other options.

xbindkeys + xdotool use with ratslap
setup g300s to send Button6 with ratslap

$./ratslap -mf4 --g5 Button6

to test what that actually did, I can identify the button with xev. it appears however that xev can't detect the buttons properly if xbindkeys is running, so we kill it first.

$ killall xbindkeys
$ xev | grep -i button

then click inside the little xev test window and see what i get on the console

ButtonPress event, serial 38, synthetic NO, window 0x2400001,
    state 0x0, button 8, same_screen YES
ButtonRelease event, serial 38, synthetic NO, window 0x2400001,
    state 0x0, button 8, same_screen YES

curious it calls that button 8 when i coded it as Button6. regardless..
configure .xbindkeysrc as follows:

# Button 8
"xdotool key 5 6"
b:8

kill any xbindkeys and restart it

$ killall xbindkeys
$ xbindkeys -f ~/.xbindkeysrc

and now when i press my g5 button 3 times, i get

565656

@krayon
Copy link
Owner

krayon commented Jun 4, 2020

I had explored xbindkeys + xdotool already and I was able to get them to work (see below); however they did not work within the proton/steam-play game "Grim Dawn.exe". Getting combos/macros working into these games is apparently non trivial. I'm still exploring other options.

I would try a key vs a mouse button too - might make a difference with the above and/or:

it appears however that xev can't detect the buttons properly if xbindkeys is running, so we kill it first.

curious it calls that button 8 when i coded it as Button6. regardless..

Does xmodmap show a one for one mapping?

xmodmap -pp

Mouse buttons work very different to keys and in fact the mouse even presents as different devices to deliver these events. I would certainly try keys as well, just in case. It doesn't even have to be one you have on your keyboard, eg F13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants