[PATCH xinput] Add --enable/--disable support

Peter Hutterer peter.hutterer at who-t.net
Mon May 14 00:29:47 PDT 2012


Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
I got sick of typing 'xinput set-prop "foo" "Device Enabled" 0'

 src/property.c |   14 ++++++++++++++
 src/xinput.c   |   10 ++++++++++
 src/xinput.h   |    2 ++
 3 files changed, 26 insertions(+)

diff --git a/src/property.c b/src/property.c
index 3ab2cb0..a4d07f6 100644
--- a/src/property.c
+++ b/src/property.c
@@ -824,3 +824,17 @@ int set_prop(Display *display, int argc, char *argv[], char *name,
 
     return do_set_prop(display, type, format, argc, argv, name, desc);
 }
+
+int disable(Display *display, int argc, char *argv[], char *name, char *desc)
+{
+    char *new_argv[3] = { NULL, "Device Enabled", "0" };
+    new_argv[0] = argv[0];
+    return set_prop(display, 3, new_argv, name, desc);
+}
+
+int enable(Display *display, int argc, char *argv[], char *name, char *desc)
+{
+    char *new_argv[3] = { NULL, "Device Enabled", "1" };
+    new_argv[0] = argv[0];
+    return set_prop(display, 3, new_argv, name, desc);
+}
diff --git a/src/xinput.c b/src/xinput.c
index a1bb221..0f86720 100644
--- a/src/xinput.c
+++ b/src/xinput.c
@@ -137,6 +137,16 @@ static entry drivers[] =
       "<device> [--type=atom|float|int] [--format=8|16|32] <property> <val> [<val> ...]",
       set_prop
     },
+    {
+      "disable",
+      "<device>",
+      disable,
+    },
+    {
+      "enable",
+      "<device>",
+      enable,
+    },
     {NULL, NULL, NULL
     }
 };
diff --git a/src/xinput.h b/src/xinput.h
index b420e61..c37e6e6 100644
--- a/src/xinput.h
+++ b/src/xinput.h
@@ -69,6 +69,8 @@ int set_atom_prop( Display* display, int argc, char *argv[], char *prog_name, ch
 int watch_props( Display* display, int argc, char *argv[], char *prog_name, char *prog_desc);
 int delete_prop( Display* display, int argc, char *argv[], char *prog_name, char *prog_desc);
 int set_prop( Display* display, int argc, char *argv[], char *prog_name, char *prog_desc);
+int disable( Display* display, int argc, char *argv[], char *prog_name, char *prog_desc);
+int enable( Display* display, int argc, char *argv[], char *prog_name, char *prog_desc);
 
 /* X Input 2.0 */
 int create_master( Display* display, int argc, char *argv[], char *prog_name, char *prog_desc);
-- 
1.7.10.1



More information about the xorg-devel mailing list