[neon/backports-focal/libevdev/Neon/release] /: New upstream version 1.12.0+dfsg

Stephen Kitt null at kde.org
Thu Dec 2 09:54:56 GMT 2021


Git commit bf180ef99cebb0d2b8774d84a6cee460716134d0 by Stephen Kitt.
Committed on 14/11/2021 at 16:24.
Pushed by jriddell into branch 'Neon/release'.

New upstream version 1.12.0+dfsg

M  +1    -0    Makefile.in
M  +6    -4    aclocal.m4
M  +24   -12   configure
M  +1    -1    configure.ac
M  +1    -0    doc/Makefile.in
M  +1    -0    include/linux/linux/input-event-codes.h
M  +1    -1    include/linux/linux/input.h
M  +1    -0    libevdev/Makefile.in
M  +8    -9    libevdev/libevdev-uinput.h
M  +1    -1    libevdev/libevdev.h
M  +3    -3    libevdev/make-event-names.py
M  +8    -2    meson.build
M  +1    -0    test/Makefile.in
M  +4    -1    tools/Makefile.am
M  +20   -3    tools/Makefile.in
A  +47   -0    tools/libevdev-list-codes.c     [License: MIT]

https://invent.kde.org/neon/backports-focal/libevdev/commit/bf180ef99cebb0d2b8774d84a6cee460716134d0

diff --git a/Makefile.in b/Makefile.in
index 225e2a1..388315e 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -370,6 +370,7 @@ program_transform_name = @program_transform_name@
 psdir = @psdir@
 pyexecdir = @pyexecdir@
 pythondir = @pythondir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
diff --git a/aclocal.m4 b/aclocal.m4
index ea6e955..5d07eb3 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1224,12 +1224,14 @@ AC_DEFUN([AM_PATH_PYTHON],
     m4_default([$3], [AC_MSG_ERROR([no suitable Python interpreter found])])
   else
 
-  dnl Query Python for its version number.  Getting [:3] seems to be
-  dnl the best way to do this; it's what "site.py" does in the standard
-  dnl library.
+  dnl Query Python for its version number.  Although site.py simply uses
+  dnl sys.version[:3], printing that failed with Python 3.10, since the
+  dnl trailing zero was eliminated. So now we output just the major
+  dnl and minor version numbers, as numbers. Apparently the tertiary
+  dnl version is not of interest.
 
   AC_CACHE_CHECK([for $am_display_PYTHON version], [am_cv_python_version],
-    [am_cv_python_version=`$PYTHON -c "import sys; sys.stdout.write(sys.version[[:3]])"`])
+    [am_cv_python_version=`$PYTHON -c "import sys; print('%u.%u' % sys.version_info[[:2]])"`])
   AC_SUBST([PYTHON_VERSION], [$am_cv_python_version])
 
   dnl Use the values of $prefix and $exec_prefix for the corresponding
diff --git a/configure b/configure
index d046853..64502a9 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for libevdev 1.11.0.
+# Generated by GNU Autoconf 2.69 for libevdev 1.12.0.
 #
 # Report bugs to <https://bugs.freedesktop.org/enter_bug.cgi?product=libevdev>.
 #
@@ -591,8 +591,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='libevdev'
 PACKAGE_TARNAME='libevdev'
-PACKAGE_VERSION='1.11.0'
-PACKAGE_STRING='libevdev 1.11.0'
+PACKAGE_VERSION='1.12.0'
+PACKAGE_STRING='libevdev 1.12.0'
 PACKAGE_BUGREPORT='https://bugs.freedesktop.org/enter_bug.cgi?product=libevdev'
 PACKAGE_URL='http://freedesktop.org/wiki/Software/libevdev/'
 
@@ -766,6 +766,7 @@ infodir
 docdir
 oldincludedir
 includedir
+runstatedir
 localstatedir
 sharedstatedir
 sysconfdir
@@ -856,6 +857,7 @@ datadir='${datarootdir}'
 sysconfdir='${prefix}/etc'
 sharedstatedir='${prefix}/com'
 localstatedir='${prefix}/var'
+runstatedir='${localstatedir}/run'
 includedir='${prefix}/include'
 oldincludedir='/usr/include'
 docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@@ -1108,6 +1110,15 @@ do
   | -silent | --silent | --silen | --sile | --sil)
     silent=yes ;;
 
