Remap Key Question

Non-platform specific questions.

Postby mrdark7734 » Fri Feb 10, 2006 4:13 am

Thanx for the review and kind words plinydogg. I've been a fan of ppcgems since it opened back in October. Keep up the great work.

P.S. Check your aol email.
User avatar
mrdark7734
 
Posts: 21
Joined: Thu Aug 25, 2005 12:49 am
Location: Texas (where we're crazy enough to shoot a president)
Score: 0 Give a positive score

Postby mrdark7734 » Sat Feb 11, 2006 5:14 am

Ok, here it is as promised. :wink:

Button_Configuration.zip

There is a text actor in the file that explains what everything is, what it does, and what is needed. It may seem like the hard way of remapping a button, but it works. Use and customize this to your hearts content.

Any questions just ask and I'll try and get back to you as soon as I can.
User avatar
mrdark7734
 
Posts: 21
Joined: Thu Aug 25, 2005 12:49 am
Location: Texas (where we're crazy enough to shoot a president)
Score: 0 Give a positive score

Postby Mardi-Gras » Sat Feb 11, 2006 12:05 pm

Nice tutorial, MrDark, very clearly explained. Many many thanks for sharing it.
User avatar
Mardi-Gras
 
Posts: 57
Joined: Sun Jan 22, 2006 10:10 pm
Location: Glenrothes, Scotland
Score: 0 Give a positive score

Postby mrdark7734 » Sun Feb 12, 2006 5:27 am

Your very welcome. I hope this helps.
User avatar
mrdark7734
 
Posts: 21
Joined: Thu Aug 25, 2005 12:49 am
Location: Texas (where we're crazy enough to shoot a president)
Score: 0 Give a positive score

Postby plinydogg » Mon Feb 13, 2006 7:19 pm

Yes, thanks for this mrdark7734.....I haven't had a chance to look at it yet (real life is SO annoying sometimes) but I will reply here once I do (in a day or so).
plinydogg
 
Posts: 104
Joined: Thu Aug 25, 2005 8:34 pm
Score: 0 Give a positive score

Postby plinydogg » Wed Feb 15, 2006 12:24 am

mrdark7734:

Good news! Your demo works great! Bad news, I can't get it to work in my own project =(

It may have something to do with the fact that I test to see whether a certain key is pressed down inside a draw actor->script editor event. I initially tried using it inside a KeyDown event, but this caused too many problems to mention =(

It's unfortunate....the game itself is all but done....it's these last minute small--but important--details that will probably force me to shelve the whole thing. Thanks for the demo though =) =)
plinydogg
 
Posts: 104
Joined: Thu Aug 25, 2005 8:34 pm
Score: 0 Give a positive score

Postby twobob » Wed Feb 15, 2006 10:52 am

The demo works very well – thanks mrdark7734 for sharing it with us.

I tried messing about with the code so that it would use the getLastKey function with a key down event, but like Plinydogg I could not get the function to work correctly in my code. The keys don’t seem to get recognized on the Pocket PC.

I then used mrdark7734’s method of key input, where the user holds down a key, and whist doing so the user uses their stylus to press a button to recognize the key – This is on a mouse down event using mrdark7734’s code.(This method uses the GetKeyState) I also included code so that it would also recognize the d-pad(joystick control).

The Pocket PC now seems to recognize the key entry and it appears to work fine for all control buttons and the directional d-pad.

As I say, have a go at the mouse down event, whilst the user is holding down the key you want to be recognized – I am sure you will get it working. Let us know how you get on.
twobob
 
Posts: 33
Joined: Sat Sep 10, 2005 10:29 am
Location: England
Score: 2 Give a positive score

Postby twobob » Sat Feb 18, 2006 4:13 pm

A problem I found is when entering a new key to a key that is already remapped previously, then it can start to cause problems with the keys in the game
The solution I found is before you remap the keys, remap every key in the pocket pc to a key that is not used when running the game.
For example:-
remapKey(KEY_POCKET_UP, KEY_g);
remapKey(KEY_POCKET_DOWN, KEY_g);
remapKey(KEY_POCKET_LEFT, KEY_g);
remapKey(KEY_POCKET_RIGHT, KEY_g);
remapKey(KEY_POCKET_A, KEY_g);
remapKey(KEY_POCKET_B, KEY_g);
remapKey(KEY_POCKET_C, KEY_g);
remapKey(KEY_POCKET_START, KEY_g);
remapKey(KEY_POCKET_AUX1, KEY_g);
remapKey(KEY_POCKET_AUX2, KEY_g);
remapKey(KEY_POCKET_AUX3, KEY_g);
remapKey(KEY_POCKET_AUX4, KEY_g);
remapKey(KEY_POCKET_AUX5, KEY_g);
remapKey(KEY_POCKET_AUX6, KEY_g);
remapKey(KEY_POCKET_AUX7, KEY_g);
remapKey(KEY_POCKET_AUX8, KEY_g);

Where the key g is not used in the game.

Also in the Config - game properties – I left all the keys to be remapped blank. When the game starts I use a saved file to load and remap the keys.
twobob
 
Posts: 33
Joined: Sat Sep 10, 2005 10:29 am
Location: England
Score: 2 Give a positive score

Postby plinydogg » Thu Feb 23, 2006 6:24 pm

twobob,

Thanks for your advice. I have implemented a button remapping system like mrdarks and have it working but only partially....

Originally the problem was that the keys (even if remapped) weren't recognized in draw actor->script editor.

To workaround this, I just avoided using remapKey() at all. Instead, I created a global integer variable (in the global code editor) for each button and then used mrdark's system to store the key pressed into that variable when the user pressed the mousedown. For example on a mousedown event I put the following:

char *key = GetKeyState();
if(key[KEY_POCKET_A] == 1)
{
buttonFire = KEY_POCKET_A;
}

Then in the draw actor-> script editor in the game I put this

char *key= GetKeyState();
if(key[buttonFire] == 1)
{
//execute some code
}

This system works fine with all buttons except for the d-pad. Does anyone know why this is the case? The only thing I can think of is that there is a problem storing a key name in an integer variable. Perhaps the non-directional pad buttons have integers that represent them while the d-pad doesn't??? Any ideas twobob?

Makslane can you help?

Thanks!
plinydogg
 
Posts: 104
Joined: Thu Aug 25, 2005 8:34 pm
Score: 0 Give a positive score

Postby plinydogg » Thu Feb 23, 2006 8:02 pm

Oops...nevermind...I'm an idiot....I had just forgotten to include the necessary code for the d-pad (i.e., mrdark's demo didn't have it and I forgot to include it).

Thanks for everyone's continuing help....hopefully I won't be posting on this topic anymore now that everythiing seems to be working okay.
plinydogg
 
Posts: 104
Joined: Thu Aug 25, 2005 8:34 pm
Score: 0 Give a positive score

Previous

Return to General

Who is online

Users browsing this forum: No registered users and 1 guest