Instead of a giant if/else block with essentially the same code, just work
on both x/y and then just trigger for the right axis. This call isn't that
expensive and readability trumps here.
---
src/xf86Wacom.c | 109 ++++++++++++++++++++++++++-----------------------------
1 files changed, 52 insertions(+), 57 deletions(-)
diff --git a/src/xf86Wacom.c b/src/xf86Wacom.c
index 50d7e14..ad21c28 100644
--- a/src/xf86Wacom.c
+++ b/src/xf86Wacom.c
@@ -330,84 +330,79 @@ void wcmInitialCoordinates(LocalDevicePtr local, int axis)
{
WacomDevicePtr priv = (WacomDevicePtr)local->private;
WacomCommonPtr common = priv->common;
- int topx = 0, topy = 0, resolution;
+ int topx = 0, topy = 0, resolution_x, resolution_y;
int bottomx = priv->maxX, bottomy = priv->maxY;
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
- Atom label;
+ Atom label_x, label_y;
#endif
wcmMappingFactor(local);
- /* x ax */
- if (axis == 0)
+ if (priv->flags & ABSOLUTE_FLAG)
{
- if (priv->flags & ABSOLUTE_FLAG)
+ topx = priv->topX;
+ topy = priv->topY;
+ bottomx = priv->sizeX + priv->topX;
+ bottomy = priv->sizeY + priv->topY;
+
+ if (priv->twinview != TV_NONE)
{
- topx = priv->topX;
- bottomx = priv->sizeX + priv->topX;
- if (priv->currentScreen == 1 && priv->twinview !=
TV_NONE)
+ if (priv->currentScreen == 1)
+ {
topx += priv->tvoffsetX;
- if (priv->currentScreen == 0 && priv->twinview !=
TV_NONE)
+ topy += priv->tvoffsetY;
+ } else if (priv->currentScreen == 0)
+ {
bottomx -= priv->tvoffsetX;
-
-#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
- label = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_X);
- } else {
- label = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
-#endif
- }
-
- resolution = priv->resolX;
- if (common->wcmScaling)
- {
- /* In case wcmDevConvert didn't get called */
- topx = 0;
- bottomx = (int)((double)priv->sizeX * priv->factorX +
0.5);
- resolution = (int)((double)resolution * priv->factorX +
0.5);
+ bottomy -= priv->tvoffsetY;
+ }
}
- InitValuatorAxisStruct(local->dev, 0,
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
- label,
+ label_x = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_X);
+ label_y = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_Y);
+ } else {
+ label_x = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
+ label_y = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
#endif
- topx, bottomx,
- resolution, 0, resolution);
}
- else if (axis == 1) /* y ax */
+ resolution_x = priv->resolX;
+ resolution_y = priv->resolY;
+
+ if (common->wcmScaling)
{
- if (priv->flags & ABSOLUTE_FLAG)
- {
- topy = priv->topY;
- bottomy = priv->sizeY + priv->topY;
- if (priv->currentScreen == 1 && priv->twinview !=
TV_NONE)
- topy += priv->tvoffsetY;
- if (priv->currentScreen == 0 && priv->twinview !=
TV_NONE)
- bottomy -= priv->tvoffsetY;
+ /* In case wcmDevConvert didn't get called */
+ topx = 0;
+ bottomx = (int)((double)priv->sizeX * priv->factorX + 0.5);
+ resolution_x = (int)((double)resolution_x * priv->factorX +
0.5);
+
+ topy = 0;
+ bottomy = (int)((double)priv->sizeY * priv->factorY + 0.5);
+ resolution_y = (int)((double)resolution_y * priv->factorY +
0.5);
+ }
+ switch(axis)
+ {
+ case 0:
+ InitValuatorAxisStruct(local->dev, 0,
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
- label = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_Y);
- } else {
- label = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
+ label_x,
#endif
- }
-
- resolution = priv->resolY;
- if (common->wcmScaling)
- {
- /* In case wcmDevConvert didn't get called */
- topy = 0;
- bottomy = (int)((double)priv->sizeY * priv->factorY +
0.5);
- resolution = (int)((double)resolution * priv->factorY +
0.5);
- }
-
- InitValuatorAxisStruct(local->dev, 1,
+ topx, bottomx,
+ resolution_x, 0, resolution_x);
+ break;
+ case 1:
+ InitValuatorAxisStruct(local->dev, 1,
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
- label,
+ label_y,
#endif
- topy, bottomy,
- resolution, 0, resolution);
- } else
- xf86Msg(X_ERROR, "%s: Cannot initialize axis %d.\n", axis);
+ topy, bottomy,
+ resolution_y, 0, resolution_y);
+ break;
+ default:
+ xf86Msg(X_ERROR, "%s: Cannot initialize axis %d.\n",
local->name, axis);
+ break;
+ }
return;
}
--
1.6.6.1
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Linuxwacom-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel