Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » More than 4 mouse buttons?

This thread is locked; no one can reply to it. rss feed Print
More than 4 mouse buttons?
IonBlade
Member #3,521
May 2003
avatar

My mouse is a Logitech Cordless Click Plus, with two side buttons for a total of 5 buttons. Allegro's install_mouse() function is returning 8, and I can detect all button presses up to the 4th button, but the 5th isn't being detected. Both side buttons are set up as generic buttons in my logitech control panel, so they're detected by everything else.

if (mouse_b & 1)  {}  //left click
if (mouse_b & 2)  {}  //right click
if (mouse_b & 4)  {}  //wheel click
if (mouse_b & 8)  {}  //side button 1
if (mouse_b & 16) {}  //side button 2. this is not being detected!

Any ideas?

------

"I've got to choose my words carefully so that I'm not misunderstood, but I think there are fewer developers around today who think about making a good game. As a creator, I find that sad..." - Hideo Kojima

Synapse Jumps
Member #3,073
December 2002

Well... I have no ideas to answer your question, but you might find this helpful:

TFM said:

Note that the number of mouse buttons returned by this function is more an indication than a physical reality. With most devices there is no way of telling how many buttons there are, and any user can override the number of mouse buttons returned by this function with a custom configuration file and the variable num_buttons. Even if this value is overriden by the user, the global mouse variables will still report whatever the hardware is sending.

Matthew Leverton
Supreme Loser
January 1999
avatar

The mouse interface that Allegro uses under Windows only supports up to four buttons. So there's nothing you can really do about it. (Rewriting Allegro to use a different interface might be a possibility.)

Allegro used to only support three buttons as a standard across all operating systems, but (somewhat) recently I updated the Windows code to recognize the fourth button since it was readily available.

IonBlade
Member #3,521
May 2003
avatar

Seems like a good candidate for a future version of Allegro; or would 5+ mouse buttons be considered too specialized for a general low level lib like Allegro?

------

"I've got to choose my words carefully so that I'm not misunderstood, but I think there are fewer developers around today who think about making a good game. As a creator, I find that sad..." - Hideo Kojima

Matthew Leverton
Supreme Loser
January 1999
avatar

My thought is that Allegro should expose as many buttons the OS allows, but that the use of more than three buttons should not be encouraged. In other words, if you want to use (mouse_b & 16), go ahead. But Allegro won't define FIFTH_MOUSE_BUTTON, neither will it provide a way to emulate it by double tapping SHIFT-CTRL-ALT while pressing the middle mouse button.

As I mentioned earlier, the only reason why I didn't go ahead and add support for the fifth button is simply the interface that Allegro uses doesn't support it. But if someone wants to write a new mouse driver that supports a million buttons under Windows, I see no good reason not to allow it.

Kitty Cat
Member #2,815
October 2002
avatar

Just thinking aloud here, but why can't mouse_dinput_handle_event in src/win/winput.c be modified to set the mouse button like so:

1case DIMOFS_BUTTON0:
2case DIMOFS_BUTTON1:
3case DIMOFS_BUTTON2:
4case DIMOFS_BUTTON3:
5case DIMOFS_BUTTON4:
6case DIMOFS_BUTTON5:
7case DIMOFS_BUTTON6:
8case DIMOFS_BUTTON7: {
9 int btn = 1<<(ofs-DIMOFS_BUTTON0);
10 if((btn <= 0x2) && (swap_mouse_button != 0))
11 mouse_swap_button ^= 0x3;
12 
13 if (data & 0x80) {
14 if (_mouse_on)
15 _mouse_b |= btn;
16 }
17 else
18 _mouse_b &= ~btn;
19 break;
20}

--
"Do not meddle in the affairs of cats, for they are subtle and will pee on your computer." -- Bruce Graham

Matthew Leverton
Supreme Loser
January 1999
avatar

Because it's not supported:

src/win/wmouse.c: In function `mouse_dinput_handle_event':
src/win/wmouse.c:304: `DIMOFS_BUTTON4' undeclared (first use in this function)
src/win/wmouse.c:304: (Each undeclared identifier is reported only once
src/win/wmouse.c:304: for each function it appears in.)
mingw32-make: *** [obj/mingw32/alleg/wmouse.o] Error 1

It's a DirectInput 3 limitation, I believe. That's why I never added it.

