Sign in to follow this  
Goguis

Having Trouble with Key Input in Mobile Handsets.

Recommended Posts

Hey guys. I'm using the value -7 to identify the Right Soft key action in some Nokia Phones... but it doesn't work. In J2ME Polish they say it's the right value. :S I have the Command Listener deactivated. Regards.

Share this post


Link to post
Share on other sites
That's strange. Usually when you don't get events for the softkeys it's either because you are not in full screen mode or because you have added Commands to you Canvas. You say you haven't done either.

You should add some code that draws the key code on the display when a key is pressed and see if it is getting called when you press the softkey, and what code it is giving.

shmoove

Share this post


Link to post
Share on other sites
Here's the code i'm using. I just don't get it. I use KEY_NUM0 or any other and it doesn't work either. I use the UP_PRESSED and it works. :S Maybe it's because i'm using GameCanvas? Should i use just Canvas?

[EDIT]
I just noticed that if i use just UP, and not UP_PRESSED, it doesn't work. This means that i need to use
Thanks shmoove.

[EDIT2]
Damn... my game is made based on GameCanvas, not on Canvas. :S If thats the problem... ufh, is there anything i can do to avoid adapting it to canvas?



public void inputInGame()
{
if(keyStates==0)
{
keyStates = getKeyStates();

switch(keyStates)
{
case UP_PRESSED:

break;
case DOWN_PRESSED:

break;
case LEFT_PRESSED:

break;
case RIGHT_PRESSED:

break;
case FIRE_PRESSED:

break;
case -7:
isMenuInGame=true;
break;
default:
break;
}
}
keyStates = getKeyStates();
}



[Edited by - Goguis on June 10, 2007 12:10:04 PM]

Share this post


Link to post
Share on other sites
Shmoove! At last I figured it out!. I was using getKeyState() when i should be using

public void keyPressed(int keyCode)
{

}

Ufh, i started to freak out! lol

Thanks for all the help!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this