On Sat, 2008-01-19 at 11:41 +1100, Carsten Haitzler wrote:
> On Sat, 05 Jan 2008 21:02:52 +0100 Tobias <[EMAIL PROTECTED]> babbled:
> 
> > Hi all,
> > 
> > I've played around with Ecore_Fb on my zaurus and I've run into some
> > problems with events getting through to evas.
> > 
> > First, there were some comments about libts support in ecore a couple of
> > weeks ago, this libts implementation (ecore_fb_ts_c) seems to be very
> > ipaq specific, and is not used anywhere and deprecated.
> 
> that's the code compiled if u don't have tslib support. #ifdef HAVE_TSLIB
> builds the tslib specific code, and otherwise its the old code i wrote
> originally for my ipaq 3660 touchscreen etc. frankly at the time i didn't
> abstract it much at all - i was just happy to make it work :)

If I'm not mistaken, it does not build the ipaq nor the tslib code,
ecore_fb_ts.c is not included in the build at all.

> > I've altered it and attach patches here to enable it again and only
> > support the libts mouse events and remove all the ipaq
> > backlightning,led,brightnes...etc stuff, I've also removed the
> > calibration.
> 
> seems mostly the patches just remove the old ipaq code (most of whihc is
> dormant) and only leave the tslib specific code - thats really just a "old
> feature cleanup" - not sure how it makes things work as opposed to not work 
> (if
> u built with tslib support). removing the led blink etc. calls are probably
> good - it's an ipaq specific thing. but what was wrong? if u had tslib - then
> it should be using it, not ipaq specific touchscreen stuff?

What was wrong was that it was never built at all; currently
ecore_fb_ts.c is outcommented in Makefile.am. I wanted to enable it, and
I found lots of ipaq specific calls. So I reasoned like this: 
It is outcommented in Makefile.am, so noone is using it. Tslib is linked
in if found, but no code is using it. There are ecore_fb_ functions that
only works on ipaq and noone is using them. Why not enable it again and
remove the ipaq calls?

What the patch does is make ecore_fb_ts_init.c compile again and removes
ipaq specific calls. Maybe you want the ipaq code to be outcommented
instead?

> > Now ecore_event_handler_add(ECORE_FB_EVENT_MOUSE_*...) events works, but
> > I can't get any evas_object_event_callbacks to work (subsequently edje
> > files don't receive any mouse events either). 
> > 
> > I've tried evas_event_feed_mouse in an app but I can't get any more
> > events than mouse_in and mouse_out fed to the evas_object. I'm not sure
> > I grok  evas_event_feed*.
> 
> these feed in raw events - ecore_evas_fb should have all that hooked up for 
> you
> - *IF* it is getting events from ecore_fb at all. i'd printf in ecore_fb when
> it adds events and see if events are being produced at all.
> 

I init the touchscreen at the end of _ecore_evas_fb_init if no mouse is
found, if successful event handlers are setup for mouse up/down/move. It
works here. New patch attached.

/Cheers
Tobias
diff -Nurd ecore.orig/src/lib/ecore_evas/ecore_evas_fb.c ecore/src/lib/ecore_evas/ecore_evas_fb.c
--- ecore.orig/src/lib/ecore_evas/ecore_evas_fb.c	2008-01-19 21:03:48.028235732 +0100
+++ ecore/src/lib/ecore_evas/ecore_evas_fb.c	2008-01-20 03:21:23.425012908 +0100
@@ -8,6 +8,7 @@
 #include "Ecore_Evas.h"
 #ifdef BUILD_ECORE_EVAS_FB
 #include "Ecore_Fb.h"
+#include "ecore_fb_private.h"
 #endif
 
 #ifdef BUILD_ECORE_EVAS_FB
@@ -314,6 +315,16 @@
 	       }
 	  }
      }
