[PATCH libevdev 1/3] Rename a few setters and getters for consistency

Peter Hutterer peter.hutterer at who-t.net
Mon Jul 29 21:36:40 PDT 2013


Deprecated:
* libevdev_get_abs_min, libevdev_get_abs_max
* libevdev_set_abs_min, libevdev_set_abs_max
* libevdev_get_input_prop_name

Will be removed in one or two versions.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 libevdev/libevdev.c            | 19 ++++++++++++----
 libevdev/libevdev.h            | 32 ++++++++++++++++++++++-----
 test/test-event-names.c        | 14 ++++++------
 test/test-libevdev-has-event.c | 50 +++++++++++++++++++++---------------------
 tools/libevdev-events.c        |  2 +-
 5 files changed, 75 insertions(+), 42 deletions(-)

diff --git a/libevdev/libevdev.c b/libevdev/libevdev.c
index 9391f15..39ab445 100644
--- a/libevdev/libevdev.c
+++ b/libevdev/libevdev.c
@@ -842,8 +842,10 @@ int libevdev_get_abs_##name(const struct libevdev *dev, unsigned int code) \
 	return absinfo ? absinfo->field : 0; \
 }
 
-ABS_GETTER(max, maximum);
-ABS_GETTER(min, minimum);
+ABS_GETTER(max, maximum); /* DEPRECATED */
+ABS_GETTER(min, minimum); /* DEPRECATED */
+ABS_GETTER(maximum, maximum);
+ABS_GETTER(minimum, minimum);
 ABS_GETTER(fuzz, fuzz)
 ABS_GETTER(flat, flat)
 ABS_GETTER(resolution, resolution)
@@ -857,8 +859,10 @@ void libevdev_set_abs_##name(struct libevdev *dev, unsigned int code, int val) \
 	dev->abs_info[code].field = val; \
 }
 
-ABS_SETTER(max, maximum)
-ABS_SETTER(min, minimum)
+ABS_SETTER(max, maximum) /* DEPRECATED */
+ABS_SETTER(min, minimum) /* DEPRECATED */
+ABS_SETTER(maximum, maximum)
+ABS_SETTER(minimum, minimum)
 ABS_SETTER(fuzz, fuzz)
 ABS_SETTER(flat, flat)
 ABS_SETTER(resolution, resolution)
@@ -1032,9 +1036,16 @@ libevdev_get_event_code_name(unsigned int type, unsigned int code)
 	return event_type_map[type][code];
 }
 
+/* DEPRECATED */
 const char*
 libevdev_get_input_prop_name(unsigned int prop)
 {
+	return libevdev_get_property_name(prop);
+}
+
+const char*
+libevdev_get_property_name(unsigned int prop)
+{
 	if (prop > INPUT_PROP_MAX)
 		return NULL;
 
diff --git a/libevdev/libevdev.h b/libevdev/libevdev.h
index ee8248f..556346b 100644
--- a/libevdev/libevdev.h
+++ b/libevdev/libevdev.h
@@ -734,7 +734,7 @@ int libevdev_has_event_code(const struct libevdev *dev, unsigned int type, unsig
  *
  * @return axis minimum for the given axis or 0 if the axis is invalid
  */
-int libevdev_get_abs_min(const struct libevdev *dev, unsigned int code);
+int libevdev_get_abs_minimum(const struct libevdev *dev, unsigned int code);
 /**
  * @ingroup bits
  *
@@ -745,7 +745,7 @@ int libevdev_get_abs_min(const struct libevdev *dev, unsigned int code);
  *
  * @return axis maximum for the given axis or 0 if the axis is invalid
  */
-int libevdev_get_abs_max(const struct libevdev *dev, unsigned int code);
+int libevdev_get_abs_maximum(const struct libevdev *dev, unsigned int code);
 /**
  * @ingroup bits
  *
@@ -926,7 +926,7 @@ int libevdev_get_current_slot(const struct libevdev *dev);
  * This function has no effect if libevdev_has_event_code() returns false for
  * this code.
  */
-void libevdev_set_abs_min(struct libevdev *dev, unsigned int code, int min);
+void libevdev_set_abs_minimum(struct libevdev *dev, unsigned int code, int min);
 
 /**
  * @ingroup kernel
@@ -935,7 +935,7 @@ void libevdev_set_abs_min(struct libevdev *dev, unsigned int code, int min);
  * This function has no effect if libevdev_has_event_code() returns false for
  * this code.
  */
-void libevdev_set_abs_max(struct libevdev *dev, unsigned int code, int max);
+void libevdev_set_abs_maximum(struct libevdev *dev, unsigned int code, int max);
 
 /**
  * @ingroup kernel
@@ -1174,7 +1174,7 @@ const char * libevdev_get_event_code_name(unsigned int type, unsigned int code);
  * @note On older kernels input properties may not be defined and
  * libevdev_get_input_prop_name() will always return NULL
  */
-const char * libevdev_get_input_prop_name(unsigned int prop);
+const char* libevdev_get_property_name(unsigned int prop);
 
 /**
  * @ingroup misc
@@ -1205,4 +1205,26 @@ int libevdev_get_event_type_max(unsigned int type);
  */
 int libevdev_get_repeat(struct libevdev *dev, int *delay, int *period);
 
+
+/********* DEPRECATED SECTION *********/
+#if defined(__GNUC__) && __GNUC__ >= 4
+#define LIBEVDEV_DEPRECATED __attribute__ ((deprecated))
+#else
+#define LIBEVDEV_DEPRECATED
+#endif
+
+/* replacement: libevdev_get_abs_minimum */
+int libevdev_get_abs_min(const struct libevdev *dev, unsigned int code) LIBEVDEV_DEPRECATED;
+/* replacement: libevdev_get_abs_maximum */
+int libevdev_get_abs_max(const struct libevdev *dev, unsigned int code) LIBEVDEV_DEPRECATED;
+
+/* replacement: libevdev_set_abs_minimum */
+void libevdev_set_abs_min(struct libevdev *dev, unsigned int code, int min) LIBEVDEV_DEPRECATED;
+/* replacement: libevdev_set_abs_maximum */
+void libevdev_set_abs_max(struct libevdev *dev, unsigned int code, int max) LIBEVDEV_DEPRECATED;
+
+/* replacment: libevdev_get_property_name */
+const char* libevdev_get_input_prop_name(unsigned int prop) LIBEVDEV_DEPRECATED;
+
+/**************************************/
 #endif /* libevdev_H */
diff --git a/test/test-event-names.c b/test/test-event-names.c
index 2701de5..74d0335 100644
--- a/test/test-event-names.c
+++ b/test/test-event-names.c
@@ -204,14 +204,14 @@ END_TEST
 
 START_TEST(test_prop_name)
 {
-	ck_assert_str_eq(libevdev_get_input_prop_name(INPUT_PROP_POINTER), "INPUT_PROP_POINTER");
-	ck_assert_str_eq(libevdev_get_input_prop_name(INPUT_PROP_DIRECT), "INPUT_PROP_DIRECT");
-	ck_assert_str_eq(libevdev_get_input_prop_name(INPUT_PROP_BUTTONPAD), "INPUT_PROP_BUTTONPAD");
-	ck_assert_str_eq(libevdev_get_input_prop_name(INPUT_PROP_SEMI_MT), "INPUT_PROP_SEMI_MT");
-	ck_assert_str_eq(libevdev_get_input_prop_name(INPUT_PROP_MAX), "INPUT_PROP_MAX");
+	ck_assert_str_eq(libevdev_get_property_name(INPUT_PROP_POINTER), "INPUT_PROP_POINTER");
+	ck_assert_str_eq(libevdev_get_property_name(INPUT_PROP_DIRECT), "INPUT_PROP_DIRECT");
+	ck_assert_str_eq(libevdev_get_property_name(INPUT_PROP_BUTTONPAD), "INPUT_PROP_BUTTONPAD");
+	ck_assert_str_eq(libevdev_get_property_name(INPUT_PROP_SEMI_MT), "INPUT_PROP_SEMI_MT");
+	ck_assert_str_eq(libevdev_get_property_name(INPUT_PROP_MAX), "INPUT_PROP_MAX");
 
-	ck_assert(libevdev_get_input_prop_name(INPUT_PROP_MAX - 1) == NULL);
-	ck_assert(libevdev_get_input_prop_name(INPUT_PROP_MAX + 1) == NULL);
+	ck_assert(libevdev_get_property_name(INPUT_PROP_MAX - 1) == NULL);
+	ck_assert(libevdev_get_property_name(INPUT_PROP_MAX + 1) == NULL);
 }
 END_TEST
 
diff --git a/test/test-libevdev-has-event.c b/test/test-libevdev-has-event.c
index 94b8f4c..8d50ea1 100644
--- a/test/test-libevdev-has-event.c
+++ b/test/test-libevdev-has-event.c
@@ -562,15 +562,15 @@ START_TEST(test_device_get_abs_info)
 	rc = libevdev_new_from_fd(uinput_device_get_fd(uidev), &dev);
 	ck_assert_msg(rc == 0, "Failed to init device: %s", strerror(-rc));;
 
-	ck_assert_int_eq(libevdev_get_abs_min(dev, ABS_MAX + 1), 0);
-	ck_assert_int_eq(libevdev_get_abs_max(dev, ABS_MAX + 1), 0);
+	ck_assert_int_eq(libevdev_get_abs_minimum(dev, ABS_MAX + 1), 0);
+	ck_assert_int_eq(libevdev_get_abs_maximum(dev, ABS_MAX + 1), 0);
 	ck_assert_int_eq(libevdev_get_abs_fuzz(dev, ABS_MAX + 1), 0);
 	ck_assert_int_eq(libevdev_get_abs_flat(dev, ABS_MAX + 1), 0);
 	ck_assert_int_eq(libevdev_get_abs_resolution(dev, ABS_MAX + 1), 0);
 	ck_assert(!libevdev_get_abs_info(dev, ABS_MAX + 1));
 
-	ck_assert_int_eq(libevdev_get_abs_min(dev, ABS_X), 0);
-	ck_assert_int_eq(libevdev_get_abs_max(dev, ABS_X), 1000);
+	ck_assert_int_eq(libevdev_get_abs_minimum(dev, ABS_X), 0);
+	ck_assert_int_eq(libevdev_get_abs_maximum(dev, ABS_X), 1000);
 	ck_assert_int_eq(libevdev_get_abs_fuzz(dev, ABS_X), 1);
 	ck_assert_int_eq(libevdev_get_abs_flat(dev, ABS_X), 2);
 	ck_assert_int_eq(libevdev_get_abs_resolution(dev, ABS_X), 3);
@@ -582,8 +582,8 @@ START_TEST(test_device_get_abs_info)
 	ck_assert_int_eq(a->flat, 2);
 	ck_assert_int_eq(a->resolution, 3);
 
-	ck_assert_int_eq(libevdev_get_abs_min(dev, ABS_MT_POSITION_X), 0);
-	ck_assert_int_eq(libevdev_get_abs_max(dev, ABS_MT_POSITION_X), 1000);
+	ck_assert_int_eq(libevdev_get_abs_minimum(dev, ABS_MT_POSITION_X), 0);
+	ck_assert_int_eq(libevdev_get_abs_maximum(dev, ABS_MT_POSITION_X), 1000);
 	ck_assert_int_eq(libevdev_get_abs_fuzz(dev, ABS_MT_POSITION_X), 1);
 	ck_assert_int_eq(libevdev_get_abs_flat(dev, ABS_MT_POSITION_X), 2);
 	ck_assert_int_eq(libevdev_get_abs_resolution(dev, ABS_MT_POSITION_X), 3);
@@ -595,8 +595,8 @@ START_TEST(test_device_get_abs_info)
 	ck_assert_int_eq(a->flat, 2);
 	ck_assert_int_eq(a->resolution, 3);
 
-	ck_assert_int_eq(libevdev_get_abs_min(dev, ABS_Y), -500);
-	ck_assert_int_eq(libevdev_get_abs_max(dev, ABS_Y), 500);
+	ck_assert_int_eq(libevdev_get_abs_minimum(dev, ABS_Y), -500);
+	ck_assert_int_eq(libevdev_get_abs_maximum(dev, ABS_Y), 500);
 	ck_assert_int_eq(libevdev_get_abs_fuzz(dev, ABS_Y), 10);
 	ck_assert_int_eq(libevdev_get_abs_flat(dev, ABS_Y), 20);
 	ck_assert_int_eq(libevdev_get_abs_resolution(dev, ABS_Y), 30);
@@ -608,8 +608,8 @@ START_TEST(test_device_get_abs_info)
 	ck_assert_int_eq(a->flat, 20);
 	ck_assert_int_eq(a->resolution, 30);
 
-	ck_assert_int_eq(libevdev_get_abs_min(dev, ABS_MT_POSITION_Y), -500);
-	ck_assert_int_eq(libevdev_get_abs_max(dev, ABS_MT_POSITION_Y), 500);
+	ck_assert_int_eq(libevdev_get_abs_minimum(dev, ABS_MT_POSITION_Y), -500);
+	ck_assert_int_eq(libevdev_get_abs_maximum(dev, ABS_MT_POSITION_Y), 500);
 	ck_assert_int_eq(libevdev_get_abs_fuzz(dev, ABS_MT_POSITION_Y), 10);
 	ck_assert_int_eq(libevdev_get_abs_flat(dev, ABS_MT_POSITION_Y), 20);
 	ck_assert_int_eq(libevdev_get_abs_resolution(dev, ABS_MT_POSITION_Y), 30);
@@ -647,15 +647,15 @@ START_TEST(test_device_set_abs)
 				    -1);
 	ck_assert_msg(rc == 0, "Failed to create device: %s", strerror(-rc));
 
-	libevdev_set_abs_min(dev, ABS_X, 1);
-	libevdev_set_abs_min(dev, ABS_Y, 5);
-	ck_assert_int_eq(libevdev_get_abs_min(dev, ABS_X),  1);
-	ck_assert_int_eq(libevdev_get_abs_min(dev, ABS_Y),  5);
+	libevdev_set_abs_minimum(dev, ABS_X, 1);
+	libevdev_set_abs_minimum(dev, ABS_Y, 5);
+	ck_assert_int_eq(libevdev_get_abs_minimum(dev, ABS_X),  1);
+	ck_assert_int_eq(libevdev_get_abs_minimum(dev, ABS_Y),  5);
 
-	libevdev_set_abs_max(dev, ABS_X, 3000);
-	libevdev_set_abs_max(dev, ABS_Y, 5000);
-	ck_assert_int_eq(libevdev_get_abs_max(dev, ABS_X),  3000);
-	ck_assert_int_eq(libevdev_get_abs_max(dev, ABS_Y),  5000);
+	libevdev_set_abs_maximum(dev, ABS_X, 3000);
+	libevdev_set_abs_maximum(dev, ABS_Y, 5000);
+	ck_assert_int_eq(libevdev_get_abs_maximum(dev, ABS_X),  3000);
+	ck_assert_int_eq(libevdev_get_abs_maximum(dev, ABS_Y),  5000);
 
 	libevdev_set_abs_fuzz(dev, ABS_X, 3);
 	libevdev_set_abs_fuzz(dev, ABS_Y, 5);
@@ -681,7 +681,7 @@ START_TEST(test_device_set_abs)
 	libevdev_set_abs_info(dev, ABS_X, &a);
 	ck_assert_int_eq(memcmp(&a, libevdev_get_abs_info(dev, ABS_X), sizeof(a)), 0);
 
-	libevdev_set_abs_min(dev, ABS_Z, 10);
+	libevdev_set_abs_minimum(dev, ABS_Z, 10);
 	ck_assert_int_eq(libevdev_has_event_code(dev, EV_ABS, ABS_Z),  0);
 
 	uinput_device_free(uidev);
@@ -857,8 +857,8 @@ START_TEST(test_device_kernel_change_axis)
 	rc = libevdev_new_from_fd(uinput_device_get_fd(uidev), &dev);
 	ck_assert_msg(rc == 0, "Failed to init device: %s", strerror(-rc));;
 
-	ck_assert_int_eq(libevdev_get_abs_min(dev, ABS_X), 0);
-	ck_assert_int_eq(libevdev_get_abs_max(dev, ABS_X), 1000);
+	ck_assert_int_eq(libevdev_get_abs_minimum(dev, ABS_X), 0);
+	ck_assert_int_eq(libevdev_get_abs_maximum(dev, ABS_X), 1000);
 	ck_assert_int_eq(libevdev_get_abs_fuzz(dev, ABS_X), 1);
 	ck_assert_int_eq(libevdev_get_abs_flat(dev, ABS_X), 2);
 	ck_assert_int_eq(libevdev_get_abs_resolution(dev, ABS_X), 3);
@@ -871,8 +871,8 @@ START_TEST(test_device_kernel_change_axis)
 	rc = libevdev_kernel_set_abs_value(dev, ABS_X, &abs);
 	ck_assert_int_eq(rc, 0);
 
-	ck_assert_int_eq(libevdev_get_abs_min(dev, ABS_X), 500);
-	ck_assert_int_eq(libevdev_get_abs_max(dev, ABS_X), 5000);
+	ck_assert_int_eq(libevdev_get_abs_minimum(dev, ABS_X), 500);
+	ck_assert_int_eq(libevdev_get_abs_maximum(dev, ABS_X), 5000);
 	ck_assert_int_eq(libevdev_get_abs_fuzz(dev, ABS_X), 10);
 	ck_assert_int_eq(libevdev_get_abs_flat(dev, ABS_X), 20);
 	ck_assert_int_eq(libevdev_get_abs_resolution(dev, ABS_X), 30);
@@ -880,8 +880,8 @@ START_TEST(test_device_kernel_change_axis)
 	/* make sure kernel device is changed */
 	rc = libevdev_new_from_fd(uinput_device_get_fd(uidev), &dev2);
 	ck_assert_msg(rc == 0, "Failed to init device: %s", strerror(-rc));
-	ck_assert_int_eq(libevdev_get_abs_min(dev2, ABS_X), 500);
-	ck_assert_int_eq(libevdev_get_abs_max(dev2, ABS_X), 5000);
+	ck_assert_int_eq(libevdev_get_abs_minimum(dev2, ABS_X), 500);
+	ck_assert_int_eq(libevdev_get_abs_maximum(dev2, ABS_X), 5000);
 	ck_assert_int_eq(libevdev_get_abs_fuzz(dev2, ABS_X), 10);
 	ck_assert_int_eq(libevdev_get_abs_flat(dev2, ABS_X), 20);
 	ck_assert_int_eq(libevdev_get_abs_resolution(dev2, ABS_X), 30);
diff --git a/tools/libevdev-events.c b/tools/libevdev-events.c
index ee64cea..9b2e1a7 100644
--- a/tools/libevdev-events.c
+++ b/tools/libevdev-events.c
@@ -103,7 +103,7 @@ print_props(struct libevdev *dev)
 	for (i = 0; i <= INPUT_PROP_MAX; i++) {
 		if (libevdev_has_property(dev, i))
 			printf("  Property type %d (%s)\n", i,
-					libevdev_get_input_prop_name(i));
+					libevdev_get_property_name(i));
 	}
 }
 
-- 
1.8.2.1



More information about the Input-tools mailing list