From: raster Date: Sun, 19 Sep 2010 03:25:15 +0000 (+0000) Subject: warnings-- X-Git-Tag: build/2012-07-04.173327~1789 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a24657ad1e382ef85a5af56aafc0696c1cda09a4;p=profile%2Fivi%2Fecore.git warnings-- git-svn-id: http://svn.enlightenment.org/svn/e/trunk/ecore@52454 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- diff --git a/src/lib/ecore_fb/ecore_fb.c b/src/lib/ecore_fb/ecore_fb.c index 3507ed7..ebc9631 100644 --- a/src/lib/ecore_fb/ecore_fb.c +++ b/src/lib/ecore_fb/ecore_fb.c @@ -18,9 +18,6 @@ static int _ecore_fb_init_count = 0; static int _ecore_fb_console_w = 0; static int _ecore_fb_console_h = 0; -static double _ecore_fb_double_click_time = 0.25; - - /** * @defgroup Ecore_FB_Library_Group Framebuffer Library Functions * @@ -38,11 +35,11 @@ EAPI int ecore_fb_init(const char *name __UNUSED__) { if (++_ecore_fb_init_count != 1) - return _ecore_fb_init_count; - + return _ecore_fb_init_count; + if (!ecore_fb_vt_init()) - return --_ecore_fb_init_count; - + return --_ecore_fb_init_count; + ECORE_FB_EVENT_KEY_DOWN = ecore_event_type_new(); ECORE_FB_EVENT_KEY_UP = ecore_event_type_new(); ECORE_FB_EVENT_MOUSE_BUTTON_DOWN = ecore_event_type_new(); @@ -64,7 +61,7 @@ EAPI int ecore_fb_shutdown(void) { if (--_ecore_fb_init_count != 0) - return _ecore_fb_init_count; + return _ecore_fb_init_count; ecore_fb_vt_shutdown(); diff --git a/src/lib/ecore_fb/ecore_fb_li.c b/src/lib/ecore_fb/ecore_fb_li.c index cc04b5a..85fef1a 100644 --- a/src/lib/ecore_fb/ecore_fb_li.c +++ b/src/lib/ecore_fb/ecore_fb_li.c @@ -25,359 +25,342 @@ static const char *_ecore_fb_li_kbd_syms[128 * 6] = * - bigeasy */ extern int long_has_neither_32_nor_64_bits(void); -static inline int test_bit(int bit, unsigned long *array) +static inline int +test_bit(int bit, unsigned long *array) { - if (sizeof(long) == 4) - return array[bit / 32] & (1 << (bit % 32)); - - else if (sizeof(long) == 8) - return array[bit / 64] & (1 << (bit % 64)); - - else long_has_neither_32_nor_64_bits(); + if (sizeof(long) == 4) + return array[bit / 32] & (1 << (bit % 32)); + else if (sizeof(long) == 8) + return array[bit / 64] & (1 << (bit % 64)); + else long_has_neither_32_nor_64_bits(); } static void -_ecore_fb_li_event_free_key_down(void *data, void *ev) +_ecore_fb_li_event_free_key_down(void *data __UNUSED__, void *ev) { - - Ecore_Fb_Event_Key_Up *e; - - e = ev; - free(e->keyname); - if (e->keysymbol) free(e->keysymbol); - if (e->key_compose) free(e->key_compose); - free(e); + Ecore_Fb_Event_Key_Up *e; + + e = ev; + free(e->keyname); + if (e->keysymbol) free(e->keysymbol); + if (e->key_compose) free(e->key_compose); + free(e); } static void -_ecore_fb_li_event_free_key_up(void *data, void *ev) +_ecore_fb_li_event_free_key_up(void *data __UNUSED__, void *ev) { - - Ecore_Fb_Event_Key_Up *e; - - e = ev; - free(e->keyname); - if (e->keysymbol) free(e->keysymbol); - if (e->key_compose) free(e->key_compose); - free(e); + Ecore_Fb_Event_Key_Up *e; + + e = ev; + free(e->keyname); + if (e->keysymbol) free(e->keysymbol); + if (e->key_compose) free(e->key_compose); + free(e); } static void _ecore_fb_li_device_event_key(Ecore_Fb_Input_Device *dev, struct input_event *iev) { - if(!dev->listen) - return; - - /* check for basic keyboard keys */ - if(iev->code >= KEY_ESC && iev->code <= KEY_COMPOSE) - { - /* check the key table */ - if(iev->value) - { - int offset = 0; - Ecore_Fb_Event_Key_Down *ev; - - ev = calloc(1, sizeof(Ecore_Fb_Event_Key_Down)); - if(dev->keyboard.shift) offset = 1; - else if(dev->keyboard.lock) offset = 2; - ev->keyname = strdup(_ecore_fb_li_kbd_syms[iev->code * 6]); - - ev->keysymbol = strdup(_ecore_fb_li_kbd_syms[(iev->code * 6) + offset]); - ev->key_compose = strdup(_ecore_fb_li_kbd_syms[(iev->code * 6) + 3 + offset]); - ev->dev = dev; - ecore_event_add(ECORE_FB_EVENT_KEY_DOWN, ev, _ecore_fb_li_event_free_key_down, NULL); - /* its a repeated key, dont increment */ - if(iev->value == 2) - return; - if (!strcmp(ev->keyname, "Control_L")) - dev->keyboard.ctrl++; - else if (!strcmp(ev->keyname, "Control_R")) - dev->keyboard.ctrl++; - else if (!strcmp(ev->keyname, "Alt_L")) - dev->keyboard.alt++; - else if (!strcmp(ev->keyname, "Alt_R")) - dev->keyboard.alt++; - else if (!strcmp(ev->keyname, "Shift_L")) - dev->keyboard.shift++; - else if (!strcmp(ev->keyname, "Shift_R")) - dev->keyboard.shift++; - else if (!strcmp(ev->keyname, "Caps_Lock")) - dev->keyboard.lock++; - if (dev->keyboard.ctrl > 2) dev->keyboard.ctrl = 2; - if (dev->keyboard.alt > 2) dev->keyboard.alt = 2; - if (dev->keyboard.shift > 2) dev->keyboard.shift = 2; - if (dev->keyboard.lock > 1) dev->keyboard.lock = 1; - } - else - { - int offset = 0; - Ecore_Fb_Event_Key_Up *ev; - - ev = calloc(1, sizeof(Ecore_Fb_Event_Key_Up)); - if(dev->keyboard.shift) offset = 1; - else if(dev->keyboard.lock) offset = 2; - ev->keyname = strdup(_ecore_fb_li_kbd_syms[iev->code * 6]); - - ev->keysymbol = strdup(_ecore_fb_li_kbd_syms[(iev->code * 6) + offset]); - ev->key_compose = strdup(_ecore_fb_li_kbd_syms[(iev->code * 6) + 3 + offset]); - ev->dev = dev; - ecore_event_add(ECORE_FB_EVENT_KEY_UP, ev, _ecore_fb_li_event_free_key_up, NULL); - if (!strcmp(ev->keyname, "Control_L")) - dev->keyboard.ctrl--; - else if (!strcmp(ev->keyname, "Control_R")) - dev->keyboard.ctrl--; - else if (!strcmp(ev->keyname, "Alt_L")) - dev->keyboard.alt--; - else if (!strcmp(ev->keyname, "Alt_R")) - dev->keyboard.alt--; - else if (!strcmp(ev->keyname, "Shift_L")) - dev->keyboard.shift--; - else if (!strcmp(ev->keyname, "Shift_R")) - dev->keyboard.shift--; - else if (!strcmp(ev->keyname, "Caps_Lock")) - dev->keyboard.lock--; - if (dev->keyboard.ctrl < 0) dev->keyboard.ctrl = 0; - if (dev->keyboard.alt < 0) dev->keyboard.alt = 0; - if (dev->keyboard.shift < 0) dev->keyboard.shift = 0; - if (dev->keyboard.lock < 0) dev->keyboard.lock = 0; - } - } - /* check for mouse button events */ - else if(iev->code >= BTN_MOUSE && iev->code < BTN_JOYSTICK) - { - int button; - - button = ((iev->code & 0x00F) + 1); - if(iev->value) - { - Ecore_Fb_Event_Mouse_Button_Down *ev; - double current; - - ev = calloc(1, sizeof(Ecore_Fb_Event_Mouse_Button_Down)); - ev->dev = dev; - ev->button = button; - ev->x = dev->mouse.x; - ev->y = dev->mouse.y; - - current = ecore_time_get(); - if((current - dev->mouse.prev) <= dev->mouse.threshold) - { - ev->double_click = 1; - } - if((current - dev->mouse.last) <= (2 * dev->mouse.threshold)) - { - ev->triple_click = 1; - /* reset */ - dev->mouse.prev = 0; - dev->mouse.last = 0; - current = 0; - } - else - { - /* update values */ - dev->mouse.last = dev->mouse.prev; - dev->mouse.prev = current; - } - ecore_event_add(ECORE_FB_EVENT_MOUSE_BUTTON_DOWN, ev, NULL ,NULL); - } - else - { - Ecore_Fb_Event_Mouse_Button_Up *ev; - - ev = calloc(1,sizeof(Ecore_Fb_Event_Mouse_Button_Up)); - ev->dev = dev; - ev->button = button; - ev->x = dev->mouse.x; - ev->y = dev->mouse.y; - - ecore_event_add(ECORE_FB_EVENT_MOUSE_BUTTON_UP, ev, NULL ,NULL); - } - } + if (!dev->listen) return; + + /* check for basic keyboard keys */ + if ((iev->code >= KEY_ESC) && (iev->code <= KEY_COMPOSE)) + { + /* check the key table */ + if (iev->value) + { + int offset = 0; + Ecore_Fb_Event_Key_Down *ev; + + ev = calloc(1, sizeof(Ecore_Fb_Event_Key_Down)); + if (dev->keyboard.shift) offset = 1; + else if (dev->keyboard.lock) offset = 2; + ev->keyname = strdup(_ecore_fb_li_kbd_syms[iev->code * 6]); + + ev->keysymbol = strdup(_ecore_fb_li_kbd_syms[(iev->code * 6) + offset]); + ev->key_compose = strdup(_ecore_fb_li_kbd_syms[(iev->code * 6) + 3 + offset]); + ev->dev = dev; + ecore_event_add(ECORE_FB_EVENT_KEY_DOWN, ev, _ecore_fb_li_event_free_key_down, NULL); + /* its a repeated key, dont increment */ + if (iev->value == 2) + return; + if (!strcmp(ev->keyname, "Control_L")) + dev->keyboard.ctrl++; + else if (!strcmp(ev->keyname, "Control_R")) + dev->keyboard.ctrl++; + else if (!strcmp(ev->keyname, "Alt_L")) + dev->keyboard.alt++; + else if (!strcmp(ev->keyname, "Alt_R")) + dev->keyboard.alt++; + else if (!strcmp(ev->keyname, "Shift_L")) + dev->keyboard.shift++; + else if (!strcmp(ev->keyname, "Shift_R")) + dev->keyboard.shift++; + else if (!strcmp(ev->keyname, "Caps_Lock")) + dev->keyboard.lock++; + if (dev->keyboard.ctrl > 2) dev->keyboard.ctrl = 2; + if (dev->keyboard.alt > 2) dev->keyboard.alt = 2; + if (dev->keyboard.shift > 2) dev->keyboard.shift = 2; + if (dev->keyboard.lock > 1) dev->keyboard.lock = 1; + } + else + { + int offset = 0; + Ecore_Fb_Event_Key_Up *ev; + + ev = calloc(1, sizeof(Ecore_Fb_Event_Key_Up)); + if (dev->keyboard.shift) offset = 1; + else if (dev->keyboard.lock) offset = 2; + ev->keyname = strdup(_ecore_fb_li_kbd_syms[iev->code * 6]); + + ev->keysymbol = strdup(_ecore_fb_li_kbd_syms[(iev->code * 6) + offset]); + ev->key_compose = strdup(_ecore_fb_li_kbd_syms[(iev->code * 6) + 3 + offset]); + ev->dev = dev; + ecore_event_add(ECORE_FB_EVENT_KEY_UP, ev, _ecore_fb_li_event_free_key_up, NULL); + if (!strcmp(ev->keyname, "Control_L")) + dev->keyboard.ctrl--; + else if (!strcmp(ev->keyname, "Control_R")) + dev->keyboard.ctrl--; + else if (!strcmp(ev->keyname, "Alt_L")) + dev->keyboard.alt--; + else if (!strcmp(ev->keyname, "Alt_R")) + dev->keyboard.alt--; + else if (!strcmp(ev->keyname, "Shift_L")) + dev->keyboard.shift--; + else if (!strcmp(ev->keyname, "Shift_R")) + dev->keyboard.shift--; + else if (!strcmp(ev->keyname, "Caps_Lock")) + dev->keyboard.lock--; + if (dev->keyboard.ctrl < 0) dev->keyboard.ctrl = 0; + if (dev->keyboard.alt < 0) dev->keyboard.alt = 0; + if (dev->keyboard.shift < 0) dev->keyboard.shift = 0; + if (dev->keyboard.lock < 0) dev->keyboard.lock = 0; + } + } + /* check for mouse button events */ + else if ((iev->code >= BTN_MOUSE) && (iev->code < BTN_JOYSTICK)) + { + int button; + + button = ((iev->code & 0x00F) + 1); + if (iev->value) + { + Ecore_Fb_Event_Mouse_Button_Down *ev; + double current; + + ev = calloc(1, sizeof(Ecore_Fb_Event_Mouse_Button_Down)); + ev->dev = dev; + ev->button = button; + ev->x = dev->mouse.x; + ev->y = dev->mouse.y; + + current = ecore_time_get(); + if ((current - dev->mouse.prev) <= dev->mouse.threshold) + ev->double_click = 1; + if ((current - dev->mouse.last) <= (2 * dev->mouse.threshold)) + { + ev->triple_click = 1; + /* reset */ + dev->mouse.prev = 0; + dev->mouse.last = 0; + current = 0; + } + else + { + /* update values */ + dev->mouse.last = dev->mouse.prev; + dev->mouse.prev = current; + } + ecore_event_add(ECORE_FB_EVENT_MOUSE_BUTTON_DOWN, ev, NULL ,NULL); + } + else + { + Ecore_Fb_Event_Mouse_Button_Up *ev; + + ev = calloc(1,sizeof(Ecore_Fb_Event_Mouse_Button_Up)); + ev->dev = dev; + ev->button = button; + ev->x = dev->mouse.x; + ev->y = dev->mouse.y; + ecore_event_add(ECORE_FB_EVENT_MOUSE_BUTTON_UP, ev, NULL ,NULL); + } + } } static void _ecore_fb_li_device_event_rel(Ecore_Fb_Input_Device *dev, struct input_event *iev) { - if(!dev->listen) - return; - /* dispatch the button events if they are queued */ - switch(iev->code) - { - case REL_X: - case REL_Y: - { - Ecore_Fb_Event_Mouse_Move *ev; - if(iev->code == REL_X) - { - dev->mouse.x += iev->value; - if(dev->mouse.x > dev->mouse.w - 1) - dev->mouse.x = dev->mouse.w; - else if(dev->mouse.x < 0) - dev->mouse.x = 0; - } - else - { - dev->mouse.y += iev->value; - if(dev->mouse.y > dev->mouse.h - 1) - dev->mouse.y = dev->mouse.h; - else if(dev->mouse.y < 0) - dev->mouse.y = 0; - } - ev = calloc(1,sizeof(Ecore_Fb_Event_Mouse_Move)); - ev->x = dev->mouse.x; - ev->y = dev->mouse.y; - ev->dev = dev; - - ecore_event_add(ECORE_FB_EVENT_MOUSE_MOVE,ev,NULL,NULL); - break; - } - case REL_WHEEL: - case REL_HWHEEL: - { - Ecore_Fb_Event_Mouse_Wheel *ev; - ev = calloc(1, sizeof(Ecore_Fb_Event_Mouse_Wheel)); - - ev->x = dev->mouse.x; - ev->y = dev->mouse.y; - if(iev->code == REL_HWHEEL) - ev->direction = 1; - ev->wheel = iev->value; - ev->dev = dev; - ecore_event_add(ECORE_FB_EVENT_MOUSE_WHEEL, ev, NULL, NULL); - break; - } - default: - break; - } + if (!dev->listen) return; + /* dispatch the button events if they are queued */ + switch (iev->code) + { + case REL_X: + case REL_Y: + { + Ecore_Fb_Event_Mouse_Move *ev; + if(iev->code == REL_X) + { + dev->mouse.x += iev->value; + if(dev->mouse.x > dev->mouse.w - 1) + dev->mouse.x = dev->mouse.w; + else if(dev->mouse.x < 0) + dev->mouse.x = 0; + } + else + { + dev->mouse.y += iev->value; + if(dev->mouse.y > dev->mouse.h - 1) + dev->mouse.y = dev->mouse.h; + else if(dev->mouse.y < 0) + dev->mouse.y = 0; + } + ev = calloc(1,sizeof(Ecore_Fb_Event_Mouse_Move)); + ev->x = dev->mouse.x; + ev->y = dev->mouse.y; + ev->dev = dev; + + ecore_event_add(ECORE_FB_EVENT_MOUSE_MOVE,ev,NULL,NULL); + break; + } + case REL_WHEEL: + case REL_HWHEEL: + { + Ecore_Fb_Event_Mouse_Wheel *ev; + ev = calloc(1, sizeof(Ecore_Fb_Event_Mouse_Wheel)); + + ev->x = dev->mouse.x; + ev->y = dev->mouse.y; + if (iev->code == REL_HWHEEL) ev->direction = 1; + ev->wheel = iev->value; + ev->dev = dev; + ecore_event_add(ECORE_FB_EVENT_MOUSE_WHEEL, ev, NULL, NULL); + break; + } + default: + break; + } } static void _ecore_fb_li_device_event_abs(Ecore_Fb_Input_Device *dev, struct input_event *iev) { - static int prev_pressure = 0; - int pressure; - - if(!dev->listen) - return; - switch(iev->code) - { - case ABS_X: - if(dev->mouse.w != 0) - { - int tmp; - - tmp = (int)((double)(iev->value - dev->mouse.min_w) / dev->mouse.rel_w); - if(tmp < 0) - dev->mouse.x = 0; - else if(tmp > dev->mouse.w) - dev->mouse.x = dev->mouse.w; - else - dev->mouse.x = tmp; - dev->mouse.event = ECORE_FB_EVENT_MOUSE_MOVE; - } - break; - - case ABS_Y: - if(dev->mouse.h != 0) - { - int tmp; - - tmp = (int)((double)(iev->value - dev->mouse.min_h) / dev->mouse.rel_h); - if(tmp < 0) - dev->mouse.y = 0; - else if(tmp > dev->mouse.h) - dev->mouse.y = dev->mouse.h; - else - dev->mouse.y = tmp; - dev->mouse.event = ECORE_FB_EVENT_MOUSE_MOVE; - } - break; - - case ABS_PRESSURE: - pressure = iev->value; - if ((pressure) && (!prev_pressure)) - { - /* DOWN: mouse is down, but was not now */ - dev->mouse.event = ECORE_FB_EVENT_MOUSE_BUTTON_DOWN; - } - else if ((!pressure) && (prev_pressure)) - { - /* UP: mouse was down, but is not now */ - dev->mouse.event = ECORE_FB_EVENT_MOUSE_BUTTON_UP; - } - prev_pressure = pressure; - break; - } + static int prev_pressure = 0; + int pressure; + + if (!dev->listen) return; + switch (iev->code) + { + case ABS_X: + if (dev->mouse.w != 0) + { + int tmp; + + tmp = (int)((double)(iev->value - dev->mouse.min_w) / dev->mouse.rel_w); + if (tmp < 0) dev->mouse.x = 0; + else if (tmp > dev->mouse.w) dev->mouse.x = dev->mouse.w; + else dev->mouse.x = tmp; + dev->mouse.event = ECORE_FB_EVENT_MOUSE_MOVE; + } + break; + + case ABS_Y: + if(dev->mouse.h != 0) + { + int tmp; + + tmp = (int)((double)(iev->value - dev->mouse.min_h) / dev->mouse.rel_h); + if (tmp < 0) dev->mouse.y = 0; + else if (tmp > dev->mouse.h) dev->mouse.y = dev->mouse.h; + else dev->mouse.y = tmp; + dev->mouse.event = ECORE_FB_EVENT_MOUSE_MOVE; + } + break; + + case ABS_PRESSURE: + pressure = iev->value; + if ((pressure) && (!prev_pressure)) + { + /* DOWN: mouse is down, but was not now */ + dev->mouse.event = ECORE_FB_EVENT_MOUSE_BUTTON_DOWN; + } + else if ((!pressure) && (prev_pressure)) + { + /* UP: mouse was down, but is not now */ + dev->mouse.event = ECORE_FB_EVENT_MOUSE_BUTTON_UP; + } + prev_pressure = pressure; + break; + } } static void -_ecore_fb_li_device_event_syn(Ecore_Fb_Input_Device *dev, struct input_event *iev) +_ecore_fb_li_device_event_syn(Ecore_Fb_Input_Device *dev, struct input_event *iev __UNUSED__) { - if(!dev->listen) - return; - - if(dev->mouse.event == ECORE_FB_EVENT_MOUSE_MOVE) - { - Ecore_Fb_Event_Mouse_Move *ev; - ev = calloc(1,sizeof(Ecore_Fb_Event_Mouse_Move)); - ev->x = dev->mouse.x; - ev->y = dev->mouse.y; - ev->dev = dev; - ecore_event_add(ECORE_FB_EVENT_MOUSE_MOVE, ev, NULL, NULL); - } - else if(dev->mouse.event == ECORE_FB_EVENT_MOUSE_BUTTON_DOWN) - { - Ecore_Fb_Event_Mouse_Button_Down *ev; - ev = calloc(1, sizeof(Ecore_Fb_Event_Mouse_Button_Down)); - ev->x = dev->mouse.x; - ev->y = dev->mouse.y; - ev->button = 1; - ecore_event_add(ECORE_FB_EVENT_MOUSE_BUTTON_DOWN, ev, NULL, NULL); - } - else if(dev->mouse.event == ECORE_FB_EVENT_MOUSE_BUTTON_UP) - { - Ecore_Fb_Event_Mouse_Button_Up *ev; - ev = calloc(1, sizeof(Ecore_Fb_Event_Mouse_Button_Up)); - ev->x = dev->mouse.x; - ev->y = dev->mouse.y; - ev->button = 1; - ecore_event_add(ECORE_FB_EVENT_MOUSE_BUTTON_UP, ev, NULL, NULL); - } + if (!dev->listen) return; + + if (dev->mouse.event == ECORE_FB_EVENT_MOUSE_MOVE) + { + Ecore_Fb_Event_Mouse_Move *ev; + ev = calloc(1,sizeof(Ecore_Fb_Event_Mouse_Move)); + ev->x = dev->mouse.x; + ev->y = dev->mouse.y; + ev->dev = dev; + ecore_event_add(ECORE_FB_EVENT_MOUSE_MOVE, ev, NULL, NULL); + } + else if (dev->mouse.event == ECORE_FB_EVENT_MOUSE_BUTTON_DOWN) + { + Ecore_Fb_Event_Mouse_Button_Down *ev; + ev = calloc(1, sizeof(Ecore_Fb_Event_Mouse_Button_Down)); + ev->x = dev->mouse.x; + ev->y = dev->mouse.y; + ev->button = 1; + ecore_event_add(ECORE_FB_EVENT_MOUSE_BUTTON_DOWN, ev, NULL, NULL); + } + else if (dev->mouse.event == ECORE_FB_EVENT_MOUSE_BUTTON_UP) + { + Ecore_Fb_Event_Mouse_Button_Up *ev; + ev = calloc(1, sizeof(Ecore_Fb_Event_Mouse_Button_Up)); + ev->x = dev->mouse.x; + ev->y = dev->mouse.y; + ev->button = 1; + ecore_event_add(ECORE_FB_EVENT_MOUSE_BUTTON_UP, ev, NULL, NULL); + } } static Eina_Bool -_ecore_fb_li_device_fd_callback(void *data, Ecore_Fd_Handler *fdh) +_ecore_fb_li_device_fd_callback(void *data, Ecore_Fd_Handler *fdh __UNUSED__) { - Ecore_Fb_Input_Device *dev; - struct input_event ev[64]; - int len; - int i; - - dev = (Ecore_Fb_Input_Device*)data; - /* read up to 64 events at once */ - len = read(dev->fd, &ev, sizeof(ev)); - // printf("[ecore_fb_li_device:fd_callback] received %d data\n", len); - for(i = 0; i < len/sizeof(ev[0]); i++) - { - switch(ev[i].type) - { - case EV_SYN: - _ecore_fb_li_device_event_syn(dev, &ev[i]); - break; - case EV_ABS: - _ecore_fb_li_device_event_abs(dev, &ev[i]); - break; - case EV_REL: - _ecore_fb_li_device_event_rel(dev, &ev[i]); - break; - case EV_KEY: - _ecore_fb_li_device_event_key(dev, &ev[i]); - break; - default: - break; - } - } - return EINA_TRUE; + Ecore_Fb_Input_Device *dev; + struct input_event ev[64]; + int len; + int i; + + dev = (Ecore_Fb_Input_Device*)data; + /* read up to 64 events at once */ + len = read(dev->fd, &ev, sizeof(ev)); + // printf("[ecore_fb_li_device:fd_callback] received %d data\n", len); + for(i = 0; i < (int)(len / sizeof(ev[0])); i++) + { + switch(ev[i].type) + { + case EV_SYN: + _ecore_fb_li_device_event_syn(dev, &ev[i]); + break; + case EV_ABS: + _ecore_fb_li_device_event_abs(dev, &ev[i]); + break; + case EV_REL: + _ecore_fb_li_device_event_rel(dev, &ev[i]); + break; + case EV_KEY: + _ecore_fb_li_device_event_key(dev, &ev[i]); + break; + default: + break; + } + } + return EINA_TRUE; } /** @@ -389,20 +372,20 @@ _ecore_fb_li_device_fd_callback(void *data, Ecore_Fd_Handler *fdh) EAPI void ecore_fb_input_device_listen(Ecore_Fb_Input_Device *dev, int listen) { - if(!dev) return; - if((listen && dev->listen) || (!listen && !dev->listen)) return; - if(listen) - { - /* if the device already had a handler */ - if(!dev->handler) - dev->handler = ecore_main_fd_handler_add(dev->fd, ECORE_FD_READ, _ecore_fb_li_device_fd_callback, dev, NULL, NULL); - - } - dev->listen = listen; + if (!dev) return; + if ((listen && dev->listen) || (!listen && !dev->listen)) return; + if (listen) + { + /* if the device already had a handler */ + if (!dev->handler) + dev->handler = ecore_main_fd_handler_add(dev->fd, ECORE_FD_READ, _ecore_fb_li_device_fd_callback, dev, NULL, NULL); + + } + dev->listen = listen; } #ifndef EV_CNT -#define EV_CNT (EV_MAX+1) +# define EV_CNT (EV_MAX+1) #endif /* @@ -414,90 +397,85 @@ ecore_fb_input_device_listen(Ecore_Fb_Input_Device *dev, int listen) EAPI Ecore_Fb_Input_Device * ecore_fb_input_device_open(const char *dev) { - Ecore_Fb_Input_Device *device; - unsigned long event_type_bitmask[EV_CNT / 32 + 1]; - int event_type; - int fd; - - if(!dev) return NULL; - device = calloc(1, sizeof(Ecore_Fb_Input_Device)); - if(!device) return NULL; - - if((fd = open(dev, O_RDONLY, O_NONBLOCK)) < 0) - { - fprintf(stderr, "[ecore_fb_li:device_open] %s %s", dev, strerror(errno)); - goto error_open; - } - /* query capabilities */ - if(ioctl(fd, EVIOCGBIT(0, EV_MAX), event_type_bitmask) < 0) - { - fprintf(stderr,"[ecore_fb_li:device_open] query capabilities %s %s", dev, strerror(errno)); - goto error_caps; - } - /* query name */ - device->info.name = calloc(256, sizeof(char)); - if(ioctl(fd, EVIOCGNAME(sizeof(char) * 256), device->info.name) < 0) - { - fprintf(stderr, "[ecore_fb_li:device_open] get name %s %s", dev, strerror(errno)); - strcpy(device->info.name, "Unknown"); - } - device->fd = fd; - device->info.dev = strdup(dev); - /* common */ - device->mouse.threshold = CLICK_THRESHOLD_DEFAULT; - - /* set info */ - for(event_type = 0; event_type < EV_MAX; event_type++) - { - if(!test_bit(event_type, event_type_bitmask)) - continue; - switch(event_type) - { - case EV_SYN : - break; - - case EV_KEY: - device->info.cap |= ECORE_FB_INPUT_DEVICE_CAP_KEYS_OR_BUTTONS; - break; - - case EV_REL: - device->info.cap |= ECORE_FB_INPUT_DEVICE_CAP_RELATIVE; - break; - - case EV_ABS: - device->info.cap |= ECORE_FB_INPUT_DEVICE_CAP_ABSOLUTE; - break; - - case EV_MSC: - case EV_LED: - case EV_SND: - case EV_REP: - case EV_FF : - case EV_FF_STATUS: - case EV_PWR: - default: - break; - } - } - _ecore_fb_li_devices = eina_list_append(_ecore_fb_li_devices, device); - return device; - - error_caps: - close(fd); - error_open: - free(device); - return NULL; - + Ecore_Fb_Input_Device *device; + unsigned long event_type_bitmask[EV_CNT / 32 + 1]; + int event_type; + int fd; + + if (!dev) return NULL; + device = calloc(1, sizeof(Ecore_Fb_Input_Device)); + if (!device) return NULL; + + if ((fd = open(dev, O_RDONLY, O_NONBLOCK)) < 0) + { + fprintf(stderr, "[ecore_fb_li:device_open] %s %s", dev, strerror(errno)); + goto error_open; + } + /* query capabilities */ + if (ioctl(fd, EVIOCGBIT(0, EV_MAX), event_type_bitmask) < 0) + { + fprintf(stderr,"[ecore_fb_li:device_open] query capabilities %s %s", dev, strerror(errno)); + goto error_caps; + } + /* query name */ + device->info.name = calloc(256, sizeof(char)); + if (ioctl(fd, EVIOCGNAME(sizeof(char) * 256), device->info.name) < 0) + { + fprintf(stderr, "[ecore_fb_li:device_open] get name %s %s", dev, strerror(errno)); + strcpy(device->info.name, "Unknown"); + } + device->fd = fd; + device->info.dev = strdup(dev); + /* common */ + device->mouse.threshold = CLICK_THRESHOLD_DEFAULT; + + /* set info */ + for (event_type = 0; event_type < EV_MAX; event_type++) + { + if(!test_bit(event_type, event_type_bitmask)) + continue; + switch (event_type) + { + case EV_SYN: + break; + case EV_KEY: + device->info.cap |= ECORE_FB_INPUT_DEVICE_CAP_KEYS_OR_BUTTONS; + break; + case EV_REL: + device->info.cap |= ECORE_FB_INPUT_DEVICE_CAP_RELATIVE; + break; + case EV_ABS: + device->info.cap |= ECORE_FB_INPUT_DEVICE_CAP_ABSOLUTE; + break; + case EV_MSC: + case EV_LED: + case EV_SND: + case EV_REP: + case EV_FF : + case EV_FF_STATUS: + case EV_PWR: + default: + break; + } + } + _ecore_fb_li_devices = eina_list_append(_ecore_fb_li_devices, device); + return device; + +error_caps: + close(fd); +error_open: + free(device); + return NULL; } EAPI void ecore_fb_input_device_close(Ecore_Fb_Input_Device *dev) { - /* close the fd */ - close(dev->fd); - /* remove the element from the list */ - _ecore_fb_li_devices = eina_list_remove(_ecore_fb_li_devices, dev); - free(dev); + /* close the fd */ + close(dev->fd); + /* remove the element from the list */ + _ecore_fb_li_devices = eina_list_remove(_ecore_fb_li_devices, dev); + free(dev); } @@ -510,64 +488,61 @@ ecore_fb_input_device_close(Ecore_Fb_Input_Device *dev) EAPI void ecore_fb_input_device_axis_size_set(Ecore_Fb_Input_Device *dev, int w, int h) { - if(!dev) - return; - if(w < 0 || h < 0) - return; - /* FIXME - * this code is for a touchscreen device, - * make it configurable (ABSOLUTE | RELATIVE) - */ - if(dev->info.cap & ECORE_FB_INPUT_DEVICE_CAP_ABSOLUTE) - { - /* FIXME looks like some kernels dont include this struct */ - struct input_absinfo abs_features; - - ioctl(dev->fd, EVIOCGABS(ABS_X), &abs_features); - dev->mouse.min_w = abs_features.minimum; - dev->mouse.rel_w = (double)(abs_features.maximum - abs_features.minimum)/(double)(w); - - ioctl(dev->fd, EVIOCGABS(ABS_Y), &abs_features); - dev->mouse.min_h = abs_features.minimum; - dev->mouse.rel_h = (double)(abs_features.maximum - abs_features.minimum)/(double)(h); - } - else if(!(dev->info.cap & ECORE_FB_INPUT_DEVICE_CAP_RELATIVE)) - return; - - /* update the local values */ - if(dev->mouse.x > w - 1) - dev->mouse.x = w -1; - if(dev->mouse.y > h - 1) - dev->mouse.y = h -1; - dev->mouse.w = w; - dev->mouse.h = h; + if (!dev) return; + if ((w < 0) || (h < 0)) return; + /* FIXME + * this code is for a touchscreen device, + * make it configurable (ABSOLUTE | RELATIVE) + */ + if (dev->info.cap & ECORE_FB_INPUT_DEVICE_CAP_ABSOLUTE) + { + /* FIXME looks like some kernels dont include this struct */ + struct input_absinfo abs_features; + + ioctl(dev->fd, EVIOCGABS(ABS_X), &abs_features); + dev->mouse.min_w = abs_features.minimum; + dev->mouse.rel_w = (double)(abs_features.maximum - abs_features.minimum)/(double)(w); + + ioctl(dev->fd, EVIOCGABS(ABS_Y), &abs_features); + dev->mouse.min_h = abs_features.minimum; + dev->mouse.rel_h = (double)(abs_features.maximum - abs_features.minimum)/(double)(h); + } + else if (!(dev->info.cap & ECORE_FB_INPUT_DEVICE_CAP_RELATIVE)) + return; + + /* update the local values */ + if (dev->mouse.x > w - 1) dev->mouse.x = w -1; + if (dev->mouse.y > h - 1) dev->mouse.y = h -1; + dev->mouse.w = w; + dev->mouse.h = h; } EAPI const char * ecore_fb_input_device_name_get(Ecore_Fb_Input_Device *dev) { - if(!dev) - return NULL; - return dev->info.name; + if (!dev) return NULL; + return dev->info.name; } + EAPI Ecore_Fb_Input_Device_Cap ecore_fb_input_device_cap_get(Ecore_Fb_Input_Device *dev) { - if(!dev) - return ECORE_FB_INPUT_DEVICE_CAP_NONE; - return dev->info.cap; + if (!dev) return ECORE_FB_INPUT_DEVICE_CAP_NONE; + return dev->info.cap; } + EAPI void ecore_fb_input_device_threshold_click_set(Ecore_Fb_Input_Device *dev, double threshold) { - if(!dev) return; - if(threshold == dev->mouse.threshold || threshold == 0) return; - dev->mouse.threshold = threshold; + if (!dev) return; + if ((threshold == dev->mouse.threshold) || (threshold == 0)) return; + dev->mouse.threshold = threshold; } + EAPI double ecore_fb_input_device_threshold_click_get(Ecore_Fb_Input_Device *dev) { - if(!dev) return 0; - return dev->mouse.threshold; + if (!dev) return 0; + return dev->mouse.threshold; } diff --git a/src/lib/ecore_fb/ecore_fb_ts.c b/src/lib/ecore_fb/ecore_fb_ts.c index c1e1f08..86992a9 100644 --- a/src/lib/ecore_fb/ecore_fb_ts.c +++ b/src/lib/ecore_fb/ecore_fb_ts.c @@ -81,28 +81,28 @@ ecore_fb_ts_init(void) #ifdef HAVE_TSLIB char *tslib_tsdevice = NULL; if ( (tslib_tsdevice = getenv("TSLIB_TSDEVICE")) ) - { + { printf( "ECORE_FB: TSLIB_TSDEVICE = '%s'\n", tslib_tsdevice ); _ecore_fb_tslib_tsdev = ts_open( tslib_tsdevice, 1 ); /* 1 = nonblocking, 0 = blocking */ - + if ( !_ecore_fb_tslib_tsdev ) - { - printf( "ECORE_FB: Can't ts_open (%s)\n", strerror( errno ) ); - return 0; - } - + { + printf( "ECORE_FB: Can't ts_open (%s)\n", strerror( errno ) ); + return 0; + } + if ( ts_config( _ecore_fb_tslib_tsdev ) ) - { - printf( "ECORE_FB: Can't ts_config (%s)\n", strerror( errno ) ); - return 0; - } + { + printf( "ECORE_FB: Can't ts_config (%s)\n", strerror( errno ) ); + return 0; + } _ecore_fb_ts_fd = ts_fd( _ecore_fb_tslib_tsdev ); if ( _ecore_fb_ts_fd < 0 ) - { - printf( "ECORE_FB: Can't open touchscreen (%s)\n", strerror( errno ) ); - return 0; - } - } + { + printf( "ECORE_FB: Can't open touchscreen (%s)\n", strerror( errno ) ); + return 0; + } + } #else _ecore_fb_ts_fd = open("/dev/touchscreen/0", O_RDONLY); #endif @@ -127,7 +127,7 @@ EAPI void ecore_fb_ts_shutdown(void) { if (_ecore_fb_ts_fd_handler_handle) - ecore_main_fd_handler_del(_ecore_fb_ts_fd_handler_handle); + ecore_main_fd_handler_del(_ecore_fb_ts_fd_handler_handle); if (_ecore_fb_ts_fd >= 0) close(_ecore_fb_ts_fd); _ecore_fb_ts_fd = -1; _ecore_fb_ts_fd_handler_handle = NULL; @@ -138,8 +138,8 @@ ecore_fb_ts_shutdown(void) * * Functions that calibrate the screen. */ - - + + /** * Calibrates the touschreen using the given parameters. * @param xscale X scaling, where 256 = 1.0 @@ -164,7 +164,6 @@ ecore_fb_touch_screen_calibrate_set(int xscale, int xtrans, int yscale, int ytra { _ecore_fb_ts_cal = cal; _ecore_fb_ts_apply_cal = 1; - } } @@ -187,11 +186,10 @@ ecore_fb_touch_screen_calibrate_get(int *xscale, int *xtrans, int *yscale, int * if (!_ecore_fb_ts_apply_cal) { if (ioctl(_ecore_fb_ts_fd, TS_GET_CAL, (void *)&cal)) - _ecore_fb_ts_cal = cal; - + _ecore_fb_ts_cal = cal; } else - cal = _ecore_fb_ts_cal; + cal = _ecore_fb_ts_cal; if (xscale) *xscale = cal.xscale; if (xtrans) *xtrans = cal.xtrans; if (yscale) *yscale = cal.yscale; @@ -212,14 +210,14 @@ _ecore_fb_ts_fd_handler(void *data __UNUSED__, Ecore_Fd_Handler *fd_handler __UN int x, y, pressure; int num; char *ptr; - double t; + double t = 0.0; int did_triple = 0; #ifdef HAVE_TSLIB if (_ecore_fb_ts_apply_cal) - num = ts_read_raw(_ecore_fb_tslib_tsdev, &_ecore_fb_tslib_event, 1); + num = ts_read_raw(_ecore_fb_tslib_tsdev, &_ecore_fb_tslib_event, 1); else - num = ts_read(_ecore_fb_tslib_tsdev, &_ecore_fb_tslib_event, 1); + num = ts_read(_ecore_fb_tslib_tsdev, &_ecore_fb_tslib_event, 1); if (num != 1) return 1; /* no more samples at this time */ x = _ecore_fb_tslib_event.x; y = _ecore_fb_tslib_event.y; @@ -235,7 +233,7 @@ _ecore_fb_ts_fd_handler(void *data __UNUSED__, Ecore_Fd_Handler *fd_handler __UN _ecore_fb_ts_event_byte_count += v; if (v < num) return 1; _ecore_fb_ts_event_byte_count = 0; - if (_ecore_fb_ts_apply_cal) + if (_ecore_fb_ts_apply_cal) { x = ((_ecore_fb_ts_cal.xscale * _ecore_fb_ts_event.x) >> 8) + _ecore_fb_ts_cal.xtrans; y = ((_ecore_fb_ts_cal.yscale * _ecore_fb_ts_event.y) >> 8) + _ecore_fb_ts_cal.ytrans; @@ -271,7 +269,7 @@ _ecore_fb_ts_fd_handler(void *data __UNUSED__, Ecore_Fd_Handler *fd_handler __UN e->y = y; e->button = 1; if ((t - last_time) <= _ecore_fb_double_click_time) - e->double_click = 1; + e->double_click = 1; if ((t - last_last_time) <= (2 * _ecore_fb_double_click_time)) { did_triple = 1; @@ -301,7 +299,7 @@ _ecore_fb_ts_fd_handler(void *data __UNUSED__, Ecore_Fd_Handler *fd_handler __UN last_last_time = last_time; last_time = t; } - retry: +retry: prev_x = x; prev_y = y; prev_pressure = pressure; diff --git a/src/lib/ecore_fb/ecore_fb_vt.c b/src/lib/ecore_fb/ecore_fb_vt.c index 2849899..e7f6fe2 100644 --- a/src/lib/ecore_fb/ecore_fb_vt.c +++ b/src/lib/ecore_fb/ecore_fb_vt.c @@ -34,186 +34,188 @@ static Eina_Bool _ecore_fb_event_filter_filter(void *data, void *loop_data, in static void _ecore_fb_event_filter_end(void *data, void *loop_data); /* prototypes */ +/* XXX: unused static void _ecore_fb_vt_switch(int vt); +*/ static Eina_Bool _ecore_fb_signal_usr_handler(void *data __UNUSED__, int type __UNUSED__, void *ev) { - - Ecore_Event_Signal_User *e; + Ecore_Event_Signal_User *e; - e = (Ecore_Event_Signal_User *)ev; - if (e->number == 1) - { - /* release vt */ - if (_ecore_fb_func_fb_lost) _ecore_fb_func_fb_lost(_ecore_fb_func_fb_lost_data); - /* TODO stop listening from the devices? let the callback do it? */ - ioctl(_ecore_fb_vt_tty_fd, VT_RELDISP, 1); - } - else if (e->number == 2) - { - /* attach vt */ - if (_ecore_fb_func_fb_gain) _ecore_fb_func_fb_gain(_ecore_fb_func_fb_gain_data); - /* TODO reattach all devices */ - } - return 1; + e = (Ecore_Event_Signal_User *)ev; + if (e->number == 1) + { + /* release vt */ + if (_ecore_fb_func_fb_lost) _ecore_fb_func_fb_lost(_ecore_fb_func_fb_lost_data); + /* TODO stop listening from the devices? let the callback do it? */ + ioctl(_ecore_fb_vt_tty_fd, VT_RELDISP, 1); + } + else if (e->number == 2) + { + /* attach vt */ + if (_ecore_fb_func_fb_gain) _ecore_fb_func_fb_gain(_ecore_fb_func_fb_gain_data); + /* TODO reattach all devices */ + } + return 1; } +/* XXX: unused static void _ecore_fb_vt_switch(int vt) { - vt++; - if (_ecore_fb_vt_tty_fd != 0) - { - if (vt != _ecore_fb_vt_current_vt) - { - tcsetattr(_ecore_fb_vt_tty_fd, TCSAFLUSH, &_ecore_fb_tty_prev_tio_mode); - ioctl(_ecore_fb_vt_tty_fd, KDSETMODE, _ecore_fb_tty_prev_kd_mode); - ioctl(_ecore_fb_vt_tty_fd, KDSKBMODE, _ecore_fb_tty_prev_mode); - } - } - ioctl(_ecore_fb_vt_tty_fd, VT_ACTIVATE, vt); + vt++; + if (_ecore_fb_vt_tty_fd != 0) + { + if (vt != _ecore_fb_vt_current_vt) + { + tcsetattr(_ecore_fb_vt_tty_fd, TCSAFLUSH, &_ecore_fb_tty_prev_tio_mode); + ioctl(_ecore_fb_vt_tty_fd, KDSETMODE, _ecore_fb_tty_prev_kd_mode); + ioctl(_ecore_fb_vt_tty_fd, KDSKBMODE, _ecore_fb_tty_prev_mode); + } + } + ioctl(_ecore_fb_vt_tty_fd, VT_ACTIVATE, vt); } +*/ static int _ecore_fb_vt_setup(void) { - char buf[64]; - struct termios tio; - struct vt_mode new_vtmode; - - if(_ecore_fb_vt_current_vt != _ecore_fb_vt_prev_vt) - { - snprintf(buf, sizeof(buf), "/dev/tty%i", _ecore_fb_vt_current_vt); - if((_ecore_fb_vt_tty_fd = open(buf, O_RDWR)) < 0) - { - printf("[ecore_fb:vt_setup] can't open tty %d\n", _ecore_fb_vt_current_vt); - return 0; - } - close(_ecore_fb_vt_tty0_fd); - _ecore_fb_vt_tty0_fd = 0; - /* FIXME detach the process from current tty ? */ - } - else - _ecore_fb_vt_tty_fd = _ecore_fb_vt_tty0_fd; - /* for backup */ - tcgetattr(_ecore_fb_vt_tty_fd, &_ecore_fb_tty_prev_tio_mode); - ioctl(_ecore_fb_vt_tty_fd, KDGETMODE, &_ecore_fb_tty_prev_kd_mode); - ioctl(_ecore_fb_vt_tty_fd, VT_GETMODE, &_ecore_fb_vt_prev_mode); - - if(ioctl(_ecore_fb_vt_tty_fd, KDSETMODE, KD_GRAPHICS) < 0) - { - perror("[ecore_fb:vt_setup] can't set the mode to KD_GRAPHICS"); - close(_ecore_fb_vt_tty_fd); - return 0; - } - ioctl(_ecore_fb_vt_tty_fd, KDGKBMODE, &_ecore_fb_tty_prev_mode); - - /* support of switching */ - new_vtmode.mode = VT_PROCESS; - new_vtmode.waitv = 0; - new_vtmode.relsig = SIGUSR1; - new_vtmode.acqsig = SIGUSR2; - if(ioctl(_ecore_fb_vt_tty_fd, VT_SETMODE, &new_vtmode) < 0) - { - perror("[ecore_fb:vt_setup] can't set the tty mode"); - close(_ecore_fb_vt_tty_fd); - return 0; - } - /* register signal handlers when alloc/detach of vt */ - _ecore_fb_user_handler = ecore_event_handler_add(ECORE_EVENT_SIGNAL_USER, + char buf[64]; +// XXX: unused +// struct termios tio; + struct vt_mode new_vtmode; + + if (_ecore_fb_vt_current_vt != _ecore_fb_vt_prev_vt) + { + snprintf(buf, sizeof(buf), "/dev/tty%i", _ecore_fb_vt_current_vt); + if ((_ecore_fb_vt_tty_fd = open(buf, O_RDWR)) < 0) + { + printf("[ecore_fb:vt_setup] can't open tty %d\n", _ecore_fb_vt_current_vt); + return 0; + } + close(_ecore_fb_vt_tty0_fd); + _ecore_fb_vt_tty0_fd = 0; + /* FIXME detach the process from current tty ? */ + } + else + _ecore_fb_vt_tty_fd = _ecore_fb_vt_tty0_fd; + /* for backup */ + tcgetattr(_ecore_fb_vt_tty_fd, &_ecore_fb_tty_prev_tio_mode); + ioctl(_ecore_fb_vt_tty_fd, KDGETMODE, &_ecore_fb_tty_prev_kd_mode); + ioctl(_ecore_fb_vt_tty_fd, VT_GETMODE, &_ecore_fb_vt_prev_mode); + + if (ioctl(_ecore_fb_vt_tty_fd, KDSETMODE, KD_GRAPHICS) < 0) + { + perror("[ecore_fb:vt_setup] can't set the mode to KD_GRAPHICS"); + close(_ecore_fb_vt_tty_fd); + return 0; + } + ioctl(_ecore_fb_vt_tty_fd, KDGKBMODE, &_ecore_fb_tty_prev_mode); + + /* support of switching */ + new_vtmode.mode = VT_PROCESS; + new_vtmode.waitv = 0; + new_vtmode.relsig = SIGUSR1; + new_vtmode.acqsig = SIGUSR2; + if (ioctl(_ecore_fb_vt_tty_fd, VT_SETMODE, &new_vtmode) < 0) + { + perror("[ecore_fb:vt_setup] can't set the tty mode"); + close(_ecore_fb_vt_tty_fd); + return 0; + } + /* register signal handlers when alloc/detach of vt */ + _ecore_fb_user_handler = ecore_event_handler_add(ECORE_EVENT_SIGNAL_USER, _ecore_fb_signal_usr_handler, NULL); - /* What does this does? */ - _ecore_fb_filter_handler = ecore_event_filter_add(_ecore_fb_event_filter_start, _ecore_fb_event_filter_filter, _ecore_fb_event_filter_end, NULL); - - usleep(40000); - if(ioctl(_ecore_fb_vt_tty_fd, VT_ACTIVATE, _ecore_fb_vt_current_vt) < 0) - { - perror("[ecore_fb:vt_setup] error on VT_ACTIVATE"); - close(_ecore_fb_vt_tty_fd); - return 0; - } - if(ioctl(_ecore_fb_vt_tty_fd, VT_WAITACTIVE, _ecore_fb_vt_current_vt) < 0) - { - perror("[ecore_fb:vt_setup] error on VT_WAITACTIVE"); - close(_ecore_fb_vt_tty_fd); - return 0; - } - /* FIXME assign the fb to the tty in case isn't setup */ - return 1; + /* What does this do? */ + _ecore_fb_filter_handler = ecore_event_filter_add(_ecore_fb_event_filter_start, _ecore_fb_event_filter_filter, _ecore_fb_event_filter_end, NULL); + + usleep(40000); + if (ioctl(_ecore_fb_vt_tty_fd, VT_ACTIVATE, _ecore_fb_vt_current_vt) < 0) + { + perror("[ecore_fb:vt_setup] error on VT_ACTIVATE"); + close(_ecore_fb_vt_tty_fd); + return 0; + } + if(ioctl(_ecore_fb_vt_tty_fd, VT_WAITACTIVE, _ecore_fb_vt_current_vt) < 0) + { + perror("[ecore_fb:vt_setup] error on VT_WAITACTIVE"); + close(_ecore_fb_vt_tty_fd); + return 0; + } + /* FIXME assign the fb to the tty in case isn't setup */ + return 1; } int ecore_fb_vt_init(void) { - struct vt_stat vtstat; - - /* as root you can allocate another tty */ - if(!geteuid()) - _ecore_fb_vt_do_switch = 1; - if((_ecore_fb_vt_tty0_fd = open("/dev/tty0", O_RDONLY)) < 0) - { - printf("[ecore_fb:init] can't open /dev/tty0\n"); - return 0; - } - /* query current vt state */ - if((ioctl(_ecore_fb_vt_tty0_fd, VT_GETSTATE, &vtstat)) < 0) - { - printf("[ecore_fb:init] can't get current tty state\n"); - return 0; - } - _ecore_fb_vt_prev_vt = vtstat.v_active; - /* switch to another tty */ - if(_ecore_fb_vt_do_switch) - { - int vtno; - - if ((ioctl(_ecore_fb_vt_tty0_fd, VT_OPENQRY, &vtno) < 0)) - { - printf("[ecore_fb:init] can't query for a vt\n"); - return 0; - } - _ecore_fb_vt_current_vt = vtno; - } - /* use current tty */ - else - _ecore_fb_vt_current_vt = _ecore_fb_vt_prev_vt; - if(!_ecore_fb_vt_setup()) - { - printf("[ecore_fb:init] can't setup the vt, restoring previous mode...\n"); - /* TODO finish this */ - if(_ecore_fb_vt_do_switch) - { - printf("[ecore_fb:init] switching back to vt %d\n", _ecore_fb_vt_prev_vt); - } - return 0; - } - return 1; + struct vt_stat vtstat; + + /* as root you can allocate another tty */ + if (!geteuid()) + _ecore_fb_vt_do_switch = 1; + if ((_ecore_fb_vt_tty0_fd = open("/dev/tty0", O_RDONLY)) < 0) + { + printf("[ecore_fb:init] can't open /dev/tty0\n"); + return 0; + } + /* query current vt state */ + if ((ioctl(_ecore_fb_vt_tty0_fd, VT_GETSTATE, &vtstat)) < 0) + { + printf("[ecore_fb:init] can't get current tty state\n"); + return 0; + } + _ecore_fb_vt_prev_vt = vtstat.v_active; + /* switch to another tty */ + if (_ecore_fb_vt_do_switch) + { + int vtno; + + if ((ioctl(_ecore_fb_vt_tty0_fd, VT_OPENQRY, &vtno) < 0)) + { + printf("[ecore_fb:init] can't query for a vt\n"); + return 0; + } + _ecore_fb_vt_current_vt = vtno; + } + /* use current tty */ + else + _ecore_fb_vt_current_vt = _ecore_fb_vt_prev_vt; + if (!_ecore_fb_vt_setup()) + { + printf("[ecore_fb:init] can't setup the vt, restoring previous mode...\n"); + /* TODO finish this */ + if (_ecore_fb_vt_do_switch) + { + printf("[ecore_fb:init] switching back to vt %d\n", _ecore_fb_vt_prev_vt); + } + return 0; + } + return 1; } void ecore_fb_vt_shutdown(void) { - /* restore the previous mode */ - if(_ecore_fb_vt_tty_fd != 0) - { - tcsetattr(_ecore_fb_vt_tty_fd, TCSAFLUSH, &_ecore_fb_tty_prev_tio_mode); - ioctl(_ecore_fb_vt_tty_fd, KDSETMODE, _ecore_fb_tty_prev_kd_mode); - ioctl(_ecore_fb_vt_tty_fd, KDSKBMODE, _ecore_fb_tty_prev_mode); - ioctl(_ecore_fb_vt_tty_fd, VT_SETMODE, &_ecore_fb_vt_prev_mode); - /* go back to previous vt */ - close(_ecore_fb_vt_tty_fd); - _ecore_fb_vt_tty_fd = 0; - } - - if(_ecore_fb_user_handler) - ecore_event_handler_del(_ecore_fb_user_handler); - _ecore_fb_user_handler = NULL; - - if(_ecore_fb_filter_handler) - ecore_event_filter_del(_ecore_fb_filter_handler); - _ecore_fb_filter_handler = NULL; + /* restore the previous mode */ + if (_ecore_fb_vt_tty_fd != 0) + { + tcsetattr(_ecore_fb_vt_tty_fd, TCSAFLUSH, &_ecore_fb_tty_prev_tio_mode); + ioctl(_ecore_fb_vt_tty_fd, KDSETMODE, _ecore_fb_tty_prev_kd_mode); + ioctl(_ecore_fb_vt_tty_fd, KDSKBMODE, _ecore_fb_tty_prev_mode); + ioctl(_ecore_fb_vt_tty_fd, VT_SETMODE, &_ecore_fb_vt_prev_mode); + /* go back to previous vt */ + close(_ecore_fb_vt_tty_fd); + _ecore_fb_vt_tty_fd = 0; + } + + if (_ecore_fb_user_handler) ecore_event_handler_del(_ecore_fb_user_handler); + _ecore_fb_user_handler = NULL; + + if (_ecore_fb_filter_handler) ecore_event_filter_del(_ecore_fb_filter_handler); + _ecore_fb_filter_handler = NULL; } /** @@ -240,9 +242,10 @@ ecore_fb_callback_lose_set(void (*func) (void *data), void *data) { _ecore_fb_func_fb_lost = func; _ecore_fb_func_fb_lost_data = data; + } typedef struct _Ecore_Fb_Filter_Data Ecore_Fb_Filter_Data; - + struct _Ecore_Fb_Filter_Data { int last_event_type;