From 759f7dafcdbb6443deb85f79b43b4cbbe64b13ec Mon Sep 17 00:00:00 2001 From: Thiep Ha Date: Wed, 30 Mar 2016 15:30:33 +0900 Subject: [PATCH] ecore: add support for rotary event @tizen_feature Change-Id: I6e79e58c49860dcaa33a683f74d19ed105a1fe00 Signed-off-by: Thiep Ha --- src/lib/ecore_input/Ecore_Input.h | 14 ++++++++++++++ src/lib/ecore_input/ecore_input.c | 3 +++ src/lib/ecore_wayland/ecore_wl_input.c | 20 ++++++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/src/lib/ecore_input/Ecore_Input.h b/src/lib/ecore_input/Ecore_Input.h index 6175827..c7482ab 100644 --- a/src/lib/ecore_input/Ecore_Input.h +++ b/src/lib/ecore_input/Ecore_Input.h @@ -57,6 +57,7 @@ extern "C" { EAPI extern int ECORE_EVENT_MOUSE_BUTTON_CANCEL; /**< @since 1.15 */ EAPI extern int ECORE_EVENT_DEVICE_ADD; EAPI extern int ECORE_EVENT_DEVICE_DEL; + EAPI extern int ECORE_EVENT_DETENT_ROTATE; //TIZEN ONLY #define ECORE_EVENT_MODIFIER_SHIFT 0x0001 #define ECORE_EVENT_MODIFIER_CTRL 0x0002 @@ -85,6 +86,7 @@ extern "C" { typedef struct _Ecore_Event_Axis_Update Ecore_Event_Axis_Update; /**< @since 1.13 */ typedef struct _Ecore_Axis Ecore_Axis; /**< @since 1.13 */ typedef struct _Ecore_Event_Device_Info Ecore_Event_Device_Info; + typedef struct _Ecore_Event_Detent_Rotate Ecore_Event_Detent_Rotate; //TIZEN ONLY /** * @typedef Ecore_Event_Modifier @@ -309,6 +311,18 @@ extern "C" { const char *seatname; unsigned int caps; }; + // TIZEN ONLY + typedef enum _Ecore_Detent_Direction + { + ECORE_DETENT_DIRECTION_CLOCKWISE, + ECORE_DETENT_DIRECTION_COUNTER_CLOCKWISE + } Ecore_Detent_Direction; + struct _Ecore_Event_Detent_Rotate + { + Ecore_Detent_Direction direction; + unsigned int timestamp; + }; + // TIZEN ONLY - END /** * @struct _Ecore_Event_Mouse_IO diff --git a/src/lib/ecore_input/ecore_input.c b/src/lib/ecore_input/ecore_input.c index 4a16611..e08267f 100644 --- a/src/lib/ecore_input/ecore_input.c +++ b/src/lib/ecore_input/ecore_input.c @@ -26,6 +26,7 @@ EAPI int ECORE_EVENT_AXIS_UPDATE = 0; EAPI int ECORE_EVENT_MOUSE_BUTTON_CANCEL = 0; EAPI int ECORE_EVENT_DEVICE_ADD = 0; EAPI int ECORE_EVENT_DEVICE_DEL = 0; +EAPI int ECORE_EVENT_DETENT_ROTATE = 0; //TIZEN ONLY static int _ecore_event_init_count = 0; @@ -60,6 +61,7 @@ ecore_event_init(void) ECORE_EVENT_MOUSE_BUTTON_CANCEL = ecore_event_type_new(); ECORE_EVENT_DEVICE_ADD = ecore_event_type_new(); ECORE_EVENT_DEVICE_DEL = ecore_event_type_new(); + ECORE_EVENT_DETENT_ROTATE = ecore_event_type_new(); //TIZEN ONLY return _ecore_event_init_count; } @@ -82,6 +84,7 @@ ecore_event_shutdown(void) ECORE_EVENT_MOUSE_BUTTON_CANCEL = 0; ECORE_EVENT_DEVICE_ADD = 0; ECORE_EVENT_DEVICE_DEL = 0; + ECORE_EVENT_DETENT_ROTATE = 0; //TIZEN ONLY eina_log_domain_unregister(_ecore_input_log_dom); _ecore_input_log_dom = -1; ecore_shutdown(); diff --git a/src/lib/ecore_wayland/ecore_wl_input.c b/src/lib/ecore_wayland/ecore_wl_input.c index c88cc22..aa774ac 100644 --- a/src/lib/ecore_wayland/ecore_wl_input.c +++ b/src/lib/ecore_wayland/ecore_wl_input.c @@ -2017,10 +2017,18 @@ _ecore_wl_input_device_cb_event_device(void *data, struct tizen_input_device *ti } static void +_ecore_wl_input_detent_rotate_free(void *data EINA_UNUSED, void *ev) +{ + Ecore_Event_Detent_Rotate *e = ev; + free(e); +} + +static void _ecore_wl_input_device_cb_axis(void *data EINA_UNUSED, struct tizen_input_device *tizen_input_device EINA_UNUSED, uint32_t axis_type, wl_fixed_t value) { Ecore_Wl_Input *input = _ecore_wl_disp->input; double dvalue = wl_fixed_to_double(value); + Ecore_Event_Detent_Rotate *e; switch (axis_type) { @@ -2041,6 +2049,18 @@ _ecore_wl_input_device_cb_axis(void *data EINA_UNUSED, struct tizen_input_device * value 1 is clockwise, * value -1 is counterclockwise, */ + if (!(e = calloc(1, sizeof(Ecore_Event_Detent_Rotate)))) + { + ERR("detent: cannot allocate memory"); + return; + } + if (dvalue == 1) + e->direction = ECORE_DETENT_DIRECTION_CLOCKWISE; + else + e->direction = ECORE_DETENT_DIRECTION_COUNTER_CLOCKWISE; + e->timestamp = (unsigned int)ecore_time_get(); + DBG("detent: dir: %d, time: %d", e->direction, e->timestamp); + ecore_event_add(ECORE_EVENT_DETENT_ROTATE, e, _ecore_wl_input_detent_rotate_free, NULL); break; default: WRN("Invalid type(%d) is ignored.\n", axis_type); -- 2.7.4