Re: key press events & holding keys down



On Mon, 19 Mar 2012 11:13:14 -0800
Christopher Howard <christopher howard frigidcode com> wrote:

On 03/19/2012 11:02 AM, Chris Vine wrote:
On Mon, 19 Mar 2012 09:21:27 -0800
Christopher Howard <christopher howard frigidcode com> wrote:
On 03/19/2012 03:34 AM, Chris Vine wrote:
Since GtkWidget objects have key-press-event and a
key-release-event signals that you can connect to (and from your
explanation, clearly you have connected to), you will probably
need to explain why these don't do what you want in order to get
a meaningful answer. Most people would monitor these in
conjunction with gdk_event_get_keyval() or
gdk_event_get_keycode() and keep state.

Chris

I'm currently attempting to code a simple space combat game. In my
game it is possible (quite likely) that two keys will be held down
at the same time (especially the up arrow and another arrow) e.g.
to turn and to accelerate at the same time. Currently I monitor
for key press events as you say; the problem is that key press
events are only being generated for the last key that was pressed.
So if a user attempts to turn and accelerate at the same time, he
will actually only do one or the other, depending on which key he
happened to press last.

A key remains pressed until a key-release-event for it is received.
That is what I meant by 'keep state'.

Chris

So, you are saying that if I receive a key-press-event, I should
artificially generate a key-release-event, which will allow more
key-press-events to be generated? How should I go about doing this?

Are you saying that on your hardware, holding one key down blocks press
and release events for all other keys?  I am not saying you are
wrong, but I find that surprising.

Chris



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]