PocketMatrix forums

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

Hardware Keys

I have a Compaq H3870. I use the following code for my button down callback...

void CFMSce::ButtonDown( int button )
{
const InputDevice::KeyList& keys = GetInput()->GetKeyList();
if(button == keys.vkA)
{
m_keys.vkA = true;
m_keys.vkATimer[0] = PocketPC::GetTickCount();
}
...
}

But when I use the hardware buttons the actual value of 'button' does not match any of the KeyList id's returned by GetInput()->GetKeyList();
That is, if(button == keys.vkA) does not work for any of my buttons. :-(

Any Ideas??
Thanx.
You created your class like so?
Code:
#include <PocketFrog.h>
using namespace Frog;
class CFMSce : public Game
{
public:
...
virtual void ButtonDown( int );
};

// And Later
void DFMSce::ButtonDown( int button )
{
}

Have you tested to make sure the ButtonDown function itself is getting called?

Like, before you test if(button == keys.vkA), have it play a sound. Make sure it does that for every button pressed. If it's getting called, then move the SoundFX.Play() inside the if(button == keys.vkA). If that all works, it must be something else.

I think it's time we added a new ButtonTest sample application to PF. I'll see if I can whip one up real quick.
The sample's done. Just unzip it to the PocketFrogPlus samples folder, open the PocketFrogPlus workspace and add the ButtonTest project to it. Compile and run.

http://www.omnytex.com/pf/fileexchange/fileexchange.asp

-John
Yep, thats exactly how my class is built. And yes the function is getting called.

GetInput()->GetKeyList() returns values of
vkUp = 38
vkDown = 40
vkLeft = 37
vkRight = 39
vkA = 195
vkB = 196
vkC = 197
vkStart = 134
vkAux = 134

But my hardware buttons return button values of:
Key 1 = 193
Key 2 = 194
Left = 37 (this is OK)
Right = 39 (this is OK)
Down = 40 (this is OK)
Up = 38 (this is OK)
Key 3 = 195
Key 4 = 196
Notepad Key = 197

Perhaps i'm getting confused as to what hardware key is what. Although it seems that my hardware keys to the left of the pad(Key 1 and 2 I call them) don't show up as any of the values returned by GetKeyList()
I guess what i'm saying is that if I want to use the hardware keys to the left of the pad I'm going to have to hard code statements to test for 'button' values of 193 and 194. I dont want to have to do this as it might not work on other types of PDA.....
This would be both ugly and slick...

The first time the user runs the program, prompt them to hit the buttons. Then save the values for future use.

Of course, it wouldn't be necessary if manufacturers collaborated on a standard, but it's our job as developers to make up for their lack of cooperation.
Good idea. I'll do that.
A little extra work on my part but it'll be worth it in the end. Thanks for your help...
What should be done is enter these values for your specific PDA in PF... Find your OEM's string and fix it in Internal::Input.cpp. This way everyone will benefit from your knowledge about your particular PDA.

If there is not enough buttons in KeyList, more should be added (aux3, aux4, ...)
And thats an even beter idea :-)

How do I get the OEM string from my PDA?

What I cant believe though is that no one has had this problem before. Surely my PDA is the same as every other Compaq out there and the Compaq tends to be the most common. Does no one use the hardware keys to the left of the pad in any of their games?????
Ok, i'm gonna try to add support for all PDA buttons on all devices and hopefully feed it back to be put into PF.
To do this, i'm going to need help from you people out there.
I have a Compaq H3870, so I have the input values for that device.

Can people please feed back to me what values they get for each of their hardware input buttons.
This should be 4 front panel buttons (2 left of pad and 2 to the right), the pad(generating left,up,right,down and start) and perhaps one top left of your PDA.
This gives a total of 10 values that i'll need for each device. I'll bundle these up and modify the necessary PF src files so that GetInput()->GetKeyList() will return the keylist relevent to your particular device.

Oh, and please tell me what device you have, ideally with the result of a PocketPC::GetModel() call.

Please send your results to my email at yeatd@yahoo.co.uk

Does this sound vaguely sensible??
Presto wrote:
The sample's done. Just unzip it to the PocketFrogPlus samples folder, open the PocketFrogPlus workspace and add the ButtonTest project to it. Compile and run.

http://www.omnytex.com/pf/fileexchange/fileexchange.asp

-John


All you need to do to compile PocketFrog programs is #include <PocketFrog.h>... you don't need to explicitly link it to the PocketFrog project.
True. I think, however, it should be re-added to the library like the one that used to be included in PF_0_4_5. (Of course, I totally forgot to include an eVC project in that zip, since eVC isn't on my work computer.)

Yeah, I'm an idiot too. Thanks for asking. :)

-John