/** * @return a string name for the key * @throws IllegalArgumentException * if <code>keyCode</code> is not a valid key code */ public String getKeyName(int keyCode) throws IllegalArgumentException { for (Iterator it = DeviceFactory.getDevice().getButtons().iterator(); it.hasNext();) { J2SEButton button = (J2SEButton) it.next(); if (button.getKeyCode() == keyCode) { return button.getName(); } } return Character.toString((char) keyCode); }
/** * * * @return a key code corresponding to this game action * @throws IllegalArgumentException * if <code>gameAction</code> is not a valid game action */ public int getKeyCode(int gameAction) { ButtonName name = ButtonDetaultDeviceKeyCodes.getButtonNameByGameAction(gameAction); return J2SEDeviceButtonsHelper.getButton(name).getKeyCode(); }
/** * Gets the game action associated with the given key code of the device. * * @return the game action corresponding to this key, or <code>0</code> if * none */ public int getGameAction(int keyCode) { for (Iterator it = DeviceFactory.getDevice().getButtons().iterator(); it.hasNext();) { J2SEButton button = (J2SEButton) it.next(); if (button.getKeyCode() == keyCode) { return ButtonDetaultDeviceKeyCodes.getGameAction(button.getFunctionalName()); } } return 0; }
public void buttonReleased(J2SEButton button, char keyChar) { int keyCode = keyChar; if (button != null && keyChar == '\0') { keyCode = button.getKeyCode(); } if (DeviceFactory.getDevice().hasRepeatEvents()) { repeatModeKeyCodes.remove(new Integer(keyCode)); keyReleasedDelayTimer.schedule(new KeyReleasedDelayTask(keyCode), 50); } else { MIDletAccess ma = MIDletBridge.getMIDletAccess(); if (ma == null) { return; } DisplayAccess da = ma.getDisplayAccess(); if (da == null) { return; } da.keyReleased(keyCode); eventAlreadyConsumed = false; } }
public void buttonPressed(J2SEButton button, char keyChar) { int keyCode = keyChar; if (button != null && keyChar == '\0') { keyCode = button.getKeyCode();
if (d != null && d instanceof Screen) { if (initialPressedSoftButton.getName().equals("up")) { da.keyPressed(getButtonByButtonName(ButtonName.UP).getKeyCode()); } else if (initialPressedSoftButton.getName().equals("down")) { da.keyPressed(getButtonByButtonName(ButtonName.DOWN).getKeyCode());
keyCode = button.getKeyCode(); da.keyPressed(button.getKeyCode()); return true;