Library for keyboard input with timestamps?
Hi, I am developing an application w/ 3d graphics and physics and the framerate can vary greatly (from 1 - 100 fps) for reasons beyond my immediate control. Therefore I would like to find a portable (Win32, Linux, Mac) way of getting keyboard input with timestamps asyncronously, without resorting to multitheading and/or polling. I know that DirectInput could do it, but unfortunatly neither SDL, Allegro nor any other library I have looked at seem to support this. Any advice?
Is this a multiplayer game? If not, I don't quite understand why polling will not suffice.
Ryan
Ryan
--Visit the Game Programming Wiki!
Quote:
Original post by Dobrelius
Hi,
I am developing an application w/ 3d graphics and physics and the framerate can vary greatly (from 1 - 100 fps) for reasons beyond my immediate control.
Therefore I would like to find a portable (Win32, Linux, Mac) way of getting keyboard input with timestamps asyncronously, without resorting to multitheading and/or polling.
I know that DirectInput could do it, but unfortunatly neither SDL, Allegro nor any other library I have looked at seem to support this.
Any advice?
The only way I can think of accompishing this is along these lines:
Uint8 *keys;Uint32 timestamps[256];update loop{ timestamp = GetTickCount (or platform timer) keys = SDL_GetKeys(null); for( int x=0;x<256;x++) { /*scan through and see if any key was pressed - if so assign its timestamp to timestamp, if not, -1*/ if( keys[x] ){timestamps[x] = timestamps++;/* this is to make it more realistic, keys cannot be pressed at the same time "in reality" per se because of the way windows works.*/}... process input ...clearalltimestamps this frame}
of course if you wanted to use a buffered input approach that DI uses, you could have some
Uint8 *keys[buffer levels];
Just an idea.
- Drew
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement