Esempio n. 1
0
  protected boolean keyDown(final int keycode, int time) {
    System.out.println("***** keyDown *****");
    System.out.println("keycode=" + keycode);
    char altedKey = '0';
    boolean useAltedKey = false;
    final int key;
    boolean isAltedKeyboard = false;
    try {
      isAltedKeyboard = hwKeyboardLayoutsLst.containsKey(Keypad.getHardwareLayout());
      // System.out.println("hw layout " + Integer.toString(Keypad.getHardwareLayout()) +
      // (isAltedKeyboard ? " alted" : " non-alted") );
    } catch (Exception e) {
      System.out.println("contains Exception " + e);
    }
    if (isAltedKeyboard) { // Alted keyboard
      altedKey = Keypad.map(Keypad.key(keycode), KeypadListener.STATUS_ALT);
      if ((altedKey == '#') || (altedKey == '*')) { // enable zoom in zoom out.
        useAltedKey = true;
      }
    }

    if (keyDownStackAddress == 0) {
      Logger.log("keyDownStackAddress = 0, before stack init ");
      return true;
    }

    key = Keypad.key(keycode);

    System.out.println("key is = " + key);

    final int status = Keypad.status(keycode);
    // System.out.println("key=" + keycode + " status=" + status);

    if (key == Keypad.KEY_MENU) {
      System.out.println("***** MENU BUTTON PRESSED *****");
      menu_open = true;
      try {
        if (c_on_menu_key_down == 0) {
          c_on_menu_key_down = CibylCallTable.getAddressByName("rim_on_menu_button");
        }
        if (c_on_menu_key_down != 0) {
          // FIXME - should send keycode to C and C should trans to UTF8
          updateUTF8Key(keycode);
          CibylCallTable.call(c_on_menu_key_down, keyDownStackAddress, key, status, time, 0);
        }
      } catch (Exception t) {
        Logger.log("Exception in UI action: " + t);
        t.printStackTrace();
      }
      return false; // return false so RIM will open the menu as necessary.
    } else if (key == Keypad.KEY_VOLUME_DOWN) {
      SoundMgr.updateSoundLevel(-10);
    } else if (key == Keypad.KEY_VOLUME_UP) {
      SoundMgr.updateSoundLevel(10);
    } else if ((key == Keypad.KEY_SEND)
        || (key == Keypad.KEY_APPLICATION)
        || (key == Keypad.KEY_SPEAKERPHONE)
        || (key == Keypad.KEY_CONVENIENCE_1)
        || (key == Keypad.KEY_CONVENIENCE_2)) {
      return false;

    } else if (key == Keypad.KEY_END) {
      return false;
    } else {
      try {
        if (c_on_key_down == 0) c_on_key_down = CibylCallTable.getAddressByName("rim_on_key_down");
      } catch (Throwable t) {
        Logger.log("Exception in keyDown: " + t);
        t.printStackTrace();

        System.exit(0);
      }

      if (c_on_key_down != 0) {
        // FIXME - should send keycode to C and C should trans to UTF8
        if (!useAltedKey) updateUTF8Key(keycode);
        else updateUTF8Key(altedKey);

        UIWorker.addUIEvent(c_on_key_down, key, status, time, 0, true);
      }
    }
    return true;
  }
Esempio n. 2
0
 public static void updateUTF8Key(int keycode) {
   char c = Keypad.map(keycode);
   updateUTF8Key(c);
 }