+   if (!mouse_handled)
+     {
+	if (ecore_fb_ts_init())
+	  {
+	     ecore_evas_event_handlers[2]  = ecore_event_handler_add(ECORE_FB_EVENT_MOUSE_BUTTON_DOWN, _ecore_evas_event_mouse_button_down, NULL);
+	     ecore_evas_event_handlers[3]  = ecore_event_handler_add(ECORE_FB_EVENT_MOUSE_BUTTON_UP, _ecore_evas_event_mouse_button_up, NULL);
+	     ecore_evas_event_handlers[4]  = ecore_event_handler_add(ECORE_FB_EVENT_MOUSE_MOVE, _ecore_evas_event_mouse_move, NULL);
+	     mouse_handled = 1;
+	  }
+     }
    return _ecore_evas_init_count;
 }
 
@@ -517,6 +528,7 @@
 	ecore_idle_enterer_del(ecore_evas_idle_enterer);
 	ecore_evas_idle_enterer = NULL;
 	if (_ecore_evas_fps_debug) _ecore_evas_fps_debug_shutdown();
+	ecore_fb_ts_shutdown();
      }
    if (_ecore_evas_init_count < 0) _ecore_evas_init_count = 0;
    return _ecore_evas_init_count;
diff -Nurd ecore.orig/src/lib/ecore_fb/Ecore_Fb.h ecore/src/lib/ecore_fb/Ecore_Fb.h
--- ecore.orig/src/lib/ecore_fb/Ecore_Fb.h	2008-01-19 21:05:46.428173079 +0100
+++ ecore/src/lib/ecore_fb/Ecore_Fb.h	2008-01-20 03:21:47.679312762 +0100
@@ -134,27 +134,7 @@
 EAPI int    ecore_fb_init(const char *name);
 EAPI int    ecore_fb_shutdown(void);
 EAPI void   ecore_fb_size_get(int *w, int *h);   
-   
-/* DEPRECATED */
-#if 0
-EAPI void   ecore_fb_touch_screen_calibrate_set(int xscale, int xtrans, int yscale, int ytrans, int xyswap);
-EAPI void   ecore_fb_touch_screen_calibrate_get(int *xscale, int *xtrans, int *yscale, int *ytrans, int *xyswap);
-
-EAPI void   ecore_fb_backlight_set(int on);
-EAPI int    ecore_fb_backlight_get(void);
-
-EAPI void   ecore_fb_backlight_brightness_set(double br);
-EAPI double ecore_fb_backlight_brightness_get(void);
-
-EAPI void   ecore_fb_led_set(int on);
-EAPI void   ecore_fb_led_blink_set(double speed);
-
-EAPI void   ecore_fb_contrast_set(double cr);
-EAPI double ecore_fb_contrast_get(void);
 
-EAPI double ecore_fb_light_sensor_get(void);
-#endif
-       
 #ifdef __cplusplus
 }
 #endif
diff -Nurd ecore.orig/src/lib/ecore_fb/Makefile.am ecore/src/lib/ecore_fb/Makefile.am
--- ecore.orig/src/lib/ecore_fb/Makefile.am	2008-01-19 21:05:46.437171707 +0100
+++ ecore/src/lib/ecore_fb/Makefile.am	2008-01-19 21:08:32.036908429 +0100
@@ -14,9 +14,9 @@
 ecore_fb.c \
 ecore_fb_vt.c \
 ecore_fb_li.c \
+ecore_fb_ts.c \
 ecore_fb_private.h
 # deprecated sources (might not compile):
-# ecore_fb_ts.c
 # ecore_fb_kbd.c
 # ecore_fb_ps2.c
 
diff -Nurd ecore.orig/src/lib/ecore_fb/ecore_fb_private.h ecore/src/lib/ecore_fb/ecore_fb_private.h
--- ecore.orig/src/lib/ecore_fb/ecore_fb_private.h	2008-01-19 21:05:46.828112066 +0100
+++ ecore/src/lib/ecore_fb/ecore_fb_private.h	2008-01-20 03:25:34.964638961 +0100
@@ -63,36 +63,12 @@
 	} keyboard;
 };
 
