[Title] support keylocation feature
authorgiwoong.kim <giwoong.kim@samsung.com>
Thu, 5 Apr 2012 08:23:57 +0000 (17:23 +0900)
committergiwoong.kim <giwoong.kim@samsung.com>
Thu, 5 Apr 2012 08:23:57 +0000 (17:23 +0900)
[Type] enhancement
[Module] Emulator / keyboard
[Priority]
[Jira#]
[Redmine#]
[Problem]
[Cause] arrow keys & _R keys
[Solution]
[TestCase]

tizen/src/emul_state.h
tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorShutdownhook.java
tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java
tizen/src/skin/client/src/org/tizen/emulator/skin/comm/sock/data/KeyEventData.java
tizen/src/skin/maruskin_keymap.c
tizen/src/skin/maruskin_keymap.h
tizen/src/skin/maruskin_operation.c
tizen/src/skin/maruskin_operation.h
tizen/src/skin/maruskin_server.c

index adfde8e..2018f8a 100644 (file)
@@ -37,7 +37,7 @@
 #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,
@@ -45,20 +45,20 @@ enum {
     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,
index bf171dc..bc5806b 100644 (file)
@@ -49,7 +49,7 @@ public class EmulatorShutdownhook extends Thread {
 
        @Override
        public void run() {
-               logger.warning( " EmulatorShutdownhook run by a signal." );
+               logger.info( " EmulatorShutdownhook run by a signal." );
                communicator.terminate();
        }
        
index 1f001fc..fda3280 100644 (file)
@@ -575,7 +575,7 @@ public class EmulatorSkin {
                                                        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 );
                                        }
 
@@ -605,7 +605,7 @@ public class EmulatorSkin {
                                                        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 );
                                        }
                                }
@@ -762,7 +762,7 @@ public class EmulatorSkin {
                                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 );
                        }
 
@@ -770,7 +770,7 @@ public class EmulatorSkin {
                        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 );
                        }
 
index fda5a86..032bda1 100644 (file)
@@ -39,16 +39,19 @@ public class KeyEventData extends AbstractSendData {
 
        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
@@ -58,6 +61,8 @@ public class KeyEventData extends AbstractSendData {
                builder.append(eventType);
                builder.append(", keycode=");
                builder.append(keycode);
+               builder.append(", keyLocation=");
+               builder.append(keyLocation);
                builder.append("]");
                return builder.toString();
        }
index 25f5376..a5f8c83 100644 (file)
@@ -36,7 +36,7 @@
 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;
@@ -83,10 +83,19 @@ int javakeycode_to_scancode(int java_keycode, int event_type)
 
     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;
@@ -100,15 +109,27 @@ int javakeycode_to_scancode(int java_keycode, int event_type)
         } 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;
 
@@ -162,7 +183,7 @@ int javakeycode_to_scancode(int java_keycode, int event_type)
                 case JAVA_KEY_BREAK :
                     return 198;
                 case JAVA_KEY_PRINT_SCREEN :
-                    //TODO:
+                    //not support
                     return -1;
                     break;
                 default :
index b43e24e..ae99f51 100644 (file)
 #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 {
@@ -224,6 +229,6 @@ static const int vkkey2scancode[KEY_MAX] = {
     ['?'] = 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_ */
index 7824768..a90a2cb 100644 (file)
@@ -86,9 +86,9 @@ void do_mouse_event( int event_type, int x, int y, int z )
 #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) {
@@ -106,7 +106,9 @@ void do_key_event( int event_type, int keycode )
        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;
index d1d13de..1b33105 100644 (file)
@@ -46,7 +46,7 @@ void start_display( int handle_id, int lcd_size_width, int lcd_size_height, doub
 
 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 );
 
index fed9c53..69faac9 100644 (file)
@@ -495,6 +495,7 @@ static void* run_skin_server( void* args ) {
                         continue;
                     }
 
+                    /* keep it consistent with emulator-skin definition */
                     int handle_id = 0;
                     int lcd_size_width = 0;
                     int lcd_size_height = 0;
@@ -535,6 +536,7 @@ static void* run_skin_server( void* args ) {
                         continue;
                     }
 
+                    /* keep it consistent with emulator-skin definition */
                     int event_type = 0;
                     int x = 0;
                     int y = 0;
@@ -566,18 +568,23 @@ static void* run_skin_server( void* args ) {
                         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: {
@@ -589,6 +596,7 @@ static void* run_skin_server( void* args ) {
                         continue;
                     }
 
+                    /* keep it consistent with emulator-skin definition */
                     int event_type = 0;
                     int keycode = 0;
 
@@ -612,6 +620,7 @@ static void* run_skin_server( void* args ) {
                         continue;
                     }
 
+                    /* keep it consistent with emulator-skin definition */
                     int scale = 0;
                     double scale_ratio = 0.0;
                     short rotation_type = 0;