sakithb / media-controls

A media indicator for the Gnome shell.
MIT License
244 stars 37 forks source link

Extra mouse button support #153

Open snoopcatt opened 6 months ago

snoopcatt commented 6 months ago

Hello everyone.
I have Logitech mouse, which has extra buttons, and I wish to use it as bindings for media widget.

I have to add this lines into function _mouseActionButton:

                            } else if (button === 8) {
                                this._mouseAction(mouseActionTypes.EXTRA1_CLICK);
                            } else if (button === 9) {
                                this._mouseAction(mouseActionTypes.EXTRA2_CLICK);
                            }

also redefine mouseActionTypes enum:

let mouseActionTypes = {
    LEFT_CLICK: 0,
    RIGHT_CLICK: 1,
    MIDDLE_CLICK: 2,
    LEFT_DBL_CLICK: 3,
    RIGHT_DBL_CLICK: 4,
    SCROLL_UP: 5,
    SCROLL_DOWN: 6,
    HOVER: 7,
    EXTRA1_CLICK: 8,
    EXTRA2_CLICK: 9,
};

and finally, in prefs.js add support to configure it:

        const mouseActionLabels = [
            _("Left click"),
            _("Right click"),
            _("Middle click"),
            _("Left double click"),
            _("Right double click"),
            _("Scroll up"),
            _("Scroll down"),
            _("Hover"),
            _("Button 8 click"),
            _("Button 9 click"),
        ];

Everything is working now and I can set actions for extra mouse buttions. Should be great if it will be in upstream some day, but have no idea, is it always Button8 and Button9, or maybe Button6/7 on some mouses, etc.

sakithb commented 6 months ago

I don't have any issue with adding support for additional mouse buttons. If you can create a pull request with the above changes, that would be helpful.

snoopcatt commented 6 months ago

There are two problems with that:

ChrisLauinger77 commented 6 months ago

We do not maintain the version below GNOME 45 any more. The code changed significantly with GNOME 45 and then the extension was rewritten in typescript.

ChrisLauinger77 commented 6 months ago

It is not really much work to add this IMHO but where to stop ? My mouse has 5 buttons. The requesters has 9. Currenty we support 3 buttons - left middle and right. In my opinion its enough. There will be for sure somebody who has 11 buttons or more. Not really a often requested feature. @sakithb What do you think - add button 4-9 or leave it alone ?

snoopcatt commented 6 months ago

@ChrisLauinger77 not so - my mouse has two extra buttons, but its codes are 0x08 and 0x09. My mouse is Logitech MX Master.

What I tried to say that I am not sure that every mouse with two extra buttons has the 0x08 and 0x09 codes and not, for example, 0x06 and 0x07.

For me personally the two extra buttons was the one feature which I was missing because there was nowhere to bind "Next" and "Prev". It could be solved by "double left" and "double right" clicks but that's not cool :) Screenshot from 2024-05-20 14-38-46

By the way, I can't contribute to new version because I'm user of Debian Stable and can not into new GNOME :)

ChrisLauinger77 commented 6 months ago

@snoopcatt You will get newer GNOME when debian stable updates next year. Until then you have your solution - we will not update the old version of the extension as said before. In the new code we would need the Clutter button representation https://github.com/sakithb/media-controls/blob/eeb83ab018924850d22a444de6b457f119a075e4/src/helpers/shell/PanelButton.ts#L890C1-L900C18