+/* ecore_fb_ts.c */
+EAPI int    ecore_fb_ts_init(void);
+EAPI void   ecore_fb_ts_shutdown(void);
+
 /* ecore_fb_vt.c */
 int  ecore_fb_vt_init(void);
 void ecore_fb_vt_shutdown(void);
 
-#if 0
-/* hacks to stop people NEEDING #include <linux/h3600_ts.h> */
-#ifndef TS_SET_CAL
-#define TS_SET_CAL 0x4014660b
-#endif
-#ifndef TS_GET_CAL
-#define TS_GET_CAL 0x8014660a
-#endif
-#ifndef TS_SET_BACKLIGHT
-#define TS_SET_BACKLIGHT 0x40086614
-#endif
-#ifndef TS_GET_BACKLIGHT
-#define TS_GET_BACKLIGHT 0x80086614
-#endif
-#ifndef LED_ON
-#define LED_ON 0x40046605
-#endif
-#ifndef TS_SET_CONTRAST
-#define TS_SET_CONTRAST 0x40046615
-#endif
-#ifndef TS_GET_CONTRAST
-#define TS_GET_CONTRAST 0x80046615
-#endif
-#ifndef FLITE_ON
-#define FLITE_ON 0x40046607
-#endif
-#endif
-
 #endif
diff -Nurd ecore.orig/src/lib/ecore_fb/ecore_fb_ts.c ecore/src/lib/ecore_fb/ecore_fb_ts.c
--- ecore.orig/src/lib/ecore_fb/ecore_fb_ts.c	2008-01-19 21:05:46.892102305 +0100
+++ ecore/src/lib/ecore_fb/ecore_fb_ts.c	2008-01-19 21:19:52.384117196 +0100
@@ -1,21 +1,17 @@
+#include "Ecore_Fb.h"
+#include "ecore_fb_private.h"
+#include "config.h"
 #ifdef HAVE_TSLIB
 #include <tslib.h>
 #include <errno.h>
 #endif
 
 typedef struct _Ecore_Fb_Ts_Event Ecore_Fb_Ts_Event;
-typedef struct _Ecore_Fb_Ts_Calibrate Ecore_Fb_Ts_Calibrate;
-typedef struct _Ecore_Fb_Ts_Backlight Ecore_Fb_Ts_Backlight;
-typedef struct _Ecore_Fb_Ts_Contrast Ecore_Fb_Ts_Contrast;
-typedef struct _Ecore_Fb_Ts_Led Ecore_Fb_Ts_Led;
-typedef struct _Ecore_Fb_Ts_Flite Ecore_Fb_Ts_Flite;
 
 static int _ecore_fb_ts_fd_handler(void *data, Ecore_Fd_Handler *fd_handler);
 static int _ecore_fb_ts_fd = 0;
 static int _ecore_fb_ts_event_byte_count = 0;
-static int _ecore_fb_ts_apply_cal = 0;
 static Ecore_Fb_Ts_Event _ecore_fb_ts_event;
-static Ecore_Fb_Ts_Calibrate _ecore_fb_ts_cal = {1,1,0,0,0};
 static Ecore_Fd_Handler *_ecore_fb_ts_fd_handler_handle = NULL;
 
 #ifdef HAVE_TSLIB
@@ -23,7 +19,7 @@
 struct ts_sample _ecore_fb_tslib_event;
 #endif
 
-
+static double _ecore_fb_double_click_time = 0.25;
 
 struct _Ecore_Fb_Ts_Event
 {
@@ -33,45 +29,10 @@
    unsigned short _unused; 
 };
 
