Re: [Linuxwacom-devel] [PATCH 8/9] Send touch events to X when gestures are disabled

2012-10-19 Thread Jason Gerecke
On Thu, Oct 18, 2012 at 7:12 PM, Thomas Jaeger thjae...@gmail.com wrote:
 On 09/29/2012 07:58 PM, Jason Gerecke wrote:
 @@ -419,6 +419,14 @@ static int wcmDevInit(DeviceIntPtr pWcm)
   return FALSE;
   }

 +#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) = 16
 + if (!InitTouchClassDeviceStruct(pInfo-dev, 0, XIDependentTouch, 2)) {
 + xf86Msg(X_ERROR, Unable to init touch class device 
 struct!\n);
 + return FALSE;
 + }
 + priv-common-touch_mask = valuator_mask_new(2);
 +#endif
 +
   if (!IsPad(priv))
   {
   wcmInitialToolSize(pInfo);

 This will register any wacom device as a direct touch device, even pens
 and erasers.

 Tom

Good catch! I'm not sure if it makes a difference to clients or not,
but its definitely not what I had intended. Enclosing it in an
IsTouch(priv) check should do the trick; I'll whip up a patch when I
get back to the office in the morning.

Jason

---
When you're rife with devastation / There's a simple explanation:
You're a toymaker's creation / Trapped inside a crystal ball.
And whichever way he tilts it / Know that we must be resilient
We won't let them break our spirits / As we sing our silly song.

--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
___
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel


Re: [Linuxwacom-devel] [PATCH 8/9] Send touch events to X when gestures are disabled

2012-10-18 Thread Thomas Jaeger
On 09/29/2012 07:58 PM, Jason Gerecke wrote:
 @@ -419,6 +419,14 @@ static int wcmDevInit(DeviceIntPtr pWcm)
   return FALSE;
   }
  
 +#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) = 16
 + if (!InitTouchClassDeviceStruct(pInfo-dev, 0, XIDependentTouch, 2)) {
 + xf86Msg(X_ERROR, Unable to init touch class device struct!\n);
 + return FALSE;
 + }
 + priv-common-touch_mask = valuator_mask_new(2);
 +#endif
 +
   if (!IsPad(priv))
   {
   wcmInitialToolSize(pInfo);

This will register any wacom device as a direct touch device, even pens
and erasers.

Tom

--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
___
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel


Re: [Linuxwacom-devel] [PATCH 8/9] Send touch events to X when gestures are disabled

2012-09-30 Thread Jason Gerecke
On Sat, Sep 29, 2012 at 7:12 PM, Thomas Jaeger thjae...@gmail.com wrote:
 On 09/29/2012 07:58 PM, Jason Gerecke wrote:
 For the moment, all touches are sent as XIDependentTouch. Direct touch
 devices such as tablet PCs and Cintiqs are not an exception. This may
 be changed in the future once frameworks are better equipped to handle
 direct input touches.

 For users that don't use gesture mode, this causes a regression:  their
 tablets behave like relative devices all of a sudden.

 Tom

Could you explain this in a little more detail? My tests with both
indirect and direct touch devices haven't revealed any regression like
this. I admittedly haven't tested the absolute case as thoroughly as
the relative one (due to a lack of software to visualize my touches),
but the experience didn't feel any different after this patch.

Use of XIDependentTouch does admittedly cause all touches to be sent
to the focused window (instead of each touch going to the window
directly underneath it), but I was running into trouble getting
touchscreens to work correctly with XIDirectTouch. I'm not sure if it
was my code or the desktop environment, but I wouldn't expect simply
switching the type I report the touch as to cause my own code to break
:D I suppose I should see how my desktop reacts with touch coming
through evdev instead to be sure though...

Jason

---
When you're rife with devastation / There's a simple explanation:
You're a toymaker's creation / Trapped inside a crystal ball.
And whichever way he tilts it / Know that we must be resilient
We won't let them break our spirits / As we sing our silly song.

--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://ad.doubleclick.net/clk;258768047;13503038;j?
http://info.appdynamics.com/FreeJavaPerformanceDownload.html
___
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel


Re: [Linuxwacom-devel] [PATCH 8/9] Send touch events to X when gestures are disabled

2012-09-30 Thread Thomas Jaeger
On 09/30/2012 07:47 PM, Jason Gerecke wrote:
 Could you explain this in a little more detail? My tests with both
 indirect and direct touch devices haven't revealed any regression like
 this. I admittedly haven't tested the absolute case as thoroughly as
 the relative one (due to a lack of software to visualize my touches),
 but the experience didn't feel any different after this patch.
That's what I get for commenting before actually testing the code.
You're right, there's no reason to assume (like I did) that dependent
touch forces the device to be relative.  I guess I'm just having a
really hard time wrapping my head around this dependent touch thing.  It
doesn't really seem powerful enough to do all the gesture processing
outside the driver.

 Use of XIDependentTouch does admittedly cause all touches to be sent
 to the focused window (instead of each touch going to the window
 directly underneath it), but I was running into trouble getting
 touchscreens to work correctly with XIDirectTouch. I'm not sure if it
 was my code or the desktop environment, but I wouldn't expect simply
 switching the type I report the touch as to cause my own code to break
 :D I suppose I should see how my desktop reacts with touch coming
 through evdev instead to be sure though...

I've noticed some issues too [1] (once I turned off easystroke...), but
given that using the touch screen can make other devices misbehave, I
mostly blame the X server (still, I have no idea why gtk3 applications
do such weird things, the pointer events that they receive seem legit).

Tom

[1] https://bugs.freedesktop.org/show_bug.cgi?id=55477

--
Got visibility?
Most devs has no idea what their production app looks like.
Find out how fast your code is with AppDynamics Lite.
http://ad.doubleclick.net/clk;262219671;13503038;y?
http://info.appdynamics.com/FreeJavaPerformanceDownload.html
___
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel


[Linuxwacom-devel] [PATCH 8/9] Send touch events to X when gestures are disabled

2012-09-29 Thread Jason Gerecke
Adds a new MULTITOUCH gesture mode that will redirect all in-contact
touches through the new multitouch code available in XI2.2 (ABI = 16).

MULTITOUCH mode will only be entered when in-driver gestures have been
disabled and at least two fingers are present. The driver will remain
in this mode until *all* fingers have left the tablet.

For the moment, all touches are sent as XIDependentTouch. Direct touch
devices such as tablet PCs and Cintiqs are not an exception. This may
be changed in the future once frameworks are better equipped to handle
direct input touches.

Signed-off-by: Jason Gerecke killert...@gmail.com
---
 man/wacom.man|  5 +--
 src/wcmTouchFilter.c | 94 
 src/xf86Wacom.c  |  8 +
 src/xf86WacomDefs.h  |  6 ++--
 4 files changed, 109 insertions(+), 4 deletions(-)

diff --git a/man/wacom.man b/man/wacom.man
index 0502860..4438cc5 100644
--- a/man/wacom.man
+++ b/man/wacom.man
@@ -232,8 +232,9 @@ The threshold applies to the normalised pressure range of 
[0..2048].
 The default is 27.
 .TP 4
 .B Option \fIGesture\fP \fIbool\fP
-Enable or disable gesture support on the device. Default: off unless the
-tablet supports multi-touch.
+Enable or disable in-driver gesture support on the device. Default: off unless 
the
+tablet supports multi-touch. Note that disabling this option may allow the 
desktop
+environment to detect gestures instead.
 .TP 4
 .B Option \fIZoomDistance\fP \fInumber\fP
 If
diff --git a/src/wcmTouchFilter.c b/src/wcmTouchFilter.c
index 41a9a74..b859973 100644
--- a/src/wcmTouchFilter.c
+++ b/src/wcmTouchFilter.c
@@ -37,12 +37,14 @@
 #define GESTURE_LAG_MODE  8
 #define GESTURE_PREDRAG_MODE 16
 #define GESTURE_DRAG_MODE32
+#define GESTURE_MULTITOUCH_MODE  64
 
 #define WCM_SCROLL_UP 5/* vertical up */
 #define WCM_SCROLL_DOWN   4/* vertical down */
 #define WCM_SCROLL_LEFT   6/* horizontal left */
 #define WCM_SCROLL_RIGHT  7/* horizontal right */
 
+static void wcmSendButtonClick(WacomDevicePtr priv, int button, int state);
 static void wcmFingerScroll(WacomDevicePtr priv);
 static void wcmFingerZoom(WacomDevicePtr priv);
 
@@ -95,6 +97,87 @@ static void getStateHistory(WacomCommonPtr common, 
WacomDeviceState states[], in
}
 }
 
