예제 #1
0
    @Override
    public boolean onKeyMultiple(int keyCode, int count, KeyEvent event) {
      if (keyCode != KeyEvent.KEYCODE_UNKNOWN || event.getAction() != KeyEvent.ACTION_MULTIPLE)
        return super.onKeyMultiple(keyCode, count, event);

      if (event.getCharacters() != null) {
        int utf8Char = event.getCharacters().codePointAt(0);
        handleKeyDown(host, utf8Char, utf8Char);
        return true;
      }

      return false;
    }
예제 #2
0
  @Override
  public boolean onKeyMultiple(final int inKeyCode, int repeatCount, KeyEvent event) {
    String s = event.getCharacters();
    if (s == null || s.length() == 0) return super.onKeyMultiple(inKeyCode, repeatCount, event);

    final char[] cc = s.toCharArray();
    int cnt = 0;
    for (int i = cc.length; --i >= 0; cnt += cc[i] != 0 ? 1 : 0) ;
    if (cnt == 0) return super.onKeyMultiple(inKeyCode, repeatCount, event);
    final Activity me = this;
    queueEvent(
        new Runnable() {
          // This method will be called on the rendering thread:
          public void run() {
            for (int i = 0, n = cc.length; i < n; i++) {
              int keyCode;
              if ((keyCode = cc[i]) != 0) {
                // Simulate key down and up...
                GodotLib.key(0, keyCode, true);
                GodotLib.key(0, keyCode, false);
              }
            }
          }
        });
    return true;
  }