Implementing more desktop mouse button events

I’m currently working on adding support for more mouse buttons for desktop mice. My goals are to extend the behavior of the pointer input device, but not interfere with the existing pointer device or change its behavior. The goal is only to pass back specific mouse button events back for the application to use as it pleases. If there is interest in incorporating this back into LVGL, I would make this a configurable feature that can be compiled out using lv_conf.h. I’m currently adding support for up to 4 additional buttons (and eventually scroll up/dn, if possible), since I believe even most PS/2 mouse protocols could support at least that.

I have a working proof of concept (see attached patch, ignore scroll for now) where I used indev_proc_press() as a guide, but it’s clearly not correct. I believe that my reusing some things from indev_proc_press() results in something with the regular pointer state getting corrupted. I believe all I need to do is get the object under the cursor, set its focus, and pass it the appropriate event, but I’m unsure of what else I might need to do. So I have a few questions:

  1. From my new indev_proc_mouse_press/release functions, is there anything special I need to pay attention to for sending pressed/released events? Anything non-obvious I need to stay away from to avoid interfering with the standard pointer or state of the screen/display?

  2. From a design perspective, would you prefer a fixed number of additional buttons as I’ve done with the proof of concept, or do you think there’s a more general approach that would work better? I could also see a single mouse press/release event being triggered, where the event handler needs to figure out which button is being pressed, similar to how key presses are handled. This might make it easier for a driver to add an arbitrary number of pointer buttons, but may complicate things a bit?

  3. Is this even a feature you would want in the official release of LVGL? If so, I can work it up and issue a pull request on github when ready. If not, I’ll not bother with config, documentation, etc…

For context, I’m using LVGL on a custom OS that runs on embedded, desktop, and server hardware where for security and/or performance reasons, we don’t want to use X windows. Having “standard” mouse behavior would be quite useful.

— patch:
lvgl_buttons_poc.txt (15.6 KB)


Yes, I’m absolutely interested in it. We usually have the development related discussions on GitHub, so let’s continue there. Please open an issue here. The exact same the text from here would be perfect as a topic starter.

New issue created as requested. Issue 3793. Thanks.

1 Like