-struct _Ecore_Fb_Ts_Calibrate
-{
-   int xscale;
-   int xtrans;
-   int yscale;
-   int ytrans;
-   int xyswap;
-};
-
-struct _Ecore_Fb_Ts_Backlight
-{
-   int           on;
-   unsigned char brightness;
-};
-
-struct _Ecore_Fb_Ts_Contrast
-{
-   unsigned char contrast;
-};
-
-struct _Ecore_Fb_Ts_Led
-{
-   unsigned char on;
-   unsigned char blink_time;
-   unsigned char on_time;
-   unsigned char off_time;
-};
-
-struct _Ecore_Fb_Ts_Flite
-{
-   unsigned char mode;
-   unsigned char pwr;
-   unsigned char brightness;
-};
-
-
-int
+EAPI int
 ecore_fb_ts_init(void)
 {
+   int prev_flags;
 #ifdef HAVE_TSLIB
    char *tslib_tsdevice = NULL;
    if ( ( tslib_tsdevice = getenv("TSLIB_TSDEVICE") ) != NULL )
@@ -119,7 +80,7 @@
    return 0;
 }
 
-void
+EAPI void
 ecore_fb_ts_shutdown(void)
 {
    if (_ecore_fb_ts_fd >= 0) close(_ecore_fb_ts_fd);
@@ -129,243 +90,6 @@
    _ecore_fb_ts_fd_handler_handle = NULL;
 }
 
