Re: [PyOpenGL-Users] Keyboard Input
Brought to you by:
mcfletch
From: Mike C. F. <mcf...@ro...> - 2004-04-12 19:30:57
|
Don't have time to do much testing, but here are some ideas: * glutIgnoreKeyRepeat -- use this, then use a timer/polling solution so that what you get are the down event, then while the key is down you issue the equivalent of a repeat every X milliseconds (glutTimerFunc), and you stop when you get the up event. To do this, you need to track the currently-down keys yourself and remove them from your tracking table when the up-event comes in. * Use PyGame as your GUI library and it's (game-oriented) mechanisms for polling current keyboard state (e.g. pygame.key.get_pressed() with the same basic event+timer mechanism as for GLUT. The advantage here being that PyGame does all the tracking of currently-down keys for you. HTH, Mike Snails wrote: > Hello all. > I'm writing a simple pong game in python, using pyOpenGL of course. > I've got most of it down, but when I used glutKeyboardFunc > <http://pyopengl.sourceforge.net/documentation/manual/glutKeyboardFunc.3GLUT.html> to > capture input from the keyboard, I encountered a problem: when a key > is pressed and not released, instead of being called continuously > (good), my callback function is called once, then there's a small > delay, and only then is it called continuously (bad). I'm not > especially knowledgeable about how the keyboard works, but this is > obviously the same behavior as in a text box, when you press any key, > it delays a bit after the initial press before generating more > keypresses. ... > Portability is rather important, but if there's no single module I can > use to read (what do you call this type of keyboard input anyway?) the > keyboard in the desired way, a platform-specific solution would be > helpful also, and the best would be one from within PyOpenGL itself. ... _______________________________________ Mike C. Fletcher Designer, VR Plumber, Coder http://members.rogers.com/mcfletch/ |