cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=1d18543719a98f9b4e99638c4d8f2e67720b84a2

commit 1d18543719a98f9b4e99638c4d8f2e67720b84a2
Author: Michelle Legrand <michelle.legr...@openwide.fr>
Date:   Thu Jan 22 11:24:42 2015 +0100

    ecore_cocoa: handle more special characters and capital characters.
    
    This patch is self contained for Mac OS X and improve its keyboard handling.
    
    Signed-off-by: Cedric BAIL <ced...@osg.samsung.com>
---
 src/lib/ecore_cocoa/Ecore_Cocoa_Keys.h | 81 ++++++++++++++++++++++------------
 src/lib/ecore_cocoa/ecore_cocoa.m      | 68 +++++++++++++++++-----------
 2 files changed, 96 insertions(+), 53 deletions(-)

diff --git a/src/lib/ecore_cocoa/Ecore_Cocoa_Keys.h 
b/src/lib/ecore_cocoa/Ecore_Cocoa_Keys.h
index 53b17ed..69a4872 100644
--- a/src/lib/ecore_cocoa/Ecore_Cocoa_Keys.h
+++ b/src/lib/ecore_cocoa/Ecore_Cocoa_Keys.h
@@ -26,7 +26,7 @@ static const struct _ecore_cocoa_keys_s keystable[] =
 { 34,                        "quotedbl",     "\"" },
 { 35,                        "numbersign",   "#" },
 { 36,                        "dollar",       "$" },
-{ 37,                        "percent",      "%%" },
+{ 37,                        "percent",      "%" },
 { 38,                        "ampersand",    "&" },
 { 39,                        "apostrophe",   "'" },
 { 40,                        "parenleft",    "(" },
@@ -47,14 +47,39 @@ static const struct _ecore_cocoa_keys_s keystable[] =
 { 55,                        "7",            "7" },
 { 56,                        "8",            "8" },
 { 57,                        "9",            "9" },
-{ 58,                        "colon",        ";" },
+{ 58,                        "colon",        ":" },
 { 59,                        "semicolon",    ";" },
 { 60,                        "less",         "<" },
 { 61,                        "equal",        "=" },
 { 62,                        "greater",      ">" },
 { 63,                        "question",     "?" },
 { 64,                        "at",           "@" },
-
+{ 65,                        "A",            "A" },
+{ 66,                        "B",            "B" },
+{ 67,                        "C",            "C" },
+{ 68,                        "D",            "D" },
+{ 69,                        "E",            "E" },
+{ 70,                        "F",            "F" },
+{ 71,                        "G",            "G" },
+{ 72,                        "H",            "H" },
+{ 73,                        "I",            "I" },
+{ 74,                        "J",            "J" },
+{ 75,                        "K",            "K" },
+{ 76,                        "L",            "L" },
+{ 77,                        "M",            "M" },
+{ 78,                        "N",            "N" },
+{ 79,                        "O",            "O" },
+{ 80,                        "P",            "P" },
+{ 81,                        "Q",            "Q" },
+{ 82,                        "R",            "R" },
+{ 83,                        "S",            "S" },
+{ 84,                        "T",            "T" },
+{ 85,                        "U",            "U" },
+{ 86,                        "V",            "V" },
+{ 87,                        "W",            "W" },
+{ 88,                        "X",            "X" },
+{ 89,                        "Y",            "Y" },
+{ 90,                        "Z",            "Z" },
 { 91,                        "bracketleft",  "[" },
 { 92,                        "backslash",    "\\" },
 { 93,                        "bracketright", "]" },
@@ -87,9 +112,9 @@ static const struct _ecore_cocoa_keys_s keystable[] =
 { 120,                       "x",            "x" },
 { 121,                       "y",            "y" },
 { 122,                       "z",            "z" },
-{ 123,                       "braceleft",    "" },
-{ 124,                       "pipe",         "" },
-{ 125,                       "braceright",   "" },
+{ 123,                       "braceleft",    "{" },
+{ 124,                       "pipe",         "|" },
+{ 125,                       "braceright",   "}" },
 { 127,                       "BackSpace",    "\177" },
 { 126,                       "asciitilde",   "~" },
 