-/**
- * @defgroup Ecore_FB_Calibrate_Group Framebuffer Calibration Functions
- *
- * Functions that calibrate the screen.
- */
-
-
-/**
- * Calibrates the touschreen using the given parameters.
- * @param   xscale X scaling, where 256 = 1.0
- * @param   xtrans X translation.
- * @param   yscale Y scaling.
- * @param   ytrans Y translation.
- * @param   xyswap Swap X & Y flag.
- * @ingroup Ecore_FB_Calibrate_Group
- */
-EAPI void
-ecore_fb_touch_screen_calibrate_set(int xscale, int xtrans, int yscale, int ytrans, int xyswap)
-{
-   Ecore_Fb_Ts_Calibrate cal;
-   
-   if (_ecore_fb_ts_fd < 0) return;
-   cal.xscale = xscale;
-   cal.xtrans = xtrans;
-   cal.yscale = yscale;
-   cal.ytrans = ytrans;
-   cal.xyswap = xyswap;
-   if (ioctl(_ecore_fb_ts_fd, TS_SET_CAL, (void *)&cal))
-     {
-	_ecore_fb_ts_cal = cal;
-	_ecore_fb_ts_apply_cal = 1;
-     }
-}
-
-/**
- * Retrieves the calibration parameters of the touchscreen.
- * @param   xscale Pointer to an integer in which to store the X scaling.
- *                 Note that 256 = 1.0.
- * @param   xtrans Pointer to an integer in which to store the X translation.
- * @param   yscale Pointer to an integer in which to store the Y scaling.
- * @param   ytrans Pointer to an integer in which to store the Y translation.
- * @param   xyswap Pointer to an integer in which to store the Swap X & Y flag.
- * @ingroup Ecore_FB_Calibrate_Group
- */
-EAPI void
-ecore_fb_touch_screen_calibrate_get(int *xscale, int *xtrans, int *yscale, int *ytrans, int *xyswap)
-{
-   Ecore_Fb_Ts_Calibrate cal;
-   
-   if (_ecore_fb_ts_fd < 0) return;
-   if (!_ecore_fb_ts_apply_cal)
-     {
-	if (ioctl(_ecore_fb_ts_fd, TS_GET_CAL, (void *)&cal))
-	  _ecore_fb_ts_cal = cal;
-     }
-   else
-     cal = _ecore_fb_ts_cal;
-   if (xscale) *xscale = cal.xscale;
-   if (xtrans) *xtrans = cal.xtrans;
-   if (yscale) *yscale = cal.yscale;
-   if (ytrans) *ytrans = cal.ytrans;
-   if (xyswap) *xyswap = cal.xyswap;
-}
-
-/**
- * @defgroup Ecore_FB_Backlight_Group Framebuffer Backlight Functions
- *
- * Functions that deal with the backlight of a framebuffer's screen.
- */
-
-/**
- * Turns on or off the backlight.
- * @param   on @c 1 to turn the backlight on.  @c 0 to turn it off.
- * @ingroup Ecore_FB_Backlight_Group
- */
-EAPI void
-ecore_fb_backlight_set(int on)
-{
-   Ecore_Fb_Ts_Backlight bl;
-   
-   if (_ecore_fb_ts_fd < 0) return;
-   ioctl(_ecore_fb_ts_fd, TS_GET_BACKLIGHT, &bl);
-   bl.on = on;
-   ioctl(_ecore_fb_ts_fd, TS_SET_BACKLIGHT, &bl);
-}
-
-/**
- * Retrieves the backlight state.
- * @return  Whether the backlight is on.
- * @ingroup Ecore_FB_Backlight_Group
- */
-EAPI int
-ecore_fb_backlight_get(void)
-{
-   Ecore_Fb_Ts_Backlight bl;
-   
-   if (_ecore_fb_ts_fd < 0) return 1;
-   ioctl(_ecore_fb_ts_fd, TS_GET_BACKLIGHT, &bl);
-   return bl.on;
-}
-
-/**
- * Sets the backlight brightness.
- * @param   br Brightness between 0.0 to 1.0, where 0.0 is darkest and 1.0
- *             is brightest.
- * @ingroup Ecore_FB_Backlight_Group
- */
-EAPI void 
-ecore_fb_backlight_brightness_set(double br)
-{
-   Ecore_Fb_Ts_Backlight bl;   
-   int val;
-   
-   if (br < 0) br = 0;
-   if (br > 1) br = 1;
-   val = (int)(255.0 * br);
-   ioctl(_ecore_fb_ts_fd, TS_GET_BACKLIGHT, &bl);
-   bl.brightness = val;
-   ioctl(_ecore_fb_ts_fd, TS_SET_BACKLIGHT, &bl);
-}
-
-/**
- * Retrieves the backlight brightness.
- * @return  The current backlight brigntess, where 0.0 is the darkest and
- *          1.0 is the brightest.
- * @ingroup Ecore_FB_Backlight_Group
- */
-EAPI double
-ecore_fb_backlight_brightness_get(void)
-{
-   Ecore_Fb_Ts_Backlight bl;
-   
-   if (_ecore_fb_ts_fd < 0) return 1.0;
-   ioctl(_ecore_fb_ts_fd, TS_GET_BACKLIGHT, &bl);
-   return (double)bl.brightness / 255.0;
-}
-
-/**
- * @defgroup Ecore_FB_LED_Group Framebuffer LED Functions
- *
- * Functions that deal with the light emitting diode connected to the
- * current framebuffer.
- */
-
-/**
- * Sets whether the current framebuffer's LED to the given state.
- * @param   on @c 1 to indicate the LED should be on, @c 0 if it should be off.
- * @ingroup Ecore_FB_LED_Group
- */
-EAPI void
-ecore_fb_led_set(int on)
-{
-   Ecore_Fb_Ts_Led led;
-   
-   if (_ecore_fb_ts_fd < 0) return;
-   if (on) led.on = 1;
-   else led.on = 0;
-   ioctl(_ecore_fb_ts_fd, LED_ON, &led);
-}
-
-/**
- * Makes the LED of the current framebuffer blink.
- * @param   speed Number to give the speed on the blink.
- * @ingroup Ecore_FB_LED_Group
- * @todo    Documentation: Work out what speed the units are in.
- */
-EAPI void
-ecore_fb_led_blink_set(double speed)
-{
-   Ecore_Fb_Ts_Led led;
-   
-   if (_ecore_fb_ts_fd < 0) return;
-   led.on = 1;
-   led.on_time = (unsigned char)(speed * 10);
-   led.off_time = (unsigned char)(speed * 10);
-   led.blink_time = 255;
-   ioctl(_ecore_fb_ts_fd, LED_ON, &led);
-}
-
-/**
- * @defgroup Ecore_FB_Contrast_Group Framebuffer Contrast Functions
- *
- * Values that set and retrieve the contrast of a framebuffer screen.
- */
-
-/**
- * Sets the contrast used by the framebuffer screen.
- * @param   cr Value between 0 and 1 that gives the new contrast of the screen.
- * @ingroup Ecore_FB_Contrast_Group
- */
-EAPI void 
-ecore_fb_contrast_set(double cr)
-{
-   Ecore_Fb_Ts_Contrast ct;
-   int val;
-   
-   if (cr < 0) cr = 0;
-   if (cr > 1) cr = 1;
-   val = (int)(255.0 * cr);
-   ct.contrast = val;
-   ioctl(_ecore_fb_ts_fd, TS_SET_CONTRAST, &ct);
-}
-
-/**
- * Retrieves the contrast currently being used by the framebuffer screen.
- * @return  A value between 0 and 1 that represents the current contrast of the
- *          screen.
- * @ingroup Ecore_FB_Contrast_Group
- */
-EAPI double
-ecore_fb_contrast_get(void)
-{
-   Ecore_Fb_Ts_Contrast ct;
-   
-   if (_ecore_fb_ts_fd < 0) return 1.0;
-   ioctl(_ecore_fb_ts_fd, TS_GET_CONTRAST, &ct);
-   return (double)ct.contrast / 255.0;
-}
-
-/**
- * To be documented.
- *
- * FIXME: To be fixed.
- */
-EAPI double
-ecore_fb_light_sensor_get(void)
-{
-   Ecore_Fb_Ts_Flite fl;
-   
-   if (_ecore_fb_ts_fd < 0) return 0.0;
-   fl.mode = 3;
-   fl.brightness = 0;
-   ioctl(_ecore_fb_ts_fd, FLITE_ON, &fl);   
-   return (double)fl.brightness / 255.0;   
-}
-
-
 static int
 _ecore_fb_ts_fd_handler(void *data __UNUSED__, Ecore_Fd_Handler *fd_handler __UNUSED__)
 {
@@ -383,10 +107,7 @@
 	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 );
