This patch adds absolute coordinate support to ecore_fb, e.g. touchscreen support. There is no calibration support yet, it just uses the values it gets from the kernel.
Lars Munch --- Index: src/lib/ecore_fb/ecore_fb_private.h =================================================================== --- src/lib/ecore_fb/ecore_fb_private.h (revision 38149) +++ src/lib/ecore_fb/ecore_fb_private.h (working copy) @@ -19,8 +19,8 @@ #define kernel_ulong_t unsigned long #define BITS_PER_LONG 32 #include <linux/input.h> - #undef kernel_ulong_t <-added - #undef BITS_PER_LONG <-added + #undef kernel_ulong_t + #undef BITS_PER_LONG #else #include <linux/input.h> #endif @@ -52,7 +52,7 @@ /* absolute axis */ int min_w, min_h; double rel_w, rel_h; - + int event; } mouse; struct { Index: src/lib/ecore_fb/ecore_fb_li.c =================================================================== --- src/lib/ecore_fb/ecore_fb_li.c (revision 38149) +++ src/lib/ecore_fb/ecore_fb_li.c (working copy) @@ -250,52 +250,110 @@ static void _ecore_fb_li_device_event_abs(Ecore_Fb_Input_Device *dev, struct input_event *iev) { + static int prev_x = 0, prev_y = 0, prev_pressure = 0; + int v = 0; + int pressure; + int num; + char *ptr; + double t; + if(!dev->listen) return; + switch(iev->code) { case ABS_X: - case ABS_Y: - { - Ecore_Fb_Event_Mouse_Move *ev; - if((iev->code == ABS_X) && (dev->mouse.w != 0)) + if(dev->mouse.w != 0) { int tmp; tmp = (int)((double)(iev->value - dev->mouse.min_w) / dev->mouse.rel_w); - if(tmp < 0) + if(tmp < 0) { dev->mouse.x = 0; - else if(tmp > dev->mouse.w) + } + else if(tmp > dev->mouse.w) { dev->mouse.x = dev->mouse.w; - else + } + else { dev->mouse.x = tmp; + } + dev->mouse.event = ECORE_FB_EVENT_MOUSE_MOVE; } - else if((iev->code == ABS_Y) && (dev->mouse.h != 0)) + 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) + if(tmp < 0) { dev->mouse.y = 0; - else if(tmp > dev->mouse.h) + } + else if(tmp > dev->mouse.h) { dev->mouse.y = dev->mouse.h; - else + } + else { dev->mouse.y = tmp; + } + dev->mouse.event = ECORE_FB_EVENT_MOUSE_MOVE; } - ev = calloc(1,sizeof(Ecore_Fb_Event_Mouse_Move)); - ev->x = dev->mouse.x; - ev->y = dev->mouse.y; - ev->dev = dev; + break; - ecore_event_add(ECORE_FB_EVENT_MOUSE_MOVE, ev, NULL, NULL); - break; - } case ABS_PRESSURE: - /* TODO emulate a button press */ + 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) +{ + 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 int _ecore_fb_li_device_fd_callback(void *data, Ecore_Fd_Handler *fdh) { @@ -312,6 +370,9 @@ { 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; Index: src/lib/ecore_evas/ecore_evas_fb.c =================================================================== --- src/lib/ecore_evas/ecore_evas_fb.c (revision 38149) +++ src/lib/ecore_evas/ecore_evas_fb.c (working copy) @@ -284,7 +284,7 @@ if (ecore_evas_input_devices) { /* Mouse */ - if (caps & ECORE_FB_INPUT_DEVICE_CAP_RELATIVE) + if ((caps & ECORE_FB_INPUT_DEVICE_CAP_RELATIVE) || (caps & ECORE_FB_INPUT_DEVICE_CAP_ABSOLUTE)) { ecore_fb_input_device_axis_size_set(device, w, h); ecore_fb_input_device_listen(device,1); ------------------------------------------------------------------------------ SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada. The future of the web can't happen without you. Join us at MIX09 to help pave the way to the Next Web now. Learn more and register at http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/ _______________________________________________ enlightenment-devel mailing list enlightenment-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-devel