[PATCH 1/5] input: allow for max < min for relative axes on InitValuatorAxisStruct
Peter Hutterer
peter.hutterer at who-t.net
Thu Sep 8 21:19:25 PDT 2011
And use this occasion to switch InitValuatorAxisStruct to return Bool
instead of just silently ignoring issues.
Relative axes are initialized with 0, -1 but so far this never had any
effect as all users of this function (for relative axes) just set it to the
defaults anyway.
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
Xi/exevents.c | 10 ++++++----
hw/xfree86/common/xf86Xinput.c | 8 ++++----
hw/xfree86/common/xf86Xinput.h | 2 +-
include/exevents.h | 2 +-
4 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/Xi/exevents.c b/Xi/exevents.c
index 4dd9b85..a6455e6 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -1067,16 +1067,16 @@ InitProximityClassDeviceStruct(DeviceIntPtr dev)
*
* @see InitValuatorClassDeviceStruct
*/
-void
+Bool
InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, Atom label, int minval, int maxval,
int resolution, int min_res, int max_res, int mode)
{
AxisInfoPtr ax;
- if (!dev || !dev->valuator || minval > maxval)
- return;
+ if (!dev || !dev->valuator || (minval > maxval && mode == Absolute))
+ return FALSE;
if (axnum >= dev->valuator->numAxes)
- return;
+ return FALSE;
ax = dev->valuator->axes + axnum;
@@ -1090,6 +1090,8 @@ InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, Atom label, int minval, int
if (mode & OutOfProximity)
dev->proximity->in_proximity = FALSE;
+
+ return TRUE;
}
static void
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 114cdd9..980ca53 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -1334,15 +1334,15 @@ xf86XInputSetScreen(InputInfoPtr pInfo,
}
-void
+Bool
xf86InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, Atom label, int minval, int maxval,
int resolution, int min_res, int max_res, int mode)
{
if (!dev || !dev->valuator)
- return;
+ return FALSE;
- InitValuatorAxisStruct(dev, axnum, label, minval, maxval, resolution, min_res,
- max_res, mode);
+ return InitValuatorAxisStruct(dev, axnum, label, minval, maxval, resolution, min_res,
+ max_res, mode);
}
/*
diff --git a/hw/xfree86/common/xf86Xinput.h b/hw/xfree86/common/xf86Xinput.h
index a4d9e58..189f7ab 100644
--- a/hw/xfree86/common/xf86Xinput.h
+++ b/hw/xfree86/common/xf86Xinput.h
@@ -145,7 +145,7 @@ extern _X_EXPORT InputInfoPtr xf86FirstLocalDevice(void);
extern _X_EXPORT int xf86ScaleAxis(int Cx, int to_max, int to_min, int from_max, int from_min);
extern _X_EXPORT void xf86XInputSetScreen(InputInfoPtr pInfo, int screen_number, int x, int y);
extern _X_EXPORT void xf86ProcessCommonOptions(InputInfoPtr pInfo, XF86OptionPtr options);
-extern _X_EXPORT void xf86InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, Atom label, int minval,
+extern _X_EXPORT Bool xf86InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, Atom label, int minval,
int maxval, int resolution, int min_res,
int max_res, int mode);
extern _X_EXPORT void xf86InitValuatorDefaults(DeviceIntPtr dev, int axnum);
diff --git a/include/exevents.h b/include/exevents.h
index 2b22698..731f31e 100644
--- a/include/exevents.h
+++ b/include/exevents.h
@@ -40,7 +40,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
extern _X_EXPORT int InitProximityClassDeviceStruct(
DeviceIntPtr /* dev */);
-extern _X_EXPORT void InitValuatorAxisStruct(
+extern _X_EXPORT Bool InitValuatorAxisStruct(
DeviceIntPtr /* dev */,
int /* axnum */,
Atom /* label */,
--
1.7.6
More information about the xorg-devel
mailing list