Event Handling (Keyboard and Mouse)

Apprentice
Posts: 19
Joined: 2005.11
Post: #1
Okay, I got a OpenGL/GLUT Real-time strategy going. Just the basics, but I'm pumped. However, I've come to the conclusion GLUT sucks for registering keyboard and mouse events. Arrow keys, mouse-wheels, F1-F16, and may other buttons don't register at all. (Unless I'm doing something wrong / missing something.) So what does everyone else use for their games? Carbon/Cocoa events?

What about cross-platform API's? (I ask mainly because I'm doing this game for a class, and in class I work on Windows machines and my program has to be compatible). I know a *little* SDL, so I'm considering loading in that API as well and just using SDL to handle keyboard/mouse events, unless someone else has a better idea.

Oh and another off-beat question... is there a way to do query what platform I'm on, i.e.:
Code:
#if MACINTOSH
#include <GL/GLUT.h>
#endif

#if WINDOWS
#include <GLUT.H>
#endif
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
Arrow keys and F-keys go to your glutSpecialFunc instead of the normal keyboard handler. There are special constants (GLUT_KEY_LEFT, etc) for them. I'm not sure about the mouse wheel in GLUT. Certainly, GLUT's event handling is more limited than games will generally want. SDL is a good choice if you want to stay cross-platform. You can't do a half-way house thing -- GLUT or SDL, not both.

The macros you want to check are
__APPLE__
_WIN32
linux

You may also need to check
__BIG_ENDIAN__
Quote this message in a reply
Apprentice
Posts: 19
Joined: 2005.11
Post: #3
Thanks OneSadCookie, that'll help me out a lot. If anybody finds out anything about mouse-wheel events, that would be great to know too, however I remain very happy with this new found knowledge and can live without a mouse-wheel event, at least for now... Later games that are Mac-only I don't know... Rasp
Quote this message in a reply
FUSION
Unregistered
 
Post: #4
I just posted an OpenGL application/game framework called FUSION in the "Tools & Technology" forum that may be of some help. It can be used as an alternative to GLUT, but only for the Macintosh. As everything boils down to handlers, it should be possible to use GLUT for Windows and FUSION for the Macintosh. Here is the link to the post:

http://www.idevgames.com/forum/showthrea...post112123
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #5
There is no reason to use FUSION and GLUT. Glut behaves the same on all platforms, so if you got it once, you got it. Of course, GLUT is stupid, but that's another story.
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #6
OneSadCookie Wrote:The macros you want to check are
__APPLE__
_WIN32
linux

You may also need to check
__BIG_ENDIAN__

So is that to say I should do something like this?
Code:
#if defined __APPLE__
...
#elseif defined _WIN32
...
#endif
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #7
Code:
#if defined(__APPLE__)
...
#elif defined(_WIN32)
...
#elif defined(linux)
...
#else
#error weirdo :p
#endif
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Keyboard Handling skyhawk 10 6,565 Oct 26, 2010 08:47 AM
Last Post: skyhawk
  keyboard limitations daveh84 8 4,474 Feb 13, 2009 02:48 PM
Last Post: ferum
  Full Screen Event Handling kodex 4 4,794 Jun 27, 2008 08:37 PM
Last Post: OneSadCookie
  Left mouse button causes moueup event despite button still being pressed. QuestingCordiial 28 11,525 Jun 21, 2008 03:18 PM
Last Post: AnotherJake
  Handling a return or enter key event on an edit text control monteboyd 7 5,725 Nov 7, 2005 03:29 PM
Last Post: monteboyd