+  -runstatedir | --runstatedir | --runstatedi | --runstated \
+  | --runstate | --runstat | --runsta | --runst | --runs \
+  | --run | --ru | --r)
+    ac_prev=runstatedir ;;
+  -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
+  | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
+  | --run=* | --ru=* | --r=*)
+    runstatedir=$ac_optarg ;;
+
   -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
     ac_prev=sbindir ;;
   -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1245,7 +1256,7 @@ fi
 for ac_var in	exec_prefix prefix bindir sbindir libexecdir datarootdir \
 		datadir sysconfdir sharedstatedir localstatedir includedir \
 		oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
-		libdir localedir mandir
+		libdir localedir mandir runstatedir
 do
   eval ac_val=\$$ac_var
   # Remove trailing slashes.
@@ -1358,7 +1369,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures libevdev 1.11.0 to adapt to many kinds of systems.
+\`configure' configures libevdev 1.12.0 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1398,6 +1409,7 @@ Fine tuning of the installation directories:
   --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
   --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
   --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
+  --runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run]
   --libdir=DIR            object code libraries [EPREFIX/lib]
   --includedir=DIR        C header files [PREFIX/include]
   --oldincludedir=DIR     C header files for non-gcc [/usr/include]
@@ -1428,7 +1440,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of libevdev 1.11.0:";;
+     short | recursive ) echo "Configuration of libevdev 1.12.0:";;
    esac
   cat <<\_ACEOF
 
@@ -1552,7 +1564,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-libevdev configure 1.11.0
+libevdev configure 1.12.0
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1921,7 +1933,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by libevdev $as_me 1.11.0, which was
+It was created by libevdev $as_me 1.12.0, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -4160,7 +4172,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='libevdev'
- VERSION='1.11.0'
+ VERSION='1.12.0'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -13047,7 +13059,7 @@ $as_echo_n "checking for $am_display_PYTHON version... " >&6; }
 if ${am_cv_python_version+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  am_cv_python_version=`$PYTHON -c "import sys; sys.stdout.write(sys.version[:3])"`
+  am_cv_python_version=`$PYTHON -c "import sys; print('%u.%u' % sys.version_info[:2])"`
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_python_version" >&5
 $as_echo "$am_cv_python_version" >&6; }
@@ -13819,7 +13831,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by libevdev $as_me 1.11.0, which was
+This file was extended by libevdev $as_me 1.12.0, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -13886,7 +13898,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-libevdev config.status 1.11.0
+libevdev config.status 1.12.0
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
diff --git a/configure.ac b/configure.ac
index f06759c..119c2a9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -7,7 +7,7 @@ AC_PREREQ([2.62])
 
 # change meson version too
 AC_INIT([libevdev],
-        [1.11.0],
+        [1.12.0],
         [https://bugs.freedesktop.org/enter_bug.cgi?product=libevdev],
         [libevdev],
         [http://freedesktop.org/wiki/Software/libevdev/])
diff --git a/doc/Makefile.in b/doc/Makefile.in
index 511ac97..1650f8e 100644
--- a/doc/Makefile.in
+++ b/doc/Makefile.in
@@ -285,6 +285,7 @@ program_transform_name = @program_transform_name@
 psdir = @psdir@
 pyexecdir = @pyexecdir@
 pythondir = @pythondir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
diff --git a/include/linux/linux/input-event-codes.h b/include/linux/linux/input-event-codes.h
index ee93428..225ec87 100644
--- a/include/linux/linux/input-event-codes.h
+++ b/include/linux/linux/input-event-codes.h
@@ -611,6 +611,7 @@
 #define KEY_VOICECOMMAND		0x246	/* Listening Voice Command */
 #define KEY_ASSISTANT		0x247	/* AL Context-aware desktop assistant */
 #define KEY_KBD_LAYOUT_NEXT	0x248	/* AC Next Keyboard Layout Select */
+#define KEY_EMOJI_PICKER	0x249	/* Show/hide emoji picker (HUTRR101) */
 
 #define KEY_BRIGHTNESS_MIN		0x250	/* Set Brightness to Minimum */
 #define KEY_BRIGHTNESS_MAX		0x251	/* Set Brightness to Maximum */
diff --git a/include/linux/linux/input.h b/include/linux/linux/input.h
index 537d23e..9826a58 100644
--- a/include/linux/linux/input.h
+++ b/include/linux/linux/input.h
@@ -82,7 +82,7 @@ struct input_id {
  * in units per radian.
  * When INPUT_PROP_ACCELEROMETER is set the resolution changes.
  * The main axes (ABS_X, ABS_Y, ABS_Z) are then reported in
- * in units per g (units/g) and in units per degree per second
+ * units per g (units/g) and in units per degree per second
  * (units/deg/s) for rotational axes (ABS_RX, ABS_RY, ABS_RZ).
  */
 struct input_absinfo {
diff --git a/libevdev/Makefile.in b/libevdev/Makefile.in
index 4ace237..30f6ceb 100644
--- a/libevdev/Makefile.in
+++ b/libevdev/Makefile.in
@@ -340,6 +340,7 @@ program_transform_name = @program_transform_name@
 psdir = @psdir@
 pyexecdir = @pyexecdir@
 pythondir = @pythondir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
diff --git a/libevdev/libevdev-uinput.h b/libevdev/libevdev-uinput.h
index 2401a78..b54ec02 100644
--- a/libevdev/libevdev-uinput.h
+++ b/libevdev/libevdev-uinput.h
@@ -42,14 +42,13 @@ struct libevdev_uinput;
  *
  * @code
  * int err;
- * int fd, new_fd, uifd;
+ * int fd, uifd;
  * struct libevdev *dev;
  * struct libevdev_uinput *uidev;
- * struct input_event ev[2];
  *
  * fd = open("/dev/input/event0", O_RDONLY);
  * if (fd < 0)
- *     return err;
+ *     return -errno;
  *
  * err = libevdev_new_from_fd(fd, &dev);
  * if (err != 0)
@@ -67,7 +66,7 @@ struct libevdev_uinput;
  * err = libevdev_uinput_write_event(uidev, EV_REL, REL_X, -1);
  * if (err != 0)
  *     return err;
- * libevdev_uinput_write_event(uidev, EV_SYN, SYN_REPORT, 0);
+ * err = libevdev_uinput_write_event(uidev, EV_SYN, SYN_REPORT, 0);
  * if (err != 0)
  *     return err;
  *
@@ -109,7 +108,7 @@ struct libevdev_uinput;
  */
 
 enum libevdev_uinput_open_mode {
-	/* intentionally -2 to avoid to avoid code like the below from accidentally working:
+	/* intentionally -2 to avoid code like below from accidentally working:
 		fd = open("/dev/uinput", O_RDWR); // fails, fd is -1
 		libevdev_uinput_create_from_device(dev, fd, &uidev); // may hide the error */
 	LIBEVDEV_UINPUT_OPEN_MANAGED = -2  /**< let libevdev open and close @c /dev/uinput */
@@ -188,7 +187,7 @@ int libevdev_uinput_get_fd(const struct libevdev_uinput *uinput_dev);
  * @ingroup uinput
  *
  * Return the syspath representing this uinput device. If the UI_GET_SYSNAME
- * ioctl not available, libevdev makes an educated guess.
+ * ioctl is not available, libevdev makes an educated guess.
  * The UI_GET_SYSNAME ioctl is available since Linux 3.15.
  *
  * The syspath returned is the one of the input node itself
@@ -197,8 +196,8 @@ int libevdev_uinput_get_fd(const struct libevdev_uinput *uinput_dev);
  *
  * @note This function may return NULL if UI_GET_SYSNAME is not available.
  * In that case, libevdev uses ctime and the device name to guess devices.
- * To avoid false positives, wait at least wait at least 1.5s between
- * creating devices that have the same name.
+ * To avoid false positives, wait at least 1.5s between creating devices that
+ * have the same name.
  *
  * @note FreeBSD does not have sysfs, on FreeBSD this function always returns
  * NULL.
@@ -221,7 +220,7 @@ const char* libevdev_uinput_get_syspath(struct libevdev_uinput *uinput_dev);
  * @note This function may return NULL. libevdev may have to guess the
  * syspath and the device node. See libevdev_uinput_get_syspath() for details.
  *
- * @note On FreeBSD, this function can not return NULL.  libudev uses the
+ * @note On FreeBSD, this function can not return NULL. libudev uses the
  * UI_GET_SYSNAME ioctl to get the device node on this platform and if that
  * fails, the call to libevdev_uinput_create_from_device() fails.
  *
diff --git a/libevdev/libevdev.h b/libevdev/libevdev.h
index 69b1dc3..30e4d6f 100644
--- a/libevdev/libevdev.h
+++ b/libevdev/libevdev.h
@@ -634,7 +634,7 @@ extern "C" {
  *         return ENOMEM;
  *
  * err = libevdev_set_fd(dev, fd);
- * if (err < 0) {
+ * if (err < 0)
  *         printf("Failed (errno %d): %s\n", -err, strerror(-err));
  *
  * libevdev_free(dev);
diff --git a/libevdev/make-event-names.py b/libevdev/make-event-names.py
index 88addd7..743b4b5 100755
--- a/libevdev/make-event-names.py
+++ b/libevdev/make-event-names.py
@@ -70,10 +70,10 @@ def print_bits(bits, prefix):
     if not hasattr(bits, prefix):
         return
     print("static const char * const %s_map[%s_MAX + 1] = {" % (prefix, prefix.upper()))
-    for val, name in list(getattr(bits, prefix).items()):
+    for val, name in sorted(list(getattr(bits, prefix).items())):
         print("    [%s] = \"%s\"," % (name, name))
     if prefix == "key":
-        for val, name in list(getattr(bits, "btn").items()):
+        for val, name in sorted(list(getattr(bits, "btn").items())):
             print("    [%s] = \"%s\"," % (name, name))
     print("};")
     print("")
@@ -118,7 +118,7 @@ def print_lookup(bits, prefix):
     if not hasattr(bits, prefix):
         return
 
-    names = list(getattr(bits, prefix).items())
+    names = sorted(list(getattr(bits, prefix).items()))
     if prefix == "btn":
         names = names + btn_additional
 
diff --git a/meson.build b/meson.build
index 531e8ab..8b5ccf7 100644
--- a/meson.build
+++ b/meson.build
@@ -1,5 +1,5 @@
 project('libevdev', 'c',
-	version: '1.11.0', # change autotools version too
+	version: '1.12.0', # change autotools version too
 	license: 'MIT/Expat',
 	default_options: [ 'c_std=gnu99', 'warning_level=2' ],
 	meson_version: '>= 0.47.0')
@@ -37,6 +37,7 @@ config_h.set('_GNU_SOURCE', '1')
 # Dependencies
 pkgconfig = import('pkgconfig')
 dep_lm = cc.find_library('m')
+dep_rt = cc.find_library('rt')
 
 input_h = join_paths(meson.source_root(), 'include', 'linux', host_machine.system(), 'input.h')
 uinput_h = join_paths(meson.source_root(), 'include', 'linux', host_machine.system(), 'uinput.h')
@@ -76,7 +77,7 @@ version_flag = '-Wl,--version-script, at 0@'.format(mapfile)
 lib_libevdev = library('evdev',
 	src_libevdev,
 	include_directories: [includes_include],
-	dependencies: [],
+	dependencies: [dep_rt],
 	version: libevdev_so_version,
 	link_args: version_flag,
 	link_depends: mapfile,
@@ -108,6 +109,11 @@ executable('libevdev-events',
 	   include_directories: [includes_include],
 	   dependencies: dep_libevdev,
 	   install: false)
+executable('libevdev-list-codes',
+	   sources: ['tools/libevdev-list-codes.c'],
+	   include_directories: [includes_include],
+	   dependencies: dep_libevdev,
+	   install: false)
 executable('touchpad-edge-detector',
 	   sources: ['tools/touchpad-edge-detector.c'],
 	   include_directories: [includes_include],
diff --git a/test/Makefile.in b/test/Makefile.in
index e59d09a..b18855e 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -653,6 +653,7 @@ program_transform_name = @program_transform_name@
 psdir = @psdir@
 pyexecdir = @pyexecdir@
 pythondir = @pythondir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 86222f7..83d6700 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -1,4 +1,4 @@
-noinst_PROGRAMS = libevdev-events
+noinst_PROGRAMS = libevdev-events libevdev-list-codes
 bin_PROGRAMS = \
 	       touchpad-edge-detector \
 	       mouse-dpi-tool \
@@ -10,6 +10,9 @@ libevdev_ldadd = $(top_builddir)/libevdev/libevdev.la
 libevdev_events_SOURCES = libevdev-events.c
 libevdev_events_LDADD = $(libevdev_ldadd)
 
+libevdev_list_codes_SOURCES = libevdev-list-codes.c
+libevdev_list_codes_LDADD = $(libevdev_ldadd)
+
 touchpad_edge_detector_SOURCES = touchpad-edge-detector.c
 touchpad_edge_detector_LDADD = $(libevdev_ldadd)
 
diff --git a/tools/Makefile.in b/tools/Makefile.in
index e63a12f..76bdbfe 100644
--- a/tools/Makefile.in
+++ b/tools/Makefile.in
@@ -88,7 +88,8 @@ PRE_UNINSTALL = :
 POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
-noinst_PROGRAMS = libevdev-events$(EXEEXT)
+noinst_PROGRAMS = libevdev-events$(EXEEXT) \
+	libevdev-list-codes$(EXEEXT)
 bin_PROGRAMS = touchpad-edge-detector$(EXEEXT) mouse-dpi-tool$(EXEEXT) \
 	libevdev-tweak-device$(EXEEXT)
 subdir = tools
@@ -113,6 +114,9 @@ AM_V_lt = $(am__v_lt_ at AM_V@)
 am__v_lt_ = $(am__v_lt_ at AM_DEFAULT_V@)
 am__v_lt_0 = --silent
 am__v_lt_1 = 
+am_libevdev_list_codes_OBJECTS = libevdev-list-codes.$(OBJEXT)
+libevdev_list_codes_OBJECTS = $(am_libevdev_list_codes_OBJECTS)
+libevdev_list_codes_DEPENDENCIES = $(libevdev_ldadd)
 am_libevdev_tweak_device_OBJECTS = libevdev-tweak-device.$(OBJEXT)
 libevdev_tweak_device_OBJECTS = $(am_libevdev_tweak_device_OBJECTS)
 libevdev_tweak_device_DEPENDENCIES = $(libevdev_ldadd)
@@ -138,6 +142,7 @@ DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
 depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp
 am__maybe_remake_depfiles = depfiles
 am__depfiles_remade = ./$(DEPDIR)/libevdev-events.Po \
+	./$(DEPDIR)/libevdev-list-codes.Po \
 	./$(DEPDIR)/libevdev-tweak-device.Po \
 	./$(DEPDIR)/mouse-dpi-tool.Po \
 	./$(DEPDIR)/touchpad-edge-detector.Po
@@ -160,9 +165,11 @@ AM_V_CCLD = $(am__v_CCLD_ at AM_V@)
 am__v_CCLD_ = $(am__v_CCLD_ at AM_DEFAULT_V@)
 am__v_CCLD_0 = @echo "  CCLD    " $@;
 am__v_CCLD_1 = 
-SOURCES = $(libevdev_events_SOURCES) $(libevdev_tweak_device_SOURCES) \
-	$(mouse_dpi_tool_SOURCES) $(touchpad_edge_detector_SOURCES)
+SOURCES = $(libevdev_events_SOURCES) $(libevdev_list_codes_SOURCES) \
+	$(libevdev_tweak_device_SOURCES) $(mouse_dpi_tool_SOURCES) \
+	$(touchpad_edge_detector_SOURCES)
 DIST_SOURCES = $(libevdev_events_SOURCES) \
+	$(libevdev_list_codes_SOURCES) \
 	$(libevdev_tweak_device_SOURCES) $(mouse_dpi_tool_SOURCES) \
 	$(touchpad_edge_detector_SOURCES)
 am__can_run_installinfo = \
@@ -351,6 +358,7 @@ program_transform_name = @program_transform_name@
 psdir = @psdir@
 pyexecdir = @pyexecdir@
 pythondir = @pythondir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
@@ -363,6 +371,8 @@ AM_CPPFLAGS = $(GCC_CFLAGS) -I$(top_srcdir) -I$(top_srcdir)/include -I$(top_srcd
 libevdev_ldadd = $(top_builddir)/libevdev/libevdev.la
 libevdev_events_SOURCES = libevdev-events.c
 libevdev_events_LDADD = $(libevdev_ldadd)
+libevdev_list_codes_SOURCES = libevdev-list-codes.c
+libevdev_list_codes_LDADD = $(libevdev_ldadd)
 touchpad_edge_detector_SOURCES = touchpad-edge-detector.c
 touchpad_edge_detector_LDADD = $(libevdev_ldadd)
 mouse_dpi_tool_SOURCES = mouse-dpi-tool.c
@@ -470,6 +480,10 @@ libevdev-events$(EXEEXT): $(libevdev_events_OBJECTS) $(libevdev_events_DEPENDENC
 	@rm -f libevdev-events$(EXEEXT)
 	$(AM_V_CCLD)$(LINK) $(libevdev_events_OBJECTS) $(libevdev_events_LDADD) $(LIBS)
 
+libevdev-list-codes$(EXEEXT): $(libevdev_list_codes_OBJECTS) $(libevdev_list_codes_DEPENDENCIES) $(EXTRA_libevdev_list_codes_DEPENDENCIES) 
+	@rm -f libevdev-list-codes$(EXEEXT)
+	$(AM_V_CCLD)$(LINK) $(libevdev_list_codes_OBJECTS) $(libevdev_list_codes_LDADD) $(LIBS)
+
 libevdev-tweak-device$(EXEEXT): $(libevdev_tweak_device_OBJECTS) $(libevdev_tweak_device_DEPENDENCIES) $(EXTRA_libevdev_tweak_device_DEPENDENCIES) 
 	@rm -f libevdev-tweak-device$(EXEEXT)
 	$(AM_V_CCLD)$(LINK) $(libevdev_tweak_device_OBJECTS) $(libevdev_tweak_device_LDADD) $(LIBS)
@@ -489,6 +503,7 @@ distclean-compile:
 	-rm -f *.tab.c
 
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libevdev-events.Po at am__quote@ # am--include-marker
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libevdev-list-codes.Po at am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libevdev-tweak-device.Po at am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/mouse-dpi-tool.Po at am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/touchpad-edge-detector.Po at am__quote@ # am--include-marker
@@ -701,6 +716,7 @@ clean-am: clean-binPROGRAMS clean-generic clean-libtool \
 
 distclean: distclean-am
 		-rm -f ./$(DEPDIR)/libevdev-events.Po
+	-rm -f ./$(DEPDIR)/libevdev-list-codes.Po
 	-rm -f ./$(DEPDIR)/libevdev-tweak-device.Po
 	-rm -f ./$(DEPDIR)/mouse-dpi-tool.Po
 	-rm -f ./$(DEPDIR)/touchpad-edge-detector.Po
@@ -750,6 +766,7 @@ installcheck-am:
 
 maintainer-clean: maintainer-clean-am
 		-rm -f ./$(DEPDIR)/libevdev-events.Po
+	-rm -f ./$(DEPDIR)/libevdev-list-codes.Po
 	-rm -f ./$(DEPDIR)/libevdev-tweak-device.Po
 	-rm -f ./$(DEPDIR)/mouse-dpi-tool.Po
 	-rm -f ./$(DEPDIR)/touchpad-edge-detector.Po
diff --git a/tools/libevdev-list-codes.c b/tools/libevdev-list-codes.c
new file mode 100644
index 0000000..8d4f7c2
--- /dev/null
+++ b/tools/libevdev-list-codes.c
@@ -0,0 +1,47 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2021 Red Hat, Inc.
+ */
+
+/* Lists all event types and codes currently known by libevdev. */
+
+#include "config.h"
+
+#include <stdio.h>
+#include <linux/input.h>
+#include "libevdev/libevdev.h"
+
+static void
+list_event_codes(unsigned int type, unsigned int max)
+{
+	const char *typestr = libevdev_event_type_get_name(type);
+
+	if (!typestr)
+		return;
+
+	printf("- %s:\n", typestr);
+
+	for (unsigned int code = 0; code <= max; code++) {
+		const char *str = libevdev_event_code_get_name(type, code);
+
+		if (!str)
+			continue;
+
+		printf("    %d: %s\n", code, str);
+	}
+}
+
+int
+main (int argc, char **argv)
+{
+	printf("codes:\n");
+	for (unsigned int type = 0; type <= EV_MAX; type++) {
+		int max = libevdev_event_type_get_max(type);
+		if (max == -1)
+			continue;
+
+		list_event_codes(type, (unsigned int)max);
+	}
+
+	return 0;
+}



More information about the Neon-commits mailing list