You are not logged in.

#1 2020-11-26 23:50:49

MountainX
Member
Registered: 2016-02-08
Posts: 371

libinput: Mouse scrolling options

I just got a Kensington Expert Mouse (which is a trackball). I want to use the trackball + "some button" to scroll pages vertically.

The following gets me toward my goal, but not all the way there:

xinput --set-prop 'Kensington Expert Mouse' 'ScrollMethod' button
xinput --set-prop 'Kensington Expert Mouse' 'libinput Button Scrolling Button' 8
xinput --set-prop 'Kensington Expert Mouse' 'libinput Button Scrolling Button Lock Enabled' 0

EDIT: this is also required. It sets scrolling method to button:

xinput --set-prop 'Kensington Expert Mouse' 'libinput Scroll Method Enabled' 0, 0, 1

On this device, button 8 is the upper right button. I would like to use the CTRL key on my keyboard instead of (preferably in addition to) mouse button 8. How can I do that?

Using the CTRL key (with the trackball movement) is more important than doing the same with the mouse buttons. But I am curious about some things related to the mouse buttons:

1: if I change button 8 to button 2, it stops working. Any idea why? (Button 2 is the upper left button on this device.)

xinput --set-prop 'Kensington Expert Mouse' 'libinput Button Scrolling Button' 2

2. could I enable both buttons 2 and 8 simultaneously for the scrolling function? This way, if I how down either button, I can scroll with the ball.
EDIT: I tried something but it doesn't fully work. I changed the button mapping so that both buttons 2 and 8 are redefined to button 7, then I set button 7 to do the scrolling action like this:

xinput --set-button-map 'Kensington Expert Mouse' 1 7 3 4 5 6 7 7
xinput --set-prop 'Kensington Expert Mouse' 'ScrollMethod' button
xinput --set-prop 'Kensington Expert Mouse' 'libinput Button Scrolling Button' 7

Now the upper left (formerly button 2) does enable scrolling with the trackball. But the upper right button (formerly 8) no longer does. Using xev, both buttons show as button 7 now, and the xev output for both is identical. But only one enables scrolling. Any ideas? (See xev output below.)

3. button 8 maps to "back" in Firefox. How can I disable that?
EDIT: I decided to try remapping button 8 to button 7. That seems to work. I'm not sure if any action is defined for button 7, but so far I haven't noticed any.

Here's some info on my device:

$ xinput list
⎡ Virtual core pointer                          id=2    [master pointer  (3)]
⎜   ...
⎜   ↳ Kensington Expert Mouse                   id=8    [slave  pointer  (2)]

$ egrep "Name|Handlers" /proc/bus/input/devices | egrep -B1 'Handlers.*mouse'
N: Name="Kensington Expert Mouse"
H: Handlers=event2 mouse0

$ grep -e "Using input driver 'libinput'" /var/log/Xorg.0.log
[1463906.917] (II) Using input driver 'libinput' for 'Kensington Expert Mouse'

libinput list-devices
...
Device:           Kensington Expert Mouse
Kernel:           /dev/input/event2
Group:            5
Seat:             seat0, default
Capabilities:     pointer 
Tap-to-click:     n/a
Tap-and-drag:     n/a
Tap drag lock:    n/a
Left-handed:      disabled
Nat.scrolling:    disabled
Middle emulation: disabled
Calibration:      n/a
Scroll methods:   button
Click methods:    none
Disable-w-typing: n/a
Accel profiles:   flat *adaptive
Rotation:         0.0

$ xinput --list-props 'Kensington Expert Mouse'
Device 'Kensington Expert Mouse':
        Device Enabled (153):   1
        Coordinate Transformation Matrix (155): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
        libinput Natural Scrolling Enabled (287):       0
        libinput Natural Scrolling Enabled Default (288):       0
        libinput Scroll Methods Available (289):        0, 0, 1
        libinput Scroll Method Enabled (290):   0, 0, 0
        libinput Scroll Method Enabled Default (291):   0, 0, 0
        libinput Button Scrolling Button (292): 2
        libinput Button Scrolling Button Default (293): 2
        libinput Button Scrolling Button Lock Enabled (294):    0
        libinput Button Scrolling Button Lock Enabled Default (295):    0
        libinput Middle Emulation Enabled (296):        0
        libinput Middle Emulation Enabled Default (297):        0
        libinput Rotation Angle (763):  0.000000
        libinput Rotation Angle Default (764):  0.000000
        libinput Accel Speed (298):     0.200000
        libinput Accel Speed Default (299):     0.000000
        libinput Accel Profiles Available (300):        1, 1
        libinput Accel Profile Enabled (301):   1, 0
        libinput Accel Profile Enabled Default (302):   1, 0
        libinput Left Handed Enabled (303):     0
        libinput Left Handed Enabled Default (304):     0
        libinput Send Events Modes Available (272):     1, 0
        libinput Send Events Mode Enabled (273):        0, 0
        libinput Send Events Mode Enabled Default (274):        0, 0
        Device Node (275):      "/dev/input/event2"
        Device Product ID (276):        1149, 4128
        libinput Drag Lock Buttons (305):       <no items>
        libinput Horizontal Scroll Enabled (306):       1

After remapping both upper buttons to button 7 in an attempt to get them both to enable scrolling, here is the xev output:

The upper left mouse key:

ButtonPress event, serial 50, synthetic NO, window 0x4ac0001,
    root 0x1f5, subw 0x4ac0002, time 1472781573, (40,34), root:(6563,85),
    state 0x10, button 7, same_screen YES

EnterNotify event, serial 50, synthetic NO, window 0x4ac0001,
    root 0x1f5, subw 0x0, time 1472781573, (40,34), root:(6563,85),
    mode NotifyGrab, detail NotifyInferior, same_screen YES,
    focus NO, state 16

KeymapNotify event, serial 50, synthetic NO, window 0x0,
    keys:  4294967285 0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   
           0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   

ButtonRelease event, serial 50, synthetic NO, window 0x4ac0001,
    root 0x1f5, subw 0x4ac0002, time 1472781573, (40,34), root:(6563,85),
    state 0x10, button 7, same_screen YES

LeaveNotify event, serial 50, synthetic NO, window 0x4ac0001,
    root 0x1f5, subw 0x0, time 1472781573, (40,34), root:(6563,85),
    mode NotifyUngrab, detail NotifyInferior, same_screen YES,
    focus NO, state 16

The upper right mouse key:

ButtonPress event, serial 50, synthetic NO, window 0x4ac0001,
    root 0x1f5, subw 0x4ac0002, time 1472788429, (40,34), root:(6563,85),
    state 0x10, button 7, same_screen YES

EnterNotify event, serial 50, synthetic NO, window 0x4ac0001,
    root 0x1f5, subw 0x0, time 1472788429, (40,34), root:(6563,85),
    mode NotifyGrab, detail NotifyInferior, same_screen YES,
    focus NO, state 16

KeymapNotify event, serial 50, synthetic NO, window 0x0,
    keys:  4294967285 0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   
           0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   

ButtonRelease event, serial 50, synthetic NO, window 0x4ac0001,
    root 0x1f5, subw 0x4ac0002, time 1472788605, (40,34), root:(6563,85),
    state 0x10, button 7, same_screen YES

LeaveNotify event, serial 50, synthetic NO, window 0x4ac0001,
    root 0x1f5, subw 0x0, time 1472788605, (40,34), root:(6563,85),
    mode NotifyUngrab, detail NotifyInferior, same_screen YES,
    focus NO, state 16

Last edited by MountainX (2020-11-27 01:51:50)

Offline

#2 2020-12-03 02:43:57

MountainX
Member
Registered: 2016-02-08
Posts: 371

Re: libinput: Mouse scrolling options

Update - I gave up on the more complex setup. I came up with a simple config that does most of what I want.

#!/bin/bash
xinput --set-prop 'Kensington Expert Mouse' 'libinput Accel Speed' 1
xinput --set-prop 'Kensington Expert Mouse' 'libinput Scroll Method Enabled' 0, 0, 1
xinput --set-prop 'Kensington Expert Mouse' 'libinput Button Scrolling Button' 1
xinput --set-prop 'Kensington Expert Mouse' 'libinput Button Scrolling Button Lock Enabled' 0
xinput --set-button-map 'Kensington Expert Mouse' 7 1 2 4 5 6 0 3 9
xinput --set-prop 'Kensington Expert Mouse' 'libinput Natural Scrolling Enabled' 0

