Some of the keys of samsung i610 do not respond to keyPressed() / keyReleased() or keyRepeated().
Anyone can show me a way to solve this issue..
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class EventEx3 extends MIDlet {
Display display;
Command lsk;
public EventEx3() {
display = Display.getDisplay(this);
}
public void destroyApp (boolean unconditional) {
}
public void pauseApp () {
System.out.println("App paused.");
}
public void startApp () {
display = Display.getDisplay(this);
Canvas canvas = new Canvas() { // anonymous class
public void paint(Graphics g) {
}
protected void keyPressed(int keyCode) {
if (keyCode == -244) {
//do what ever u need when lsk is pressed
} else if (keyCode == -243) {
//do what ever u need when rsk is pressed
} else if (keyCode > 0) {
System.out.println("keyPressed " +((char)keyCode));
} else {
System.out.println("keyPressed action " +getGameAction(keyCode));
}
}
protected void keyReleased(int keyCode) {
if (keyCode > 0) {
System.out.println("keyReleased " +((char)keyCode));
} else {
System.out.println("keyReleased action " +getGameAction(keyCode));
}
}
}; // end of anonymous class
lsk = new Command("LSK", Command.STOP, 1);
rsk = new Command("RSK", Command.STOP, 1);
canvas.addCommand(lsk);
canvas.addCommand(rsk);
canvas.setCommandListener(new CommandListener() {
public void commandAction(Command c, Displayable d) {
if(c == lsk) {
canva.keyPressed(-244);
} else if(c == rsk) {
canva.keyPressed(-243);
} else {
System.out.println("Saw the command: "+c);
}
}
});
display.setCurrent(canvas);
}
} Return to Mobile Game Porting and Testing
Users browsing this forum: No registered users and 1 guest