@@ -100,7 +125,7 @@ static const struct _ecore_cocoa_keys_s keystable[] =
 { 164,                       "w4",           "" },
 { 165,                       "w5",           "" },
 { 166,                       "w6",           "" },
-{ 167,                       "w7",           "" },
+{ 167,                       "w7",           "§" },
 { 168,                       "w8",           "" },
 { 169,                       "w9",           "" },
 { 170,                       "w10",          "" },
@@ -109,7 +134,7 @@ static const struct _ecore_cocoa_keys_s keystable[] =
 { 173,                       "w13",          "" },
 { 174,                       "w14",          "" },
 { 175,                       "w15",          "" },
-{ 176,                       "w16",          "" },
+{ 176,                       "w16",          "°" },
 { 177,                       "w17",          "" },
 { 178,                       "w18",          "" },
 { 179,                       "w19",          "" },
@@ -157,38 +182,38 @@ static const struct _ecore_cocoa_keys_s keystable[] =
 { 221,                       "w61",          "" },
 { 222,                       "w62",          "" },
 { 223,                       "w63",          "" },
-{ 224,                       "w64",          "" },
+{ 224,                       "w64",          "à" },
 { 225,                       "w65",          "" },
-{ 226,                       "w66",          "" },
-{ 227,                       "w67",          "" },
-{ 228,                       "w68",          "" },
+{ 226,                       "w66",          "â" },
+{ 227,                       "w67",          "ã" },
+{ 228,                       "w68",          "ä" },
 { 229,                       "w69",          "" },
 { 230,                       "w70",          "" },
-{ 231,                       "w71",          "" },
-{ 232,                       "w72",          "" },
-{ 233,                       "w73",          "" },
-{ 234,                       "w74",          "" },
-{ 235,                       "w75",          "" },
-{ 236,                       "w76",          "" },
+{ 231,                       "w71",          "ç" },
+{ 232,                       "w72",          "è" },
+{ 233,                       "w73",          "é" },
+{ 234,                       "w74",          "ê" },
+{ 235,                       "w75",          "ë" },
+{ 236,                       "w76",          "ì" },
 { 237,                       "w77",          "" },
-{ 238,                       "w78",          "" },
-{ 239,                       "w79",          "" },
+{ 238,                       "w78",          "î" },
+{ 239,                       "w79",          "ï" },
 { 240,                       "w80",          "" },
 { 241,                       "w81",          "" },
-{ 242,                       "w82",          "" },
+{ 242,                       "w82",          "ò" },
 { 243,                       "w83",          "" },
-{ 244,                       "w84",          "" },
-{ 245,                       "w85",          "" },
-{ 246,                       "w86",          "" },
+{ 244,                       "w84",          "ô" },
+{ 245,                       "w85",          "õ" },
+{ 246,                       "w86",          "ö"},
 { 247,                       "w87",          "" },
 { 248,                       "w88",          "" },
-{ 249,                       "w89",          "" },
+{ 249,                       "w89",          "ù" },
 { 250,                       "w90",          "" },
-{ 251,                       "w91",          "" },
-{ 252,                       "w92",          "" },
+{ 251,                       "w91",          "û" },
+{ 252,                       "w92",          "ü" },
 { 253,                       "w93",          "" },
 { 254,                       "w94",          "" },
-{ 255,                       "w95",          "" },
+{ 255,                       "w95",          "ÿ" },
 
 { 256,                       "KP0",          "0" },
 { 257,                       "KP1",          "1" },
diff --git a/src/lib/ecore_cocoa/ecore_cocoa.m 
b/src/lib/ecore_cocoa/ecore_cocoa.m
index f02601b..d57fd06 100644
--- a/src/lib/ecore_cocoa/ecore_cocoa.m
+++ b/src/lib/ecore_cocoa/ecore_cocoa.m
@@ -106,6 +106,8 @@ ecore_cocoa_feed_events(void *anEvent)
    NSEvent *event = anEvent;
    unsigned int time = (unsigned int)((unsigned long long)(ecore_time_get() * 
1000.0) & 0xffffffff);
    Eina_Bool pass = EINA_FALSE;
