for (Enumeration en = dev.getButtons().elements(); en.hasMoreElements();) { J2SEButton button = (J2SEButton) en.nextElement(); int keyCodes[] = button.getKeyboardKeyCodes(); for (int i = 0; i < keyCodes.length; i++) { inf.keyboardKeyCodes.put(new Integer(keyCodes[i]), button); char charCodes[] = button.getKeyboardCharCodes(); for (int i = 0; i < charCodes.length; i++) { inf.keyboardCharCodes.put(new Integer(charCodes[i]), button); inf.functions.put(button.getFunctionalName(), button); if (button.isModeChange()) { hasModeChange = true; J2SEButton button = (J2SEButton) inf.functions.get(ButtonName.KEY_POUND); if (button != null) { button.setModeChange(); } else { Logger.warn("Device has no ModeChange and POUND buttons"); dev.getButtons().add(new J2SEButton(ButtonName.DELETE)); dev.getButtons().add(new J2SEButton(ButtonName.BACK_SPACE));
public boolean isChar(char c, int inputMode) { if (inputToChars == null) { return false; } c = Character.toLowerCase(c); char[] chars = getChars(inputMode); if (chars != null) { for (int i = 0; i < chars.length; i++) { if (c == Character.toLowerCase(chars[i])) { return true; } } } return false; }
/** * @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); }
/** * 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; }
keyCode = button.getKeyCode(); ButtonName functionalName = button.getFunctionalName(); da.keyPressed(button.getKeyCode()); return true; if (button.isModeChange()) { switch (inputMethodListener.getConstraints() & TextField.CONSTRAINT_MASK) { case TextField.ANY: synchronized (this) { lastButtonCharIndex++; char[] buttonChars = filterConstraints(filterInputMode(button.getChars(getInputMode()))); if (keyChar != '\0') {
public static J2SEButton getSkinButton(MouseEvent ev) { for (Enumeration en = DeviceFactory.getDevice().getButtons().elements(); en.hasMoreElements();) { J2SEButton button = (J2SEButton) en.nextElement(); if (button.getShape() != null) { if (button.getShape().contains(ev.getX(), ev.getY())) { return button; } } } return null; }
/** * * * @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(); }
public Button createButton(int skinVersion, String name, org.microemu.device.impl.Shape shape, int keyCode, String keyboardKeys, String keyboardChars, Hashtable inputToChars, boolean modeChange) { return new J2SEButton(skinVersion, name, shape, keyCode, keyboardKeys, keyboardChars, inputToChars, modeChange); }
private J2SEButton getButtonByButtonName(ButtonName buttonName) { J2SEButton result; for (Enumeration e = DeviceFactory.getDevice().getButtons().elements(); e.hasMoreElements();) { result = (J2SEButton) e.nextElement(); if (result.getFunctionalName() == buttonName) { return result; } } return null; } }
public J2SEButton getButton(KeyEvent ev) { J2SEButton button = J2SEDeviceButtonsHelper.getButton(ev); if (button != null) { return button; } if (getInputMode() != INPUT_123) { for (Enumeration e = DeviceFactory.getDevice().getButtons().elements(); e.hasMoreElements();) { button = (J2SEButton) e.nextElement(); if (button.isChar(ev.getKeyChar(), getInputMode())) { return button; } } } return null; } }
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; } }
pressedButton = null; if (prevOverButton != null) { org.microemu.device.impl.Shape shape = prevOverButton.getShape(); if (shape != null) { repaint(shape.getBounds());
public void buttonPressed(J2SEButton button, char keyChar) { int keyCode = keyChar; if (button != null && keyChar == '\0') { keyCode = button.getKeyCode();
keyChar = '\0'; org.microemu.device.impl.Shape shape = button.getShape(); if (shape != null) { repaint(shape.getBounds());
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());
org.microemu.device.impl.Shape shape = prevOverButton.getShape(); if (shape != null) { drawImageInShape(offg, ((J2SEImmutableImage) device.getNormalImage()).getImage(), shape); org.microemu.device.impl.Shape shape = overButton.getShape(); if (shape != null) { drawImageInShape(offg, ((J2SEImmutableImage) device.getOverImage()).getImage(), shape); org.microemu.device.impl.Shape shape = pressedButton.getShape(); if (shape != null) { drawImageInShape(offg, ((J2SEImmutableImage) device.getPressedImage()).getImage(), shape);
public void mouseReleased(MouseEvent e) { mouseButtonDown = false; MouseRepeatedTimerTask.stop(); if (pressedButton == null) { return; } if (MIDletBridge.getCurrentMIDlet() == null) { return; } Device device = DeviceFactory.getDevice(); J2SEInputMethod inputMethod = (J2SEInputMethod) device.getInputMethod(); J2SEButton prevOverButton = J2SEDeviceButtonsHelper.getSkinButton(e); if (prevOverButton != null) { inputMethod.buttonReleased(prevOverButton, '\0'); } pressedButton = null; // optimize for some video cards. if (prevOverButton != null) { repaint(prevOverButton.getShape().getBounds()); } else { repaint(); } }
repaint(pressedButton.getShape().getBounds());