Yes. ... and ...williamaadams wrote:If you're reading from stdin, you don't want to be reading /dev/input/event, the latter being low level. stdin will give you the 'characters' coming from the keyboard, already mapped. There will be a difference between 'd' and 'D'. The keymapping has already occured.
Which is exactly what I want so that I can track keys like Alt/Ctl/Shift/Windblows to modify the effect of mouse movements. (E.g. Alt with mouse up/down = zoom in/out Shift with mouse = Pan and TIlt Mouse alone = move forward/backward/side to side.)If you read from /dev/input/eventxxx, then no key mapping is happening. You're getting raw virtual keys from the keyboard, so you will get KEY_D, and KEY_LSHIFT as separate 'events' and it's up to you to keep your own state management.
I prefer to put all inputs into a poll loop (in gtk that is handled via g_io_add_watch etc)Another typical game loop thing to do is simply ask the keyboard for its current state of all the keys at once, by calling ioctl. Then you do what you want from there.
PeterOSo, it depends on what kind of interaction you want your game to have, but those links should show you how to read from the keyboard raw.
Users browsing this forum: ait and 1 guest