+   static Eina_Bool compose = EINA_FALSE;
+   static NSText *edit;
 
    switch ([event type])
    {
@@ -243,25 +245,38 @@ ecore_cocoa_feed_events(void *anEvent)
          Ecore_Event_Key *ev;
          unsigned int     i;
          EcoreCocoaWindow *window = (EcoreCocoaWindow *)[event window];
+         NSString *keychar = [event characters];
 
          ev = calloc(1, sizeof (Ecore_Event_Key));
          if (!ev) return pass;
          ev->timestamp = time;
          ev->modifiers = _ecore_cocoa_event_modifiers([event modifierFlags]);
 
-         for (i = 0; i < sizeof (keystable) / sizeof (struct 
_ecore_cocoa_keys_s); ++i)
-         {
-            if (keystable[i].code == tolower([[event 
charactersIgnoringModifiers] characterAtIndex:0]))
-            {
-               printf("Key pressed : %s\n", keystable[i].name);
-               ev->keyname = keystable[i].name;
-               ev->key = keystable[i].name;
-               ev->string = keystable[i].compose;
-               ev->window = (Ecore_Window)window.ecore_window_data;
-               ev->event_window = ev->window;
-               ecore_event_add(ECORE_EVENT_KEY_DOWN, ev, NULL, NULL);
-               return pass;
-            }
+         if (compose)
+           {
+              [edit interpretKeyEvents:[NSArray arrayWithObject:event]];
+              compose=EINA_FALSE;
+           }
+
+         if ([keychar length] > 0){
+           for (i = 0; i < sizeof (keystable) / sizeof (struct 
_ecore_cocoa_keys_s); ++i)
+           {
+              if (keystable[i].code == [keychar characterAtIndex:0])
+              {
+                 printf("Key pressed : %s\n", keystable[i].name);
+                 ev->keyname = keystable[i].name;
+                 ev->key = keystable[i].name;
+                 ev->string = keystable[i].compose;
+                 ev->window = (Ecore_Window)window.ecore_window_data;
+                 ev->event_window = ev->window;
+                 ecore_event_add(ECORE_EVENT_KEY_DOWN, ev, NULL, NULL);
+                 return pass;
+              }
+           }
+         }else{
+            compose=EINA_TRUE;
+            edit = [[event window]  fieldEditor:YES forObject:nil];
+            [edit interpretKeyEvents:[NSArray arrayWithObject:event]];
          }
 
          break;
@@ -271,6 +286,7 @@ ecore_cocoa_feed_events(void *anEvent)
          Ecore_Event_Key *ev;
          unsigned int     i;
          EcoreCocoaWindow *window = (EcoreCocoaWindow *)[event window];
+         NSString *keychar = [event characters];
 
          printf("Key Up\n");
 
@@ -279,18 +295,20 @@ ecore_cocoa_feed_events(void *anEvent)
          ev->timestamp = time;
          ev->modifiers = _ecore_cocoa_event_modifiers([event modifierFlags]);
 
-         for (i = 0; i < sizeof (keystable) / sizeof (struct 
_ecore_cocoa_keys_s); ++i)
-         {
-            if (keystable[i].code == tolower([[event 
charactersIgnoringModifiers] characterAtIndex:0]))
-            {
-               ev->keyname = keystable[i].name;
-               ev->key = keystable[i].name;
-               ev->string = keystable[i].compose;
-               ev->window = (Ecore_Window)window.ecore_window_data;
-               ev->event_window = ev->window;
-               ecore_event_add(ECORE_EVENT_KEY_UP, ev, NULL, NULL);
-               return pass;
-            }
+         if ([keychar length] > 0){
+           for (i = 0; i < sizeof (keystable) / sizeof (struct 
_ecore_cocoa_keys_s); ++i)
+           {
+              if (keystable[i].code == tolower([keychar characterAtIndex:0]))
+              {
+                 ev->keyname = keystable[i].name;
+                 ev->key = keystable[i].name;
+                 ev->string = keystable[i].compose;
+                 ev->window = (Ecore_Window)window.ecore_window_data;
+                 ev->event_window = ev->window;
+                 ecore_event_add(ECORE_EVENT_KEY_UP, ev, NULL, NULL);
+                 return pass;
+              }
+           }
          }
 
          break;

-- 


Reply via email to