Fixed: Support for > 3 Mouse Buttons as Hotkeys

Started by Simon, December 16, 2024, 03:09:29 AM

Previous topic - Next topic

0 Members and 4 Guests are viewing this topic.

Silken Healer

Perhaps WillLem's fourth and fifth mouse button can also be used to go back and forward in a browser?

I am sorry, I am not an expert on how exactly it works. But surely it's a bug in Lix if I had to change my settings in my manufactuers' software on a hunch to get it to work, can use this to get physically different buttons to react as the 4th and 5th, and this only supports <= 5 buttons?

and to be clear, I'm not saying this because I personally want it. I personally didn't mind doing it the old way. I just don't want it to be a bug for the greater good of Lix.

Quote from: Simon on December 18, 2024, 05:55:38 AMYour manufacturer's software sees MB4, and calls MB4 "browser backwards".

It doesn't. It calls it mouse button 4 and 5, and then I select what I want it do, e.g. press the left arrow, press the right arrow, do the "Forwards" action, do the "Backwards" action, etc.

Simon

QuoteBut surely it's a bug in Lix if I had to change my settings in my manufactuers' software on a hunch to get it to work, can use this to get physically different buttons to react as the 4th and 5th, and this only supports <= 5 buttons?

Doesn't follow.

Situation 1: Your environment is fine and Lix has a bug. You reconfigure to work around half of the bug.

Situation 2: Your environment is a jumbled mess and Lix is bug-free. Then you reconfigure the environment and solve a part of the problem.

Your findings don't distinguish between these two situations.

QuoteI select what I want it do, e.g. press the left arrow, press the right arrow, do the "Forwards" action, do the "Backwards" action, etc.

Okay, then it does react to mouse buttons by firing non-button events. It doesn't merely swap buttons. Now we want to see if it eats the input for good, i.e., if it prevents the raw mouse button press event from seeping through to Lix.

What's the exact name of that software? Who made it?

-- Simon

Silken Healer


Silken Healer

Quote from: Simon on December 18, 2024, 06:35:58 AMDoesn't follow.

Situation 1: Your environment is fine and Lix has a bug. You reconfigure to work around half of the bug.

Situation 2: Your environment is a jumbled mess and Lix is bug-free. Then you reconfigure the environment and solve a part of the problem.

That is why I said it's an hypothesis

Simon

Reddit: set the side buttons to just Mouse 3 and 4 and not "Forward" and "Back"?

He couldn't solve it in G-Hub. This is the closest-looking problem that I've found by websearching. It's from August 2022.

I'm inclined to blame your problem on G-Hub.

People on the internet are annoyed with G-Hub in general. But most complain that G-Hub switches erratically between profiles when it should stick with its current one. That's unrelated here.

-- Simon

Simon

#20


MS reference for winuser.h: This part of the Win32 API offers only 5 buttons, RI_MOUSE_BUTTON_1_DOWN through RI_MOUSE_BUTTON_5_DOWN, and no more than those 5. And Allegro calls into that API: Allegro 5's Windows mouse event generator looks at these 5 buttons, and at no more.

I don't know if Lix can even see more than 5 buttons on Windows. I'd have to ask the Allegro devs.

Curiously, WillLem tested exactly 5 buttons.

-- Simon

Silken Healer

I am so confused. Is this a bug with Lix or something else? Does Mouse Button 4/5 do it's own action or Forwards/Backwards?

Quote from: Simon on December 18, 2024, 11:40:22 AM
That cat looks so scary

Simon

#22
Mouse --hardw-protocol--> Windows --Win32-API--> Allegro 5 --A5-API--> Lix
Hardware                  v     ^                DLLs in Lix       my code
                          >G-Hub^

The first culprit is the anemic mouse hardware protocol between the mouse hardware and Windows, i.e., what travels through the mouse's cable. There is a standard way for mice to send the first 5 buttons to Windows. Mouse manufacturers and Microsoft's designers have never sat down to agree on a standard hardware protocol beyond 5 buttons.

From the 6th button onward, the mouse is on its own. When you press the hardware button MB6, your mouse sends some Logitech-specific signal. G-Hub accepts that and knows that you pressed MB6.

The second culprit -- and IMHO the main culprit -- is that Windows doesn't offer an application-side standard way to offer more than 5 buttons. The Win32 API exposes 5 buttons, no more. Even if G-Hub understands your mouse hardware perfectly, G-Hub (which works like a driver here) can't encourage Windows to offer to applications (via the Win32 API) your mouse's MB6 as MB6. G-Hub can only encourage Windows to offer your MB6 as MB5, or to offer your MB6 as some keypress.

Now, when G-Hub presents your incoming button press (from the mouse to Windows) of MB6 as an outging (from Windows to applications) button press of MB5, G-Hub doesn't call it "MB5", it calls it "browser forward".

Allegro reads up to 5 buttons from the Win32 API. (Remember that Win32 only exposes 5.) Allegro reads MB1 through MB5, and what comes in as MB5 is what you sent from G-Hub as "browser forward". Allegro will never think that MB6 is pressed. As long as Allegro sticks with calling the Win32 API (and that looks reasonable), it will be impossible for Allegro to receive MB6 from Windows.

My usercode in Lix (my code that calls the Allegro 5 API) reads up to 30 mouse buttons from Allegro, but Allegro will, on Windows, only ever give me the first 5. Lix believes that there are 30 buttons and that the upper 25 are never pressed.

-- Simon

Silken Healer

So let me get this straight. There's no such thing as a "Forward"/"Backwards" action, there is just Mouse Button 4/5, browsers typically react to Mouse Button 4/5 with backwards/fowards, but that's not the action of the button, and when Logitech G Hub acts like a "Forwards"/"Backwards" action exists, it's actually just making Mouse Button 4/5 be on a different physical button under the hood, and there was no bug in the first place?

Simon

I believe that everything you say in your reply #23 is correct, yes.

There is one far-fetched theory that I can't refute: G-Hub might send a special go-back command in addition to sending MB4/MB5. But I don't know about such a special command. I'd also assume that, if browsers saw such an extra command, the browser would go back twice: Once for the special command, once for the MB4.

But I think: All that G-Hub feeds into your system (when you configure someting to "backwards"/"forwards") is MB4/MB5, and therefore I think you're right.

-- Simon

Silken Healer

Sorry for wasting your time then if there was no bug in the first place  :-[

Simon

All good. Thanks for prodding me to drill into Allegro 5's source and the Win32 API, and understand that only 5 buttons can ever get through to Lix on Windows. I've learned something new.

-- Simon

Silken Healer

Quote from: Simon on December 19, 2024, 01:01:22 AMI've learned something new.
Me too



In follow-up though, for MB6+, what people typically do is in their manufactures software (or some other software that can do so) they'll set their MB6+ to a F13+ key. These keys are typically never on any keyboards, but you can technically buy keyboards that have them. But what they do is they use F13+ as a sort of "temp" key. Then, they can do things with the F13+ key as it's supported.

So should there be a way to add to keys you don't have in the Lix controls setting, by pressing a button to select a key from the list of options, or at least give the keys in the options.sdl names based on what they are rather than the number so people can edit the file in a text editor to add F13+ keys

Simon

In any version of Lix (stable or experimental), please try;

  • In G-Hub, bind MB6 to F13.
  • In user/options.sdl, bind the builder skill to number 145.
  • Play a Lix level with builders. Does MB6 select builder?

-- Simon

Silken Healer

It works, but it says "145" under the image of the Lix building in the skill bar in grey not "F13"