Receiving mouse clicks from different buttons
I'm using the Classic/Carbon function Button() to get the state of the mouse button. However, this function returns true if any of the two buttons is down. And I want to support at least a two-button mouse in my game. On Macs a click with the right button is like a mouse click with the control key down. This way I can check whether the right or left mouse button is down. But if I click both the right and the left button, the left mouse button is ignored of course. Also if I click with the left button and hold the control-key down the game will think that the right button is clicked. Is there a way to get the state of the mouse buttons seperately?
I want to put the jump on the right mouse button and the gun shot on the left button, but with the current method the player would not be able to shoot when jumping.
Thanks in advance,
-Tobias
I want to put the jump on the right mouse button and the gun shot on the left button, but with the current method the player would not be able to shoot when jumping.
Thanks in advance,
-Tobias
If you are willing to restrict your game to carbon, you should use carbon events. They will let you know which button is clicked, or even if the mouse wheel is moved (so you can zoom in your sniper scope for ex. - or maybe to change weapons!)
check out:
http://developer.apple.com/techpubs/maco...ample.html and http://developer.apple.com/techpubs/maco...nager.html
If you also want to support classic - maybe you could see if Input Sprockets supports multi-button mice.
good luck,
Codemattic
check out:
http://developer.apple.com/techpubs/maco...ample.html and http://developer.apple.com/techpubs/maco...nager.html
If you also want to support classic - maybe you could see if Input Sprockets supports multi-button mice.
good luck,
Codemattic
Quote:Originally posted by codemattic
[b]If you are willing to restrict your game to carbon, you should use carbon events. They will let you know which button is clicked, or even if the mouse wheel is moved (so you can zoom in your sniper scope for ex. - or maybe to change weapons!)
Is there anything on Cocoa? Just wondering...
Cocoa has documented support for three mouse buttons, and (I think as yet) undocumented support for up to 32. If you're interested, see the Omni Group's GDC sample code.
Quote:Originally posted by OneSadCookie
Cocoa has documented support for three mouse buttons, and (I think as yet) undocumented support for up to 32. If you're interested, see the Omni Group's GDC sample code.
hmmm... Can't wait for that 32 Buttons USB Mouse to come out on Mac!
I can see it now... "Grr... I can never remember if button 27 updates my website or if that is button 14..."
OK, thanks your help. My prog has now support for 3 buttons on OS X now using the Carbon Event Manager. For some reason Apple also put special functions just for Wacom Tablets inside their Framework, just because the Tablet Mouse does not consider itself a multi-button mouse. It submits 1 as the button code regardless of what button you click. The following method should work with nearly every multi-button mouse, but not with the tablet:
On Wacom devices whichButton is always 1 by default. (It is possible to hack the "Tablet Preferences" file inside /Users/Shared/Tablet to make it submit the correct button code. How this works is quite self-explanatory if you take a look at the file. But it seems impossible to do using the Tablet control panel application.). To get the state of the Wacom tablet mouse without having to hack the prefs call:
(The code is totally uncomplete. You need to receive the event first and check if it is either "kEventMouseDown" or "kEventMouseUp". Also variable declarations are missing.)
Why can Apple not include a function like GetAsyncKeyState() on Windoze?
This is a cool combination of the Mac GetKeys() and Button() function which works perfectly with all keyboards and mice.
Code:
GetEventParameter (ev, kEventParamMouseButton, typeMouseButton, NULL, sizeof(EventMouseButton), NULL, &whichButton);Code:
GetEventParameter (ev, kEventParamTabletEventType, typeUInt32, NULL, sizeof(UInt32), NULL, &whatTableEvent);
if (whatTableEvent==kEventTabletPoint)
{
TabletPointRec tpr;
Boolean buttonStates[3];
GetEventParameter (ev, kEventParamTabletPointRec, typeTabletPointRec, NULL, sizeof(TabletPointRec), NULL, &tpr);
buttonStates[0]=tpr.buttons & 1;//Left button is in bit 0 of the buttons field
buttonStates[1]=tpr.buttons & 2;//Right button is in bit 1
buttonStates[2]=tpr.buttons & 4;//Middle buttons i in bit 2
}Why can Apple not include a function like GetAsyncKeyState() on Windoze?
This is a cool combination of the Mac GetKeys() and Button() function which works perfectly with all keyboards and mice.
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Game buttons | Miglu | 7 | 3,331 |
Sep 25, 2010 01:42 PM Last Post: AnotherJake |
|
| Strange bug with yellow minimize buttons | GolfHacker | 21 | 8,890 |
Jun 20, 2007 05:15 PM Last Post: GolfHacker |
|
| GLUI buttons | eShad0w | 1 | 6,004 |
Jul 6, 2006 12:17 PM Last Post: Duane |
|
| textured windows/animated buttons | hyperzoanoid | 5 | 3,583 |
Jan 5, 2003 01:19 PM Last Post: hyperzoanoid |
|

