summaryrefslogtreecommitdiff
path: root/legacy
diff options
context:
space:
mode:
authorJorge Luis Zapata Muga <jorgeluis.zapata@gmail.com>2006-08-02 21:41:11 +0000
committerJorge Luis Zapata Muga <jorgeluis.zapata@gmail.com>2006-08-02 21:41:11 +0000
commit255a87c0e89834cb1bac9370f3a8292465077819 (patch)
tree09567a7e2369139537bc01fc223ec7d898a3e7ae /legacy
parent8cda88c2e6cf796700becb734acd9dae21f24dc3 (diff)
Ecore_Evas_Fb
============= + Now we send events to evas from all input devices SVN revision: 24370
Diffstat (limited to '')
-rw-r--r--legacy/ecore/src/lib/ecore_evas/ecore_evas_fb.c131
-rw-r--r--legacy/ecore/src/lib/ecore_fb/Ecore_Fb.h1
2 files changed, 90 insertions, 42 deletions
diff --git a/legacy/ecore/src/lib/ecore_evas/ecore_evas_fb.c b/legacy/ecore/src/lib/ecore_evas/ecore_evas_fb.c
index a5bdd16b0b..3b367a9a23 100644
--- a/legacy/ecore/src/lib/ecore_evas/ecore_evas_fb.c
+++ b/legacy/ecore/src/lib/ecore_evas/ecore_evas_fb.c
@@ -11,12 +11,11 @@
11static int _ecore_evas_init_count = 0; 11static int _ecore_evas_init_count = 0;
12 12
13static int _ecore_evas_fps_debug = 0; 13static int _ecore_evas_fps_debug = 0;
14 14static char *ecore_evas_default_display = "0";
15static Ecore_List *ecore_evas_input_devices = NULL;
15static Ecore_Evas *ecore_evases = NULL; 16static Ecore_Evas *ecore_evases = NULL;
16static Ecore_Event_Handler *ecore_evas_event_handlers[6]; 17static Ecore_Event_Handler *ecore_evas_event_handlers[6] = {NULL, NULL, NULL, NULL, NULL, NULL};
17static Ecore_Idle_Enterer *ecore_evas_idle_enterer = NULL; 18static Ecore_Idle_Enterer *ecore_evas_idle_enterer = NULL;
18static Ecore_Fb_Input_Device *stdkbd = NULL;
19static Ecore_Fb_Input_Device *stdmouse = NULL;
20 19
21static void 20static void
22_ecore_evas_mouse_move_process(Ecore_Evas *ee, int x, int y, unsigned int timestamp) 21_ecore_evas_mouse_move_process(Ecore_Evas *ee, int x, int y, unsigned int timestamp)
@@ -77,6 +76,7 @@ static void
77_ecore_evas_fb_lose(void *data __UNUSED__) 76_ecore_evas_fb_lose(void *data __UNUSED__)
78{ 77{
79 Ecore_List2 *l; 78 Ecore_List2 *l;
79 Ecore_Fb_Input_Device *dev;
80 80
81 for (l = (Ecore_List2 *)ecore_evases; l; l = l->next) 81 for (l = (Ecore_List2 *)ecore_evases; l; l = l->next)
82 { 82 {
@@ -85,14 +85,19 @@ _ecore_evas_fb_lose(void *data __UNUSED__)
85 ee = (Ecore_Evas *)l; 85 ee = (Ecore_Evas *)l;
86 ee->visible = 0; 86 ee->visible = 0;
87 } 87 }
88 ecore_fb_input_device_listen(stdmouse, 0); 88 ecore_list_goto_first(ecore_evas_input_devices);
89 ecore_fb_input_device_listen(stdkbd, 0); 89 dev = ecore_list_current(ecore_evas_input_devices);
90 do
91 {
92 ecore_fb_input_device_listen(dev, 0);
93 }while((dev = ecore_list_next(ecore_evas_input_devices)));
90} 94}
91 95
92static void 96static void
93_ecore_evas_fb_gain(void *data __UNUSED__) 97_ecore_evas_fb_gain(void *data __UNUSED__)
94{ 98{
95 Ecore_List2 *l; 99 Ecore_List2 *l;
100 Ecore_Fb_Input_Device *dev;
96 101
97 for (l = (Ecore_List2 *)ecore_evases; l; l = l->next) 102 for (l = (Ecore_List2 *)ecore_evases; l; l = l->next)
98 { 103 {
@@ -102,8 +107,12 @@ _ecore_evas_fb_gain(void *data __UNUSED__)
102 ee->visible = 1; 107 ee->visible = 1;
103 evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); 108 evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
104 } 109 }
105 ecore_fb_input_device_listen(stdmouse, 1); 110 ecore_list_goto_first(ecore_evas_input_devices);
106 ecore_fb_input_device_listen(stdkbd, 1); 111 dev = ecore_list_current(ecore_evas_input_devices);
112 do
113 {
114 ecore_fb_input_device_listen(dev, 1);
115 }while((dev = ecore_list_next(ecore_evas_input_devices)));
107} 116}
108 117
109static int 118static int
@@ -115,7 +124,6 @@ _ecore_evas_event_key_down(void *data __UNUSED__, int type __UNUSED__, void *eve
115 e = event; 124 e = event;
116 ee = _ecore_evas_fb_match(); 125 ee = _ecore_evas_fb_match();
117 if (!ee) return 1; /* pass on event */ 126 if (!ee) return 1; /* pass on event */
118 if (e->dev != stdkbd) return 1;
119 evas_event_feed_key_down(ee->evas, e->keyname, e->keysymbol, e->key_compose, NULL, (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff), NULL); 127 evas_event_feed_key_down(ee->evas, e->keyname, e->keysymbol, e->key_compose, NULL, (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff), NULL);
120 return 0; /* dont pass it on */ 128 return 0; /* dont pass it on */
121} 129}
@@ -129,7 +137,6 @@ _ecore_evas_event_key_up(void *data __UNUSED__, int type __UNUSED__, void *event
129 e = event; 137 e = event;
130 ee = _ecore_evas_fb_match(); 138 ee = _ecore_evas_fb_match();
131 if (!ee) return 1; /* pass on event */ 139 if (!ee) return 1; /* pass on event */
132 if (e->dev != stdkbd) return 1;
133 evas_event_feed_key_up(ee->evas, e->keyname, e->keysymbol, e->key_compose, NULL, (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff), NULL); 140 evas_event_feed_key_up(ee->evas, e->keyname, e->keysymbol, e->key_compose, NULL, (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff), NULL);
134 return 0; /* dont pass it on */ 141 return 0; /* dont pass it on */
135} 142}
@@ -144,7 +151,6 @@ _ecore_evas_event_mouse_button_down(void *data __UNUSED__, int type __UNUSED__,
144 e = event; 151 e = event;
145 ee = _ecore_evas_fb_match(); 152 ee = _ecore_evas_fb_match();
146 if (!ee) return 1; /* pass on event */ 153 if (!ee) return 1; /* pass on event */
147 if (e->dev != stdmouse) return 1;
148 _ecore_evas_mouse_move_process(ee, e->x, e->y, (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff)); 154 _ecore_evas_mouse_move_process(ee, e->x, e->y, (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff));
149 if (e->double_click) flags |= EVAS_BUTTON_DOUBLE_CLICK; 155 if (e->double_click) flags |= EVAS_BUTTON_DOUBLE_CLICK;
150 if (e->triple_click) flags |= EVAS_BUTTON_TRIPLE_CLICK; 156 if (e->triple_click) flags |= EVAS_BUTTON_TRIPLE_CLICK;
@@ -161,7 +167,6 @@ _ecore_evas_event_mouse_button_up(void *data __UNUSED__, int type __UNUSED__, vo
161 e = event; 167 e = event;
162 ee = _ecore_evas_fb_match(); 168 ee = _ecore_evas_fb_match();
163 if (!ee) return 1; /* pass on event */ 169 if (!ee) return 1; /* pass on event */
164 if (e->dev != stdmouse) return 1;
165 _ecore_evas_mouse_move_process(ee, e->x, e->y, (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff)); 170 _ecore_evas_mouse_move_process(ee, e->x, e->y, (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff));
166 evas_event_feed_mouse_up(ee->evas, e->button, EVAS_BUTTON_NONE, (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff), NULL); 171 evas_event_feed_mouse_up(ee->evas, e->button, EVAS_BUTTON_NONE, (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff), NULL);
167 return 0; /* dont pass it on */ 172 return 0; /* dont pass it on */
@@ -176,7 +181,6 @@ _ecore_evas_event_mouse_move(void *data __UNUSED__, int type __UNUSED__, void *e
176 e = event; 181 e = event;
177 ee = _ecore_evas_fb_match(); 182 ee = _ecore_evas_fb_match();
178 if (!ee) return 1; /* pass on event */ 183 if (!ee) return 1; /* pass on event */
179 if (e->dev != stdmouse) return 1;
180 _ecore_evas_mouse_move_process(ee, e->x, e->y, (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff)); 184 _ecore_evas_mouse_move_process(ee, e->x, e->y, (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff));
181 return 0; /* dont pass it on */ 185 return 0; /* dont pass it on */
182} 186}
@@ -190,7 +194,6 @@ _ecore_evas_event_mouse_wheel(void *data __UNUSED__, int type __UNUSED__, void *
190 e = event; 194 e = event;
191 ee = _ecore_evas_fb_match(); 195 ee = _ecore_evas_fb_match();
192 if (!ee) return 1; /* pass on event */ 196 if (!ee) return 1; /* pass on event */
193 if (e->dev != stdmouse) return 1;
194 _ecore_evas_mouse_move_process(ee, e->x, e->y, (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff)); 197 _ecore_evas_mouse_move_process(ee, e->x, e->y, (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff));
195 return 0; /* dont pass it on */ 198 return 0; /* dont pass it on */
196} 199}
@@ -242,19 +245,67 @@ _ecore_evas_idle_enter(void *data __UNUSED__)
242} 245}
243 246
244static int 247static int
245_ecore_evas_fb_init(void) 248_ecore_evas_fb_init(int w, int h)
246{ 249{
250 Ecore_Fb_Input_Device *device;
251 Ecore_Fb_Input_Device_Cap caps;
252 int mouse_handled = 0;
253 int keyboard_handled = 0;
254
255 DIR *input_dir;
256 struct dirent *input_entry;
257
247 _ecore_evas_init_count++; 258 _ecore_evas_init_count++;
248 if (_ecore_evas_init_count > 1) return _ecore_evas_init_count; 259 if (_ecore_evas_init_count > 1) return _ecore_evas_init_count;
260
249 if (getenv("ECORE_EVAS_FPS_DEBUG")) _ecore_evas_fps_debug = 1; 261 if (getenv("ECORE_EVAS_FPS_DEBUG")) _ecore_evas_fps_debug = 1;
250 ecore_evas_idle_enterer = ecore_idle_enterer_add(_ecore_evas_idle_enter, NULL); 262 ecore_evas_idle_enterer = ecore_idle_enterer_add(_ecore_evas_idle_enter, NULL);
251 ecore_evas_event_handlers[0] = ecore_event_handler_add(ECORE_FB_EVENT_KEY_DOWN, _ecore_evas_event_key_down, NULL);
252 ecore_evas_event_handlers[1] = ecore_event_handler_add(ECORE_FB_EVENT_KEY_UP, _ecore_evas_event_key_up, NULL);
253 ecore_evas_event_handlers[2] = ecore_event_handler_add(ECORE_FB_EVENT_MOUSE_BUTTON_DOWN, _ecore_evas_event_mouse_button_down, NULL);
254 ecore_evas_event_handlers[3] = ecore_event_handler_add(ECORE_FB_EVENT_MOUSE_BUTTON_UP, _ecore_evas_event_mouse_button_up, NULL);
255 ecore_evas_event_handlers[4] = ecore_event_handler_add(ECORE_FB_EVENT_MOUSE_MOVE, _ecore_evas_event_mouse_move, NULL);
256 ecore_evas_event_handlers[5] = ecore_event_handler_add(ECORE_FB_EVENT_MOUSE_WHEEL, _ecore_evas_event_mouse_wheel, NULL);
257 if (_ecore_evas_fps_debug) _ecore_evas_fps_debug_init(); 263 if (_ecore_evas_fps_debug) _ecore_evas_fps_debug_init();
264 /* register all input devices */
265 input_dir = opendir("/dev/input/");
266 if(!input_dir) return _ecore_evas_init_count;
267
268 ecore_evas_input_devices = ecore_list_new();
269 while((input_entry = readdir(input_dir)))
270 {
271 char device_path[256];
272 if (strncmp(input_entry->d_name, "event", 5) != 0)
273 continue;
274
275 snprintf(device_path, 256, "/dev/input/%s", input_entry->d_name);
276 if (!(device = ecore_fb_input_device_open(device_path)))
277 continue;
278
279 caps = ecore_fb_input_device_cap_get(device);
280
281 /* Mouse */
282 if (caps & ECORE_FB_INPUT_DEVICE_CAP_RELATIVE)
283 {
284 ecore_fb_input_device_axis_size_set(device, w, h);
285 ecore_fb_input_device_listen(device,1);
286 ecore_list_append(ecore_evas_input_devices, device);
287 if (!mouse_handled)
288 {
289 ecore_evas_event_handlers[2] = ecore_event_handler_add(ECORE_FB_EVENT_MOUSE_BUTTON_DOWN, _ecore_evas_event_mouse_button_down, NULL);
290 ecore_evas_event_handlers[3] = ecore_event_handler_add(ECORE_FB_EVENT_MOUSE_BUTTON_UP, _ecore_evas_event_mouse_button_up, NULL);
291 ecore_evas_event_handlers[4] = ecore_event_handler_add(ECORE_FB_EVENT_MOUSE_MOVE, _ecore_evas_event_mouse_move, NULL);
292 ecore_evas_event_handlers[5] = ecore_event_handler_add(ECORE_FB_EVENT_MOUSE_WHEEL, _ecore_evas_event_mouse_wheel, NULL);
293 mouse_handled = 1;
294 }
295 }
296 /* Keyboard */
297 else if ((caps & ECORE_FB_INPUT_DEVICE_CAP_KEYS_OR_BUTTONS) && !(caps & ECORE_FB_INPUT_DEVICE_CAP_ABSOLUTE))
298 {
299 ecore_fb_input_device_listen(device,1);
300 ecore_list_append(ecore_evas_input_devices, device);
301 if (!keyboard_handled)
302 {
303 ecore_evas_event_handlers[0] = ecore_event_handler_add(ECORE_FB_EVENT_KEY_DOWN, _ecore_evas_event_key_down, NULL);
304 ecore_evas_event_handlers[1] = ecore_event_handler_add(ECORE_FB_EVENT_KEY_UP, _ecore_evas_event_key_up, NULL);
305 keyboard_handled = 1;
306 }
307 }
308 }
258 return _ecore_evas_init_count; 309 return _ecore_evas_init_count;
259} 310}
260 311
@@ -419,7 +470,16 @@ _ecore_evas_fullscreen_set(Ecore_Evas *ee, int on)
419 } 470 }
420 ee->prop.fullscreen = on; 471 ee->prop.fullscreen = on;
421 /* rescale the input device area */ 472 /* rescale the input device area */
422 ecore_fb_input_device_axis_size_set(stdmouse, ee->w, ee->h); 473 {
474 Ecore_Fb_Input_Device *dev;
475
476 ecore_list_goto_first(ecore_evas_input_devices);
477 dev = ecore_list_current(ecore_evas_input_devices);
478 do
479 {
480 ecore_fb_input_device_axis_size_set(dev, ee->w, ee->h);
481 }while((dev = ecore_list_next(ecore_evas_input_devices)));
482 }
423 if (resized) 483 if (resized)
424 { 484 {
425 if (ee->func.fn_resize) ee->func.fn_resize(ee); 485 if (ee->func.fn_resize) ee->func.fn_resize(ee);
@@ -503,29 +563,15 @@ ecore_evas_fb_new(char *disp_name, int rotation, int w, int h)
503#ifdef BUILD_ECORE_EVAS_FB 563#ifdef BUILD_ECORE_EVAS_FB
504 Evas_Engine_Info_FB *einfo; 564 Evas_Engine_Info_FB *einfo;
505 Ecore_Evas *ee; 565 Ecore_Evas *ee;
506 Ecore_Fb_Input_Device *tmp_dev; 566
507 Ecore_Fb_Input_Device_Cap tmp_cap;
508 int rmethod; 567 int rmethod;
509 568
569 if (!disp_name)
570 disp_name = ecore_evas_default_display;
571
510 rmethod = evas_render_method_lookup("fb"); 572 rmethod = evas_render_method_lookup("fb");
511 if (!rmethod) return NULL; 573 if (!rmethod) return NULL;
512 /* register the default input devices (keyboard + mouse) */ 574
513 tmp_dev = ecore_fb_input_device_open("/dev/input/event0");
514 if (!tmp_dev) return NULL;
515 tmp_cap = ecore_fb_input_device_cap_get(tmp_dev);
516 if ((tmp_cap & ECORE_FB_INPUT_DEVICE_CAP_RELATIVE) || (tmp_cap & ECORE_FB_INPUT_DEVICE_CAP_ABSOLUTE)) stdmouse = tmp_dev;
517 else stdkbd = tmp_dev;
518
519 ecore_fb_input_device_listen(tmp_dev, 1);
520
521 tmp_dev = ecore_fb_input_device_open("/dev/input/event1");
522 if (!stdmouse) stdmouse = tmp_dev;
523 else stdkbd = tmp_dev;
524
525 if (!tmp_dev) return NULL;
526 ecore_fb_input_device_listen(tmp_dev, 1);
527 ecore_fb_input_device_axis_size_set(stdmouse, w, h);
528
529 if (!ecore_fb_init(disp_name)) return NULL; 575 if (!ecore_fb_init(disp_name)) return NULL;
530 ecore_fb_callback_gain_set(_ecore_evas_fb_gain, NULL); 576 ecore_fb_callback_gain_set(_ecore_evas_fb_gain, NULL);
531 ecore_fb_callback_lose_set(_ecore_evas_fb_lose, NULL); 577 ecore_fb_callback_lose_set(_ecore_evas_fb_lose, NULL);
@@ -534,7 +580,7 @@ ecore_evas_fb_new(char *disp_name, int rotation, int w, int h)
534 580
535 ECORE_MAGIC_SET(ee, ECORE_MAGIC_EVAS); 581 ECORE_MAGIC_SET(ee, ECORE_MAGIC_EVAS);
536 582
537 _ecore_evas_fb_init(); 583 _ecore_evas_fb_init(w, h);
538 584
539 ee->engine.func = (Ecore_Evas_Engine_Func *)&_ecore_fb_engine_func; 585 ee->engine.func = (Ecore_Evas_Engine_Func *)&_ecore_fb_engine_func;
540 586
@@ -570,6 +616,7 @@ ecore_evas_fb_new(char *disp_name, int rotation, int w, int h)
570 if (einfo) 616 if (einfo)
571 { 617 {
572 einfo->info.virtual_terminal = 0; 618 einfo->info.virtual_terminal = 0;
619 einfo->info.device_number = strtol(disp_name, NULL, 10);
573 einfo->info.device_number = 0; 620 einfo->info.device_number = 0;
574 einfo->info.refresh = 0; 621 einfo->info.refresh = 0;
575 einfo->info.rotation = ee->rotation; 622 einfo->info.rotation = ee->rotation;
diff --git a/legacy/ecore/src/lib/ecore_fb/Ecore_Fb.h b/legacy/ecore/src/lib/ecore_fb/Ecore_Fb.h
index cc83b7c4c8..5d85d0a3ef 100644
--- a/legacy/ecore/src/lib/ecore_fb/Ecore_Fb.h
+++ b/legacy/ecore/src/lib/ecore_fb/Ecore_Fb.h
@@ -35,6 +35,7 @@
35 * backlight support using new kernel interface 35 * backlight support using new kernel interface
36 * absolute axis 36 * absolute axis
37 * joystick 37 * joystick
38 * ecore_fb_li_device_close_all ? or a shutdown of the subsystem?
38 * 39 *
39 */ 40 */
40 41