Page 1 of 2

Possibly silly question about keylist...

PostPosted: Feb 20, 2004 @ 6:12am
by fzammetti

PostPosted: Feb 20, 2004 @ 1:45pm
by Layre5150
If you're trying to do what I think you are (which would be to check if a certain key/button is pressed outside of the input events) you could try using GetAsyncKeyState( vk_code ). Using the Hiword of the return value will give you your answer as to what is being pressed (or released).

If you needed a valid GDKEYLIST structure outside of the event handlers, my guess is that you would have to manually fill it in yourself and with using GetAsyncKeyState.

However, you may be doing something else other than what I think you're doing - in which case my reply may not even relevant.

PostPosted: Feb 20, 2004 @ 2:57pm
by fzammetti
That was a good guess Layre5150! Actually though, I was writing a key mapping screen in my game. What I've done is I have six DWORD variables in my game class, vkUp, vkDown, vkLeft, vkRight, vmCommand and vkAction. In my key mapping button event handler, I'm basically doing:

// If we're assigning the vkCommand button...
if (dwKey == keylist.vkA) { vkCommand = keylist.vkA; }
// ... and so on

So, what I wanted to do was have default values in those six variables that echo what's in keylist, since chances are they won't even need to be remapped most of the time anyway. Doing it in InitInstance() seemed to make the most sense.

I'd still like to know the answer to my question, but it's actually no longer relevant since something dawned on me in the shower (where most of my good ideas hit me!)... instead of checking for the various members of keylist in my handler and assigning as appropriate, all I really need to do is:

// If we're assigning the vkCommand button...
vkCommand = dwKey;
// If we're assigning the vkAction button...
vkAction = dwKey;
// ... and so on

That way, I can handle buttons that aren't registered in keylist too (I assume they would still come through Johan? I'm thinking maybe the fourth button on an Axim, which I would guess would be vkD if it was a member of the structure, but since it isn't, I'd still get some values passed to KeyUp, right?).


EDIT: Please ignore the part where I say this is no longer relevant! It still may be, so I still need an answer. I'm thinking about the whole "phantom" button press thing... I presume that the first value passed in would NOT be one of the values in keylist, therefore it's probably correct to still check against what's in the structure, in which case I'll still need to be able to set default. I'm probably just confusing things here, so ignore it all and just focus on the underlying question: How can I get the value of the vkA member in keylist (for example), outside of a KeyDown handler method, preferably in InitInstance()?

PostPosted: Feb 20, 2004 @ 4:48pm
by mlepage

PostPosted: Feb 20, 2004 @ 4:59pm
by fzammetti

PostPosted: Feb 21, 2004 @ 9:04am
by Johan

PostPosted: Feb 21, 2004 @ 2:33pm
by fzammetti
Ok, good. Johan, what about my original question? Is it possible to get at the values in keylist outside an event handler?

PostPosted: Feb 21, 2004 @ 6:06pm
by Johan

PostPosted: Feb 21, 2004 @ 6:35pm
by ppcStudios

PostPosted: Feb 21, 2004 @ 11:37pm
by fzammetti

PostPosted: Feb 22, 2004 @ 12:22am
by ppcStudios

PostPosted: Feb 22, 2004 @ 2:14am
by fzammetti

PostPosted: Feb 22, 2004 @ 2:32am
by mlepage

PostPosted: Feb 22, 2004 @ 2:53am
by ppcStudios

PostPosted: Feb 22, 2004 @ 3:31am
by fzammetti