From: Peter Hutterer Date: Sun, 10 Mar 2013 05:25:38 +0000 (+1000) Subject: Add support for XINPUT_XI2_VERSION environment variable to override version X-Git-Url: https://diplodocus.org/git/xorg-xinput/commitdiff_plain/5dce5636d23f366d72f88c341ca1ff9da4427f66?hp=bcfa9123b41da8048450ed27aaeffff17b8eee99 Add support for XINPUT_XI2_VERSION environment variable to override version By default, xinput announces whatever version it was built against. For debugging it can be useful to set this version on-the-fly. Signed-off-by: Peter Hutterer --- diff --git a/src/xinput.c b/src/xinput.c index 0f86720..16a13df 100644 --- a/src/xinput.c +++ b/src/xinput.c @@ -202,6 +202,7 @@ xinput_version(Display *display) /* Announce our supported version so the server treats us correctly. */ if (vers >= XI_2_Major) { + const char *forced_version; int maj = 2, min = 0; @@ -211,6 +212,16 @@ xinput_version(Display *display) min = 2; #endif + forced_version = getenv("XINPUT_XI2_VERSION"); + if (forced_version) { + if (sscanf(forced_version, "%d.%d", &maj, &min) != 2) { + fprintf(stderr, "Invalid format of XINPUT_XI2_VERSION " + "environment variable. Need major.minor\n"); + exit(1); + } + printf("Overriding XI2 version to: %d.%d\n", maj, min); + } + XIQueryVersion(display, &maj, &min); } #endif