19

I know I can use xinput to remap mouse buttons on only one mouse but leave others unchanged. This is very useful. In my case, I use it to connect two mice to my desktop, one right-handed and the other left-handed.

Can something like this also be done when there's more than one keyboard connected? Can I remap keys to other keys on one keyboard, and leave others unchanged?

In my specific case my mouse appears to be registered as an additional keyboard and its 6th and 7th button are translated to pageup and pagedown, I would like to bind them to copy/paste instead - but I don't want to affect the regular pageup and pagedown keys on my standard keyboard.

Here's how the output of xinput looks - the keyboard in question is with id 10:

$ xinput
⎡ Virtual core pointer                      id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ SteelSeries Diablo III Gaming Mouse       id=9    [slave  pointer  (2)]
⎜   ↳ SteelSeries Diablo III Gaming Mouse       id=11   [slave  pointer  (2)]
⎜   ↳ Logitech USB Optical Mouse                id=12   [slave  pointer  (2)]
⎣ Virtual core keyboard                     id=3    [master keyboard (2)]
    ↳ Virtual core XTEST keyboard               id=5    [slave  keyboard (3)]
    ↳ Power Button                              id=6    [slave  keyboard (3)]
    ↳ Power Button                              id=7    [slave  keyboard (3)]
    ↳ Creative Technology Ltd SB Tactic3D Rage USB  id=8    [slave  keyboard (3)]
    ↳ SteelSeries Diablo III Gaming Mouse       id=10   [slave  keyboard (3)]
    ↳ Logitech USB Keyboard                     id=13   [slave  keyboard (3)]
    ↳ Logitech USB Keyboard                     id=14   [slave  keyboard (3)]
    ↳ HP WMI hotkeys                            id=15   [slave  keyboard (3)]
Jon S.
  • 90
  • 6
Oak
  • 291
  • 1
  • 8
  • 4th and 5th are the up and down scroll, is that what you mean? – Tim Jul 17 '14 at 14:34
  • @Tim I mean my two side buttons; they're not actually mapped to mouse buttons anyway. – Oak Jul 17 '14 at 14:36
  • 1
    Can you post the output of xinput? – Tim Jul 17 '14 at 14:39
  • @Tim added. But is that really needed? Is there no generic solution for this question, regardless of my setup? – Oak Jul 17 '14 at 14:43
  • 1
    if you run the command `xinput float 10` does the mouse stop working at all? Then run `xinput reattach 10 3` – Tim Jul 17 '14 at 14:46
  • @Tim it stops the mouse side buttons from working, but does not affect anything else in the mouse. – Oak Jul 20 '14 at 08:24
  • Run the command `xev`, hover in the black box then click the mouse button you want to change. What output does it give? (You will need to terminate it (Ctrl+C) then scroll up a bit). – Tim Jul 21 '14 at 07:23
  • @Tim `keycode 117 (keysym 0xff56, Next)`. I used `xev` before, that's how I realized the mouse is acting as a keyboard. – Oak Jul 21 '14 at 09:00
  • Right, got it! Now I understand the question. What happens if you float id 9 and 11 - do any of the buttons work? – Tim Jul 21 '14 at 09:40
  • @Tim floating 9 disables mouse movement and regular mouse buttons, but not the side buttons. Floating 11 appears to do nothing. – Oak Jul 21 '14 at 11:32
  • Could you post `lsusb -t`, I want to know which driver is used by that mouse? – user.dz Feb 24 '15 at 17:57
  • I can think of a way to do it, but not of a way to make it efficient. but perhaps, you could make a script, and run the script when the keyboard is plugged in. then have a check go to lsusb -v for the productID them, if the device is present, remap the keyboard. but what if you remove the keyboard? rerun the script for layout maybe. would that be acceptable? otherwise youll be running a background process to identify your keyboard. that could be more resource intensive than you might like) – j0h Mar 30 '15 at 18:43

2 Answers2

1

Your question is more about remapping mouse buttons than keyboard buttons, right ? I think ImWheel can remap several devices. I use it and have a writeup here: http://www.gdargaud.net/Hack/LinuxMouse.html

dargaud
  • 880
  • 3
  • 12
  • 24
0

This can't be done with xinput/xf86-input-evdev, you would have to do it directly in evdev, check out evtest package.