[PATCH libevdev] Export INPUT_PROP_MAX through libevdev_property_get_max()

Benjamin Tissoires benjamin.tissoires at gmail.com
Fri Aug 15 10:40:07 PDT 2014


On Thu, Aug 14, 2014 at 11:17 PM, Peter Hutterer
<peter.hutterer at who-t.net> wrote:
> 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.
>

Hmm... this is not exactly what I would have loved given the current
evemu python port.

What is missing is libevdev_property_from_name{_n}()

This way, we can ask for
libevdev_property_from_name("INPUT_PROP_MAX"); which would return 32
=> this will solve this case.
We could also just ask for libevdev_property_from_name("INPUT_PROP_BUTTONPAD");

Thanks,
Benjamin

PS: I know, patches welcome :)

> 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