bk138 / gromit-mpx

Gromit-MPX is an on-screen annotation tool that works with any Unix desktop environment under X11 as well as Wayland.
GNU General Public License v2.0
975 stars 81 forks source link

support for extra mouse buttons #199

Open brccabral opened 6 months ago

brccabral commented 6 months ago

Hi, My mouse has buttons 8 and 9 and I was able to make them work. Let me know if you have any questions. Cheers, Bruno

bk138 commented 6 months ago

Hi Bruno, Thanks for the contribution! Can you please give an outline of the approach taken and how it works?

brccabral commented 6 months ago

Hi @bk138 , I updated the way the tools lookup deal with the buttons mask in key2string().
The buttons mask was only 1-5, 0b 0001 1111, and as it is one byte it could be converted to gchar straight away.
To have buttons up to 10 we need two bytes, 0b 0000 0011 1111 1111, so, in the lookup I added one extra gchar to deal with two bytes, one for 1-8, the new one for 9-16.
The 10 limit happens in the parse_name and in the on_buttonpress callback, but looking at it now we could have up to 16 buttons no problem (I don't have a way to test it, but it should work). As said, I tested buttons 8 and 9.
I think it is standard that buttons 4-5 are mouse wheel scroll up and down, but I didn't test it.

To add even more buttons, just update the parse_name and the lookup key2string.

Let me know if you have more questions. Bruno