Having Trouble with Key Input in Mobile Handsets.

Started by
4 comments, last by Goguis 16 years, 10 months ago
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.
Advertisement
Are you using a full screen canvas?

shmoove
Yes I'm.
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
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]
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!

This topic is closed to new replies.

Advertisement