[PATCH libevdev] Export INPUT_PROP_MAX through libevdev_property_get_max()

Peter Hutterer peter.hutterer at who-t.net
Thu Aug 14 20:17:25 PDT 2014


The value of INPUT_PROP_MAX is compiled into libevdev, like all other *_MAX.
Export this value rather than asking clients to soley rely on their
INPUT_PROP_MAX, which may be different.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 libevdev/libevdev.c     |  6 ++++++
 libevdev/libevdev.h     | 13 +++++++++++++
 libevdev/libevdev.sym   |  1 +
 test/test-event-names.c |  7 +++++++
 4 files changed, 27 insertions(+)

diff --git a/libevdev/libevdev.c b/libevdev/libevdev.c
index 903a286..1223bfb 100644
--- a/libevdev/libevdev.c
+++ b/libevdev/libevdev.c
@@ -1593,6 +1593,12 @@ libevdev_property_get_name(unsigned int prop)
 	return input_prop_map[prop];
 }
 
+LIBEVDEV_EXPORT unsigned int
+libevdev_property_get_max(void)
+{
+	return INPUT_PROP_MAX;
+}
+
 LIBEVDEV_EXPORT int
 libevdev_event_type_get_max(unsigned int type)
 {
diff --git a/libevdev/libevdev.h b/libevdev/libevdev.h
index 4f33cb7..3688787 100644
--- a/libevdev/libevdev.h
+++ b/libevdev/libevdev.h
@@ -1994,6 +1994,19 @@ const char* libevdev_property_get_name(unsigned int prop);
 /**
  * @ingroup misc
  *
+ * @return The maximum value for an input prop value, i.e. the value of
+ * INPUT_PROP_MAX at libevdev compile-time. Values above this maximum are
+ * considered invalid when used in libevdev_property_get_name().
+ * @retval 0 if INPUT_PROP_MAX was not defined at libevdev compile-time.
+ *
+ * @note The maximum value is compiled into libevdev. If the kernel
+ * increases INPUT_PROP_MAX, libevdev will not automatically pick it up.
+ */
+unsigned int libevdev_property_get_max(void);
+
+/**
+ * @ingroup misc
+ *
  * @param type The event type to return the maximum for (EV_ABS, EV_REL, etc.). No max is defined for
  * EV_SYN.
  *
diff --git a/libevdev/libevdev.sym b/libevdev/libevdev.sym
index 228e555..2817820 100644
--- a/libevdev/libevdev.sym
+++ b/libevdev/libevdev.sym
@@ -106,6 +106,7 @@ local:
 LIBEVDEV_1_3 {
 global:
 	libevdev_set_device_log_function;
+	libevdev_property_get_max;
 
 local:
 	*;
diff --git a/test/test-event-names.c b/test/test-event-names.c
index 8d7e6d6..b7d11b2 100644
--- a/test/test-event-names.c
+++ b/test/test-event-names.c
@@ -216,6 +216,12 @@ START_TEST(test_event_type_max)
 }
 END_TEST
 
+START_TEST(test_input_props_max)
+{
+	ck_assert_int_eq(libevdev_property_get_max(), INPUT_PROP_MAX);
+}
+END_TEST
+
 START_TEST(test_event_type)
 {
 	struct input_event ev;
@@ -269,6 +275,7 @@ event_name_suite(void)
 	TCase *tc = tcase_create("type limits");
 	tcase_add_test(tc, test_limits);
 	tcase_add_test(tc, test_event_type_max);
+	tcase_add_test(tc, test_input_props_max);
 	suite_add_tcase(s, tc);
 
 	tc = tcase_create("type names");
-- 
1.9.3



More information about the Input-tools mailing list