Bug 32533 - RFE: Allow re-mapping of button 6, button 7 scroll wheel functionality
Summary: RFE: Allow re-mapping of button 6, button 7 scroll wheel functionality
Status: RESOLVED NOTABUG
Alias: None
Product: xorg
Classification: Unclassified
Component: Input/evdev (show other bugs)
Version: 7.5 (2009.10)
Hardware: All Linux (All)
: medium enhancement
Assignee: Peter Hutterer
QA Contact: Xorg Project Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-20 12:56 UTC by Rick Stockton <AKA rickst29>
Modified: 2011-01-05 14:27 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Rick Stockton <AKA rickst29> 2010-12-20 12:56:22 UTC
On a mouse with tilt-wheel functionality, some users may prefer to have tilt-left and tilt-right treated as "normal" buttons. (I.e., via ButtonPress and ButtonRelease events, rather than continuous "spinning" of ButtonPress events.)

Some other users with "gaming" mice might like to use a different button for these functions -- e.g., implementing "scroll left" on a thumb wheel. I wonder, could evdev be modified to do this on the basis of user-defined button mapping?

I attempted the following map for my 9-button mouse:
 
xinput set-button-map 9 1 2 3 4 5 8 9 10 11 12 13 

(The default mapping is "1 2 3 4 5 6 7 8 9 10 11 12 13", of course.) xev shows that my thumb buttons now emit "Button 10" and "Button 11" press/release events, as requested. But "Button 6", "Button 7" still behave as continuous scrolling actions, and the events still appear with e*->button as #6 and #7.
- - - - -

If the correct product is the Server, rather than the Driver, please fix that Component selection. I'm asking in advance of submitting some patches to enhance support for "more buttons!" in Qt-x11 and the KDE desktop. (Two of the top-twenty KDE enhancement requests are about this.) I can do a lot without this change, but it would be an easy way to get out of all the "Does it HAVE TO spin like that?" questions which will happen without this feature. With the enhancement the response would be, "It's a basic feature of X11 - but you can avoid it by remapping your mouse buttons..." put right inside the help files. Without, I'll probably be getting bug-spam for years. ;)

Thanks for reading.
Comment 1 Peter Hutterer 2010-12-20 23:18:00 UTC
what's the evtest output for these buttons? we send one click event (one press, one release) for each ABS_WHEEL event, so we'd have to put some filtering logic in
Comment 2 Rick Stockton <AKA rickst29> 2010-12-21 12:26:37 UTC
Peter, here's what I get with Button4 (each single indent of of the wheel gets it's own ButtonRelease evt):

ButtonPress event, serial 31, synthetic NO, window 0xec00001,
    root 0x15a, subw 0xec00002, time 13799052, (23,37), root:(31,70),
    state 0x10, button 4, same_screen YES

EnterNotify event, serial 31, synthetic NO, window 0xec00001,
    root 0x15a, subw 0x0, time 13799052, (23,37), root:(31,70),
    mode NotifyGrab, detail NotifyInferior, same_screen YES,
    focus YES, state 2064

KeymapNotify event, serial 31, synthetic NO, window 0x0,
    keys:  90  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 31, synthetic NO, window 0xec00001,
    root 0x15a, subw 0xec00002, time 13799052, (23,37), root:(31,70),
    state 0x810, button 4, same_screen YES

LeaveNotify event, serial 31, synthetic NO, window 0xec00001,
    root 0x15a, subw 0x0, time 13799052, (23,37), root:(31,70),
    mode NotifyUngrab, detail NotifyInferior, same_screen YES,
    focus YES, state 16
Comment 3 Rick Stockton <AKA rickst29> 2010-12-21 12:37:38 UTC
Thanks for the comment- I *did* fail to notice the matching ButtonRelease events. Here's what I get with Button6 (tilt left):


ButtonPress event, serial 34, synthetic NO, window 0xec00001,
    root 0x15a, subw 0xec00002, time 14357412, (41,27), root:(49,1041),
    state 0x10, button 6, same_screen YES

EnterNotify event, serial 34, synthetic NO, window 0xec00001,
    root 0x15a, subw 0x0, time 14357412, (41,27), root:(49,1041),
    mode NotifyGrab, detail NotifyInferior, same_screen YES,
    focus YES, state 16

KeymapNotify event, serial 34, synthetic NO, window 0x0,
    keys:  90  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 34, synthetic NO, window 0xec00001,
    root 0x15a, subw 0xec00002, time 14357412, (41,27), root:(49,1041),
    state 0x10, button 6, same_screen YES

LeaveNotify event, serial 34, synthetic NO, window 0xec00001,
    root 0x15a, subw 0x0, time 14357412, (41,27), root:(49,1041),
    mode NotifyUngrab, detail NotifyInferior, same_screen YES,
    focus YES, state 16

ButtonPress event, serial 34, synthetic NO, window 0xec00001,
    root 0x15a, subw 0xec00002, time 14357516, (41,27), root:(49,1041),
    state 0x10, button 6, same_screen YES

