[PATCH libinput 1/3] evdev: de-duplicate the model property->model flag list

Peter Hutterer peter.hutterer at who-t.net
Tue May 3 21:13:41 UTC 2016


Rather than a list where the only difference is the LIBINPUT_MODEL vs
EVDEV_MODEL prefix, use a macro.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/evdev.c | 41 ++++++++++++++++++++++-------------------
 1 file changed, 22 insertions(+), 19 deletions(-)

diff --git a/src/evdev.c b/src/evdev.c
index bcd9c5b..97a8fff 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1715,26 +1715,29 @@ evdev_read_model_flags(struct evdev_device *device)
 		const char *property;
 		enum evdev_device_model model;
 	} model_map[] = {
-		{ "LIBINPUT_MODEL_LENOVO_X230", EVDEV_MODEL_LENOVO_X230 },
-		{ "LIBINPUT_MODEL_LENOVO_X220_TOUCHPAD_FW81", EVDEV_MODEL_LENOVO_X220_TOUCHPAD_FW81 },
-		{ "LIBINPUT_MODEL_CHROMEBOOK", EVDEV_MODEL_CHROMEBOOK },
-		{ "LIBINPUT_MODEL_SYSTEM76_BONOBO", EVDEV_MODEL_SYSTEM76_BONOBO },
-		{ "LIBINPUT_MODEL_SYSTEM76_GALAGO", EVDEV_MODEL_SYSTEM76_GALAGO },
-		{ "LIBINPUT_MODEL_SYSTEM76_KUDU", EVDEV_MODEL_SYSTEM76_KUDU },
-		{ "LIBINPUT_MODEL_CLEVO_W740SU", EVDEV_MODEL_CLEVO_W740SU },
-		{ "LIBINPUT_MODEL_APPLE_TOUCHPAD", EVDEV_MODEL_APPLE_TOUCHPAD },
-		{ "LIBINPUT_MODEL_WACOM_TOUCHPAD", EVDEV_MODEL_WACOM_TOUCHPAD },
-		{ "LIBINPUT_MODEL_ALPS_TOUCHPAD", EVDEV_MODEL_ALPS_TOUCHPAD },
-		{ "LIBINPUT_MODEL_SYNAPTICS_SERIAL_TOUCHPAD", EVDEV_MODEL_SYNAPTICS_SERIAL_TOUCHPAD },
-		{ "LIBINPUT_MODEL_JUMPING_SEMI_MT", EVDEV_MODEL_JUMPING_SEMI_MT },
-		{ "LIBINPUT_MODEL_ELANTECH_TOUCHPAD", EVDEV_MODEL_ELANTECH_TOUCHPAD },
-		{ "LIBINPUT_MODEL_APPLE_INTERNAL_KEYBOARD", EVDEV_MODEL_APPLE_INTERNAL_KEYBOARD },
-		{ "LIBINPUT_MODEL_CYBORG_RAT", EVDEV_MODEL_CYBORG_RAT },
-		{ "LIBINPUT_MODEL_CYAPA", EVDEV_MODEL_CYAPA },
-		{ "LIBINPUT_MODEL_ALPS_RUSHMORE", EVDEV_MODEL_ALPS_RUSHMORE },
-		{ "LIBINPUT_MODEL_LENOVO_T450_TOUCHPAD", EVDEV_MODEL_LENOVO_T450_TOUCHPAD },
-		{ "LIBINPUT_MODEL_WOBBLY_TOUCHPAD", EVDEV_MODEL_WOBBLY_TOUCHPAD },
+#define MODEL(name) { "LIBINPUT_MODEL_" #name, EVDEV_MODEL_##name }
+		MODEL(LENOVO_X230),
+		MODEL(LENOVO_X230),
+		MODEL(LENOVO_X220_TOUCHPAD_FW81),
+		MODEL(CHROMEBOOK),
+		MODEL(SYSTEM76_BONOBO),
+		MODEL(SYSTEM76_GALAGO),
+		MODEL(SYSTEM76_KUDU),
+		MODEL(CLEVO_W740SU),
+		MODEL(APPLE_TOUCHPAD),
+		MODEL(WACOM_TOUCHPAD),
+		MODEL(ALPS_TOUCHPAD),
+		MODEL(SYNAPTICS_SERIAL_TOUCHPAD),
+		MODEL(JUMPING_SEMI_MT),
+		MODEL(ELANTECH_TOUCHPAD),
+		MODEL(APPLE_INTERNAL_KEYBOARD),
+		MODEL(CYBORG_RAT),
+		MODEL(CYAPA),
+		MODEL(ALPS_RUSHMORE),
+		MODEL(LENOVO_T450_TOUCHPAD),
+		MODEL(WOBBLY_TOUCHPAD),
 		{ NULL, EVDEV_MODEL_DEFAULT },
+#undef MODEL
 	};
 	const struct model_map *m = model_map;
 	uint32_t model_flags = 0;
-- 
2.7.4



More information about the wayland-devel mailing list