Now, if one changes the top of the file to #define DIRECTINPUT_VERSION 0x0700 then it "works." It still doesn't get registered, but I assume it would be as easy upgrading some function call to Foo2() or something.

It wouldn't work on NT machines, as they only support DX 3.

Kitty Cat
Member #2,815
October 2002
avatar

Doesn't Allegro already use DX 5 on non-NT machines? Is there a reason Allegro can't upgrade to DX7 (the lowest SDK version the webpage has for MinGW) on non-NT machines? AFAIK, even Win95 can get up to DX7 (if not 8).

--
"Do not meddle in the affairs of cats, for they are subtle and will pee on your computer." -- Bruce Graham

Matthew Leverton
Supreme Loser
January 1999
avatar

I would assume it's possible to have both a DX3 and DX7 mouse driver if someone were to write them both. Personally I wouldn't even care if Allegro required DX7 to function.

gillius
Member #119
April 2000

Removing the DX3 requirement is probably not a deal, as Windows NT is probably pretty dead by now.

However, the "old-school" and "software" design of Allegro might come in infinitely handy for me. I was going into a huge tirade here but I decided not to hijack the thread so I'm starting a new one about why the old-school design is handy for me.

Gillius
Gillius's Programming -- https://gillius.org/

Thomas Harte
Member #33
April 2000
avatar

Quote:

Removing the DX3 requirement is probably not a deal, as Windows NT is probably pretty dead by now.

You say that, but have you seen the fervour with which some people have protected the DOS port in the past?

I personally think a case can be made that while the first Allegro golden age was DOS/DJGPP hosted, NT support has never been widely exploited and dropping it would not be to lose any significant link with the past. Of course, I don't understand why DOS support is still wanted either, but that isn't the topic for discussion.

vpenquerch
Member #233
April 2000

Jumping in on Thomas' comments here: are DJGPP compiled programs
still running on newer Windows ? They used to do, but I've kind of
heard about more and more problems doing so.

Matthew Leverton
Supreme Loser
January 1999
avatar

Quote:

NT support has never been widely exploited and dropping it would not be to lose any significant link with the past

It really comes down to if someone is willing to keep a port working, then it will not be dropped. I would agree that the number of Allegro NT 4.0 users is (and always has been) quite limited, and the usefulness of Allegro on such a system is almost nothing.

Allegro is old enough to have been designed with DOS in mind. Just dropping DOS for the sake of it won't help anything. Now, if Allegro were to be redesigned (Version 4.4 or 5.0, whatever) then it doesn't make any sense to give any design consideration to DOS. If someone comes along and decides to keep the DOS version in sync, then good for him. And I think thats pretty much the general consensus.

Quote:

are DJGPP compiled programs still running on newer Windows

Short answer is no. DOS programs never ran well under NT which is what 2000 and XP are based on.

Arthur Kalliokoski
Second in Command
February 2005
avatar

I tried compiling the last few Allegro ports with the latest djgpp I have (has gcc 4.0.0) and they don't finish compiling, I forget the error. Watcom 1.3 won't compile either. I did get some old open watcom to compile a couple years ago, but it crashed on all the examples. But now with 256Mb in my main computer, the windows version isn't too bad (well except the last couple Allegros I downloaded don't do the keys right, and 4.2.0 doesn't do sound at all). I got too many fish to fry to debug it though. I also suspect that Allegro is getting too spread out with all those defines etc. to work right.

I sometimes wonder why the polls on the main page stay up so long on a specific question. If you sped them up to, say, a couple weeks each, it'd be easier to fit in stuff we really need for programming, such as what CPU, OS, physical memory etc. everybody has. If only two people use DOS (not just want to keep it for sentimental reasons), go ahead and drop it.

They all watch too much MSNBC... they get ideas.

A J
Member #3,025
December 2002
avatar

I think Matthews comments are without doubt quite sound, and i strongly support the continued disregard for NT support. DX7 as a minimum, 98 can support DX7, 95 probably could too? 2k/XP can emulate all the dx7 functionality... i welcome our new DX7 overlord !

___________________________
The more you talk, the more AJ is right. - ML

IonBlade
Member #3,521
May 2003
avatar

i welcome hardware acceleration ;D

------

"I've got to choose my words carefully so that I'm not misunderstood, but I think there are fewer developers around today who think about making a good game. As a creator, I find that sad..." - Hideo Kojima

Go to: