summaryrefslogtreecommitdiff
path: root/src/lib/ecore_input
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
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')
-rw-r--r--src/lib/ecore_input/Ecore_Input.h39
-rw-r--r--src/lib/ecore_input/ecore_input.c3
2 files changed, 42 insertions, 0 deletions
diff --git a/src/lib/ecore_input/Ecore_Input.h b/src/lib/ecore_input/Ecore_Input.h
index e6e1259c08..b9723c8835 100644
--- a/src/lib/ecore_input/Ecore_Input.h
+++ b/src/lib/ecore_input/Ecore_Input.h
@@ -53,6 +53,7 @@ extern "C" {
53 EAPI extern int ECORE_EVENT_MOUSE_WHEEL; 53 EAPI extern int ECORE_EVENT_MOUSE_WHEEL;
54 EAPI extern int ECORE_EVENT_MOUSE_IN; 54 EAPI extern int ECORE_EVENT_MOUSE_IN;
55 EAPI extern int ECORE_EVENT_MOUSE_OUT; 55 EAPI extern int ECORE_EVENT_MOUSE_OUT;
56 EAPI extern int ECORE_EVENT_AXIS_UPDATE; /**< @since 1.13 */
56 57
57#define ECORE_EVENT_MODIFIER_SHIFT 0x0001 58#define ECORE_EVENT_MODIFIER_SHIFT 0x0001
58#define ECORE_EVENT_MODIFIER_CTRL 0x0002 59#define ECORE_EVENT_MODIFIER_CTRL 0x0002
@@ -78,6 +79,8 @@ extern "C" {
78 typedef struct _Ecore_Event_Mouse_Move Ecore_Event_Mouse_Move; 79 typedef struct _Ecore_Event_Mouse_Move Ecore_Event_Mouse_Move;
79 typedef struct _Ecore_Event_Mouse_IO Ecore_Event_Mouse_IO; 80 typedef struct _Ecore_Event_Mouse_IO Ecore_Event_Mouse_IO;
80 typedef struct _Ecore_Event_Modifiers Ecore_Event_Modifiers; 81 typedef struct _Ecore_Event_Modifiers Ecore_Event_Modifiers;
82 typedef struct _Ecore_Event_Axis_Update Ecore_Event_Axis_Update; /**< @since 1.13 */
83 typedef struct _Ecore_Axis Ecore_Axis; /**< @since 1.13 */
81 84
82 /** 85 /**
83 * @typedef Ecore_Event_Modifier 86 * @typedef Ecore_Event_Modifier
@@ -246,6 +249,42 @@ extern "C" {
246 } multi; 249 } multi;
247 }; 250 };
248 251
252 typedef enum _Ecore_Axis_Label
253 {
254 ECORE_AXIS_LABEL_UNKNOWN, /**< Axis type is not known. Range: Unbounded. Unit: Undefined. @since 1.13 */
255 ECORE_AXIS_LABEL_X, /**< Position along physical X axis; not window relative. Range: Unbounded. Unit: Undefined. @since 1.13 */
256 ECORE_AXIS_LABEL_Y, /**< Position along physical Y axis; not window relative. Range: Unbounded. Unit: Undefined. @since 1.13 */
257 ECORE_AXIS_LABEL_PRESSURE, /**< Force applied to tool tip. Range: [0.0, 1.0]. Unit: Unitless. @since 1.13 */
258 ECORE_AXIS_LABEL_DISTANCE, /**< Relative distance along physical Z axis. Range: [0.0, 1.0]. Unit: Unitless. @since 1.13 */
259 ECORE_AXIS_LABEL_AZIMUTH, /**< Angle of tool about the Z axis from positive X axis. Range: [-PI, PI]. Unit: Radians. @since 1.13*/
260 ECORE_AXIS_LABEL_TILT, /**< Angle of tool about plane of sensor from positive Z axis. Range: [0.0, PI]. Unit: Radians. @since 1.13 */
261 ECORE_AXIS_LABEL_TWIST, /**< Rotation of tool about its major axis from its "natural" position. Range: [-PI, PI] Unit: Radians. @since 1.13 */
262 ECORE_AXIS_LABEL_TOUCH_WIDTH_MAJOR, /**< Length of contact ellipse along AZIMUTH. Range: Unbounded: Unit: Same as ECORE_AXIS_LABEL_{X,Y}. @since 1.13 */
263 ECORE_AXIS_LABEL_TOUCH_WIDTH_MINOR, /**< Length of contact ellipse perpendicular to AZIMUTH. Range: Unbounded. Unit: Same as ECORE_AXIS_LABEL_{X,Y}. @since 1.13 */
264 ECORE_AXIS_LABEL_TOOL_WIDTH_MAJOR, /**< Length of tool ellipse along AZIMUTH. Range: Unbounded. Unit: Same as ECORE_AXIS_LABEL_{X,Y}. @since 1.13 */
265 ECORE_AXIS_LABEL_TOOL_WIDTH_MINOR /**< Length of tool ellipse perpendicular to AZIMUTH. Range: Unbounded. Unit: Same as ECORE_AXIS_LABEL_{X,Y}. @since 1.13 */
266 } Ecore_Axis_Label; /**< @since 1.13 */
267
268 struct _Ecore_Axis
269 {
270 Ecore_Axis_Label label;
271 double value;
272 };
273
274 struct _Ecore_Event_Axis_Update
275 {
276 Ecore_Window window;
277 Ecore_Window root_window;
278 Ecore_Window event_window;
279
280 unsigned int timestamp;
281 int device;
282 int toolid;
283
284 int naxis;
285 Ecore_Axis *axis;
286 };
287
249 /** 288 /**
250 * @struct _Ecore_Event_Mouse_IO 289 * @struct _Ecore_Event_Mouse_IO
251 * Contains information about an Ecore mouse input/output event. 290 * Contains information about an Ecore mouse input/output event.
diff --git a/src/lib/ecore_input/ecore_input.c b/src/lib/ecore_input/ecore_input.c
index 8f4b1f9bc0..ac8b60db17 100644
--- a/src/lib/ecore_input/ecore_input.c
+++ b/src/lib/ecore_input/ecore_input.c
@@ -22,6 +22,7 @@ EAPI int ECORE_EVENT_MOUSE_MOVE = 0;
22EAPI int ECORE_EVENT_MOUSE_WHEEL = 0; 22EAPI int ECORE_EVENT_MOUSE_WHEEL = 0;
23EAPI int ECORE_EVENT_MOUSE_IN = 0; 23EAPI int ECORE_EVENT_MOUSE_IN = 0;
24EAPI int ECORE_EVENT_MOUSE_OUT = 0; 24EAPI int ECORE_EVENT_MOUSE_OUT = 0;
25EAPI int ECORE_EVENT_AXIS_UPDATE = 0;
25 26
26static int _ecore_event_init_count = 0; 27static int _ecore_event_init_count = 0;
27 28
@@ -52,6 +53,7 @@ ecore_event_init(void)
52 ECORE_EVENT_MOUSE_WHEEL = ecore_event_type_new(); 53 ECORE_EVENT_MOUSE_WHEEL = ecore_event_type_new();
53 ECORE_EVENT_MOUSE_IN = ecore_event_type_new(); 54 ECORE_EVENT_MOUSE_IN = ecore_event_type_new();
54 ECORE_EVENT_MOUSE_OUT = ecore_event_type_new(); 55 ECORE_EVENT_MOUSE_OUT = ecore_event_type_new();
56 ECORE_EVENT_AXIS_UPDATE = ecore_event_type_new();
55 57
56 return _ecore_event_init_count; 58 return _ecore_event_init_count;
57} 59}
@@ -70,6 +72,7 @@ ecore_event_shutdown(void)
70 ECORE_EVENT_MOUSE_WHEEL = 0; 72 ECORE_EVENT_MOUSE_WHEEL = 0;
71 ECORE_EVENT_MOUSE_IN = 0; 73 ECORE_EVENT_MOUSE_IN = 0;
72 ECORE_EVENT_MOUSE_OUT = 0; 74 ECORE_EVENT_MOUSE_OUT = 0;
75 ECORE_EVENT_AXIS_UPDATE = 0;
73 eina_log_domain_unregister(_ecore_input_log_dom); 76 eina_log_domain_unregister(_ecore_input_log_dom);
74 _ecore_input_log_dom = -1; 77 _ecore_input_log_dom = -1;
75 ecore_shutdown(); 78 ecore_shutdown();