diff options
author | Chris Bagwell <chris@cnpbagwell.com> | 2011-11-22 20:12:21 -0600 |
---|---|---|
committer | Chris Bagwell <chris@cnpbagwell.com> | 2011-11-26 18:37:27 -0600 |
commit | b0aab508269acb3a8bf9e6699a4a283f374e8488 (patch) | |
tree | e8350ceb502f889ae30fef4dc553fb59f03a36d4 | |
parent | f9fe7c7b74418378a5fc09a03c2da381a87b4561 (diff) |
default gesture distance values based on hw maximums
2 finger Gestures will start working on a wider range of
hardware with different resolutions now.
Signed-off-by: Chris Bagwell <chris@cnpbagwell.com>
Reviewed-by: Jason Gerecke <killertofu@gmail.com>
-rw-r--r-- | src/wcmCommon.c | 4 | ||||
-rw-r--r-- | src/wcmTouchFilter.c | 22 | ||||
-rw-r--r-- | src/wcmValidateDevice.c | 20 | ||||
-rw-r--r-- | src/xf86WacomDefs.h | 3 |
4 files changed, 30 insertions, 19 deletions
diff --git a/src/wcmCommon.c b/src/wcmCommon.c index 600991e..f1ef677 100644 --- a/src/wcmCommon.c +++ b/src/wcmCommon.c @@ -1395,11 +1395,7 @@ WacomCommonPtr wcmNewCommon(void) common->wcmFlags = 0; /* various flags */ common->wcmProtocolLevel = WCM_PROTOCOL_4; /* protocol level */ common->wcmTPCButton = 0; /* set Tablet PC button on/off */ - common->wcmGestureParameters.wcmZoomDistance = 50; - common->wcmGestureParameters.wcmZoomDistanceDefault = 50; common->wcmGestureParameters.wcmScrollDirection = 0; - common->wcmGestureParameters.wcmScrollDistance = 20; - common->wcmGestureParameters.wcmScrollDistanceDefault = 20; common->wcmGestureParameters.wcmTapTime = 250; common->wcmGestureParameters.wcmTapTimeDefault = 250; common->wcmRotate = ROTATE_NONE; /* default tablet rotation to off */ diff --git a/src/wcmTouchFilter.c b/src/wcmTouchFilter.c index b788e34..7fa2975 100644 --- a/src/wcmTouchFilter.c +++ b/src/wcmTouchFilter.c @@ -24,7 +24,6 @@ #include <math.h> /* Defines for 2FC Gesture */ -#define WACOM_INLINE_DISTANCE 40 #define WACOM_HORIZ_ALLOWED 1 #define WACOM_VERT_ALLOWED 2 #define WACOM_GESTURE_LAG_TIME 10 @@ -61,17 +60,18 @@ static Bool pointsInLine(WacomCommonPtr common, WacomDeviceState ds0, WACOM_HORIZ_ALLOWED : WACOM_VERT_ALLOWED; int vertical_rotated = (rotated) ? WACOM_VERT_ALLOWED : WACOM_HORIZ_ALLOWED; + int max_spread = common->wcmGestureParameters.wcmMaxScrollFingerSpread; if (!common->wcmGestureParameters.wcmScrollDirection) { - if ((abs(ds0.x - ds1.x) < WACOM_INLINE_DISTANCE) && - (abs(ds0.y - ds1.y) > WACOM_INLINE_DISTANCE)) + if ((abs(ds0.x - ds1.x) < max_spread) && + (abs(ds0.y - ds1.y) > max_spread)) { common->wcmGestureParameters.wcmScrollDirection = horizon_rotated; ret = TRUE; } - if ((abs(ds0.y - ds1.y) < WACOM_INLINE_DISTANCE) && - (abs(ds0.x - ds1.x) > WACOM_INLINE_DISTANCE)) + if ((abs(ds0.y - ds1.y) < max_spread) && + (abs(ds0.x - ds1.x) > max_spread)) { common->wcmGestureParameters.wcmScrollDirection = vertical_rotated; ret = TRUE; @@ -79,12 +79,12 @@ static Bool pointsInLine(WacomCommonPtr common, WacomDeviceState ds0, } else if (common->wcmGestureParameters.wcmScrollDirection == vertical_rotated) { - if (abs(ds0.y - ds1.y) < WACOM_INLINE_DISTANCE) + if (abs(ds0.y - ds1.y) < max_spread) ret = TRUE; } else if (common->wcmGestureParameters.wcmScrollDirection == horizon_rotated) { - if (abs(ds0.x - ds1.x) < WACOM_INLINE_DISTANCE) + if (abs(ds0.x - ds1.x) < max_spread) ret = TRUE; } return ret; @@ -413,6 +413,7 @@ static void wcmFingerScroll(WacomDevicePtr priv) int midPoint_old = 0; int i = 0, dist = 0; WacomFilterState filterd; /* borrow this struct */ + int max_spread = common->wcmGestureParameters.wcmMaxScrollFingerSpread; DBG(10, priv, "\n"); @@ -420,7 +421,7 @@ static void wcmFingerScroll(WacomDevicePtr priv) { if (abs(touchDistance(ds[0], ds[1]) - touchDistance(common->wcmGestureState[0], - common->wcmGestureState[1])) < WACOM_INLINE_DISTANCE) + common->wcmGestureState[1])) < max_spread) { /* two fingers stay close to each other all the time and * move in vertical or horizontal direction together @@ -510,6 +511,7 @@ static void wcmFingerZoom(WacomDevicePtr priv) int count, button; int dist = touchDistance(common->wcmGestureState[0], common->wcmGestureState[1]); + int max_spread = common->wcmGestureParameters.wcmMaxScrollFingerSpread; DBG(10, priv, "\n"); @@ -519,13 +521,13 @@ static void wcmFingerZoom(WacomDevicePtr priv) if (abs(touchDistance(ds[0], ds[1]) - touchDistance(common->wcmGestureState[0], common->wcmGestureState[1])) > - (3 * WACOM_INLINE_DISTANCE)) + (3 * max_spread)) { /* left button might be down, send it up first */ wcmSendButtonClick(priv, 1, 0); /* fingers moved apart more than 3 times - * WACOM_INLINE_DISTANCE, zoom mode is entered */ + * wcmMaxScrollFingerSpread, zoom mode is entered */ common->wcmGestureMode = GESTURE_ZOOM_MODE; } } diff --git a/src/wcmValidateDevice.c b/src/wcmValidateDevice.c index e947fbe..d2cf636 100644 --- a/src/wcmValidateDevice.c +++ b/src/wcmValidateDevice.c @@ -927,6 +927,12 @@ error: return FALSE; } +/* The values were based on trail and error. */ +#define WCM_BAMBOO3_MAXX 4096.0 +#define WCM_BAMBOO3_ZOOM_DISTANCE 180.0 +#define WCM_BAMBOO3_SCROLL_DISTANCE 80.0 +#define WCM_BAMBOO3_SCROLL_SPREAD_DISTANCE 350.0 + /** * Parse post-init options for this device. Useful for overriding HW * specific options computed during init phase (HW distances for example). @@ -950,16 +956,24 @@ Bool wcmPostInitParseOptions(InputInfoPtr pInfo, Bool is_primary, common->wcmMaxZ); /* 2FG touch device */ - if (TabletHasFeature(common, WCM_2FGT)) + if (TabletHasFeature(common, WCM_2FGT) && IsTouch(priv)) { + int zoom_distance = common->wcmMaxTouchX * + (WCM_BAMBOO3_ZOOM_DISTANCE / WCM_BAMBOO3_MAXX); + int scroll_distance = common->wcmMaxTouchX * + (WCM_BAMBOO3_SCROLL_DISTANCE / WCM_BAMBOO3_MAXX); common->wcmGestureParameters.wcmZoomDistance = xf86SetIntOption(pInfo->options, "ZoomDistance", - common->wcmGestureParameters.wcmZoomDistanceDefault); + zoom_distance); common->wcmGestureParameters.wcmScrollDistance = xf86SetIntOption(pInfo->options, "ScrollDistance", - common->wcmGestureParameters.wcmScrollDistanceDefault); + scroll_distance); + + common->wcmGestureParameters.wcmMaxScrollFingerSpread = + common->wcmMaxTouchX * + (WCM_BAMBOO3_SCROLL_SPREAD_DISTANCE / WCM_BAMBOO3_MAXX); } diff --git a/src/xf86WacomDefs.h b/src/xf86WacomDefs.h index a95e5d3..417fe1d 100644 --- a/src/xf86WacomDefs.h +++ b/src/xf86WacomDefs.h @@ -388,10 +388,9 @@ extern WacomDeviceClass gWacomISDV4Device; typedef struct { int wcmZoomDistance; /* minimum distance for a zoom touch gesture */ - int wcmZoomDistanceDefault; /* default minimum distance for a zoom touch gesture */ int wcmScrollDistance; /* minimum motion before sending a scroll gesture */ int wcmScrollDirection; /* store the vertical or horizontal bit in use */ - int wcmScrollDistanceDefault; /* default minimum motion before sending a scroll gesture */ + int wcmMaxScrollFingerSpread; /* maximum distance between fingers for scroll gesture */ int wcmGestureUsed; /* retain used gesture count within one in-prox event */ int wcmTapTime; /* minimum time between taps for a right click */ int wcmTapTimeDefault; /* default minimum time between taps for a right click */ |