Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Key down: show/hide soft keyboard on menu button. Back button turns the mouse
- // yellow for one click. Page up button turns the mouse blue for one click.
- public boolean onKeyDown(int keyCode, KeyEvent event) {
- ctx.toastMsg("Key Event: " + event + " " + keyCode);
- switch(keyCode) {
- case KeyEvent.KEYCODE_BACK:
- buttonBits = yellowButtonBit;
- ctx.toastMsg("mouse yellow");
- return true;
- case 92: //KeyEvent.KEYCODE_PAGE_UP:
- buttonBits = blueButtonBit;
- ctx.toastMsg("mouse blue");
- return true;
- case KeyEvent.KEYCODE_MENU:
- InputMethodManager imm = (InputMethodManager)
- ctx.getSystemService(Context.INPUT_METHOD_SERVICE);
- if (softKbdOn) { // true: hide
- imm.hideSoftInputFromWindow(this.getWindowToken(), 0);
- } else { // false: show
- imm.showSoftInput(this, 0);
- }
- softKbdOn = !softKbdOn;
- return true;
- case KeyEvent.KEYCODE_DEL: // special handling for DEL
- vm.sendEvent( 2 /* EventTypeKeyboard */,
- 0 /* timeStamp */,
- 8 /* charCode */,
- 0 /* EventKeyChar */,
- 0 /* modifiers */,
- 8 /* utf32Code */,
- 0 /* reserved1 */,
- 0 /* windowIndex */);
- vm.interpret();
- break;
- default: // send key event
- ctx.setTitle("Key Event: " + event + " " + keyCode);
- int uchar = event.getUnicodeChar();
- vm.sendEvent( 2 /* EventTypeKeyboard */,
- 0 /* timeStamp */,
- uchar /* charCode */,
- 0 /* EventKeyChar */,
- 0 /* modifiers */,
- uchar /* utf32Code */,
- 0 /* reserved1 */,
- 0 /* windowIndex */);
- vm.interpret();
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment