Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Second mouse button under OSX?

This thread is locked; no one can reply to it. rss feed Print
Second mouse button under OSX?
netcat
Member #6,097
August 2005

mouse_b & 2 doesn't work.. Do I have to do something apart from install_mouse() in order to be able to use the second button?

Maikol
Member #4,997
September 2004
avatar

As Allegro manual says, on some platforms you need to call pollmouse manually. you may try this as code as many times as possible:

if (mouse_needs_poll()) //maybe not needed
   poll_mouse();

perhaps clics have been taken but your program doesn't update them

El sabio no dice todo lo que piensa, pero siempre piensa todo lo que dice
Aristóteles

netcat
Member #6,097
August 2005

Nope, that didn't fix anything, unless I did something wrong.

Matthew Leverton
Supreme Loser
January 1999
avatar

It may be a limitation of Allegro under OSX. What does install_mouse() return?

BAF
Member #2,981
December 2002
avatar

Quote:

Global variables containing the current mouse position and button state. Wherever possible these values will be updated asynchronously, but if mouse_needs_poll() returns TRUE, you must manually call poll_mouse() to update them with the current input state. The `mouse_x' and `mouse_y' positions are integers ranging from zero to the bottom right corner of the screen. The `mouse_z' variable holds the current wheel position, when using an input driver that supports wheel mice. The `mouse_b' variable is a bitfield indicating the state of each button: bit 0 is the left button, bit 1 the right, and bit 2 the middle button. Additional non standard mouse buttons might be available as higher bits in this variable.

Should it be mouse_b & 1?

Matthew Leverton
Supreme Loser
January 1999
avatar

bit 0 = 1 (left/primary)
bit 1 = 2 (right/secondary)
bit 2 = 4 (middle)

Peter Hull
Member #1,136
March 2001

Have you tried with the test program? (On the I/O|Mouse menu) On my iBook with a 1 button mouse I can access the other buttons with ctrl+click and command+click, and if I plug a 3 button USB mouse in, I can use the buttons directly.

If it works with the test program, it must be your code. Post some code!

Otherwise, can you tell us your Allegro version, OSX version and what type of Mac it is (intel or PPC)

Cheers,

Peter
ps. You don't need poll_mouse on OSX.

Evert
Member #794
November 2000
avatar

Quote:

As Allegro manual says, on some platforms you need to call pollmouse manually.

It lies.

About the second button: it's possible that Allegro's mouse driver only looks atthe first physical mouse button and emulates the second and third buttons with Option+click and Command+click (or the other way around). Can you check if those combinations work as a second and third mouse button?
It's possible that there is an option in the config file that can be used to change this behavior, though I suspect it will only disable the emulation, not enable the detection of the second button.

netcat
Member #6,097
August 2005

Ctrl-Click works.

Quote:

Otherwise, can you tell us your Allegro version, OSX version and what type of Mac it is (intel or PPC)

I have Allegro v. 4.2 and the latest version of OSX on an iBook G4 (obviously a PPC).

Now that I think about it, I believe I had a program where mouse_b & 2 worked as it should, but I can't find it so I assume I deleted it for some reason.

Also, mouse_b & 4 checks for left mouse button clicks and not middle as it should (I think?).

edit: the example file only worked with ctrl-click and option-click, too.

Go to: