[PATCH libevdev 3/3] Rename ID setters/getters to have a consistent naming scheme

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


Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 libevdev/libevdev.c            | 26 ++++++++++++++++++--------
 libevdev/libevdev.h            | 21 +++++++++++++--------
 test/test-libevdev-has-event.c | 32 ++++++++++++++++----------------
 tools/libevdev-events.c        |  6 +++---
 4 files changed, 50 insertions(+), 35 deletions(-)

diff --git a/libevdev/libevdev.c b/libevdev/libevdev.c
index f8d7fb6..24367eb 100644
--- a/libevdev/libevdev.c
+++ b/libevdev/libevdev.c
@@ -684,10 +684,15 @@ void libevdev_set_##name(struct libevdev *dev, int field) \
 	dev->ids.field = field;\
 }
 
-PRODUCT_SETTER(product_id, product);
-PRODUCT_SETTER(vendor_id, vendor);
-PRODUCT_SETTER(bustype, bustype);
-PRODUCT_SETTER(version, version);
+PRODUCT_SETTER(product_id, product); /* DEPRECATED */
+PRODUCT_SETTER(vendor_id, vendor); /* DEPRECATED */
+PRODUCT_SETTER(bustype, bustype); /* DEPRECATED */
+PRODUCT_SETTER(version, version); /* DEPRECATED */
+
+PRODUCT_SETTER(id_product, product);
+PRODUCT_SETTER(id_vendor, vendor);
+PRODUCT_SETTER(id_bustype, bustype);
+PRODUCT_SETTER(id_version, version);
 
 #define PRODUCT_GETTER(name, field) \
 int libevdev_get_##name(const struct libevdev *dev) \
@@ -695,10 +700,15 @@ int libevdev_get_##name(const struct libevdev *dev) \
 	return dev->ids.field; \
 }
 
-PRODUCT_GETTER(product_id, product);
-PRODUCT_GETTER(vendor_id, vendor);
-PRODUCT_GETTER(bustype, bustype);
-PRODUCT_GETTER(version, version);
+PRODUCT_GETTER(product_id, product); /* DEPRECATED */
+PRODUCT_GETTER(vendor_id, vendor); /* DEPRECATED */
+PRODUCT_GETTER(bustype, bustype); /* DEPRECATED */
+PRODUCT_GETTER(version, version); /* DEPRECATED */
+
+PRODUCT_GETTER(id_product, product);
+PRODUCT_GETTER(id_vendor, vendor);
+PRODUCT_GETTER(id_bustype, bustype);
+PRODUCT_GETTER(id_version, version);
 
 int libevdev_get_driver_version(const struct libevdev *dev)
 {
diff --git a/libevdev/libevdev.h b/libevdev/libevdev.h
index 556346b..9c0bc87 100644
--- a/libevdev/libevdev.h
+++ b/libevdev/libevdev.h
@@ -584,7 +584,7 @@ void libevdev_set_uniq(struct libevdev *dev, const char *uniq);
  *
  * @note This function is signal-safe.
  */
-int libevdev_get_product_id(const struct libevdev *dev);
+int libevdev_get_id_product(const struct libevdev *dev);
 
 /**
  * @ingroup kernel
@@ -595,7 +595,7 @@ int libevdev_get_product_id(const struct libevdev *dev);
  * @note This function may be called before libevdev_set_fd(). A call to
  * libevdev_set_fd() will overwrite any previously set value.
  */
-void libevdev_set_product_id(struct libevdev *dev, int product_id);
+void libevdev_set_id_product(struct libevdev *dev, int product_id);
 
 /**
  * @ingroup bits
@@ -606,7 +606,7 @@ void libevdev_set_product_id(struct libevdev *dev, int product_id);
  *
  * @note This function is signal-safe.
  */
-int libevdev_get_vendor_id(const struct libevdev *dev);
+int libevdev_get_id_vendor(const struct libevdev *dev);
 
 /**
  * @ingroup kernel
@@ -617,7 +617,7 @@ int libevdev_get_vendor_id(const struct libevdev *dev);
  * @note This function may be called before libevdev_set_fd(). A call to
  * libevdev_set_fd() will overwrite any previously set value.
  */
-void libevdev_set_vendor_id(struct libevdev *dev, int vendor_id);
+void libevdev_set_id_vendor(struct libevdev *dev, int vendor_id);
 
 /**
  * @ingroup bits
@@ -628,7 +628,7 @@ void libevdev_set_vendor_id(struct libevdev *dev, int vendor_id);
  *
  * @note This function is signal-safe.
  */
-int libevdev_get_bustype(const struct libevdev *dev);
+int libevdev_get_id_bustype(const struct libevdev *dev);
 
 /**
  * @ingroup kernel
@@ -639,7 +639,7 @@ int libevdev_get_bustype(const struct libevdev *dev);
  * @note This function may be called before libevdev_set_fd(). A call to
  * libevdev_set_fd() will overwrite any previously set value.
  */
-void libevdev_set_bustype(struct libevdev *dev, int bustype);
+void libevdev_set_id_bustype(struct libevdev *dev, int bustype);
 
 /**
  * @ingroup bits
@@ -650,7 +650,7 @@ void libevdev_set_bustype(struct libevdev *dev, int bustype);
  *
  * @note This function is signal-safe.
  */
-int libevdev_get_version(const struct libevdev *dev);
+int libevdev_get_id_version(const struct libevdev *dev);
 
 /**
  * @ingroup kernel
@@ -661,7 +661,7 @@ int libevdev_get_version(const struct libevdev *dev);
  * @note This function may be called before libevdev_set_fd(). A call to
  * libevdev_set_fd() will overwrite any previously set value.
  */
-void libevdev_set_version(struct libevdev *dev, int version);
+void libevdev_set_id_version(struct libevdev *dev, int version);
 
 /**
  * @ingroup bits
@@ -1226,5 +1226,10 @@ void libevdev_set_abs_max(struct libevdev *dev, unsigned int code, int max) LIBE
 /* replacment: libevdev_get_property_name */
 const char* libevdev_get_input_prop_name(unsigned int prop) LIBEVDEV_DEPRECATED;
 
+void libevdev_set_product_id(struct libevdev *dev, int product_id) LIBEVDEV_DEPRECATED;
+void libevdev_set_vendor_id(struct libevdev *dev, int vendor_id) LIBEVDEV_DEPRECATED;
+void libevdev_set_bustype(struct libevdev *dev, int bustype) LIBEVDEV_DEPRECATED;
+void libevdev_set_version(struct libevdev *dev, int version) LIBEVDEV_DEPRECATED;
+
 /**************************************/
 #endif /* libevdev_H */
diff --git a/test/test-libevdev-has-event.c b/test/test-libevdev-has-event.c
index 8d50ea1..c79078c 100644
--- a/test/test-libevdev-has-event.c
+++ b/test/test-libevdev-has-event.c
@@ -430,10 +430,10 @@ START_TEST(test_device_name)
 	str = libevdev_get_uniq(dev);
 	ck_assert(str == NULL);
 
-	ck_assert_int_eq(libevdev_get_bustype(dev), ids.bustype);
-	ck_assert_int_eq(libevdev_get_vendor_id(dev), ids.vendor);
-	ck_assert_int_eq(libevdev_get_product_id(dev), ids.product);
-	ck_assert_int_eq(libevdev_get_version(dev), ids.version);
+	ck_assert_int_eq(libevdev_get_id_bustype(dev), ids.bustype);
+	ck_assert_int_eq(libevdev_get_id_vendor(dev), ids.vendor);
+	ck_assert_int_eq(libevdev_get_id_product(dev), ids.product);
+	ck_assert_int_eq(libevdev_get_id_version(dev), ids.version);
 	ck_assert_int_eq(libevdev_get_driver_version(dev), EV_VERSION);
 
 	uinput_device_free(uidev);
@@ -497,15 +497,15 @@ START_TEST(test_device_set_ids)
 
 	dev = libevdev_new();
 
-	libevdev_set_product_id(dev, 10);
-	libevdev_set_vendor_id(dev, 20);
-	libevdev_set_bustype(dev, 30);
-	libevdev_set_version(dev, 40);
+	libevdev_set_id_product(dev, 10);
+	libevdev_set_id_vendor(dev, 20);
+	libevdev_set_id_bustype(dev, 30);
+	libevdev_set_id_version(dev, 40);
 
-	ck_assert_int_eq(libevdev_get_product_id(dev), 10);
-	ck_assert_int_eq(libevdev_get_vendor_id(dev), 20);
-	ck_assert_int_eq(libevdev_get_bustype(dev), 30);
-	ck_assert_int_eq(libevdev_get_version(dev), 40);
+	ck_assert_int_eq(libevdev_get_id_product(dev), 10);
+	ck_assert_int_eq(libevdev_get_id_vendor(dev), 20);
+	ck_assert_int_eq(libevdev_get_id_bustype(dev), 30);
+	ck_assert_int_eq(libevdev_get_id_version(dev), 40);
 
 	rc = uinput_device_new_with_events(&uidev, TEST_DEVICE_NAME, &ids,
 					   EV_ABS, ABS_X,
@@ -514,10 +514,10 @@ START_TEST(test_device_set_ids)
 	rc = libevdev_set_fd(dev, uinput_device_get_fd(uidev));
 	ck_assert_msg(rc == 0, "Failed to init device: %s", strerror(-rc));;
 
-	ck_assert_int_eq(libevdev_get_bustype(dev), ids.bustype);
-	ck_assert_int_eq(libevdev_get_vendor_id(dev), ids.vendor);
-	ck_assert_int_eq(libevdev_get_product_id(dev), ids.product);
-	ck_assert_int_eq(libevdev_get_version(dev), ids.version);
+	ck_assert_int_eq(libevdev_get_id_bustype(dev), ids.bustype);
+	ck_assert_int_eq(libevdev_get_id_vendor(dev), ids.vendor);
+	ck_assert_int_eq(libevdev_get_id_product(dev), ids.product);
+	ck_assert_int_eq(libevdev_get_id_version(dev), ids.version);
 
 	uinput_device_free(uidev);
 	libevdev_free(dev);
diff --git a/tools/libevdev-events.c b/tools/libevdev-events.c
index 9b2e1a7..1590965 100644
--- a/tools/libevdev-events.c
+++ b/tools/libevdev-events.c
@@ -158,9 +158,9 @@ main(int argc, char **argv)
 	}
 
 	printf("Input device ID: bus %#x vendor %#x product %#x\n",
-			libevdev_get_bustype(dev),
-			libevdev_get_vendor_id(dev),
-			libevdev_get_product_id(dev));
+			libevdev_get_id_bustype(dev),
+			libevdev_get_id_vendor(dev),
+			libevdev_get_id_product(dev));
 	printf("Evdev version: %x\n", libevdev_get_driver_version(dev));
 	printf("Input device name: \"%s\"\n", libevdev_get_name(dev));
 	printf("Phys location: %s\n", libevdev_get_phys(dev));
-- 
1.8.2.1



More information about the Input-tools mailing list