package api; /** * * @author PLUTONiUM */ public abstract class GameCanvas extends javax.microedition.lcdui.game.GameCanvas { public static final int DOWN_PRESSED = 2; public static final int FIRE_PRESSED = (2 << 1); public static final int LEFT_PRESSED = (2 << 2); public static final int RIGHT_PRESSED = (2 << 3); public static final int UP_PRESSED = (2 << 4); public static final int GAME_A_PRESSED = (2 << 5); public static final int GAME_B_PRESSED = (2 << 6); public static final int GAME_C_PRESSED = (2 << 7); public static final int GAME_D_PRESSED = (2 << 8); public static final int KEY_NUM0_PRESSED = (2 << 9); public static final int KEY_NUM1_PRESSED = (2 << 10); public static final int KEY_NUM2_PRESSED = (2 << 11); public static final int KEY_NUM3_PRESSED = (2 << 12); public static final int KEY_NUM4_PRESSED = (2 << 13); public static final int KEY_NUM5_PRESSED = (2 << 14); public static final int KEY_NUM6_PRESSED = (2 << 15); public static final int KEY_NUM7_PRESSED = (2 << 16); public static final int KEY_NUM8_PRESSED = (2 << 17); public static final int KEY_NUM9_PRESSED = (2 << 18); public static final int KEY_POUND_PRESSED = (2 << 19); public static final int KEY_STAR_PRESSED = (2 << 20); private int keyStates; protected GameCanvas(boolean suppressKeyEvents) { super(suppressKeyEvents); } public int getKeyStates() { return keyStates; } protected void keyPressed(int keyCode) { switch(keyCode) { case DOWN: keyStates |= DOWN_PRESSED; break; case FIRE: keyStates |= FIRE_PRESSED; break; case LEFT: keyStates |= LEFT_PRESSED; break; case RIGHT: keyStates |= RIGHT_PRESSED; break; case UP: keyStates |= UP_PRESSED; break; case GAME_A: keyStates |= GAME_A_PRESSED; break; case GAME_B: keyStates |= GAME_B_PRESSED; break; case GAME_C: keyStates |= GAME_C_PRESSED; break; case GAME_D: keyStates |= GAME_D_PRESSED; break; case KEY_NUM0: keyStates |= KEY_NUM0_PRESSED; break; case KEY_NUM1: keyStates |= KEY_NUM1_PRESSED; break; case KEY_NUM2: keyStates |= KEY_NUM2_PRESSED; break; case KEY_NUM3: keyStates |= KEY_NUM3_PRESSED; break; case KEY_NUM4: keyStates |= KEY_NUM4_PRESSED; break; case KEY_NUM5: keyStates |= KEY_NUM5_PRESSED; break; case KEY_NUM6: keyStates |= KEY_NUM6_PRESSED; break; case KEY_NUM7: keyStates |= KEY_NUM7_PRESSED; break; case KEY_NUM8: keyStates |= KEY_NUM8_PRESSED; break; case KEY_NUM9: keyStates |= KEY_NUM9_PRESSED; break; case KEY_POUND: keyStates |= KEY_POUND_PRESSED; break; case KEY_STAR: keyStates |= KEY_STAR_PRESSED; break; } } protected void keyReleased(int keyCode) { switch(keyCode) { case DOWN: keyStates ^= DOWN_PRESSED; break; case FIRE: keyStates ^= FIRE_PRESSED; break; case LEFT: keyStates ^= LEFT_PRESSED; break; case RIGHT: keyStates ^= RIGHT_PRESSED; break; case UP: keyStates ^= UP_PRESSED; break; case GAME_A: keyStates ^= GAME_A_PRESSED; break; case GAME_B: keyStates ^= GAME_B_PRESSED; break; case GAME_C: keyStates ^= GAME_C_PRESSED; break; case GAME_D: keyStates ^= GAME_D_PRESSED; break; case KEY_NUM0: keyStates ^= KEY_NUM0_PRESSED; break; case KEY_NUM1: keyStates ^= KEY_NUM1_PRESSED; break; case KEY_NUM2: keyStates ^= KEY_NUM2_PRESSED; break; case KEY_NUM3: keyStates ^= KEY_NUM3_PRESSED; break; case KEY_NUM4: keyStates ^= KEY_NUM4_PRESSED; break; case KEY_NUM5: keyStates ^= KEY_NUM5_PRESSED; break; case KEY_NUM6: keyStates ^= KEY_NUM6_PRESSED; break; case KEY_NUM7: keyStates ^= KEY_NUM7_PRESSED; break; case KEY_NUM8: keyStates ^= KEY_NUM8_PRESSED; break; case KEY_NUM9: keyStates ^= KEY_NUM9_PRESSED; break; case KEY_POUND: keyStates ^= KEY_POUND_PRESSED; break; case KEY_STAR: keyStates ^= KEY_STAR_PRESSED; break; } } }