[PATCH 5/6] Allow compiling against older headers

Peter Hutterer peter.hutterer at who-t.net
Thu Sep 28 21:05:34 UTC 2017


On Wed, Sep 27, 2017 at 10:58:30AM -0700, Dmitry Torokhov wrote:
> Instead of requiring to compile against the newest kernel headers or
> lose newer certain event definitions, let's check for the presence of
> "official" defines and add missing ones ourselves (they form ABI so
> there is no risk of them changing and getting out of sync). This allows
> us to produce fully-functional version of evtest even if kernel headers
> on the build system are slightly older.
> 
> Signed-off-by: Dmitry Torokhov <dtor at chromium.org>

tbh, I'm not a big fan of this patch. The main reason I'm keeping evtest
alive is because it's a single file and can still be compiled with a simple
'gcc evtest.c' without having to worry about automake, dependencies, etc.
Once that advantage goes away evtest is a less-featureful cousin to
evemu-record. And that has the advantage of being replayable.

That aside, Martin's suggestion of just adding linux/input(-event-codes).h
would be a better choice here, that should keep the `gcc evtest.c` option
alive.

Cheers,
   Peter

> ---
>  event-codes.h | 546 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  evtest.c      | 330 +++++++++--------------------------
>  2 files changed, 632 insertions(+), 244 deletions(-)
>  create mode 100644 event-codes.h
> 
> diff --git a/event-codes.h b/event-codes.h
> new file mode 100644
> index 0000000..0231b33
> --- /dev/null
> +++ b/event-codes.h
> @@ -0,0 +1,546 @@
> +/*
> + *  Copyright (c) 2017 Google, Inc
> + */
> +
> +/*
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + */
> +
> +#include <linux/input.h>
> +
> +/*
> + * Device properties and quirks
> + */
> +
> +#ifndef INPUT_PROP_SEMI_MT
> +#define INPUT_PROP_POINTER		0x00
> +#define INPUT_PROP_DIRECT		0x01
> +#define INPUT_PROP_BUTTONPAD		0x02
> +#define INPUT_PROP_SEMI_MT		0x03
> +#endif
> +
> +#ifndef INPUT_PROP_TOPBUTTONPAD
> +#define INPUT_PROP_TOPBUTTONPAD		0x04
> +#endif
> +
> +#ifndef INPUT_PROP_POINTING_STICK
> +#define INPUT_PROP_POINTING_STICK	0x05
> +#endif
> +
> +#ifndef INPUT_PROP_ACCELEROMETER
> +#define INPUT_PROP_ACCELEROMETER	0x06
> +#endif
> +
> +#define LOCAL_INPUT_PROP_MAX		0x1f
> +#ifndef INPUT_PROP_MAX
> +#define INPUT_PROP_MAX			LOCAL_INPUT_PROP_MAX
> +#endif
> +
> +/*
> + * Event types
> + */
> +
> +#ifndef EV_SYN
> +#define EV_SYN				0
> +#endif
> +
> +#define LOCAL_EV_MAX			0x1f
> +#ifndef EV_MAX
> +#define EV_MAX				LOCAL_EV_MAX
> +#endif
> +
> +/*
> + * Synchronization events.
> + */
> +
> +#ifndef SYN_MT_REPORT
> +#define SYN_MT_REPORT			2
> +#endif
> +
> +#ifndef SYN_DROPPED
> +#define SYN_DROPPED			3
> +#endif
> +
> +#define LOCAL_SYN_MAX			3
> +#ifndef SYN_MAX
> +#define SYN_MAX				LOCAL_SYN_MAX
> +#endif
> +
> +/*
> + * Keys and buttons
> + */
> +
> +#ifndef KEY_SCALE
> +#define KEY_SCALE			120
> +#endif
> +
> +#ifndef KEY_DASHBOARD
> +#define KEY_DASHBOARD			204
> +#endif
> +
> +#ifndef KEY_WWAN
> +#define KEY_WLAN			238
> +#endif
> +
> +#ifndef KEY_UWB
> +#define KEY_UWB				239
> +#endif
> +
> +#ifndef KEY_VIDEO_NEXT
> +#define KEY_VIDEO_NEXT			241
> +#define KEY_VIDEO_PREV			242
> +#define KEY_BRIGHTNESS_CYCLE		243
> +#define KEY_DISPLAY_OFF			245
> +#endif
> +
> +#ifndef KEY_BRIGHTNESS_AUTO
> +#define KEY_BRIGHTNESS_AUTO		244
> +#endif
> +
> +#ifndef KEY_WWAN
> +#define KEY_WWAN			246
> +#endif
> +
> +#ifndef KEY_RFKILL
> +#define KEY_RFKILL			247
> +#endif
> +
> +#ifndef KEY_MICMUTE
> +#define KEY_MICMUTE			248
> +#endif
> +
> +#ifndef BTN_SOUTH
> +#define BTN_SOUTH			0x130
> +#define BTN_EAST			0x131
> +#define BTN_NORTH			0x133
> +#define BTN_WEST			0x134
> +#endif
> +
> +#ifndef BTN_TOOL_QUINTTAP
> +#define BTN_TOOL_QUINTTAP		0x148
> +#endif
> +
> +#ifndef BTN_TOOL_QUADTAP
> +#define BTN_TOOL_QUADTAP		0x14f
> +#endif
> +
> +#ifndef KEY_SPELLCHECK
> +#define KEY_SPELLCHECK			0x1b0
> +#endif
> +
> +#ifndef KEY_LOGOFF
> +#define KEY_LOGOFF			0x1b1
> +#endif
> +
> +#ifndef KEY_DOLLAR
> +#define KEY_DOLLAR			0x1b2
> +#endif
> +
> +#ifndef KEY_EURO
> +#define KEY_EURO			0x1b3
> +#endif
> +
> +#ifndef KEY_FRAMEBACK
> +#define KEY_FRAMEBACK			0x1b4
> +#define KEY_FRAMEFORWARD		0x1b5
> +#endif
> +
> +#ifndef KEY_CONTEXT_MENU
> +#define KEY_CONTEXT_MENU		0x1b6
> +#endif
> +
> +#ifndef KEY_MEDIA_REPEAT
> +#define KEY_MEDIA_REPEAT		0x1b7
> +#endif
> +
> +#ifndef KEY_10CHANNELSUP
> +#define KEY_10CHANNELSUP		0x1b8
> +#define KEY_10CHANNELSDOWN		0x1b9
> +#endif
> +
> +#ifndef KEY_IMAGES
> +#define KEY_IMAGES			0x1ba
> +#endif
> +
> +#ifndef KEY_FN
> +#define KEY_FN				0x1d0
> +#define KEY_FN_ESC			0x1d1
> +#define KEY_FN_F1			0x1d2
> +#define KEY_FN_F2			0x1d3
> +#define KEY_FN_F3			0x1d4
> +#define KEY_FN_F4			0x1d5
> +#define KEY_FN_F5			0x1d6
> +#define KEY_FN_F6			0x1d7
> +#define KEY_FN_F7			0x1d8
> +#define KEY_FN_F8			0x1d9
> +#define KEY_FN_F9			0x1da
> +#define KEY_FN_F10			0x1db
> +#define KEY_FN_F11			0x1dc
> +#define KEY_FN_F12			0x1dd
> +#define KEY_FN_1			0x1de
> +#define KEY_FN_2			0x1df
> +#define KEY_FN_D			0x1e0
> +#define KEY_FN_E			0x1e1
> +#define KEY_FN_F			0x1e2
> +#define KEY_FN_S			0x1e3
> +#define KEY_FN_B			0x1e4
> +#endif
> +
> +#ifndef KEY_BRL_DOT1
> +#define KEY_BRL_DOT1			0x1f1
> +#define KEY_BRL_DOT2			0x1f2
> +#define KEY_BRL_DOT3			0x1f3
> +#define KEY_BRL_DOT4			0x1f4
> +#define KEY_BRL_DOT5			0x1f5
> +#define KEY_BRL_DOT6			0x1f6
> +#define KEY_BRL_DOT7			0x1f7
> +#define KEY_BRL_DOT8			0x1f8
> +#define KEY_BRL_DOT9			0x1f9
> +#define KEY_BRL_DOT10			0x1fa
> +#endif
> +
> +#ifndef KEY_NUMERIC_0
> +#define KEY_NUMERIC_0			0x200
> +#define KEY_NUMERIC_1			0x201
> +#define KEY_NUMERIC_2			0x202
> +#define KEY_NUMERIC_3			0x203
> +#define KEY_NUMERIC_4			0x204
> +#define KEY_NUMERIC_5			0x205
> +#define KEY_NUMERIC_6			0x206
> +#define KEY_NUMERIC_7			0x207
> +#define KEY_NUMERIC_8			0x208
> +#define KEY_NUMERIC_9			0x209
> +#define KEY_NUMERIC_STAR		0x20a
> +#define KEY_NUMERIC_POUND		0x20b
> +#define KEY_NUMERIC_A			0x20c
> +#define KEY_NUMERIC_B			0x20d
> +#define KEY_NUMERIC_C			0x20e
> +#define KEY_NUMERIC_D			0x20f
> +#endif
> +
> +#ifndef KEY_CAMERA_FOCUS
> +#define KEY_CAMERA_FOCUS		0x210
> +#endif
> +
> +#ifndef KEY_WPS_BUTTON
> +#define KEY_WPS_BUTTON			0x211
> +#endif
> +
> +#ifndef KEY_TOUCHPAD_TOGGLE
> +#define KEY_TOUCHPAD_TOGGLE		0x212
> +#define KEY_TOUCHPAD_ON			0x213
> +#define KEY_TOUCHPAD_OFF		0x214
> +#endif
> +
> +#ifndef KEY_CAMERA_ZOOMIN
> +#define KEY_CAMERA_ZOOMIN		0x215
> +#define KEY_CAMERA_ZOOMOUT		0x216
> +#define KEY_CAMERA_UP			0x217
> +#define KEY_CAMERA_DOWN			0x218
> +#define KEY_CAMERA_LEFT			0x219
> +#define KEY_CAMERA_RIGHT		0x21a
> +#endif
> +
> +#ifndef KEY_ATTENDANT_ON
> +#define KEY_ATTENDANT_ON		0x21b
> +#define KEY_ATTENDANT_OFF		0x21c
> +#define KEY_ATTENDANT_TOGGLE		0x21d
> +#define KEY_LIGHTS_TOGGLE		0x21e
> +#endif
> +
> +#ifndef BTN_DPAD_UP
> +#define BTN_DPAD_UP			0x220
> +#define BTN_DPAD_DOWN			0x221
> +#define BTN_DPAD_LEFT			0x222
> +#define BTN_DPAD_RIGHT			0x223
> +#endif
> +
> +#ifndef KEY_ALS_TOGGLE
> +#define KEY_ALS_TOGGLE			0x230
> +#endif
> +
> +#ifndef KEY_BUTTONCONFIG
> +#define KEY_BUTTONCONFIG		0x240
> +#define KEY_TASKMANAGER			0x241
> +#define KEY_JOURNAL			0x242
> +#define KEY_CONTROLPANEL		0x243
> +#define KEY_APPSELECT			0x244
> +#define KEY_SCREENSAVER			0x245
> +#define KEY_VOICECOMMAND		0x246
> +#endif
> +
> +#ifndef KEY_ASSISTANT
> +#define KEY_ASSISTANT			0x247
> +#endif
> +
> +#ifndef KEY_BRIGHTNESS_MIN
> +#define KEY_BRIGHTNESS_MIN		0x250
> +#define KEY_BRIGHTNESS_MAX		0x251
> +#endif
> +
> +#ifndef KEY_KBDINPUTASSIST_PREV
> +#define KEY_KBDINPUTASSIST_PREV		0x260
> +#define KEY_KBDINPUTASSIST_NEXT		0x261
> +#define KEY_KBDINPUTASSIST_PREVGROUP	0x262
> +#define KEY_KBDINPUTASSIST_NEXTGROUP	0x263
> +#define KEY_KBDINPUTASSIST_ACCEPT	0x264
> +#define KEY_KBDINPUTASSIST_CANCEL	0x265
> +#endif
> +
> +#ifndef KEY_RIGHT_UP
> +#define KEY_RIGHT_UP			0x266
> +#define KEY_RIGHT_DOWN			0x267
> +#define KEY_LEFT_UP			0x268
> +#define KEY_LEFT_DOWN			0x269
> +#endif
> +
> +#ifndef KEY_ROOT_MENU
> +#define KEY_ROOT_MENU			0x26a
> +#define KEY_MEDIA_TOP_MENU		0x26b
> +#define KEY_AUDIO_DESC			0x26e
> +#define KEY_3D_MODE			0x26f
> +#define KEY_NEXT_FAVORITE		0x270
> +#define KEY_STOP_RECORD			0x271
> +#define KEY_PAUSE_RECORD		0x272
> +#define KEY_VOD				0x273
> +#define KEY_UNMUTE			0x274
> +#define KEY_FASTREVERSE			0x275
> +#define KEY_SLOWREVERSE			0x276
> +#endif
> +
> +#ifndef KEY_NUMERIC_11
> +#define KEY_NUMERIC_11			0x26c
> +#define KEY_NUMERIC_12			0x26d
> +#endif
> +
> +#ifndef KEY_DATA
> +#define KEY_DATA			0x277
> +#endif
> +
> +#ifndef KEY_ONSCREEN_KEYBOARD
> +#define KEY_ONSCREEN_KEYBOARD		0x278
> +#endif
> +
> +#ifndef BTN_TRIGGER_HAPPY
> +#define BTN_TRIGGER_HAPPY		0x2c0
> +#define BTN_TRIGGER_HAPPY1		0x2c0
> +#define BTN_TRIGGER_HAPPY2		0x2c1
> +#define BTN_TRIGGER_HAPPY3		0x2c2
> +#define BTN_TRIGGER_HAPPY4		0x2c3
> +#define BTN_TRIGGER_HAPPY5		0x2c4
> +#define BTN_TRIGGER_HAPPY6		0x2c5
> +#define BTN_TRIGGER_HAPPY7		0x2c6
> +#define BTN_TRIGGER_HAPPY8		0x2c7
> +#define BTN_TRIGGER_HAPPY9		0x2c8
> +#define BTN_TRIGGER_HAPPY10		0x2c9
> +#define BTN_TRIGGER_HAPPY11		0x2ca
> +#define BTN_TRIGGER_HAPPY12		0x2cb
> +#define BTN_TRIGGER_HAPPY13		0x2cc
> +#define BTN_TRIGGER_HAPPY14		0x2cd
> +#define BTN_TRIGGER_HAPPY15		0x2ce
> +#define BTN_TRIGGER_HAPPY16		0x2cf
> +#define BTN_TRIGGER_HAPPY17		0x2d0
> +#define BTN_TRIGGER_HAPPY18		0x2d1
> +#define BTN_TRIGGER_HAPPY19		0x2d2
> +#define BTN_TRIGGER_HAPPY20		0x2d3
> +#define BTN_TRIGGER_HAPPY21		0x2d4
> +#define BTN_TRIGGER_HAPPY22		0x2d5
> +#define BTN_TRIGGER_HAPPY23		0x2d6
> +#define BTN_TRIGGER_HAPPY24		0x2d7
> +#define BTN_TRIGGER_HAPPY25		0x2d8
> +#define BTN_TRIGGER_HAPPY26		0x2d9
> +#define BTN_TRIGGER_HAPPY27		0x2da
> +#define BTN_TRIGGER_HAPPY28		0x2db
> +#define BTN_TRIGGER_HAPPY29		0x2dc
> +#define BTN_TRIGGER_HAPPY30		0x2dd
> +#define BTN_TRIGGER_HAPPY31		0x2de
> +#define BTN_TRIGGER_HAPPY32		0x2df
> +#define BTN_TRIGGER_HAPPY33		0x2e0
> +#define BTN_TRIGGER_HAPPY34		0x2e1
> +#define BTN_TRIGGER_HAPPY35		0x2e2
> +#define BTN_TRIGGER_HAPPY36		0x2e3
> +#define BTN_TRIGGER_HAPPY37		0x2e4
> +#define BTN_TRIGGER_HAPPY38		0x2e5
> +#define BTN_TRIGGER_HAPPY39		0x2e6
> +#define BTN_TRIGGER_HAPPY40		0x2e7
> +#endif
> +
> +#define LOCAL_KEY_MAX			0x2ff
> +#ifndef KEY_MAX
> +#define KEY_MAX				LOCAL_KEY_MAX
> +#endif
> +
> +/*
> + * Relative axes
> + */
> +
> +#define LOCAL_REL_MAX			0x0f
> +#ifndef REL_MAX
> +#define REL_MAX				LOCAL_REL_MAX
> +#endif
> +
> +/*
> + * Absolute axes
> + */
> +
> +#ifndef ABS_MT_SLOT
> +#define ABS_MT_SLOT			0x2f
> +#endif
> +
> +#ifndef ABS_MT_BLOB_ID
> +#define ABS_MT_TOUCH_MAJOR		0x30
> +#define ABS_MT_TOUCH_MINOR		0x31
> +#define ABS_MT_WIDTH_MAJOR		0x32
> +#define ABS_MT_WIDTH_MINOR		0x33
> +#define ABS_MT_ORIENTATION		0x34
> +#define ABS_MT_POSITION_X		0x35
> +#define ABS_MT_POSITION_Y		0x36
> +#define ABS_MT_TOOL_TYPE		0x37
> +#define ABS_MT_BLOB_ID			0x38
> +#endif
> +
> +#ifndef ABS_MT_TRACKING_ID
> +#define ABS_MT_TRACKING_ID		0x39
> +#endif
> +
> +#ifndef ABS_MT_PRESSURE
> +#define ABS_MT_PRESSURE			0x3a
> +#endif
> +
> +#ifndef ABS_MT_DISTANCE
> +#define ABS_MT_DISTANCE			0x3b
> +#endif
> +
> +#ifndef ABS_MT_TOOL_X
> +#define ABS_MT_TOOL_X			0x3c
> +#define ABS_MT_TOOL_Y			0x3d
> +#endif
> +
> +#define LOCAL_ABS_MAX			0x3f
> +#ifndef ABS_MAX
> +#define ABS_MAX				LOCAL_ABS_MAX
> +#endif
> +
> +/*
> + * Switches.
> + */
> +
> +#ifndef SW_RFKILL_ALL
> +#define SW_RFKILL_ALL			0x03
> +#endif
> +
> +#ifndef SW_MICROPHONE_INSERT
> +#define SW_MICROPHONE_INSERT		0x04
> +#endif
> +
> +#ifndef SW_DOCK
> +#define SW_DOCK				0x05
> +#endif
> +
> +#ifndef SW_LINEOUT_INSERT
> +#define SW_LINEOUT_INSERT		0x06
> +#endif
> +
> +#ifndef SW_JACK_PHYSICAL_INSERT
> +#define SW_JACK_PHYSICAL_INSERT		0x07
> +#endif
> +
> +#ifndef SW_VIDEOOUT_INSERT
> +#define SW_VIDEOOUT_INSERT		0x08
> +#endif
> +
> +#ifndef SW_CAMERA_LENS_COVER
> +#define SW_CAMERA_LENS_COVER		0x09
> +#define SW_KEYPAD_SLIDE			0x0a
> +#define SW_FRONT_PROXIMITY		0x0b
> +#endif
> +
> +#ifndef SW_ROTATE_LOCK
> +#define SW_ROTATE_LOCK			0x0c
> +#endif
> +
> +#ifndef SW_LINEIN_INSERT
> +#define SW_LINEIN_INSERT		0x0d
> +#endif
> +
> +#ifndef SW_MUTE_DEVICE
> +#define SW_MUTE_DEVICE			0x0e
> +#endif
> +
> +#ifndef SW_PEN_INSERTED
> +#define SW_PEN_INSERTED			0x0f
> +#endif
> +
> +#define LOCAL_SW_MAX			0x0f
> +#ifndef SW_MAX
> +#define SW_MAX				LOCAL_SW_MAX
> +#endif
> +
> +/*
> + * Miscellaneous events
> + */
> +#ifndef MSC_TIMESTAMP
> +#define MSC_TIMESTAMP			0x05
> +#endif
> +
> +#define LOCAL_MSC_MAX			0x07
> +#ifndef MSC_MAX
> +#define MSC_MAX				LOCAL_MSC_MAX
> +#endif
> +
> +/*
> + * LEDs.
> + */
> +
> +#ifndef LED_MAIL
> +#define LED_MAIL			0x09
> +#endif
> +
> +#ifndef LED_CHARGING
> +#define LED_CHARGING			0x0a
> +#endif
> +
> +#define LOCAL_LED_MAX			0x0f
> +#ifndef LED_MAX
> +#define LED_MAX				LOCAL_LED_MAX
> +#endif
> +
> +/*
> + * Autorepeat
> + */
> +
> +#define LOCAL_REP_MAX			0x01
> +#ifndef REP_MAX
> +#define REP_MAX				LOCAL_REP_MAX
> +#endif
> +
> +/*
> + * Sounds
> + */
> +
> +#define LOCAL_SND_MAX			0x07
> +#ifndef SND_MAX
> +#define SND_MAX				LOCAL_SND_MAX
> +#endif
> +
> +/*
> + * Force feedback.
> + */
> +
> +#define LOCAL_FF_MAX			0x7f
> +#ifndef FF_MAX
> +#define FF_MAX				LOCAL_FF_MAX
> +#endif
> +
> +#define LOCAL_FF_STATUS_MAX		0x0f
> +#ifndef FF_STATUS_MAX
> +#define FF_STATUS_MAX			LOCAL_FF_STATUS_MAX
> +#endif
> diff --git a/evtest.c b/evtest.c
> index 44d3f4d..60714c6 100644
> --- a/evtest.c
> +++ b/evtest.c
> @@ -60,6 +60,8 @@
>  #include <sys/types.h>
>  #include <unistd.h>
>  
> +#include "event-codes.h"
> +
>  #define BITS_PER_LONG (sizeof(long) * 8)
>  #define NBITS(x) ((((x)-1)/BITS_PER_LONG)+1)
>  #define OFF(x)  ((x)%BITS_PER_LONG)
> @@ -70,22 +72,23 @@
>  #define DEV_INPUT_EVENT "/dev/input"
>  #define EVENT_DEV_NAME "event"
>  
> -#ifndef EV_SYN
> -#define EV_SYN 0
> -#endif
> -#ifndef SYN_MAX
> -#define SYN_MAX 3
> -#define SYN_CNT (SYN_MAX + 1)
> -#endif
> -#ifndef SYN_MT_REPORT
> -#define SYN_MT_REPORT 2
> -#endif
> -#ifndef SYN_DROPPED
> -#define SYN_DROPPED 3
> -#endif
> -
>  #define NAME_ELEMENT(element) [element] = #element
>  
> +#define max(v1, v2)		((v1) > (v2) ? (v1) : (v2))
> +#define EVTEST_EV_MAX		max(EV_MAX, LOCAL_EV_MAX)
> +#define EVTEST_SYN_MAX		max(SYN_MAX, LOCAL_SYN_MAX)
> +#define EVTEST_KEY_MAX		max(KEY_MAX, LOCAL_KEY_MAX)
> +#define EVTEST_REL_MAX		max(REL_MAX, LOCAL_REL_MAX)
> +#define EVTEST_ABS_MAX		max(ABS_MAX, LOCAL_ABS_MAX)
> +#define EVTEST_MSC_MAX		max(MSC_MAX, LOCAL_MSC_MAX)
> +#define EVTEST_SW_MAX		max(SW_MAX, LOCAL_SW_MAX)
> +#define EVTEST_LED_MAX		max(LED_MAX, LOCAL_LED_MAX)
> +#define EVTEST_SND_MAX		max(SND_MAX, LOCAL_SND_MAX)
> +#define EVTEST_REP_MAX		max(REP_MAX, LOCAL_REP_MAX)
> +#define EVTEST_FF_MAX		max(FF_MAX, LOCAL_FF_MAX)
> +#define EVTEST_FF_STATUS_MAX	max(FF_STATUS_MAX, LOCAL_FF_STATUS_MAX)
> +#define EVTEST_INPUT_PROP_MAX	max(INPUT_PROP_MAX, LOCAL_INPUT_PROP_MAX)
> +
>  enum evtest_mode {
>  	MODE_CAPTURE,
>  	MODE_QUERY,
> @@ -98,10 +101,10 @@ static const struct query_mode {
>  	int max;
>  	int rq;
>  } query_modes[] = {
> -	{ "EV_KEY", EV_KEY, KEY_MAX, EVIOCGKEY(KEY_MAX) },
> -	{ "EV_LED", EV_LED, LED_MAX, EVIOCGLED(LED_MAX) },
> -	{ "EV_SND", EV_SND, SND_MAX, EVIOCGSND(SND_MAX) },
> -	{ "EV_SW",  EV_SW, SW_MAX, EVIOCGSW(SW_MAX) },
> +	{ "EV_KEY", EV_KEY, EVTEST_KEY_MAX, EVIOCGKEY(EVTEST_KEY_MAX) },
> +	{ "EV_LED", EV_LED, EVTEST_LED_MAX, EVIOCGLED(EVTEST_LED_MAX) },
> +	{ "EV_SND", EV_SND, EVTEST_SND_MAX, EVIOCGSND(EVTEST_SND_MAX) },
> +	{ "EV_SW",  EV_SW, EVTEST_SW_MAX, EVIOCGSW(EVTEST_SW_MAX) },
>  };
>  
>  static int grab_flag = 0;
> @@ -171,8 +174,8 @@ static const struct query_mode *find_query_mode(const char *query_mode)
>  	}
>  }
>  
> -static const char * const events[EV_MAX + 1] = {
> -	[0 ... EV_MAX] = NULL,
> +static const char * const events[EVTEST_EV_MAX + 1] = {
> +	[0 ... EVTEST_EV_MAX] = NULL,
>  	NAME_ELEMENT(EV_SYN),			NAME_ELEMENT(EV_KEY),
>  	NAME_ELEMENT(EV_REL),			NAME_ELEMENT(EV_ABS),
>  	NAME_ELEMENT(EV_MSC),			NAME_ELEMENT(EV_LED),
> @@ -181,8 +184,8 @@ static const char * const events[EV_MAX + 1] = {
>  	NAME_ELEMENT(EV_FF_STATUS),		NAME_ELEMENT(EV_SW),
>  };
>  
> -static const int maxval[EV_MAX + 1] = {
> -	[0 ... EV_MAX] = -1,
> +static const int maxval[EVTEST_EV_MAX + 1] = {
> +	[0 ... EVTEST_EV_MAX] = -1,
>  	[EV_SYN] = SYN_MAX,
>  	[EV_KEY] = KEY_MAX,
>  	[EV_REL] = REL_MAX,
> @@ -196,28 +199,19 @@ static const int maxval[EV_MAX + 1] = {
>  	[EV_FF_STATUS] = FF_STATUS_MAX,
>  };
>  
> -
> -#ifdef INPUT_PROP_SEMI_MT
> -static const char * const props[INPUT_PROP_MAX + 1] = {
> -	[0 ... INPUT_PROP_MAX] = NULL,
> +static const char * const props[EVTEST_INPUT_PROP_MAX + 1] = {
> +	[0 ... EVTEST_INPUT_PROP_MAX] = NULL,
>  	NAME_ELEMENT(INPUT_PROP_POINTER),
>  	NAME_ELEMENT(INPUT_PROP_DIRECT),
>  	NAME_ELEMENT(INPUT_PROP_BUTTONPAD),
>  	NAME_ELEMENT(INPUT_PROP_SEMI_MT),
> -#ifdef INPUT_PROP_TOPBUTTONPAD
>  	NAME_ELEMENT(INPUT_PROP_TOPBUTTONPAD),
> -#endif
> -#ifdef INPUT_PROP_POINTING_STICK
>  	NAME_ELEMENT(INPUT_PROP_POINTING_STICK),
> -#endif
> -#ifdef INPUT_PROP_ACCELEROMETER
>  	NAME_ELEMENT(INPUT_PROP_ACCELEROMETER),
> -#endif
>  };
> -#endif
>  
> -static const char * const keys[KEY_MAX + 1] = {
> -	[0 ... KEY_MAX] = NULL,
> +static const char * const keys[EVTEST_KEY_MAX + 1] = {
> +	[0 ... EVTEST_KEY_MAX] = NULL,
>  	NAME_ELEMENT(KEY_RESERVED),		NAME_ELEMENT(KEY_ESC),
>  	NAME_ELEMENT(KEY_1),			NAME_ELEMENT(KEY_2),
>  	NAME_ELEMENT(KEY_3),			NAME_ELEMENT(KEY_4),
> @@ -260,7 +254,7 @@ static const char * const keys[KEY_MAX + 1] = {
>  	NAME_ELEMENT(KEY_KPPLUS),		NAME_ELEMENT(KEY_KP1),
>  	NAME_ELEMENT(KEY_KP2),			NAME_ELEMENT(KEY_KP3),
>  	NAME_ELEMENT(KEY_KP0),			NAME_ELEMENT(KEY_KPDOT),
> -	NAME_ELEMENT(KEY_ZENKAKUHANKAKU), 	NAME_ELEMENT(KEY_102ND),
> +	NAME_ELEMENT(KEY_ZENKAKUHANKAKU),	NAME_ELEMENT(KEY_102ND),
>  	NAME_ELEMENT(KEY_F11),			NAME_ELEMENT(KEY_F12),
>  	NAME_ELEMENT(KEY_RO),			NAME_ELEMENT(KEY_KATAKANA),
>  	NAME_ELEMENT(KEY_HIRAGANA),		NAME_ELEMENT(KEY_HENKAN),
> @@ -307,7 +301,7 @@ static const char * const keys[KEY_MAX + 1] = {
>  	NAME_ELEMENT(KEY_EXIT),			NAME_ELEMENT(KEY_MOVE),
>  	NAME_ELEMENT(KEY_EDIT),			NAME_ELEMENT(KEY_SCROLLUP),
>  	NAME_ELEMENT(KEY_SCROLLDOWN),		NAME_ELEMENT(KEY_KPLEFTPAREN),
> -	NAME_ELEMENT(KEY_KPRIGHTPAREN), 	NAME_ELEMENT(KEY_F13),
> +	NAME_ELEMENT(KEY_KPRIGHTPAREN),		NAME_ELEMENT(KEY_F13),
>  	NAME_ELEMENT(KEY_F14),			NAME_ELEMENT(KEY_F15),
>  	NAME_ELEMENT(KEY_F16),			NAME_ELEMENT(KEY_F17),
>  	NAME_ELEMENT(KEY_F18),			NAME_ELEMENT(KEY_F19),
> @@ -366,45 +360,21 @@ static const char * const keys[KEY_MAX + 1] = {
>  	NAME_ELEMENT(KEY_ZOOMIN),		NAME_ELEMENT(KEY_ZOOMOUT),
>  	NAME_ELEMENT(KEY_ZOOMRESET),		NAME_ELEMENT(KEY_WORDPROCESSOR),
>  	NAME_ELEMENT(KEY_EDITOR),		NAME_ELEMENT(KEY_SPREADSHEET),
> -	NAME_ELEMENT(KEY_GRAPHICSEDITOR), 	NAME_ELEMENT(KEY_PRESENTATION),
> +	NAME_ELEMENT(KEY_GRAPHICSEDITOR),	NAME_ELEMENT(KEY_PRESENTATION),
>  	NAME_ELEMENT(KEY_DATABASE),		NAME_ELEMENT(KEY_NEWS),
>  	NAME_ELEMENT(KEY_VOICEMAIL),		NAME_ELEMENT(KEY_ADDRESSBOOK),
>  	NAME_ELEMENT(KEY_MESSENGER),		NAME_ELEMENT(KEY_DISPLAYTOGGLE),
> -#ifdef KEY_SPELLCHECK
>  	NAME_ELEMENT(KEY_SPELLCHECK),
> -#endif
> -#ifdef KEY_LOGOFF
>  	NAME_ELEMENT(KEY_LOGOFF),
> -#endif
> -#ifdef KEY_DOLLAR
> -	NAME_ELEMENT(KEY_DOLLAR),
> -#endif
> -#ifdef KEY_EURO
> -	NAME_ELEMENT(KEY_EURO),
> -#endif
> -#ifdef KEY_FRAMEBACK
> -	NAME_ELEMENT(KEY_FRAMEBACK),
> -#endif
> -#ifdef KEY_FRAMEFORWARD
> -	NAME_ELEMENT(KEY_FRAMEFORWARD),
> -#endif
> -#ifdef KEY_CONTEXT_MENU
> +	NAME_ELEMENT(KEY_DOLLAR),		NAME_ELEMENT(KEY_EURO),
> +	NAME_ELEMENT(KEY_FRAMEBACK),		NAME_ELEMENT(KEY_FRAMEFORWARD),
>  	NAME_ELEMENT(KEY_CONTEXT_MENU),
> -#endif
> -#ifdef KEY_MEDIA_REPEAT
>  	NAME_ELEMENT(KEY_MEDIA_REPEAT),
> -#endif
> -#ifdef KEY_10CHANNELSUP
>  	NAME_ELEMENT(KEY_10CHANNELSUP),
> -#endif
> -#ifdef KEY_10CHANNELSDOWN
>  	NAME_ELEMENT(KEY_10CHANNELSDOWN),
> -#endif
> -#ifdef KEY_IMAGES
>  	NAME_ELEMENT(KEY_IMAGES),
> -#endif
>  	NAME_ELEMENT(KEY_DEL_EOL),		NAME_ELEMENT(KEY_DEL_EOS),
> -	NAME_ELEMENT(KEY_INS_LINE),	 	NAME_ELEMENT(KEY_DEL_LINE),
> +	NAME_ELEMENT(KEY_INS_LINE),		NAME_ELEMENT(KEY_DEL_LINE),
>  	NAME_ELEMENT(KEY_FN),			NAME_ELEMENT(KEY_FN_ESC),
>  	NAME_ELEMENT(KEY_FN_F1),		NAME_ELEMENT(KEY_FN_F2),
>  	NAME_ELEMENT(KEY_FN_F3),		NAME_ELEMENT(KEY_FN_F4),
> @@ -421,74 +391,49 @@ static const char * const keys[KEY_MAX + 1] = {
>  	NAME_ELEMENT(KEY_BRL_DOT5),		NAME_ELEMENT(KEY_BRL_DOT6),
>  	NAME_ELEMENT(KEY_BRL_DOT7),		NAME_ELEMENT(KEY_BRL_DOT8),
>  	NAME_ELEMENT(KEY_BRL_DOT9),		NAME_ELEMENT(KEY_BRL_DOT10),
> -#ifdef KEY_NUMERIC_0
> +
>  	NAME_ELEMENT(KEY_NUMERIC_0),		NAME_ELEMENT(KEY_NUMERIC_1),
>  	NAME_ELEMENT(KEY_NUMERIC_2),		NAME_ELEMENT(KEY_NUMERIC_3),
>  	NAME_ELEMENT(KEY_NUMERIC_4),		NAME_ELEMENT(KEY_NUMERIC_5),
>  	NAME_ELEMENT(KEY_NUMERIC_6),		NAME_ELEMENT(KEY_NUMERIC_7),
>  	NAME_ELEMENT(KEY_NUMERIC_8),		NAME_ELEMENT(KEY_NUMERIC_9),
>  	NAME_ELEMENT(KEY_NUMERIC_STAR),		NAME_ELEMENT(KEY_NUMERIC_POUND),
> -#endif
> -#ifdef KEY_NUMERIC_11
>  	NAME_ELEMENT(KEY_NUMERIC_11),		NAME_ELEMENT(KEY_NUMERIC_12),
> -#endif
> +
>  	NAME_ELEMENT(KEY_BATTERY),
>  	NAME_ELEMENT(KEY_BLUETOOTH),		NAME_ELEMENT(KEY_BRIGHTNESS_CYCLE),
> -	NAME_ELEMENT(KEY_BRIGHTNESS_ZERO),
> -#ifdef KEY_DASHBOARD
> +	NAME_ELEMENT(KEY_BRIGHTNESS_AUTO),
> +
>  	NAME_ELEMENT(KEY_DASHBOARD),
> -#endif
> +
>  	NAME_ELEMENT(KEY_DISPLAY_OFF),		NAME_ELEMENT(KEY_DOCUMENTS),
>  	NAME_ELEMENT(KEY_FORWARDMAIL),		NAME_ELEMENT(KEY_NEW),
>  	NAME_ELEMENT(KEY_KBDILLUMDOWN),		NAME_ELEMENT(KEY_KBDILLUMUP),
> -	NAME_ELEMENT(KEY_KBDILLUMTOGGLE), 	NAME_ELEMENT(KEY_REDO),
> +	NAME_ELEMENT(KEY_KBDILLUMTOGGLE),	NAME_ELEMENT(KEY_REDO),
>  	NAME_ELEMENT(KEY_REPLY),		NAME_ELEMENT(KEY_SAVE),
> -#ifdef KEY_SCALE
>  	NAME_ELEMENT(KEY_SCALE),
> -#endif
>  	NAME_ELEMENT(KEY_SEND),
>  	NAME_ELEMENT(KEY_SCREENLOCK),		NAME_ELEMENT(KEY_SWITCHVIDEOMODE),
> -#ifdef KEY_UWB
>  	NAME_ELEMENT(KEY_UWB),
> -#endif
> -#ifdef KEY_VIDEO_NEXT
>  	NAME_ELEMENT(KEY_VIDEO_NEXT),
> -#endif
> -#ifdef KEY_VIDEO_PREV
>  	NAME_ELEMENT(KEY_VIDEO_PREV),
> -#endif
> -#ifdef KEY_WIMAX
> -	NAME_ELEMENT(KEY_WIMAX),
> -#endif
> -#ifdef KEY_WLAN
> +	NAME_ELEMENT(KEY_WWAN),
>  	NAME_ELEMENT(KEY_WLAN),
> -#endif
> -#ifdef KEY_RFKILL
>  	NAME_ELEMENT(KEY_RFKILL),
> -#endif
> -#ifdef KEY_MICMUTE
>  	NAME_ELEMENT(KEY_MICMUTE),
> -#endif
> -#ifdef KEY_CAMERA_FOCUS
>  	NAME_ELEMENT(KEY_CAMERA_FOCUS),
> -#endif
> -#ifdef KEY_WPS_BUTTON
>  	NAME_ELEMENT(KEY_WPS_BUTTON),
> -#endif
> -#ifdef KEY_TOUCHPAD_TOGGLE
> +
>  	NAME_ELEMENT(KEY_TOUCHPAD_TOGGLE),
>  	NAME_ELEMENT(KEY_TOUCHPAD_ON),
>  	NAME_ELEMENT(KEY_TOUCHPAD_OFF),
> -#endif
> -#ifdef KEY_CAMERA_ZOOMIN
> +
>  	NAME_ELEMENT(KEY_CAMERA_ZOOMIN),	NAME_ELEMENT(KEY_CAMERA_ZOOMOUT),
>  	NAME_ELEMENT(KEY_CAMERA_UP),		NAME_ELEMENT(KEY_CAMERA_DOWN),
>  	NAME_ELEMENT(KEY_CAMERA_LEFT),		NAME_ELEMENT(KEY_CAMERA_RIGHT),
> -#endif
> -#ifdef KEY_ATTENDANT_ON
> +
>  	NAME_ELEMENT(KEY_ATTENDANT_ON),		NAME_ELEMENT(KEY_ATTENDANT_OFF),
>  	NAME_ELEMENT(KEY_ATTENDANT_TOGGLE),	NAME_ELEMENT(KEY_LIGHTS_TOGGLE),
> -#endif
>  
>  	NAME_ELEMENT(BTN_0),			NAME_ELEMENT(BTN_1),
>  	NAME_ELEMENT(BTN_2),			NAME_ELEMENT(BTN_3),
> @@ -506,13 +451,8 @@ static const char * const keys[KEY_MAX + 1] = {
>  	NAME_ELEMENT(BTN_BASE3),		NAME_ELEMENT(BTN_BASE4),
>  	NAME_ELEMENT(BTN_BASE5),		NAME_ELEMENT(BTN_BASE6),
>  	NAME_ELEMENT(BTN_DEAD),			NAME_ELEMENT(BTN_C),
> -#ifdef BTN_SOUTH
>  	NAME_ELEMENT(BTN_SOUTH),		NAME_ELEMENT(BTN_EAST),
>  	NAME_ELEMENT(BTN_NORTH),		NAME_ELEMENT(BTN_WEST),
> -#else
> -	NAME_ELEMENT(BTN_A),			NAME_ELEMENT(BTN_B),
> -	NAME_ELEMENT(BTN_X),			NAME_ELEMENT(BTN_Y),
> -#endif
>  	NAME_ELEMENT(BTN_Z),			NAME_ELEMENT(BTN_TL),
>  	NAME_ELEMENT(BTN_TR),			NAME_ELEMENT(BTN_TL2),
>  	NAME_ELEMENT(BTN_TR2),			NAME_ELEMENT(BTN_SELECT),
> @@ -522,77 +462,34 @@ static const char * const keys[KEY_MAX + 1] = {
>  	NAME_ELEMENT(BTN_TOOL_BRUSH),		NAME_ELEMENT(BTN_TOOL_PENCIL),
>  	NAME_ELEMENT(BTN_TOOL_AIRBRUSH),	NAME_ELEMENT(BTN_TOOL_FINGER),
>  	NAME_ELEMENT(BTN_TOOL_MOUSE),		NAME_ELEMENT(BTN_TOOL_LENS),
> -	NAME_ELEMENT(BTN_TOUCH),		NAME_ELEMENT(BTN_STYLUS),
> -	NAME_ELEMENT(BTN_STYLUS2),		NAME_ELEMENT(BTN_TOOL_DOUBLETAP),
> -	NAME_ELEMENT(BTN_TOOL_TRIPLETAP),
> -#ifdef BTN_TOOL_QUADTAP
> -	NAME_ELEMENT(BTN_TOOL_QUADTAP),
> -#endif
> -	NAME_ELEMENT(BTN_GEAR_DOWN),
> -	NAME_ELEMENT(BTN_GEAR_UP),
> -
> -#ifdef BTN_DPAD_UP
> +	NAME_ELEMENT(BTN_TOUCH),
> +	NAME_ELEMENT(BTN_STYLUS),		NAME_ELEMENT(BTN_STYLUS2),
> +	NAME_ELEMENT(BTN_TOOL_DOUBLETAP),	NAME_ELEMENT(BTN_TOOL_TRIPLETAP),
> +	NAME_ELEMENT(BTN_TOOL_QUADTAP),		NAME_ELEMENT(BTN_TOOL_QUINTTAP),
> +	NAME_ELEMENT(BTN_GEAR_DOWN),		NAME_ELEMENT(BTN_GEAR_UP),
>  	NAME_ELEMENT(BTN_DPAD_UP),		NAME_ELEMENT(BTN_DPAD_DOWN),
>  	NAME_ELEMENT(BTN_DPAD_LEFT),		NAME_ELEMENT(BTN_DPAD_RIGHT),
> -#endif
> -#ifdef KEY_ALS_TOGGLE
>  	NAME_ELEMENT(KEY_ALS_TOGGLE),
> -#endif
> -#ifdef KEY_BUTTONCONFIG
>  	NAME_ELEMENT(KEY_BUTTONCONFIG),
> -#endif
> -#ifdef KEY_TASKMANAGER
>  	NAME_ELEMENT(KEY_TASKMANAGER),
> -#endif
> -#ifdef KEY_JOURNAL
>  	NAME_ELEMENT(KEY_JOURNAL),
> -#endif
> -#ifdef KEY_CONTROLPANEL
>  	NAME_ELEMENT(KEY_CONTROLPANEL),
> -#endif
> -#ifdef KEY_APPSELECT
>  	NAME_ELEMENT(KEY_APPSELECT),
> -#endif
> -#ifdef KEY_SCREENSAVER
>  	NAME_ELEMENT(KEY_SCREENSAVER),
> -#endif
> -#ifdef KEY_VOICECOMMAND
>  	NAME_ELEMENT(KEY_VOICECOMMAND),
> -#endif
> -#ifdef KEY_ASSISTANT
>  	NAME_ELEMENT(KEY_ASSISTANT),
> -#endif
> -#ifdef KEY_BRIGHTNESS_MIN
> -	NAME_ELEMENT(KEY_BRIGHTNESS_MIN),
> -#endif
> -#ifdef KEY_BRIGHTNESS_MAX
> -	NAME_ELEMENT(KEY_BRIGHTNESS_MAX),
> -#endif
> -#ifdef KEY_KBDINPUTASSIST_PREV
> +	NAME_ELEMENT(KEY_BRIGHTNESS_MIN),	NAME_ELEMENT(KEY_BRIGHTNESS_MAX),
> +
>  	NAME_ELEMENT(KEY_KBDINPUTASSIST_PREV),
> -#endif
> -#ifdef KEY_KBDINPUTASSIST_NEXT
>  	NAME_ELEMENT(KEY_KBDINPUTASSIST_NEXT),
> -#endif
> -#ifdef KEY_KBDINPUTASSIST_PREVGROUP
>  	NAME_ELEMENT(KEY_KBDINPUTASSIST_PREVGROUP),
> -#endif
> -#ifdef KEY_KBDINPUTASSIST_NEXTGROUP
>  	NAME_ELEMENT(KEY_KBDINPUTASSIST_NEXTGROUP),
> -#endif
> -#ifdef KEY_KBDINPUTASSIST_ACCEPT
>  	NAME_ELEMENT(KEY_KBDINPUTASSIST_ACCEPT),
> -#endif
> -#ifdef KEY_KBDINPUTASSIST_CANCEL
>  	NAME_ELEMENT(KEY_KBDINPUTASSIST_CANCEL),
> -#endif
>  
> -#ifdef KEY_RIGHT_UP
>  	NAME_ELEMENT(KEY_RIGHT_UP),		NAME_ELEMENT(KEY_RIGHT_DOWN),
>  	NAME_ELEMENT(KEY_LEFT_UP),		NAME_ELEMENT(KEY_LEFT_DOWN),
> -#endif
>  
> -#ifdef KEY_ROOT_MENU
>  	NAME_ELEMENT(KEY_ROOT_MENU),
>  	NAME_ELEMENT(KEY_MEDIA_TOP_MENU),
>  	NAME_ELEMENT(KEY_AUDIO_DESC),
> @@ -604,17 +501,10 @@ static const char * const keys[KEY_MAX + 1] = {
>  	NAME_ELEMENT(KEY_UNMUTE),
>  	NAME_ELEMENT(KEY_FASTREVERSE),
>  	NAME_ELEMENT(KEY_SLOWREVERSE),
> -#endif
>  
> -#ifdef KEY_DATA
>  	NAME_ELEMENT(KEY_DATA),
> -#endif
> -
> -#ifdef KEY_ONSCREEN_KEYBOARD
>  	NAME_ELEMENT(KEY_ONSCREEN_KEYBOARD),
> -#endif
>  
> -#ifdef BTN_TRIGGER_HAPPY
>  	NAME_ELEMENT(BTN_TRIGGER_HAPPY1),	NAME_ELEMENT(BTN_TRIGGER_HAPPY11),
>  	NAME_ELEMENT(BTN_TRIGGER_HAPPY2),	NAME_ELEMENT(BTN_TRIGGER_HAPPY12),
>  	NAME_ELEMENT(BTN_TRIGGER_HAPPY3),	NAME_ELEMENT(BTN_TRIGGER_HAPPY13),
> @@ -636,16 +526,12 @@ static const char * const keys[KEY_MAX + 1] = {
>  	NAME_ELEMENT(BTN_TRIGGER_HAPPY28),	NAME_ELEMENT(BTN_TRIGGER_HAPPY38),
>  	NAME_ELEMENT(BTN_TRIGGER_HAPPY29),	NAME_ELEMENT(BTN_TRIGGER_HAPPY39),
>  	NAME_ELEMENT(BTN_TRIGGER_HAPPY30),	NAME_ELEMENT(BTN_TRIGGER_HAPPY40),
> -#endif
> -#ifdef BTN_TOOL_QUINTTAP
> -	NAME_ELEMENT(BTN_TOOL_QUINTTAP),
> -#endif
>  };
>  
>  static const char * const absval[6] = { "Value", "Min  ", "Max  ", "Fuzz ", "Flat ", "Resolution "};
>  
> -static const char * const relatives[REL_MAX + 1] = {
> -	[0 ... REL_MAX] = NULL,
> +static const char * const relatives[EVTEST_REL_MAX + 1] = {
> +	[0 ... EVTEST_REL_MAX] = NULL,
>  	NAME_ELEMENT(REL_X),			NAME_ELEMENT(REL_Y),
>  	NAME_ELEMENT(REL_Z),			NAME_ELEMENT(REL_RX),
>  	NAME_ELEMENT(REL_RY),			NAME_ELEMENT(REL_RZ),
> @@ -654,8 +540,8 @@ static const char * const relatives[REL_MAX + 1] = {
>  	NAME_ELEMENT(REL_MISC),
>  };
>  
> -static const char * const absolutes[ABS_MAX + 1] = {
> -	[0 ... ABS_MAX] = NULL,
> +static const char * const absolutes[EVTEST_ABS_MAX + 1] = {
> +	[0 ... EVTEST_ABS_MAX] = NULL,
>  	NAME_ELEMENT(ABS_X),			NAME_ELEMENT(ABS_Y),
>  	NAME_ELEMENT(ABS_Z),			NAME_ELEMENT(ABS_RX),
>  	NAME_ELEMENT(ABS_RY),			NAME_ELEMENT(ABS_RZ),
> @@ -669,7 +555,6 @@ static const char * const absolutes[ABS_MAX + 1] = {
>  	NAME_ELEMENT(ABS_DISTANCE),		NAME_ELEMENT(ABS_TILT_X),
>  	NAME_ELEMENT(ABS_TILT_Y),		NAME_ELEMENT(ABS_TOOL_WIDTH),
>  	NAME_ELEMENT(ABS_VOLUME),		NAME_ELEMENT(ABS_MISC),
> -#ifdef ABS_MT_BLOB_ID
>  	NAME_ELEMENT(ABS_MT_TOUCH_MAJOR),
>  	NAME_ELEMENT(ABS_MT_TOUCH_MINOR),
>  	NAME_ELEMENT(ABS_MT_WIDTH_MAJOR),
> @@ -679,112 +564,74 @@ static const char * const absolutes[ABS_MAX + 1] = {
>  	NAME_ELEMENT(ABS_MT_POSITION_Y),
>  	NAME_ELEMENT(ABS_MT_TOOL_TYPE),
>  	NAME_ELEMENT(ABS_MT_BLOB_ID),
> -#endif
> -#ifdef ABS_MT_TRACKING_ID
>  	NAME_ELEMENT(ABS_MT_TRACKING_ID),
> -#endif
> -#ifdef ABS_MT_PRESSURE
>  	NAME_ELEMENT(ABS_MT_PRESSURE),
> -#endif
> -#ifdef ABS_MT_SLOT
>  	NAME_ELEMENT(ABS_MT_SLOT),
> -#endif
> -#ifdef ABS_MT_TOOL_X
>  	NAME_ELEMENT(ABS_MT_TOOL_X),
>  	NAME_ELEMENT(ABS_MT_TOOL_Y),
>  	NAME_ELEMENT(ABS_MT_DISTANCE),
> -#endif
> -
>  };
>  
> -static const char * const misc[MSC_MAX + 1] = {
> -	[ 0 ... MSC_MAX] = NULL,
> +static const char * const misc[EVTEST_MSC_MAX + 1] = {
> +	[ 0 ... EVTEST_MSC_MAX] = NULL,
>  	NAME_ELEMENT(MSC_SERIAL),		NAME_ELEMENT(MSC_PULSELED),
>  	NAME_ELEMENT(MSC_GESTURE),		NAME_ELEMENT(MSC_RAW),
>  	NAME_ELEMENT(MSC_SCAN),
> -#ifdef MSC_TIMESTAMP
>  	NAME_ELEMENT(MSC_TIMESTAMP),
> -#endif
>  };
>  
> -static const char * const leds[LED_MAX + 1] = {
> -	[0 ... LED_MAX] = NULL,
> +static const char * const leds[EVTEST_LED_MAX + 1] = {
> +	[0 ... EVTEST_LED_MAX] = NULL,
>  	NAME_ELEMENT(LED_NUML),			NAME_ELEMENT(LED_CAPSL),
>  	NAME_ELEMENT(LED_SCROLLL),		NAME_ELEMENT(LED_COMPOSE),
>  	NAME_ELEMENT(LED_KANA),			NAME_ELEMENT(LED_SLEEP),
>  	NAME_ELEMENT(LED_SUSPEND),		NAME_ELEMENT(LED_MUTE),
>  	NAME_ELEMENT(LED_MISC),
> -#ifdef LED_MAIL
>  	NAME_ELEMENT(LED_MAIL),
> -#endif
> -#ifdef LED_CHARGING
>  	NAME_ELEMENT(LED_CHARGING),
> -#endif
>  };
>  
> -static const char * const repeats[REP_MAX + 1] = {
> -	[0 ... REP_MAX] = NULL,
> +static const char * const repeats[EVTEST_REP_MAX + 1] = {
> +	[0 ... EVTEST_REP_MAX] = NULL,
>  	NAME_ELEMENT(REP_DELAY),		NAME_ELEMENT(REP_PERIOD)
>  };
>  
> -static const char * const sounds[SND_MAX + 1] = {
> -	[0 ... SND_MAX] = NULL,
> +static const char * const sounds[EVTEST_SND_MAX + 1] = {
> +	[0 ... EVTEST_SND_MAX] = NULL,
>  	NAME_ELEMENT(SND_CLICK),		NAME_ELEMENT(SND_BELL),
>  	NAME_ELEMENT(SND_TONE)
>  };
>  
> -static const char * const syns[SYN_MAX + 1] = {
> -	[0 ... SYN_MAX] = NULL,
> +static const char * const syns[EVTEST_SYN_MAX + 1] = {
> +	[0 ... EVTEST_SYN_MAX] = NULL,
>  	NAME_ELEMENT(SYN_REPORT),
>  	NAME_ELEMENT(SYN_CONFIG),
>  	NAME_ELEMENT(SYN_MT_REPORT),
>  	NAME_ELEMENT(SYN_DROPPED)
>  };
>  
> -static const char * const switches[SW_MAX + 1] = {
> -	[0 ... SW_MAX] = NULL,
> +static const char * const switches[EVTEST_SW_MAX + 1] = {
> +	[0 ... EVTEST_SW_MAX] = NULL,
>  	NAME_ELEMENT(SW_LID),
>  	NAME_ELEMENT(SW_TABLET_MODE),
>  	NAME_ELEMENT(SW_HEADPHONE_INSERT),
> -#ifdef SW_RFKILL_ALL
>  	NAME_ELEMENT(SW_RFKILL_ALL),
> -#endif
> -#ifdef SW_MICROPHONE_INSERT
>  	NAME_ELEMENT(SW_MICROPHONE_INSERT),
> -#endif
> -#ifdef SW_DOCK
>  	NAME_ELEMENT(SW_DOCK),
> -#endif
> -#ifdef SW_LINEOUT_INSERT
>  	NAME_ELEMENT(SW_LINEOUT_INSERT),
> -#endif
> -#ifdef SW_JACK_PHYSICAL_INSERT
>  	NAME_ELEMENT(SW_JACK_PHYSICAL_INSERT),
> -#endif
> -#ifdef SW_VIDEOOUT_INSERT
>  	NAME_ELEMENT(SW_VIDEOOUT_INSERT),
> -#endif
> -#ifdef SW_CAMERA_LENS_COVER
>  	NAME_ELEMENT(SW_CAMERA_LENS_COVER),
>  	NAME_ELEMENT(SW_KEYPAD_SLIDE),
>  	NAME_ELEMENT(SW_FRONT_PROXIMITY),
> -#endif
> -#ifdef SW_ROTATE_LOCK
>  	NAME_ELEMENT(SW_ROTATE_LOCK),
> -#endif
> -#ifdef SW_LINEIN_INSERT
>  	NAME_ELEMENT(SW_LINEIN_INSERT),
> -#endif
> -#ifdef SW_MUTE_DEVICE
>  	NAME_ELEMENT(SW_MUTE_DEVICE),
> -#endif
> -#ifdef SW_PEN_INSERTED
>  	NAME_ELEMENT(SW_PEN_INSERTED),
> -#endif
>  };
>  
> -static const char * const force[FF_MAX + 1] = {
> -	[0 ... FF_MAX] = NULL,
> +static const char * const force[EVTEST_FF_MAX + 1] = {
> +	[0 ... EVTEST_FF_MAX] = NULL,
>  	NAME_ELEMENT(FF_RUMBLE),		NAME_ELEMENT(FF_PERIODIC),
>  	NAME_ELEMENT(FF_CONSTANT),		NAME_ELEMENT(FF_SPRING),
>  	NAME_ELEMENT(FF_FRICTION),		NAME_ELEMENT(FF_DAMPER),
> @@ -795,13 +642,13 @@ static const char * const force[FF_MAX + 1] = {
>  	NAME_ELEMENT(FF_GAIN),			NAME_ELEMENT(FF_AUTOCENTER),
>  };
>  
> -static const char * const forcestatus[FF_STATUS_MAX + 1] = {
> -	[0 ... FF_STATUS_MAX] = NULL,
> +static const char * const forcestatus[EVTEST_FF_STATUS_MAX + 1] = {
> +	[0 ... EVTEST_FF_STATUS_MAX] = NULL,
>  	NAME_ELEMENT(FF_STATUS_STOPPED),	NAME_ELEMENT(FF_STATUS_PLAYING),
>  };
>  
> -static const char * const * const names[EV_MAX + 1] = {
> -	[0 ... EV_MAX] = NULL,
> +static const char * const * const names[EVTEST_EV_MAX + 1] = {
> +	[0 ... EVTEST_EV_MAX] = NULL,
>  	[EV_SYN] = syns,			[EV_KEY] = keys,
>  	[EV_REL] = relatives,			[EV_ABS] = absolutes,
>  	[EV_MSC] = misc,			[EV_LED] = leds,
> @@ -970,7 +817,7 @@ static void print_repdata(int fd)
>  
>  	ioctl(fd, EVIOCGREP, rep);
>  
> -	for (i = 0; i <= REP_MAX; i++) {
> +	for (i = 0; i <= EVTEST_REP_MAX; i++) {
>  		printf("    Repeat code %d (%s)\n", i, names[EV_REP] ? (names[EV_REP][i] ? names[EV_REP][i] : "?") : "?");
>  		printf("      Value %6d\n", rep[i]);
>  	}
> @@ -979,20 +826,18 @@ static void print_repdata(int fd)
>  
>  static inline const char* typename(unsigned int type)
>  {
> -	return (type <= EV_MAX && events[type]) ? events[type] : "?";
> +	return (type <= EVTEST_EV_MAX && events[type]) ? events[type] : "?";
>  }
>  
>  static inline const char* codename(unsigned int type, unsigned int code)
>  {
> -	return (type <= EV_MAX && code <= maxval[type] && names[type] && names[type][code]) ? names[type][code] : "?";
> +	return (type <= EVTEST_EV_MAX && code <= maxval[type] && names[type] && names[type][code]) ? names[type][code] : "?";
>  }
>  
> -#ifdef INPUT_PROP_SEMI_MT
>  static inline const char* propname(unsigned int prop)
>  {
> -	return (prop <= INPUT_PROP_MAX && props[prop]) ? props[prop] : "?";
> +	return (prop <= EVTEST_INPUT_PROP_MAX && props[prop]) ? props[prop] : "?";
>  }
> -#endif
>  
>  static int get_state(int fd, unsigned int type, unsigned long *array, size_t size)
>  {
> @@ -1033,12 +878,10 @@ static int print_device_info(int fd)
>  	int version;
>  	unsigned short id[4];
>  	char name[256] = "Unknown";
> -	unsigned long bit[EV_MAX][NBITS(KEY_MAX)];
> -	unsigned long state[KEY_CNT] = {0};
> -#ifdef INPUT_PROP_SEMI_MT
> +	unsigned long bit[EVTEST_EV_MAX][NBITS(EVTEST_KEY_MAX)];
> +	unsigned long state[EVTEST_KEY_MAX + 1] = {0};
>  	unsigned int prop;
> -	unsigned long propbits[INPUT_PROP_MAX];
> -#endif
> +	unsigned long propbits[EVTEST_INPUT_PROP_MAX];
>  	int stateval;
>  	int have_state;
>  
> @@ -1058,16 +901,16 @@ static int print_device_info(int fd)
>  	printf("Input device name: \"%s\"\n", name);
>  
>  	memset(bit, 0, sizeof(bit));
> -	ioctl(fd, EVIOCGBIT(0, EV_MAX), bit[0]);
> +	ioctl(fd, EVIOCGBIT(0, EVTEST_EV_MAX), bit[0]);
>  	printf("Supported events:\n");
>  
> -	for (type = 0; type < EV_MAX; type++) {
> +	for (type = 0; type < EVTEST_EV_MAX; type++) {
>  		if (test_bit(type, bit[0]) && type != EV_REP) {
>  			have_state = (get_state(fd, type, state, sizeof(state)) == 0);
>  
>  			printf("  Event type %d (%s)\n", type, typename(type));
>  			if (type == EV_SYN) continue;
> -			ioctl(fd, EVIOCGBIT(type, KEY_MAX), bit[type]);
> +			ioctl(fd, EVIOCGBIT(type, EVTEST_KEY_MAX), bit[type]);
>  			for (code = 0; code < KEY_MAX; code++)
>  				if (test_bit(code, bit[type])) {
>  					if (have_state) {
> @@ -1088,15 +931,14 @@ static int print_device_info(int fd)
>  		printf("  Repeat type %d (%s)\n", EV_REP, events[EV_REP] ?  events[EV_REP] : "?");
>  		print_repdata(fd);
>  	}
> -#ifdef INPUT_PROP_SEMI_MT
> +
>  	memset(propbits, 0, sizeof(propbits));
>  	ioctl(fd, EVIOCGPROP(sizeof(propbits)), propbits);
>  	printf("Properties:\n");
> -	for (prop = 0; prop < INPUT_PROP_MAX; prop++) {
> +	for (prop = 0; prop < EVTEST_INPUT_PROP_MAX; prop++) {
>  		if (test_bit(prop, propbits))
>  			printf("  Property type %d (%s)\n", prop, propname(prop));
>  	}
> -#endif
>  
>  	return 0;
>  }
> -- 
> 2.14.2.822.g60be5d43e6-goog
> 
> _______________________________________________
> Input-tools mailing list
> Input-tools at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/input-tools
> 


More information about the Input-tools mailing list