#include "maru_common.h"
#include "maru_finger.h"
-/* keep it consistent with java definition */
+/* keep it consistent with emulator-skin definition */
enum {
HARD_KEY_HOME = 101,
HARD_KEY_POWER = 103,
HARD_KEY_VOL_DOWN = 114,
};
-/* keep it consistent with java definition */
+/* keep it consistent with emulator-skin definition */
enum {
MOUSE_DOWN = 1,
MOUSE_UP = 2,
MOUSE_DRAG = 3,
};
-/* keep it consistent with java definition */
+/* keep it consistent with emulator-skin definition */
enum {
KEY_PRESSED = 1,
KEY_RELEASED = 2,
};
-/* keep it consistent with java definition */
+/* keep it consistent with emulator-skin definition */
enum {
ROTATION_PORTRAIT = 0,
ROTATION_LANDSCAPE = 1,
@Override
public void run() {
- logger.warning( " EmulatorShutdownhook run by a signal." );
+ logger.info( " EmulatorShutdownhook run by a signal." );
communicator.terminate();
}
shell.redraw( currentHoverRegion.x, currentHoverRegion.y, currentHoverRegion.width + 1,
currentHoverRegion.height + 1, false );
}
- KeyEventData keyEventData = new KeyEventData( KeyEventType.RELEASED.value(), keyCode );
+ KeyEventData keyEventData = new KeyEventData( KeyEventType.RELEASED.value(), keyCode, 0 );
communicator.sendToQEMU( SendCommand.SEND_HARD_KEY_EVENT, keyEventData );
}
gc.dispose();
}
- KeyEventData keyEventData = new KeyEventData( KeyEventType.PRESSED.value(), keyCode );
+ KeyEventData keyEventData = new KeyEventData( KeyEventType.PRESSED.value(), keyCode, 0 );
communicator.sendToQEMU( SendCommand.SEND_HARD_KEY_EVENT, keyEventData );
}
}
logger.info( "key released. key event:" + e );
int keyCode = e.keyCode | e.stateMask;
- KeyEventData keyEventData = new KeyEventData( KeyEventType.RELEASED.value(), keyCode );
+ KeyEventData keyEventData = new KeyEventData( KeyEventType.RELEASED.value(), keyCode, e.keyLocation );
communicator.sendToQEMU( SendCommand.SEND_KEY_EVENT, keyEventData );
}
public void keyPressed( KeyEvent e ) {
logger.info( "key pressed. key event:" + e );
int keyCode = e.keyCode | e.stateMask;
- KeyEventData keyEventData = new KeyEventData( KeyEventType.PRESSED.value(), keyCode );
+ KeyEventData keyEventData = new KeyEventData( KeyEventType.PRESSED.value(), keyCode, e.keyLocation );
communicator.sendToQEMU( SendCommand.SEND_KEY_EVENT, keyEventData );
}
int eventType;
int keycode;
+ int keyLocation;
- public KeyEventData(int eventType, int keycode) {
+ public KeyEventData(int eventType, int keycode, int keyLocation) {
this.eventType = eventType;
this.keycode = keycode;
+ this.keyLocation = keyLocation;
}
@Override
protected void write() throws IOException {
writeInt(eventType);
writeInt(keycode);
+ writeInt(keyLocation);
}
@Override
builder.append(eventType);
builder.append(", keycode=");
builder.append(keycode);
+ builder.append(", keyLocation=");
+ builder.append(keyLocation);
builder.append("]");
return builder.toString();
}
MULTI_DEBUG_CHANNEL(qemu, skin_keymap);
-int javakeycode_to_scancode(int java_keycode, int event_type)
+int javakeycode_to_scancode(int java_keycode, int event_type, int key_location)
{
int state_mask = java_keycode & JAVA_KEYCODE_BIT;
int vk = java_keycode & JAVA_KEY_MASK;
if (vk == 0) { //meta keys
if (java_keycode == JAVA_KEYCODE_BIT_CTRL) { //ctrl key
+ if (key_location == JAVA_KEYLOCATION_RIGHT) {
+ kbd_put_keycode(224); //0xE0
+ }
return 29;
} else if (java_keycode == JAVA_KEYCODE_BIT_SHIFT) { //shift key
+ if (key_location == JAVA_KEYLOCATION_RIGHT) {
+ return 54; //Shift_R
+ }
return 42;
} else if (java_keycode == JAVA_KEYCODE_BIT_ALT) { //alt key
+ if (key_location == JAVA_KEYLOCATION_RIGHT) {
+ kbd_put_keycode(224);
+ }
return 56;
} else {
return -1;
} else { //special keys
switch(vk) {
case JAVA_KEY_ARROW_UP :
+ if (key_location != JAVA_KEYLOCATION_KEYPAD) {
+ kbd_put_keycode(224);
+ }
vk = KEY_UP;
break;
case JAVA_KEY_ARROW_DOWN :
+ if (key_location != JAVA_KEYLOCATION_KEYPAD) {
+ kbd_put_keycode(224);
+ }
vk = KEY_DOWN;
break;
case JAVA_KEY_ARROW_LEFT :
+ if (key_location != JAVA_KEYLOCATION_KEYPAD) {
+ kbd_put_keycode(224);
+ }
vk = KEY_LEFT;
break;
case JAVA_KEY_ARROW_RIGHT :
+ if (key_location != JAVA_KEYLOCATION_KEYPAD) {
+ kbd_put_keycode(224);
+ }
vk = KEY_RIGHT;
break;
case JAVA_KEY_BREAK :
return 198;
case JAVA_KEY_PRINT_SCREEN :
- //TODO:
+ //not support
return -1;
break;
default :
#define MARUSKIN_KEYMAP_H_
-/* keep it consistent with java virtual keycode */
+/* keep it consistent with emulator-skin(swt) virtual keycode */
#define JAVA_KEYCODE_BIT (1 << 24)
#define JAVA_KEYCODE_BIT_CTRL (1 << 18)
#define JAVA_KEYCODE_BIT_SHIFT (1 << 17)
#define JAVA_KEYCODE_BIT_ALT (1 << 16)
+//key location
+#define JAVA_KEYLOCATION_KEYPAD (1 << 1)
+#define JAVA_KEYLOCATION_LEFT (1 << 14)
+#define JAVA_KEYLOCATION_RIGHT (1 << 17)
+
#define JAVA_KEY_MASK 0xFFFF;
enum JAVA_KEYCODE {
['?'] = 53 | SHIFT,
};
-int javakeycode_to_scancode(int java_keycode, int event_type);
+int javakeycode_to_scancode(int java_keycode, int event_type, int key_location);
#endif /* MARUSKIN_KEYMAP_H_ */
#endif
}
-void do_key_event( int event_type, int keycode )
+void do_key_event( int event_type, int keycode, int key_location )
{
- TRACE( "key_event event_type:%d, keycode:%d\n", event_type, keycode );
+ TRACE( "key_event event_type:%d, keycode:%d, key_location:%d\n", event_type, keycode, key_location );
//is multi-touch mode ?
if (keycode == JAVA_KEYCODE_BIT_CTRL && get_emul_max_touch_point() > 1) {
return;
}
- int scancode = javakeycode_to_scancode(keycode, event_type);
+ int scancode = javakeycode_to_scancode(keycode, event_type, key_location);
+ TRACE("javakeycode_to_scancode : %d\n", scancode);
+
if (scancode == -1) {
INFO("cannot find scancode\n");
return;
void do_mouse_event( int event_type, int x, int y, int z );
-void do_key_event( int event_type, int keycode );
+void do_key_event( int event_type, int keycode, int key_location );
void do_hardkey_event( int event_type, int keycode );
continue;
}
+ /* keep it consistent with emulator-skin definition */
int handle_id = 0;
int lcd_size_width = 0;
int lcd_size_height = 0;
continue;
}
+ /* keep it consistent with emulator-skin definition */
int event_type = 0;
int x = 0;
int y = 0;
continue;
}
+ /* keep it consistent with emulator-skin definition */
int event_type = 0;
int keycode = 0;
+ int key_location = 0;
char* p = recvbuf;
memcpy( &event_type, p, sizeof( event_type ) );
p += sizeof( event_type );
memcpy( &keycode, p, sizeof( keycode ) );
+ p += sizeof( keycode );
+ memcpy( &key_location, p, sizeof( key_location ) );
event_type = ntohl( event_type );
keycode = ntohl( keycode );
+ key_location = ntohl( key_location );
- do_key_event( event_type, keycode );
+ do_key_event( event_type, keycode, key_location );
break;
}
case RECV_HARD_KEY_EVENT: {
continue;
}
+ /* keep it consistent with emulator-skin definition */
int event_type = 0;
int keycode = 0;
continue;
}
+ /* keep it consistent with emulator-skin definition */
int scale = 0;
double scale_ratio = 0.0;
short rotation_type = 0;