From 60526528a6cc85050a74d5d45f6502ea5c07d70f Mon Sep 17 00:00:00 2001 From: Jean-Philippe Andre Date: Thu, 25 Aug 2016 17:54:04 +0900 Subject: evas: Add normalized and window coordinates to axis events This is for Wacom graphics tablets (with a pen). The raw data sent by ecore to evas (and then to apps) is pretty useless as it's not normalized, and apps have no way of knowing the dimensions of the tablet, without themselves opening the device (we don't know nor expose the path to the device). This is for Xi2 only for now, as Wayland support hasn't been done yet. The intent is to deprecate LABEL_X and LABEL_Y. I'm not sure yet if the normalized value is useful or not (it would seem we may not be able to provide this info in Wayland). The new WINDOW_X, WINDOW_Y labels will be used in the new event type (Efl.Event.Pointer). Normalized values are not exposed yet, let's decide if we want them or not first (based on what can be done in Wayland space). @feature --- src/lib/ecore_x/xlib/ecore_x_xi2.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'src/lib/ecore_x') diff --git a/src/lib/ecore_x/xlib/ecore_x_xi2.c b/src/lib/ecore_x/xlib/ecore_x_xi2.c index be19de2c94..089c2a7029 100644 --- a/src/lib/ecore_x/xlib/ecore_x_xi2.c +++ b/src/lib/ecore_x/xlib/ecore_x_xi2.c @@ -494,7 +494,7 @@ _ecore_x_input_axis_handler(XEvent *xevent, XIDeviceInfo *dev) { if (xevent->type != GenericEvent) return; XIDeviceEvent *evd = (XIDeviceEvent *)(xevent->xcookie.data); - unsigned int n = _ecore_x_count_bits(*evd->valuators.mask); + unsigned int n = _ecore_x_count_bits(*evd->valuators.mask) + 4; int i; int j = 0; double tiltx = 0, tilty = 0; @@ -514,15 +514,29 @@ _ecore_x_input_axis_handler(XEvent *xevent, XIDeviceInfo *dev) { if (inf->label == _ecore_x_input_get_axis_label("Abs X")) { + int x = evd->valuators.values[j]; axis_ptr->label = ECORE_AXIS_LABEL_X; - axis_ptr->value = evd->valuators.values[j]; + axis_ptr->value = x; axis_ptr++; + if (inf->max > inf->min) + { + axis_ptr->label = ECORE_AXIS_LABEL_NORMAL_X; + axis_ptr->value = (x - inf->min) / (inf->max - inf->min); + axis_ptr++; + } } else if (inf->label == _ecore_x_input_get_axis_label("Abs Y")) { + int y = evd->valuators.values[j]; axis_ptr->label = ECORE_AXIS_LABEL_Y; - axis_ptr->value = evd->valuators.values[j]; + axis_ptr->value = y; axis_ptr++; + if (inf->max > inf->min) + { + axis_ptr->label = ECORE_AXIS_LABEL_NORMAL_Y; + axis_ptr->value = (y - inf->min) / (inf->max - inf->min); + axis_ptr++; + } } else if (inf->label == _ecore_x_input_get_axis_label("Abs Pressure")) { @@ -602,6 +616,15 @@ _ecore_x_input_axis_handler(XEvent *xevent, XIDeviceInfo *dev) n = (axis_ptr - axis); if (n > 0) { + /* event position in the window - most useful */ + axis_ptr->label = ECORE_AXIS_LABEL_WINDOW_X; + axis_ptr->value = evd->event_x; + axis_ptr++; + axis_ptr->label = ECORE_AXIS_LABEL_WINDOW_Y; + axis_ptr->value = evd->event_y; + axis_ptr++; + n += 2; + shrunk_axis = realloc(axis, n * sizeof(Ecore_Axis)); if (shrunk_axis != NULL) axis = shrunk_axis; _ecore_x_axis_update(evd->child ? evd->child : evd->event, -- cgit v1.2.1