....etc....
Comment 4 Rick Stockton <AKA rickst29> 2010-12-21 12:57:31 UTC
I made another error in my initial description: following mapping, the left/right scroll buttons ARE showing as "button8 and "button9" ... they're just behaving like button6 and button7.

My map command (from comment #1) excluded button 6 and button 7 entirely. So it's all WAD, but I still think that it would be nice to make the "wheel-spin" effect avoidable. And the easiest way I can imagine would be to use the already-present mapping utilities:

Just change the loop which creates the automatic "Release/Re-Press" spin behavior, so that it executes on the basis of LOGICAL button6 and button7, rather than PHYSICAL button6 and button7.



Slightly OT: This would depend on the ability to create high-numbered logical button freely, without regard to the physical device. I've seen that back in my Release (Xorg 7.5, Mandriva) I can't execute a "set-button-map" for a logical number bigger than 13. Is this still true in Git-Current?

I'm sorry about my lack of accuracy in the initial description- Thanks for your query to have me re-check. ;)
Comment 5 Peter Hutterer 2010-12-22 21:03:28 UTC
(In reply to comment #4)
> Just change the loop which creates the automatic "Release/Re-Press" spin
> behavior, so that it executes on the basis of LOGICAL button6 and button7,
> rather than PHYSICAL button6 and button7.

the driver doesn't know about the logical button mapping. so that loop is based on "we get 5 wheel events, we send 5 button 4/5/6/7 events". the server doesn't know that it's a wheel, it just sees button 4/5/6/7 events and passes them on. the whole notion that these buttons represent wheels is by convention, not policy.

> Slightly OT: This would depend on the ability to create high-numbered logical
> button freely, without regard to the physical device. I've seen that back in my
> Release (Xorg 7.5, Mandriva) I can't execute a "set-button-map" for a logical
> number bigger than 13. Is this still true in Git-Current?

xinput set-button-map <device> 18

works.
Comment 6 Rick Stockton <AKA rickst29> 2010-12-28 16:03:55 UTC
(In reply to comment #5)
> 
> xinput set-button-map <device> 18
> works.

Thanks for your test. :) I'm still confused by one thing, though: Button-4 and Button-5 really DO have a scroll wheel, and I think that each "click" of rotation causes one set of ButtonPress - ButtonRelease events.

Button-6 and Button-7 don't have a wheel. Is all mice with such buttons built to send paired events, as hardware-emulation-of-horizontal-wheel? Or is the "convention" implemented in driver code?

if ButtonPress and (Button = Button6 || Button7) {
  loop while (physical ButtonRelease hasn't been received) {
    send ButtonPress event;
    send ButtonRelease event;
    pause some milliseconds;
  } //loop

  // cleanup, maybe
}
Comment 7 Peter Hutterer 2011-01-03 16:43:30 UTC
(In reply to comment #6)
> Button-6 and Button-7 don't have a wheel. Is all mice with such buttons built
> to send paired events, as hardware-emulation-of-horizontal-wheel? Or is the
> "convention" implemented in driver code?

driver code, see http://cgit.freedesktop.org/xorg/driver/xf86-input-evdev/tree/src/evdev.c#n600. we get a wheel event from the kernel and send out a button 4/5/6/7 press+release event instead. so for your hardware, it pretty much depends on what the event the tilt wheel send is. evtest should tell you.
Comment 8 Rick Stockton <AKA rickst29> 2011-01-05 14:27:55 UTC
Thanks for confirming my un-qualified suspicion. (I looked at both the xorg driver and the kernel "glue code", and saw no such spin-loop in place.) This seems, instead, to be a traditional implementation in hardware: Tilt-wheel mice do the loop within device microcode, so it can't be "prevented".

The "wheel speed" could be reduced (in Xorg, or within higher level Toolkits), by consuming rapid, consecutive sets of Kernel and Evdev ButtonPress / ButtonRelease events (from the kernel) and re-emitting them to user code in a smaller number. But, such "tuning" code should have a GUI, so IMO it really belongs in the land of ToolKits and DEs. That's where "wheel speed" tuning for the Button4/Button5 wheel is done now.

In fact, qt ALREADY contains a loop which "quietly eats most of the events", and it works on both the Vertical (B4/B5) and Horizontal (B6/B7) axes. But the amount of "event consumption" is hard coded, and I'm thinking that I should write a BugZilla for qt to provide Getter/Setter Methods on those values. (As you remember, KDE is my primary target for this research, so qt is the toolkit in question.) 

Definitely "Working As Designed", and the traditional behavior of such mice is not something we can change. (As found in comment 4, we can emit a different button number-- but tilting the wheel will ALWAYS result in "spinning" Press/Release Events while the button is down.)

So, do we close this in X11? (I'll try marking it "RESOLVED/NOTABUG" with this comment, even though I'm not the assignee.) It's fundamentally WAD in X11. The "bug" is only useful as a reference, if a future "X12" wants to take over the job of "wheel-speed tuning" from higher-level Toolkits.

It's up to you, we're all done here :)) And BTW, I'm really, REALLY grateful for your incredibly generous "hand-holding" of this clueless newby. Thank you!


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.