Score:0

How to remap (only) mouse keys? (special case)

de flag

I've remapped some mouse keys to help me navigate in firefox, later I'll extend the use to other applications.

In particular, I remapped button 4 of the mouse so that the active web page scrolls up at the beginning, i.e. what happens by pressing the 'Home' key on the keyboard.

The problem is that now if I press button 4 on my keyboard the same thing happens as if I press button 4 on my mouse, ie it's like pressing 'Home.' This doesn't happen with the numeric keypad.

For example, if I'm in a text box and I want to type the number '4' to write '44 cats in a row with the remainder of 2', as soon as I press 4, the cursor returns to the beginning of the line.

I don't understand why, mouse button 4 is the same character 4 of the keyboard, and xev confirms it for me:

mouse key 4 button:

KeyPress event, serial 49, synthetic NO, window 0x4200001,
root 0x78a, subw 0x0, time 2402842, (93,102), root:(964,583),
state 0x10, keycode 13 (keysym 0x34, 4), same_screen YES,
XLookupString gives 1 bytes: (34) "4"
XmbLookupString gives 1 bytes: (34) "4"
XFilterEvent returns: False

keyboard key 4 button:

KeyRelease event, serial 40, synthetic NO, window 0x3200001,
root 0x78a, subw 0x0, time 11553777, (170,-9), root:(1041,472),
state 0x10, keycode 13 (keysym 0x34, 4), same_screen YES,
XLookupString gives 1 bytes: (34) "4"
XFilterEvent returns: False

Below is the xbindkeys configuration code and the script to scrool up the page to the top:

;; mouse #4
(xbindkey '("c:13") "/home/andrea/programmazione/bash-scripts/script-mouse-binding-scroll-up.sh")
;; mouse #7
(xbindkey '("c:16") "/home/andrea/programmazione/bash-scripts/script-mouse-binding-scroll-down.sh")
;; mouse #6
(xbindkey '("c:15") "/home/andrea/programmazione/bash-scripts/script-mouse-key6-binding.sh")

Basically all additional mouse keys 4, 5, 6, 7, 8, 9 are assigned to their respective numbers.

So now my question is intuitive, how do I avoid this behavior? I thought about changing the mouse button mapping from source, i.e. not assigning it the character '4', but I don't know where to start.

Thank you

Zelotes C-13

Score:0
de flag

I solved it using the xkb utility, in fact xkb remaps the keys even for just one device, in my case the mouse keyboard.
Yes basically I found out that the mouse numpads are actually a mini keyboard. This explains the behavior described above.

This below is the script I used to remap the mouse keyboard keys.

#!/bin/bash
remote_id=18 #device code

mkdir -p /tmp/xkb/symbols
cat >/tmp/xkb/symbols/custom <<\EOF

xkb_symbols "remote" {
    key <AE04> { [ Home ] }; #Keycodes, see the link below
    key <AE07> { [ End ] };
    key <AE05> { [ Prior ] };
    key <AE08> { [ Next ] };
};
EOF

setxkbmap -device $remote_id -print \
 | sed 's/\(xkb_symbols.*\)"/\1+custom(remote)"/' \
 | xkbcomp -I/tmp/xkb -i $remote_id -synch - $DISPLAY 2>/dev/null

I located the device code via xinput list from terminal.

Virtual core pointer                          id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ SOAI USB Gaming Mouse                     id=9    [slave  pointer  (2)]
⎜   ↳ SOAI USB Gaming Mouse Keyboard            id=10   [slave  pointer  (2)]
⎜   ↳ ELAN0709:00 04F3:30A0 Mouse               id=12   [slave  pointer  (2)]
⎜   ↳ ELAN0709:00 04F3:30A0 Touchpad            id=13   [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)]
    ↳ Video Bus                                 id=7    [slave  keyboard (3)]
    ↳ Power Button                              id=8    [slave  keyboard (3)]
    ↳ HP TrueVision HD Camera: HP Tru           id=11   [slave  keyboard (3)]
    ↳ Intel HID events                          id=14   [slave  keyboard (3)]
    ↳ Intel HID 5 button array                  id=15   [slave  keyboard (3)]
    ↳ AT Translated Set 2 keyboard              id=16   [slave  keyboard (3)]
    ↳ HP WMI hotkeys                            id=17   [slave  keyboard (3)]
    ↳ SOAI USB Gaming Mouse Keyboard            id=18   [slave  keyboard (3)]

To know the codes related to the keys I used xbindkeys --key from the terminal.

"(Scheme function)"
m:0x10 + c:13
Mod2 + Home

To find out which code of the system corresponds to the code of the key on the mouse keyboard, I have viewed this link.
Instead, to find out the codes of the keys I wanted to assign, I followed the same link but in this section

key <AE04> { [ Home ] }; #Keycodes

On every reboot of the system I run this script

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.