summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Aguirre <aguirre.nicolas@gmail.com>2011-10-06 06:21:39 +0000
committerNicolas Aguirre <aguirre.nicolas@gmail.com>2011-10-06 06:21:39 +0000
commit3255c4ca4cdaeca07ffffa2d70ec8f3efae76284 (patch)
tree94887fa88bbd581d857f25978893689b3d8e8674
parent7b462f7c571b5909ad2fd0ab941bd17c7bb8e0d8 (diff)
PROTO/equate: keyboard support
SVN revision: 63875
-rw-r--r--src/main.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
index df6d177..955acf4 100644
--- a/src/main.c
+++ b/src/main.c
@@ -7,6 +7,49 @@
7static Evas_Object *win; 7static Evas_Object *win;
8static Evas_Object *ly; 8static Evas_Object *ly;
9 9
10
11static const struct
12{
13 const char *keyname;
14 int op;
15} _keymap[] = {
16 {"KP_0", NUM_0},
17 {"0", NUM_0},
18 {"KP_1", NUM_1},
19 {"1", NUM_1},
20 {"KP_2", NUM_2},
21 {"2", NUM_2},
22 {"KP_3", NUM_3},
23 {"3", NUM_3},
24 {"KP_4", NUM_4},
25 {"4", NUM_4},
26 {"KP_5", NUM_5},
27 {"5", NUM_5},
28 {"KP_6", NUM_6},
29 {"6", NUM_6},
30 {"KP_7", NUM_7},
31 {"7", NUM_7},
32 {"KP_8", NUM_8},
33 {"8", NUM_8},
34 {"KP_9", NUM_9},
35 {"9", NUM_9},
36 {"KP_Divide", OP_DIV},
37 {"KP_Multiply", OP_MUT},
38 {"KP_Subtract", OP_SUB},
39 {"KP_Add", OP_ADD},
40 {"plus", OP_ADD},
41 {"minus", OP_SUB},
42 {"asterisk", OP_MUT},
43 {"slash", OP_DIV},
44 {"KP_Enter", OP_EQU},
45 {"Return", OP_EQU},
46 {"BackSpace", OP_CLR},
47 {"period", OP_DEC},
48 {"comma", OP_DEC},
49 NULL
50};
51
52
10static void 53static void
11_signal_cb(void *data, Evas_Object * o, const char *emission, const 54_signal_cb(void *data, Evas_Object * o, const char *emission, const
12 char *source) 55 char *source)
@@ -192,6 +235,25 @@ _edje_callbacks_define(Evas_Object * o)
192 edje_object_signal_callback_add(o, "NUM_PI", "*", _signal_cb, (void *) NUM_PI); 235 edje_object_signal_callback_add(o, "NUM_PI", "*", _signal_cb, (void *) NUM_PI);
193} 236}
194 237
238static Eina_Bool
239_key_down_cb(void *data, int type, void *event)
240{
241 Ecore_Event_Key *ev = event;
242 int i;
243
244 printf("{\"%s\", },\n", ev->key);
245
246 for (i = 0; _keymap[i].keyname; i++)
247 {
248 if (!strcmp(_keymap[i].keyname, ev->key))
249 {
250 _signal_cb((void*)_keymap[i].op, elm_layout_edje_get(ly), NULL, NULL);
251 }
252 }
253 return EINA_TRUE;
254
255}
256
195static void 257static void
196_create_gui(void) 258_create_gui(void)
197{ 259{
@@ -210,6 +272,8 @@ _create_gui(void)
210 elm_win_resize_object_add(win, ly); 272 elm_win_resize_object_add(win, ly);
211 evas_object_show(ly); 273 evas_object_show(ly);
212 274
275 ecore_event_handler_add (ECORE_EVENT_KEY_DOWN, _key_down_cb, NULL);
276
213 evas_object_show(win); 277 evas_object_show(win);
214 evas_object_resize(win, 240, 320); 278 evas_object_resize(win, 240, 320);
215 279