[PATCH libevdev 3/6] Replace libevdev_get_abs_* with macro-generated ones

Peter Hutterer peter.hutterer at who-t.net
Sun Jul 28 22:34:34 PDT 2013


Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 libevdev/libevdev.c | 46 ++++++++++------------------------------------
 1 file changed, 10 insertions(+), 36 deletions(-)

diff --git a/libevdev/libevdev.c b/libevdev/libevdev.c
index c7f5102..28ae59f 100644
--- a/libevdev/libevdev.c
+++ b/libevdev/libevdev.c
@@ -796,45 +796,19 @@ libevdev_get_abs_info(const struct libevdev *dev, unsigned int code)
 	return &dev->abs_info[code];
 }
 
-int
-libevdev_get_abs_min(const struct libevdev *dev, unsigned int code)
-{
-	const struct input_absinfo *absinfo = libevdev_get_abs_info(dev, code);
-
-	return absinfo ? absinfo->minimum : 0;
-}
-
-int
-libevdev_get_abs_max(const struct libevdev *dev, unsigned int code)
-{
-	const struct input_absinfo *absinfo = libevdev_get_abs_info(dev, code);
-
-	return absinfo ? absinfo->maximum : 0;
+#define ABS_GETTER(name, field) \
+int libevdev_get_abs_##name(const struct libevdev *dev, unsigned int code) \
+{ \
+	const struct input_absinfo *absinfo = libevdev_get_abs_info(dev, code); \
+	return absinfo ? absinfo->field : 0; \
 }
 
-int
-libevdev_get_abs_fuzz(const struct libevdev *dev, unsigned int code)
-{
-	const struct input_absinfo *absinfo = libevdev_get_abs_info(dev, code);
-
-	return absinfo ? absinfo->fuzz : 0;
-}
+ABS_GETTER(max, maximum);
+ABS_GETTER(min, minimum);
+ABS_GETTER(fuzz, fuzz)
+ABS_GETTER(flat, flat)
+ABS_GETTER(resolution, resolution)
 
-int
-libevdev_get_abs_flat(const struct libevdev *dev, unsigned int code)
-{
-	const struct input_absinfo *absinfo = libevdev_get_abs_info(dev, code);
-
-	return absinfo ? absinfo->flat : 0;
-}
-
-int
-libevdev_get_abs_resolution(const struct libevdev *dev, unsigned int code)
-{
-	const struct input_absinfo *absinfo = libevdev_get_abs_info(dev, code);
-
-	return absinfo ? absinfo->resolution : 0;
-}
 
 #define ABS_SETTER(name, field) \
 void libevdev_set_abs_##name(struct libevdev *dev, unsigned int code, int val) \
-- 
1.8.2.1



More information about the Input-tools mailing list