+/**
+ * Send a touch event for the provided contact ID. This makes use of
+ * the multitouch API available in XI2.2.
+ *
+ * @param[in] priv
+ * @param[in] channelChannel to send a touch event for
+ * @param[in] no_update  If 'true', TouchUpdate events will not be created.
+ * This should be used when entering multitouch mode to ensure TouchBegin
+ * events are sent for already-in-prox contacts.
+ */
+static void
+wcmSendTouchEvent(WacomDevicePtr priv, WacomChannelPtr channel, Bool no_update)
+{
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) = 16
+   ValuatorMask *mask = priv-common-touch_mask;
+   WacomDeviceState state = channel-valid.state;
+   WacomDeviceState oldstate = channel-valid.states[1];
+   int type = -1;
+
+   valuator_mask_set(mask, 0, state.x);
+   valuator_mask_set(mask, 1, state.y);
+
+   if (!state.proximity) {
+   DBG(6, priv-common, This is a touch end event\n);
+   type = XI_TouchEnd;
+   }
+   else if (!oldstate.proximity || no_update) {
+   DBG(6, priv-common, This is a touch begin event\n);
+   type = XI_TouchBegin;
+   }
+   else {
+   DBG(6, priv-common, This is a touch update event\n);
+   type = XI_TouchUpdate;
+   }
+
+   xf86PostTouchEvent(priv-pInfo-dev, state.serial_num - 1, type, 0, 
mask);
+#endif
+}
+
+/**
+ * Send multitouch events. If entering multitouch mode (indicated by
+ * GESTURE_LAG_MODE), then touch events are sent for all in-prox
+ * contacts. Otherwise, only the specified contact has a touch event
+ * generated.
+ *
+ * @param[in] priv
+ * @param[in] contact_id  ID of the contact to send event for (at minimum)
+ */
+static void
+wcmFingerMultitouch(WacomDevicePtr priv, int contact_id) {
+   Bool lag_mode = priv-common-wcmGestureMode == GESTURE_LAG_MODE;
+   Bool prox = FALSE;
+   int i;
+
+   if (lag_mode  TabletHasFeature(priv-common, WCM_LCD)) {
+   /* wcmSingleFingerPress triggers a button press as
+* soon as a single finger appears. ensure we release
+* that button before getting too far along
+*/
+   wcmSendButtonClick(priv, 1, 0);
+   }
+
+   for (i = 0; i  MAX_CHANNELS; i++) {
+   WacomChannelPtr channel = priv-common-wcmChannel+i;
+   WacomDeviceState state  = channel-valid.state;
+   if (state.device_type != TOUCH_ID)
+   continue;
+
+   if (lag_mode || state.serial_num == contact_id + 1) {
+   

Re: [Linuxwacom-devel] [PATCH 8/9] Send touch events to X when gestures are disabled

2012-09-29 Thread Thomas Jaeger
On 09/29/2012 07:58 PM, Jason Gerecke wrote:
 Adds a new MULTITOUCH gesture mode that will redirect all in-contact
 touches through the new multitouch code available in XI2.2 (ABI = 16).

 MULTITOUCH mode will only be entered when in-driver gestures have been
 disabled and at least two fingers are present. The driver will remain
 in this mode until *all* fingers have left the tablet.
I've only taken a quick look at the code, so forgive me if this is
incorrect, but it looks to me that a first touch is always sent as a
click.  This is just asking for trouble.  Why not have the server
emulate the click if there are no touch-aware clients?


 For the moment, all touches are sent as XIDependentTouch. Direct touch
 devices such as tablet PCs and Cintiqs are not an exception. This may
 be changed in the future once frameworks are better equipped to handle
 direct input touches.
I'm curious, what problems do frameworks currently have handing direct
touch?

Tom

--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://ad.doubleclick.net/clk;258768047;13503038;j?
http://info.appdynamics.com/FreeJavaPerformanceDownload.html
___
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel


Re: [Linuxwacom-devel] [PATCH 8/9] Send touch events to X when gestures are disabled

2012-09-29 Thread Thomas Jaeger
On 09/29/2012 09:37 PM, Thomas Jaeger wrote:
 On 09/29/2012 07:58 PM, Jason Gerecke wrote:
 Adds a new MULTITOUCH gesture mode that will redirect all in-contact
 touches through the new multitouch code available in XI2.2 (ABI = 16).

 MULTITOUCH mode will only be entered when in-driver gestures have been
 disabled and at least two fingers are present. The driver will remain
 in this mode until *all* fingers have left the tablet.
 I've only taken a quick look at the code, so forgive me if this is
 incorrect, but it looks to me that a first touch is always sent as a
 click.  This is just asking for trouble.  Why not have the server
 emulate the click if there are no touch-aware clients?
Sorry, I misunderstood how dependent touch devices work.  You're right,
you're supposed to send your own pointer events in this case.

Tom

--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://ad.doubleclick.net/clk;258768047;13503038;j?
http://info.appdynamics.com/FreeJavaPerformanceDownload.html
___
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel


Re: [Linuxwacom-devel] [PATCH 8/9] Send touch events to X when gestures are disabled

2012-09-29 Thread Thomas Jaeger
On 09/29/2012 07:58 PM, Jason Gerecke wrote:
 For the moment, all touches are sent as XIDependentTouch. Direct touch
 devices such as tablet PCs and Cintiqs are not an exception. This may
 be changed in the future once frameworks are better equipped to handle
 direct input touches.

For users that don't use gesture mode, this causes a regression:  their
tablets behave like relative devices all of a sudden.

Tom

--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://ad.doubleclick.net/clk;258768047;13503038;j?
http://info.appdynamics.com/FreeJavaPerformanceDownload.html
___
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel