PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

one button press - two key codes !?

I have ASUS A620BT + eVC 3.0 + PF_0_8_1

During my game if I press left, up, right or down button on my PocketPC
The - void Pyromania::ButtonDown (int button){} is called

At first I get the right key code (from int button) - 37, 38, 39, 40 (the same as vkLeft, vkUp...)
but suddenly after that the ButtonDown called with the second "wrong key code" it is the same key code for all four buttons - 132 !?

When I press any other button - contacts, record etc.
At first I get the "wrong key code" - it is the same for all other buttons - 91
and suddenly after that I get the right key code 193, 194 etc - different for different buttons.

I use the standard PocketFrog_0_8_1 game class with virtual ButtonDown function?

Now I filter incoming keycodes with something like this:

void Pyromania::ButtonDown (int button)
{
if(inbutton ==m_keys.vkRight || inbutton ==m_keys.vkA || //etc )
{
//Get input
}
}

so is the key codes:

int16_t vkUp;
int16_t vkDown;
int16_t vkLeft;
int16_t vkRight;
int16_t vkStart;
int16_t vkA;
int16_t vkB;
int16_t vkC;
int16_t vkAux1;
int16_t vkAux2;
int16_t vkAux3;
int16_t vkAux4;
int16_t vkAux5;
int16_t vkAux6;
int16_t vkAux7;
int16_t vkAux8;

(as seen in input.h)
all the "right keycodes" I could receive on "average PocketPC device" (without hardware keyboard)
I'm asking because I have customizable buttons in my game and I should separate right from wrong key codes. Is there any other better way?
P.S. Fogot to say: I've read previous threads about "phantom keycodes", but I still cannot understand how could I separate this phantom keycodes from normal one.
Because if((m_keys.vkUp == button || m_keys.vkDown == button etc){do something} is not the best solution - it restricts some true, not phantom key codes from access on my PC, for example.
The way I'd do it is something like this...

Use a struct of all buttons:
struct
{
bool vkUp,
vkDown,
vkLeft,
vkRight,
vkStart,
vkA,
vkB,
vkC;
} buttons;

Then in the KeyDown/Up event:
switch(button)
{
case vkUp: buttons.vkUp = true; break;
case vkDown: buttons.vkDown = true; break;
...
}

Then use a pointer to bool for mapping the function...

bool * jump = &buttons.vkA;

Of course, this means you would process your button actions in the mainloop, not actually in the KeyDown even.

This also means that some buttons won't work - like the 4th button on an x30... it's not vkA, B, or C... but it does get the ignoring of phantom code taken care of.
Thank you fast_rx for your advice.
About X30 problem - maybe this button is just one of Aux1-8 buttons?
In my game I use much more complex system - because my in game hero could be controlled by buttons and stylus simultaneously - one button should disable some actions made by stylus and vice versa.
Another complexity - I let user to change all 10 keycodes (only six are important move(4), action(use, get, etc.), fire).
I store these keycodes in config file that is at first time generated (all PDA's have different keycodes).

But to make it all clear - my problem is: when user makes button customization I should get the RIGHT key code from the user but when I get PHANTOM keycodes that comes always with RIGHT key code - have I any better then if(button == vkUp ||...){someactionbutton = button;} way to see that this button is PHANTOM and I shouldn't save it as a button keycode for this kind of action?