Find the answer to your Linux question:
Results 1 to 3 of 3
Hello Though this thread is old, I have the same problem, I have a MX 518 which as 5 additionnal buttons, I'm trying to bind the thumb button to Control ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Sep 2010
    Posts
    3

    [SOLVED] map mouse button to a modifier key


    Hello

    Though this thread is old, I have the same problem, I have a MX 518 which as 5 additionnal buttons, I'm trying to bind the thumb button to Control or Shift.

    I'm fighting against it since yesterday, I tried many things : easystroke, imwheel, xbindkeys/xvkbd
    I'm a bit new to Linux so I can still miss something very important.
    I read a tutorial about that mouse, all went well but it isn't explained how to set up what I wish.

    I'm still searching and will post if I manage to fix it, but I'd like some help to be able to play my favourite game with my usual binds! Mouahaha!

    Merci !

    [Edit : Thanks for the del/move]

  2. #2
    Just Joined!
    Join Date
    Sep 2010
    Posts
    3
    I just got a bit ahead but still not working as expected... I'm using xbindkeys and xdotool :
    I tried these GUILE configuration files, xdotool fakes keypresses.

    Sends ctrl key down when the mouse button is pressed, sends ctrl key up + clear all modifiers when released :
    Code:
    (xbindkey '("b:12") "xdotool keydown ctrl ")
    (xbindkey '( release "b:12") "xdotool keyup --clearmodifiers ctrl ")
    Slightly different :
    Code:
    (xbindkey '("b:12") "xdotool keydown ctrl ")
    (xbindkey '( release "b:12") "xdotool keyup ctrl ")
    The snippets quoted above work if I press the mouse button twice, then ctrl seems to be locked
    down, the result is kinda messy : no left click, no typing etc...

    There instead of sending the ctrl on release I put an unused keycode + the clear modifiers :
    Code:
    (xbindkey '("b:12") "xdotool keydown ctrl ")
    (xbindkey '( release "b:12") "xdotool key --clearmodifiers 0x0dde ")
    This works, the toggle seems ok but when looking at xev | grep keycode events, it is not what I expected.

    The answer could be somewhere inside the modifiers passed to xbindkeys...
    Still working on it...We will see

  3. #3
    Just Joined!
    Join Date
    Sep 2010
    Posts
    3
    I has done it !
    Code:
    ;;Modifiers keys on mouse :
    ;;Control
    (xbindkey '("m:0x14" "b:12") "xdotool keydown ctrl")
    (xbindkey '( Release "m:0x14" "b:12") "xdotool keyup ctrl")
    
    (xbindkey '("b:12") "xdotool keydown ctrl")
    (xbindkey '( Release "b:12") "xdotool keyup ctrl")
    
    ;;Shift
    (xbindkey '("b:10") "xdotool keydown shift")
    (xbindkey '( Release "b:10") "xdotool keyup shift")
    
    (xbindkey '("m:0x11" "b:10") "xdotool keydown shift")
    (xbindkey '( Release "m:0x11" "b:10") "xdotool keyup shift")
    I've noticed with xev that the modifier part of the event (m:0x[mod]) wasn't the same depending on the previous state of the modifier, that's why it was kept locked. So I just added another case for both ctrl and shift modifiers (m:0x14 and m:0x11).
    Do xev | grep keycode with NumLock on :
    Press ctrl once, two lines appear starting with "state 0x10" or something.
    The first one is the state when the key is pressed. The second is the state AFTER the release of the key and this state has to be added to your xbindkeys configuration.
    If you want to bind Ctrl or Shift or any other mod, take my code, replace the mouse button ID ("b:__") and replace the "m:0x__" with the state you get in xev on the release of your modifier key.

    I hope this will help.
    I'm not good at GUILE scripting but I am pretty sure there's another way to get this working.

  4. $spacer_open
    $spacer_close

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •