summaryrefslogtreecommitdiff
path: root/src/lib/ecore_input_evas
diff options
context:
space:
mode:
authorJason Gerecke <killertofu@gmail.com>2014-11-25 12:07:50 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2014-11-25 12:43:15 +0900
commit26c943bac0d4b62bce63a6b575c58d15e5e6113f (patch)
tree79fef2ccc792a21408577ae579e287f3442acada /src/lib/ecore_input_evas
parent86aef83eb2aa89a76135e0cbab6999684f51839a (diff)
Expose device (e.g. pen) axis information to applications
Summary: This patch set adds the necessary code to expose device axis state to applications. This was primarily written with graphics tablets in mind, which -- in addition to acting like a mouse -- also provide information about pen pressure, tilt, etc. Other devices could potentially benefit from this API as well: touchscreens, joysticks, knob controllers, "spaceballs", etc. Whenever an update to the device state is recieved, an "Axis update" event is synthesized. This event contains the updated information, typically scaled and normalized to a particular logical range (e.g. zero to one for pressure, -pi to pi radians for angles, etc.). Information about the tool which generated the event is also stored so that applications can disambiguate events from multiple devices (or in the case of multitouch screens, individual fingers). This API is only wired up for use with X11 at the moment. Support for other backends (e.g. Wayland) should be easy to add for those familiar them. **Note**: The following is a list of changes from the "v2" patches originally sent to the mailinglist //Define and implement new Ecore_Event_Axis_Update events// * Harcode axis labels instead of including xserver-properties.h * Use C89-style comments * Use doxygen comments * Update comment text to note axes with unbounded/undefined ranges/units * Create "Ecore_Axis" and "Ecore_Axis_Label" typedefs * Reference typedef'd instead of raw types * Adjust how we count through valuators to support tilt/az * Add support for tilt and azimuth * Tweak memory management in case number of valuators differ * Expand TWIST axis normalization to declared range * Only normalize TWIST axis if resolution == 1 (wacom bug) * Cache label atoms on first use to minimize round-trips //Implement EVAS_CALLBACK_AXIS_UPDATE event and friends// * Update to doxygen comments * Update comment text to note axes with unbounded/undefined ranges/units * Typedef 'Evas_Axis_Label', 'Evas_Axis' * Move typedef for 'Evas_Event_Axis_Update' * Reference typedef'd instead of raw types //Wire the Ecore and Evas implementations of axis update events together// * Expose ecore_event_evas_axis_update in Ecore_Input_Evas.h * Move ecore_event_evas_axis_update to more logical position //DEBUG: Add axis update logging to evas-multi-touch.c// * Removed from patch set //Make evas-multi-touch demo use new axis functionality// * Have pressure adjust rectangle brightness instead of size * Use more available axis data when rendering rectangle (azimuth, tilt, twist) Test Plan: The evas-multi-touch demo was updated to support axis update events. A graphics tablet was then used to verify that the pressure, azimuth, tilt, and twist data was coming through correctly. Reviewers: cedric, raster Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D1514 Conflicts: src/lib/ecore_input/Ecore_Input.h Carsten Haitzler - ** fixed forward enum typedefs (make things unhappy) ** fixed conflict above ** fixed wrong param type for _evas_canvas_event_feed_axis_update() ** fixed @sinces to be 1.13 ** fixed formatting/indeting ** fixed order of operation reliance in if's with ()'s to be clear ** fixed functions to be static that should have been
Diffstat (limited to 'src/lib/ecore_input_evas')
-rw-r--r--src/lib/ecore_input_evas/Ecore_Input_Evas.h1
-rw-r--r--src/lib/ecore_input_evas/ecore_input_evas.c18
2 files changed, 18 insertions, 1 deletions
diff --git a/src/lib/ecore_input_evas/Ecore_Input_Evas.h b/src/lib/ecore_input_evas/Ecore_Input_Evas.h
index c97274eb0b..82f81c830d 100644
--- a/src/lib/ecore_input_evas/Ecore_Input_Evas.h
+++ b/src/lib/ecore_input_evas/Ecore_Input_Evas.h
@@ -49,6 +49,7 @@ EAPI Eina_Bool ecore_event_evas_mouse_wheel(void *data, int type, void *event);
49EAPI Eina_Bool ecore_event_evas_mouse_move(void *data, int type, void *event); 49EAPI Eina_Bool ecore_event_evas_mouse_move(void *data, int type, void *event);
50EAPI Eina_Bool ecore_event_evas_mouse_in(void *data, int type, void *event); 50EAPI Eina_Bool ecore_event_evas_mouse_in(void *data, int type, void *event);
51EAPI Eina_Bool ecore_event_evas_mouse_out(void *data, int type, void *event); 51EAPI Eina_Bool ecore_event_evas_mouse_out(void *data, int type, void *event);
52EAPI Eina_Bool ecore_event_evas_axis_update(void *data, int type, void *event);
52 53
53EAPI void ecore_event_window_register(Ecore_Window id, void *window, Evas *evas, Ecore_Event_Mouse_Move_Cb move_mouse, Ecore_Event_Multi_Move_Cb move_multi, Ecore_Event_Multi_Down_Cb down_multi, Ecore_Event_Multi_Up_Cb up_multi); 54EAPI void ecore_event_window_register(Ecore_Window id, void *window, Evas *evas, Ecore_Event_Mouse_Move_Cb move_mouse, Ecore_Event_Multi_Move_Cb move_multi, Ecore_Event_Multi_Down_Cb down_multi, Ecore_Event_Multi_Up_Cb up_multi);
54EAPI void ecore_event_window_unregister(Ecore_Window id); 55EAPI void ecore_event_window_unregister(Ecore_Window id);
diff --git a/src/lib/ecore_input_evas/ecore_input_evas.c b/src/lib/ecore_input_evas/ecore_input_evas.c
index 52058624fa..e9e7fb9040 100644
--- a/src/lib/ecore_input_evas/ecore_input_evas.c
+++ b/src/lib/ecore_input_evas/ecore_input_evas.c
@@ -46,7 +46,7 @@ struct _Ecore_Input_Last
46}; 46};
47 47
48static int _ecore_event_evas_init_count = 0; 48static int _ecore_event_evas_init_count = 0;
49static Ecore_Event_Handler *ecore_event_evas_handlers[8]; 49static Ecore_Event_Handler *ecore_event_evas_handlers[9];
50static Eina_Hash *_window_hash = NULL; 50static Eina_Hash *_window_hash = NULL;
51 51
52static Eina_List *_last_events = NULL; 52static Eina_List *_last_events = NULL;
@@ -541,6 +541,19 @@ ecore_event_evas_mouse_out(void *data EINA_UNUSED, int type EINA_UNUSED, void *e
541 return _ecore_event_evas_mouse_io((Ecore_Event_Mouse_IO *)event, ECORE_OUT); 541 return _ecore_event_evas_mouse_io((Ecore_Event_Mouse_IO *)event, ECORE_OUT);
542} 542}
543 543
544EAPI Eina_Bool
545ecore_event_evas_axis_update(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
546{
547 Ecore_Event_Axis_Update *e;
548 Ecore_Input_Window *lookup;
549
550 e = event;
551 lookup = _ecore_event_window_match(e->event_window);
552 if (!lookup) return ECORE_CALLBACK_PASS_ON;
553 evas_event_feed_axis_update(lookup->evas, e->timestamp, e->device, e->toolid, e->naxis, e->axis, NULL);
554 return ECORE_CALLBACK_PASS_ON;
555}
556
544EAPI int 557EAPI int
545ecore_event_evas_init(void) 558ecore_event_evas_init(void)
546{ 559{
@@ -589,6 +602,9 @@ ecore_event_evas_init(void)
589 ecore_event_evas_handlers[7] = ecore_event_handler_add(ECORE_EVENT_MOUSE_OUT, 602 ecore_event_evas_handlers[7] = ecore_event_handler_add(ECORE_EVENT_MOUSE_OUT,
590 ecore_event_evas_mouse_out, 603 ecore_event_evas_mouse_out,
591 NULL); 604 NULL);
605 ecore_event_evas_handlers[8] = ecore_event_handler_add(ECORE_EVENT_AXIS_UPDATE,
606 ecore_event_evas_axis_update,
607 NULL);
592 608
593 _window_hash = eina_hash_pointer_new(free); 609 _window_hash = eina_hash_pointer_new(free);
594 610