lentinj / tp-compact-keyboard

Fn-Lock switcher for ThinkPad Compact Bluetooth Keyboard with TrackPoint
GNU General Public License v2.0
347 stars 33 forks source link

disable lenovo_event_cptkbd #49

Open amosbird opened 4 years ago

amosbird commented 4 years ago

Hi, I'd like to let libinput to handle the middle button press instead of doing it inside the kernel. Is there a way to disable this feature in current hid-lenovo driver? Should I create a new driver to override it or is there better ways to disable this feature?

lentinj commented 4 years ago

hid-lenovo isn't really handling middle-button behaviour either, it's built into the keyboard. None of the modes I know of on the keyboards produce unadultered trackpoint movements whilst the middle button is pressed, only scroll wheel events. Presumably this wasn't useful for them to add, given Windows doesn't have built-in scroll-emulation like Linux.

You could unbind the lenovo driver from the device and bind to the generic driver: https://lwn.net/Articles/143397/ or bind with your own driver. You'd then have to use --native-mouse-disable to return to the native middle button mode (an instantaneous press/release as you lift the middle mouse button).

amosbird commented 4 years ago

hid-lenovo isn't really handling middle-button behaviour either,

hmm, then what does this code do? https://github.com/torvalds/linux/blob/master/drivers/hid/hid-lenovo.c#L371

You could unbind the lenovo driver from the device

Does that mean I lose the ability to tune the trackpoint's sensitivity?

lentinj commented 4 years ago

hid-lenovo isn't really handling middle-button behaviour either,

hmm, then what does this code do? https://github.com/torvalds/linux/blob/master/drivers/hid/hid-lenovo.c#L371

Suppress middle-click events if you middle-click-and-scroll. Otherwise you'll trigger paste (or whatever middle click does) every time you scroll.

amosbird commented 4 years ago

Suppress middle-click events

That's exactly what I want to disable :) (override the lenovo_event_cptkbd function) And I don't think it's related to whether hid-lenovo handles middle-button behaviour.

amosbird commented 4 years ago

Suppress middle-click events if you middle-click-and-scroll. Otherwise you'll trigger paste (or whatever middle click does) every time you scroll.

btw, libinput also has this logic. I think we can get rid of it from kernel driver

lentinj commented 4 years ago

Suppress middle-click events if you middle-click-and-scroll. Otherwise you'll trigger paste (or whatever middle click does) every time you scroll.

btw, libinput also has this logic. I think we can get rid of it from kernel driver

Yes, libinput is probably the more correct place for this sort of hackery nowadays. But I'm not sure there's any value in a painful transition process by removing it from the kernel. Implementing a sysfs configuration to disable it would be easy enough, and seems more preferable to me if this is something that's truly required.

OTOH, you may achieve very similar results with --native-mouse-disable in the userland tools, which off the top of my head will result in wheel events, then a middle button instantaneous down-up at the end. Due to the ordering it shouldn't trigger the middle-mouse-button suppression.

amosbird commented 4 years ago

Implementing a sysfs configuration to disable it would be easy enough

Could you give some hints over this route? ( if it's really easy enough...)

amosbird commented 4 years ago

I just tried --native-mouse-disable. It doesn't pass the middle-mouse-button and the middle scroll is also disabled.

lentinj commented 4 years ago

Implementing a sysfs configuration to disable it would be easy enough

Could you give some hints over this route? ( if it's really easy enough...)

I'd do something along these lines:

amosbird commented 4 years ago

Hmm, does that mean updating the driver and commiting to the kernel code base?

trevor403 commented 4 years ago

Yes but you could also build the driver out of tree and insmod it yourself. I've done this before.