by fzammetti » Feb 20, 2004 @ 2:57pm
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()?
...and so I said to Mr. Gates: "$640 billion should be enough for anyone!"