summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichelle Legrand <michelle.legrand@openwide.fr>2015-01-22 11:24:42 +0100
committerCedric BAIL <cedric@osg.samsung.com>2015-02-05 16:38:07 +0100
commit1d18543719a98f9b4e99638c4d8f2e67720b84a2 (patch)
treeb973634a536d61bdac22eca013aeeddbc257edec
parent8c56edbdf5311295a9ef3254d20d413389756425 (diff)
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 <cedric@osg.samsung.com>
-rw-r--r--src/lib/ecore_cocoa/Ecore_Cocoa_Keys.h81
-rw-r--r--src/lib/ecore_cocoa/ecore_cocoa.m68
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 53b17ed23f..69a487248f 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[] =
26{ 34, "quotedbl", "\"" }, 26{ 34, "quotedbl", "\"" },
27{ 35, "numbersign", "#" }, 27{ 35, "numbersign", "#" },
28{ 36, "dollar", "$" }, 28{ 36, "dollar", "$" },
29{ 37, "percent", "%%" }, 29{ 37, "percent", "%" },
30{ 38, "ampersand", "&" }, 30{ 38, "ampersand", "&" },
31{ 39, "apostrophe", "'" }, 31{ 39, "apostrophe", "'" },
32{ 40, "parenleft", "(" }, 32{ 40, "parenleft", "(" },
@@ -47,14 +47,39 @@ static const struct _ecore_cocoa_keys_s keystable[] =
47{ 55, "7", "7" }, 47{ 55, "7", "7" },
48{ 56, "8", "8" }, 48{ 56, "8", "8" },
49{ 57, "9", "9" }, 49{ 57, "9", "9" },
50{ 58, "colon", ";" }, 50{ 58, "colon", ":" },
51{ 59, "semicolon", ";" }, 51{ 59, "semicolon", ";" },
52{ 60, "less", "<" }, 52{ 60, "less", "<" },
53{ 61, "equal", "=" }, 53{ 61, "equal", "=" },
54{ 62, "greater", ">" }, 54{ 62, "greater", ">" },
55{ 63, "question", "?" }, 55{ 63, "question", "?" },
56{ 64, "at", "@" }, 56{ 64, "at", "@" },
57 57{ 65, "A", "A" },
58{ 66, "B", "B" },
59{ 67, "C", "C" },
60{ 68, "D", "D" },
61{ 69, "E", "E" },
62{ 70, "F", "F" },
63{ 71, "G", "G" },
64{ 72, "H", "H" },
65{ 73, "I", "I" },
66{ 74, "J", "J" },
67{ 75, "K", "K" },
68{ 76, "L", "L" },
69{ 77, "M", "M" },
70{ 78, "N", "N" },
71{ 79, "O", "O" },
72{ 80, "P", "P" },
73{ 81, "Q", "Q" },
74{ 82, "R", "R" },
75{ 83, "S", "S" },
76{ 84, "T", "T" },
77{ 85, "U", "U" },
78{ 86, "V", "V" },
79{ 87, "W", "W" },
80{ 88, "X", "X" },
81{ 89, "Y", "Y" },
82{ 90, "Z", "Z" },
58{ 91, "bracketleft", "[" }, 83{ 91, "bracketleft", "[" },
59{ 92, "backslash", "\\" }, 84{ 92, "backslash", "\\" },
60{ 93, "bracketright", "]" }, 85{ 93, "bracketright", "]" },
@@ -87,9 +112,9 @@ static const struct _ecore_cocoa_keys_s keystable[] =
87{ 120, "x", "x" }, 112{ 120, "x", "x" },
88{ 121, "y", "y" }, 113{ 121, "y", "y" },
89{ 122, "z", "z" }, 114{ 122, "z", "z" },
90{ 123, "braceleft", "" }, 115{ 123, "braceleft", "{" },
91{ 124, "pipe", "" }, 116{ 124, "pipe", "|" },
92{ 125, "braceright", "" }, 117{ 125, "braceright", "}" },
93{ 127, "BackSpace", "\177" }, 118{ 127, "BackSpace", "\177" },
94{ 126, "asciitilde", "~" }, 119{ 126, "asciitilde", "~" },
95 120
@@ -100,7 +125,7 @@ static const struct _ecore_cocoa_keys_s keystable[] =
100{ 164, "w4", "" }, 125{ 164, "w4", "" },
101{ 165, "w5", "" }, 126{ 165, "w5", "" },
102{ 166, "w6", "" }, 127{ 166, "w6", "" },
103{ 167, "w7", "" }, 128{ 167, "w7", "§" },
104{ 168, "w8", "" }, 129{ 168, "w8", "" },
105{ 169, "w9", "" }, 130{ 169, "w9", "" },
106{ 170, "w10", "" }, 131{ 170, "w10", "" },
@@ -109,7 +134,7 @@ static const struct _ecore_cocoa_keys_s keystable[] =
109{ 173, "w13", "" }, 134{ 173, "w13", "" },
110{ 174, "w14", "" }, 135{ 174, "w14", "" },
111{ 175, "w15", "" }, 136{ 175, "w15", "" },
112{ 176, "w16", "" }, 137{ 176, "w16", "°" },
113{ 177, "w17", "" }, 138{ 177, "w17", "" },
114{ 178, "w18", "" }, 139{ 178, "w18", "" },
115{ 179, "w19", "" }, 140{ 179, "w19", "" },
@@ -157,38 +182,38 @@ static const struct _ecore_cocoa_keys_s keystable[] =
157{ 221, "w61", "" }, 182{ 221, "w61", "" },
158{ 222, "w62", "" }, 183{ 222, "w62", "" },
159{ 223, "w63", "" }, 184{ 223, "w63", "" },
160{ 224, "w64", "" }, 185{ 224, "w64", "à" },
161{ 225, "w65", "" }, 186{ 225, "w65", "" },
162{ 226, "w66", "" }, 187{ 226, "w66", "â" },
163{ 227, "w67", "" }, 188{ 227, "w67", "ã" },
164{ 228, "w68", "" }, 189{ 228, "w68", "ä" },
165{ 229, "w69", "" }, 190{ 229, "w69", "" },
166{ 230, "w70", "" }, 191{ 230, "w70", "" },
167{ 231, "w71", "" }, 192{ 231, "w71", "ç" },
168{ 232, "w72", "" }, 193{ 232, "w72", "è" },
169{ 233, "w73", "" }, 194{ 233, "w73", "é" },
170{ 234, "w74", "" }, 195{ 234, "w74", "ê" },
171{ 235, "w75", "" }, 196{ 235, "w75", "ë" },
172{ 236, "w76", "" }, 197{ 236, "w76", "ì" },
173{ 237, "w77", "" }, 198{ 237, "w77", "" },
174{ 238, "w78", "" }, 199{ 238, "w78", "î" },
175{ 239, "w79", "" }, 200{ 239, "w79", "ï" },
176{ 240, "w80", "" }, 201{ 240, "w80", "" },
177{ 241, "w81", "" }, 202{ 241, "w81", "" },
178{ 242, "w82", "" }, 203{ 242, "w82", "ò" },
179{ 243, "w83", "" }, 204{ 243, "w83", "" },
180{ 244, "w84", "" }, 205{ 244, "w84", "ô" },
181{ 245, "w85", "" }, 206{ 245, "w85", "õ" },
182{ 246, "w86", "" }, 207{ 246, "w86", "ö"},
183{ 247, "w87", "" }, 208{ 247, "w87", "" },
184{ 248, "w88", "" }, 209{ 248, "w88", "" },
185{ 249, "w89", "" }, 210{ 249, "w89", "ù" },
186{ 250, "w90", "" }, 211{ 250, "w90", "" },
187{ 251, "w91", "" }, 212{ 251, "w91", "û" },
188{ 252, "w92", "" }, 213{ 252, "w92", "ü" },
189{ 253, "w93", "" }, 214{ 253, "w93", "" },
190{ 254, "w94", "" }, 215{ 254, "w94", "" },
191{ 255, "w95", "" }, 216{ 255, "w95", "ÿ" },
192 217
193{ 256, "KP0", "0" }, 218{ 256, "KP0", "0" },
194{ 257, "KP1", "1" }, 219{ 257, "KP1", "1" },
diff --git a/src/lib/ecore_cocoa/ecore_cocoa.m b/src/lib/ecore_cocoa/ecore_cocoa.m
index f02601bb5d..d57fd06482 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)
106 NSEvent *event = anEvent; 106 NSEvent *event = anEvent;
107 unsigned int time = (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff); 107 unsigned int time = (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff);
108 Eina_Bool pass = EINA_FALSE; 108 Eina_Bool pass = EINA_FALSE;
109 static Eina_Bool compose = EINA_FALSE;
110 static NSText *edit;
109 111
110 switch ([event type]) 112 switch ([event type])
111 { 113 {
@@ -243,25 +245,38 @@ ecore_cocoa_feed_events(void *anEvent)
243 Ecore_Event_Key *ev; 245 Ecore_Event_Key *ev;
244 unsigned int i; 246 unsigned int i;
245 EcoreCocoaWindow *window = (EcoreCocoaWindow *)[event window]; 247 EcoreCocoaWindow *window = (EcoreCocoaWindow *)[event window];
248 NSString *keychar = [event characters];
246 249
247 ev = calloc(1, sizeof (Ecore_Event_Key)); 250 ev = calloc(1, sizeof (Ecore_Event_Key));
248 if (!ev) return pass; 251 if (!ev) return pass;
249 ev->timestamp = time; 252 ev->timestamp = time;
250 ev->modifiers = _ecore_cocoa_event_modifiers([event modifierFlags]); 253 ev->modifiers = _ecore_cocoa_event_modifiers([event modifierFlags]);
251 254
252 for (i = 0; i < sizeof (keystable) / sizeof (struct _ecore_cocoa_keys_s); ++i) 255 if (compose)
253 { 256 {
254 if (keystable[i].code == tolower([[event charactersIgnoringModifiers] characterAtIndex:0])) 257 [edit interpretKeyEvents:[NSArray arrayWithObject:event]];
255 { 258 compose=EINA_FALSE;
256 printf("Key pressed : %s\n", keystable[i].name); 259 }
257 ev->keyname = keystable[i].name; 260
258 ev->key = keystable[i].name; 261 if ([keychar length] > 0){
259 ev->string = keystable[i].compose; 262 for (i = 0; i < sizeof (keystable) / sizeof (struct _ecore_cocoa_keys_s); ++i)
260 ev->window = (Ecore_Window)window.ecore_window_data; 263 {
261 ev->event_window = ev->window; 264 if (keystable[i].code == [keychar characterAtIndex:0])
262 ecore_event_add(ECORE_EVENT_KEY_DOWN, ev, NULL, NULL); 265 {
263 return pass; 266 printf("Key pressed : %s\n", keystable[i].name);
264 } 267 ev->keyname = keystable[i].name;
268 ev->key = keystable[i].name;
269 ev->string = keystable[i].compose;
270 ev->window = (Ecore_Window)window.ecore_window_data;
271 ev->event_window = ev->window;
272 ecore_event_add(ECORE_EVENT_KEY_DOWN, ev, NULL, NULL);
273 return pass;
274 }
275 }
276 }else{
277 compose=EINA_TRUE;
278 edit = [[event window] fieldEditor:YES forObject:nil];
279 [edit interpretKeyEvents:[NSArray arrayWithObject:event]];
265 } 280 }
266 281
267 break; 282 break;
@@ -271,6 +286,7 @@ ecore_cocoa_feed_events(void *anEvent)
271 Ecore_Event_Key *ev; 286 Ecore_Event_Key *ev;
272 unsigned int i; 287 unsigned int i;
273 EcoreCocoaWindow *window = (EcoreCocoaWindow *)[event window]; 288 EcoreCocoaWindow *window = (EcoreCocoaWindow *)[event window];
289 NSString *keychar = [event characters];
274 290
275 printf("Key Up\n"); 291 printf("Key Up\n");
276 292
@@ -279,18 +295,20 @@ ecore_cocoa_feed_events(void *anEvent)
279 ev->timestamp = time; 295 ev->timestamp = time;
280 ev->modifiers = _ecore_cocoa_event_modifiers([event modifierFlags]); 296 ev->modifiers = _ecore_cocoa_event_modifiers([event modifierFlags]);
281 297
282 for (i = 0; i < sizeof (keystable) / sizeof (struct _ecore_cocoa_keys_s); ++i) 298 if ([keychar length] > 0){
283 { 299 for (i = 0; i < sizeof (keystable) / sizeof (struct _ecore_cocoa_keys_s); ++i)
284 if (keystable[i].code == tolower([[event charactersIgnoringModifiers] characterAtIndex:0])) 300 {
285 { 301 if (keystable[i].code == tolower([keychar characterAtIndex:0]))
286 ev->keyname = keystable[i].name; 302 {
287 ev->key = keystable[i].name; 303 ev->keyname = keystable[i].name;
288 ev->string = keystable[i].compose; 304 ev->key = keystable[i].name;
289 ev->window = (Ecore_Window)window.ecore_window_data; 305 ev->string = keystable[i].compose;
290 ev->event_window = ev->window; 306 ev->window = (Ecore_Window)window.ecore_window_data;
291 ecore_event_add(ECORE_EVENT_KEY_UP, ev, NULL, NULL); 307 ev->event_window = ev->window;
292 return pass; 308 ecore_event_add(ECORE_EVENT_KEY_UP, ev, NULL, NULL);
293 } 309 return pass;
310 }
311 }
294 } 312 }
295 313
296 break; 314 break;