On Mon, 19 Mar 2012 13:37:45 -0800 Christopher Howard <christopher.how...@frigidcode.com> wrote: [snip] > So, you mean, receive both key press and key release events, and then > maintain my own tracking of whether or not the key is currently being > held down? Okay, that makes sense to me, provided of course I can be > certain that all key press and key release events are properly > reported to my program (otherwise my internal state my gets screwed) > and in the correct order.
Yes, if you really want to design the game that way (see below). To the best of my knowledge standard PC keyboard hardware is edge triggered anyway, although I could be wrong, and if you have a strong stomach you could look at the linux or BSD kernel code to see if I am right. However, many keyboards are used with serial (USB or bluetooth) interfaces with edge triggering, so further clouding the issue. However, I think you are allowing one particular library with which you are familiar, namely ClanLib, to dominate your thinking. Since (if I am right) the hardware and its interfaces are edge triggered, and GDK certainly is, go with the flow and construct your program by reference to these events. That is, assume key state remains the same, and continue your space ships in a particular direction, or keep firing phasors on maximum stun, until a key press or key release event in the glib main loop tells you something different. Doing it through a timer by reference to stored state is an alternative, but could be viewed as a cludge. It may be a necessary cludge if you are porting existing code and that is how it does it, but that doesn't seem to be the case here. > However, the approach I was hoping for, i.e. simply checking the > current "reality" state of a key (whether it is actually pressed down > or not) sounds more convenient. If anyone could tell me how to do > that, I would be grateful. This is what keeping state does. I think you are tying yourself up in unnecessary knots here. Chris _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list