This works.

However, when I try to translate that to an xorg config, I cannot get it to work. It either does not map the buttons, or it changes the buttons on my other mouse.

What am I doing wrong with this config?

sudo cat /etc/X11/xorg.conf.d/40-kensington-expert-trackball.conf
Section "InputClass"
    Identifier "Kensington Expert Mouse"
    Option "Name" "Kensington Expert Mouse"
    Driver "libinput"
    Option "AutoServerLayout" "true"
    Option "Accel Speed" "1.0"
    Option "ButtonMapping" "7 1 2 4 5 6 0 3 9"
    Option "Scroll Method Enabled" "0, 0, 1"
    Option "Button Scrolling Button" "1"
    Option "Button Scrolling Button Lock Enabled" "0"
EndSection

See OP above for how I determined the device identifier.

Offline

#3 2020-12-03 08:03:37

seth
Member
Registered: 2012-09-03
Posts: 51,165

Re: libinput: Mouse scrolling options

Using the xinput property strings as X11 options verbatim would be too easy ;-)

see "man 4 libinput"

Offline

#4 2020-12-03 17:30:38

MountainX
Member
Registered: 2016-02-08
Posts: 371

Re: libinput: Mouse scrolling options

seth wrote:

Using the xinput property strings as X11 options verbatim would be too easy ;-)

see "man 4 libinput"

I did look at the man page before. The two sections in the man page are confusing to me. There is "SUPPORTED PROPERTIES" and "CONFIGURATION DETAILS". For example, one lists [libinput Scroll Method Enabled] and the other lists [Option "ScrollMethod"]. I thought that if I listed the driver as libinput, I should use the libinput property strings from the "SUPPORTED PROPERTIES" section of the man page. Is that wrong?

Which of these is correct?

Section "InputClass"
    Identifier "Kensington Expert Mouse"
    Driver "libinput"
    Option "libinput Scroll Method Enabled" "0, 0, 1"
EndSection

or

Section "InputClass"
    Identifier "Kensington Expert Mouse"
    Driver "libinput"
    Option "Scroll Method Enabled" "0, 0, 1"
EndSection

or

Section "InputClass"
    Identifier "Kensington Expert Mouse"
    Driver "libinput"
    Option "ScrollMethod" "button"
EndSection

It seems like I have seen both the first and the last used as examples, but I'm not 100% sure now. I think I have confused myself by trying too many non-working iterations.

Offline

#5 2020-12-03 17:41:30

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,723

Re: libinput: Mouse scrolling options

For xorg.config the Options under Configuration Details are what's relevant. The other properties are runtime properties exposed and manipulateable via xinput as you have noted, I'm not sure what the actual reason for this naming  discrepancy is, but if you are intending to do configuration via xorg config files you need to use the Options methods/strings. So in this example the last option would be correct.

Potentially relevant sidebit, the identifier is not used for identifying the device but is used for the xorg config snippet you are configuring, if you intend this configuration to only apply to a specific device you need to use the MatchProduct/Match* directives of the InputClass ( man 5 xorg.conf ) to narrow down the device to apply the options to.

Offline

#6 2020-12-03 17:51:13

MountainX
Member
Registered: 2016-02-08
Posts: 371

Re: libinput: Mouse scrolling options

V1del wrote:

For xorg.config the Options under Configuration Details are what's relevant.

OK, I appreciate that clarification.

V1del wrote:

So in this example the last option would be correct.

OK.

V1del wrote:

the identifier is not used for identifying the device ... you need to use the MatchProduct/Match* directives of the InputClass ( man 5 xorg.conf ) to narrow down the device to apply the options to.

Yes, that is very helpful. It explains a large part of what was confusing me in my testing. Thanks!

Offline

#7 2020-12-03 17:54:28

MountainX
Member
Registered: 2016-02-08
Posts: 371

Re: libinput: Mouse scrolling options

One more question on this topic. I do not have any other xorg.conf sections or files. Specifically, I don't have a Server Layout section. My understanding from the reading I have done so far is that I don't need any other sections if I am using the Section "InputClass". Is that correct? I'm trying to keep my xorg config very simple.

In fact, I might just use a bash script that runs the xinput commands instead... is that preferred?

Offline

#8 2020-12-03 21:22:52

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,723

Re: libinput: Mouse scrolling options

Yes the point of InputClass and OutputClass and the like sections is to have minimal pieces of configuration that handle a single type of device, this will get propagated to all screens and monitors that might eventually turn up.

Whether that's preferred or simply running the commands is ultimately up to you.

Offline

#9 2020-12-03 21:23:10

seth
Member
Registered: 2012-09-03
Posts: 51,165

Re: libinput: Mouse scrolling options

I don't need any other sections if I am using the Section "InputClass". Is that correct?

Yes.

I'm trying to keep my xorg config very simple.

Good, static server layouts are discouraged.

I might just use a bash script ... is that preferred?

No. Esp. if the device gets re-added (re-plugged, power saving, …) the InputClass configlet will be re-applied, but your script wouldn't run.
If you know the desired setup when the server starts, apply it then.
Runtime scripts are maybe a good idea in a multi-user context where the users have different preferences. Otherwise not.

Edi: oh, c'mon ;-)

Last edited by seth (2020-12-03 21:23:47)

Offline

#10 2020-12-04 01:09:22

MountainX
Member
Registered: 2016-02-08
Posts: 371

Re: libinput: Mouse scrolling options

seth wrote:

I might just use a bash script ... is that preferred?

No. Esp. if the device gets re-added (re-plugged, power saving, …) the InputClass configlet will be re-applied, but your script wouldn't run.
If you know the desired setup when the server starts, apply it then.
Runtime scripts are maybe a good idea in a multi-user context where the users have different preferences. Otherwise not.

Those are good points. In terms of applying the desired setup when the server starts, is the xorg config file the best choice? Thank you.

Offline

#11 2020-12-04 01:22:34

MountainX
Member
Registered: 2016-02-08
Posts: 371

Re: libinput: Mouse scrolling options

Here's what I came up with. Won't be able to test it until tomorrow. Does it look OK?

Section "InputClass"
    Identifier "Kensington Expert Mouse"
    Option "Name" "Kensington Expert Mouse"
    MatchProduct  "Kensington Expert Mouse"
    Driver "libinput"
    Option "AccelSpeed" "1.0"
    Option "ButtonMapping" "7 1 2 4 5 6 0 3 9"
    Option "ScrollMethod" "button"
    Option "ScrollButton" "1"
    Option "ScrollButtonLock" "false"
EndSection

I got the product name for the MatchProduct directive from this info:

$ xinput list
⎡ Virtual core pointer                          id=2    [master pointer  (3)]
⎜   ...
⎜   ↳ Kensington Expert Mouse                   id=8    [slave  pointer  (2)]

$ egrep "Name|Handlers" /proc/bus/input/devices | egrep -B1 'Handlers.*mouse'
N: Name="Kensington Expert Mouse"
H: Handlers=event2 mouse0

$ grep -e "Using input driver 'libinput'" /var/log/Xorg.0.log
[1463906.917] (II) Using input driver 'libinput' for 'Kensington Expert Mouse'

libinput list-devices
...
Device:           Kensington Expert Mouse

I don't know what method Xorg will use to determine the device's product name, but in my case, everything returns 'Kensington Expert Mouse'. However, I would like to know where Xorg pulls the value from.

Offline

#12 2020-12-04 07:08:40

seth
Member
Registered: 2012-09-03
Posts: 51,165

Re: libinput: Mouse scrolling options

is the xorg config file the best choice

Don't use /etc/X11/xorg.conf but a configlet in the modular /etc/X11/xorg.conf.d/ (the filename doesn't matter aside te suffix, but number-description.conf is a good idea)

Option "Name" "Kensington Expert Mouse"

I don't think this is a valid option.

Option "ScrollButtonLock" "false"

Not wrong, but also the default.

MatchProduct is the relevant match and it should match the entry in the "xinput" output.
nb. that some devices register as keyboard AND mouse in which case you might want to utilize one of

       MatchIsKeyboard     "bool"
       MatchIsPointer      "bool"
       MatchIsJoystick     "bool"
       MatchIsTablet       "bool"
       MatchIsTabletPad    "bool"
       MatchIsTouchpad     "bool"
       MatchIsTouchscreen  "bool"

Offline

Board footer

Powered by FluxBB