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 043bf4a5d6..22c1a7cd44 100644 --- a/legacy/ecore/src/lib/ecore_evas/ecore_evas_fb.c +++ b/legacy/ecore/src/lib/ecore_evas/ecore_evas_fb.c @@ -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 @@ _ecore_evas_fb_init(int w, int h) } } } + 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_evas_fb_shutdown(void) 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 --git a/legacy/ecore/src/lib/ecore_fb/Ecore_Fb.h b/legacy/ecore/src/lib/ecore_fb/Ecore_Fb.h index 3eae77b774..537481758f 100644 --- a/legacy/ecore/src/lib/ecore_fb/Ecore_Fb.h +++ b/legacy/ecore/src/lib/ecore_fb/Ecore_Fb.h @@ -43,16 +43,15 @@ extern "C" { #endif - typedef struct _Ecore_Fb_Input_Device Ecore_Fb_Input_Device; /* an input device handler */ /* device capabilities */ enum _Ecore_Fb_Input_Device_Cap { - ECORE_FB_INPUT_DEVICE_CAP_NONE = 0x00000000, - ECORE_FB_INPUT_DEVICE_CAP_RELATIVE = 0x00000001, - ECORE_FB_INPUT_DEVICE_CAP_ABSOLUTE = 0x00000002, - ECORE_FB_INPUT_DEVICE_CAP_KEYS_OR_BUTTONS = 0x00000004 + ECORE_FB_INPUT_DEVICE_CAP_NONE = 0x00000000, + ECORE_FB_INPUT_DEVICE_CAP_RELATIVE = 0x00000001, + ECORE_FB_INPUT_DEVICE_CAP_ABSOLUTE = 0x00000002, + ECORE_FB_INPUT_DEVICE_CAP_KEYS_OR_BUTTONS = 0x00000004 }; typedef enum _Ecore_Fb_Input_Device_Cap Ecore_Fb_Input_Device_Cap; @@ -72,52 +71,53 @@ typedef struct _Ecore_Fb_Event_Mouse_Wheel Ecore_Fb_Event_Mouse_Wheel; /** struct _Ecore_Fb_Event_Key_Down /** FB Key Down event */ { - Ecore_Fb_Input_Device *dev; /**< The device associated with the event */ - char *keyname; /**< The name of the key that was pressed */ - char *keysymbol; /**< The logical symbol of the key that was pressed */ - char *key_compose; /**< The UTF-8 string conversion if any */ + Ecore_Fb_Input_Device *dev; /**< The device associated with the event */ + char *keyname; /**< The name of the key that was pressed */ + char *keysymbol; /**< The logical symbol of the key that was pressed */ + char *key_compose; /**< The UTF-8 string conversion if any */ }; struct _Ecore_Fb_Event_Key_Up /** FB Key Up event */ { - Ecore_Fb_Input_Device *dev; /**< The device associated with the event */ - char *keyname; /**< The name of the key that was released */ - char *keysymbol; /**< The logical symbol of the key that was pressed */ - char *key_compose; /**< The UTF-8 string conversion if any */ + Ecore_Fb_Input_Device *dev; /**< The device associated with the event */ + char *keyname; /**< The name of the key that was released */ + char *keysymbol; /**< The logical symbol of the key that was pressed */ + char *key_compose; /**< The UTF-8 string conversion if any */ }; struct _Ecore_Fb_Event_Mouse_Button_Down /** FB Mouse Down event */ { - Ecore_Fb_Input_Device *dev; /**< The device associated with the event */ - int button; /**< Mouse button that was pressed (1 - 32) */ - int x; /**< Mouse co-ordinates when mouse button was pressed */ - int y; /**< Mouse co-ordinates when mouse button was pressed */ - int double_click : 1; /**< Set if click was a double click */ - int triple_click : 1; /**< Set if click was a triple click */ + Ecore_Fb_Input_Device *dev; /**< The device associated with the event */ + int button; /**< Mouse button that was pressed (1 - 32) */ + int x; /**< Mouse co-ordinates when mouse button was pressed */ + int y; /**< Mouse co-ordinates when mouse button was pressed */ + int double_click : 1; /**< Set if click was a double click */ + int triple_click : 1; /**< Set if click was a triple click */ }; struct _Ecore_Fb_Event_Mouse_Button_Up /** FB Mouse Up event */ { - Ecore_Fb_Input_Device *dev; /**< The device associated with the event */ - int button; /**< Mouse button that was released (1 - 32) */ - int x; /**< Mouse co-ordinates when mouse button was raised */ - int y; /**< Mouse co-ordinates when mouse button was raised */ + Ecore_Fb_Input_Device *dev; /**< The device associated with the event */ + int button; /**< Mouse button that was released (1 - 32) */ + int x; /**< Mouse co-ordinates when mouse button was raised */ + int y; /**< Mouse co-ordinates when mouse button was raised */ }; struct _Ecore_Fb_Event_Mouse_Move /** FB Mouse Move event */ { - Ecore_Fb_Input_Device *dev; /**< The device associated with the event */ - int x; /**< Mouse co-ordinates where the mouse cursor moved to */ - int y; /**< Mouse co-ordinates where the mouse cursor moved to */ + Ecore_Fb_Input_Device *dev; /**< The device associated with the event */ + int x; /**< Mouse co-ordinates where the mouse cursor moved to */ + int y; /**< Mouse co-ordinates where the mouse cursor moved to */ }; - + struct _Ecore_Fb_Event_Mouse_Wheel /** FB Mouse Wheel event */ { - Ecore_Fb_Input_Device *dev; - int x,y; - int direction; /* 0 = vertical, 1 = horizontal */ - int wheel; /* value 1 (left/up), -1 (right/down) */ + Ecore_Fb_Input_Device *dev; + int x,y; + int direction; /* 0 = vertical, 1 = horizontal */ + int wheel; /* value 1 (left/up), -1 (right/down) */ }; + /* ecore_fb_vt.c */ EAPI void ecore_fb_callback_gain_set(void (*func) (void *data), void *data); EAPI void ecore_fb_callback_lose_set(void (*func) (void *data), void *data); @@ -134,27 +134,10 @@ EAPI double ecore_fb_input_threshold_click_get(Ecore_F 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 --git a/legacy/ecore/src/lib/ecore_fb/Makefile.am b/legacy/ecore/src/lib/ecore_fb/Makefile.am index 82238e156b..5cc71bb800 100644 --- a/legacy/ecore/src/lib/ecore_fb/Makefile.am +++ b/legacy/ecore/src/lib/ecore_fb/Makefile.am @@ -14,9 +14,9 @@ libecore_fb_la_SOURCES = \ 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 --git a/legacy/ecore/src/lib/ecore_fb/ecore_fb_private.h b/legacy/ecore/src/lib/ecore_fb/ecore_fb_private.h index f687ea4d4c..2d098095e0 100644 --- a/legacy/ecore/src/lib/ecore_fb/ecore_fb_private.h +++ b/legacy/ecore/src/lib/ecore_fb/ecore_fb_private.h @@ -63,11 +63,14 @@ struct _Ecore_Fb_Input_Device } 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 */ #ifndef TS_SET_CAL #define TS_SET_CAL 0x4014660b @@ -75,24 +78,5 @@ void ecore_fb_vt_shutdown(void); #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 --git a/legacy/ecore/src/lib/ecore_fb/ecore_fb_ts.c b/legacy/ecore/src/lib/ecore_fb/ecore_fb_ts.c index 469300fc6f..f8bb57b512 100644 --- a/legacy/ecore/src/lib/ecore_fb/ecore_fb_ts.c +++ b/legacy/ecore/src/lib/ecore_fb/ecore_fb_ts.c @@ -1,3 +1,6 @@ +#include "Ecore_Fb.h" +#include "ecore_fb_private.h" +#include "config.h" #ifdef HAVE_TSLIB #include #include @@ -15,7 +18,6 @@ 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 +25,7 @@ struct tsdev *_ecore_fb_tslib_tsdev = NULL; struct ts_sample _ecore_fb_tslib_event; #endif - +static double _ecore_fb_double_click_time = 0.25; struct _Ecore_Fb_Ts_Event { @@ -68,10 +70,10 @@ struct _Ecore_Fb_Ts_Flite 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 +121,7 @@ ecore_fb_ts_init(void) return 0; } -void +EAPI void ecore_fb_ts_shutdown(void) { if (_ecore_fb_ts_fd >= 0) close(_ecore_fb_ts_fd); @@ -134,8 +136,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 @@ -160,6 +162,7 @@ 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; + } } @@ -183,6 +186,7 @@ ecore_fb_touch_screen_calibrate_get(int *xscale, int *xtrans, int *yscale, int * { if (ioctl(_ecore_fb_ts_fd, TS_GET_CAL, (void *)&cal)) _ecore_fb_ts_cal = cal; + } else cal = _ecore_fb_ts_cal; @@ -193,179 +197,6 @@ ecore_fb_touch_screen_calibrate_get(int *xscale, int *xtrans, int *yscale, int * 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,18 +214,16 @@ _ecore_fb_ts_fd_handler(void *data __UNUSED__, Ecore_Fd_Handler *fd_handler __UN 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 ); - if ( num != 1 ) - { - return 1; /* no more samples at this time */ - } - x = _ecore_fb_tslib_event.x; - y = _ecore_fb_tslib_event.y; - pressure = _ecore_fb_tslib_event.pressure; - v = 1; /* loop, there might be more samples */ + 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); + if (num != 1) return 1; /* no more samples at this time */ + x = _ecore_fb_tslib_event.x; + 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,9 +232,8 @@ _ecore_fb_ts_fd_handler(void *data __UNUSED__, Ecore_Fd_Handler *fd_handler __UN 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) + 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; @@ -440,7 +268,7 @@ _ecore_fb_ts_fd_handler(void *data __UNUSED__, Ecore_Fd_Handler *fd_handler __UN 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)) {