-    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 */
@@ -395,6 +116,7 @@
     y = _ecore_fb_tslib_event.y;
     pressure = _ecore_fb_tslib_event.pressure;
     v = 1; /* loop, there might be more samples */
+    t = ecore_time_get();
 #else
 	ptr = (char *)&(_ecore_fb_ts_event);
 	ptr += _ecore_fb_ts_event_byte_count;
@@ -403,18 +125,9 @@
 	if (v < 0) return 1;
 	_ecore_fb_ts_event_byte_count += v;
 	if (v < num) return 1;
-	t = ecore_time_get();
 	_ecore_fb_ts_event_byte_count = 0;
-	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;
-	  }
-	else
-	  {
-	     x = _ecore_fb_ts_event.x;
-	     y = _ecore_fb_ts_event.y;
-	  }
+	 x = _ecore_fb_ts_event.x;
+	 y = _ecore_fb_ts_event.y;
 	pressure = _ecore_fb_ts_event.pressure;
 #endif   
 	/* add event to queue */
@@ -440,7 +153,7 @@
 	     e->x = x;
 	     e->y = y;
 	     e->button = 1;
-             if ((t - last_time) <= _ecore_fb_double_click_time)
+	     if ((t - last_time) <= _ecore_fb_double_click_time)
 	       e->double_click = 1;
 	     if ((t - last_last_time) <= (2 * _ecore_fb_double_click_time))
 	       {
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to