[PATCH xinput 1/1] Support the new Scroll class

Peter Hutterer peter.hutterer at who-t.net
Sun Aug 21 22:35:23 PDT 2011


Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 configure.ac   |    8 +++++++-
 src/list.c     |   24 ++++++++++++++++++++++++
 src/test_xi2.c |   11 +++++++++++
 3 files changed, 42 insertions(+), 1 deletions(-)

diff --git a/configure.ac b/configure.ac
index 37f998f..7bfe64d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -45,9 +45,15 @@ PKG_CHECK_MODULES(XI2, [xi >= 1.2.99.2] [inputproto >= 1.9.99.15],
                   HAVE_XI2="yes"; AC_DEFINE(HAVE_XI2, 1, [XI2 available]),
                   HAVE_XI2="no");
 AM_CONDITIONAL(HAVE_XI2, [ test "$HAVE_XI2" = "yes" ])
-
 AC_SUBST(HAVE_XI2)
 
+# XI2.1 support
+PKG_CHECK_MODULES(XI21, [xi >= 1.4.99.1] [inputproto >= 2.0.99.1],
+                  HAVE_XI21="yes"; AC_DEFINE(HAVE_XI21, 1, [XI2.1 available]),
+                  HAVE_XI21="no");
+AM_CONDITIONAL(HAVE_XI21, [ test "$HAVE_XI21" = "yes" ])
+AC_SUBST(HAVE_XI21)
+
 AC_OUTPUT([Makefile
            src/Makefile
            man/Makefile])
diff --git a/src/list.c b/src/list.c
index 236011e..64848e3 100644
--- a/src/list.c
+++ b/src/list.c
@@ -201,6 +201,30 @@ print_classes_xi2(Display* display, XIAnyClassInfo **classes,
                     XFree(name);
                 }
                 break;
+#if HAVE_XI21
+            case XIScrollClass:
+                {
+                    XIScrollClassInfo *s = (XIScrollClassInfo*)classes[i];
+
+                    printf("XIScrollClass\n");
+                    printf("\t\tScroll info for Valuator %d\n", s->number);
+                    printf("\t\t  type: %d (%s)\n", s->scroll_type,
+                           (s->scroll_type == XIScrollTypeHorizontal) ? "horizontal" :
+                              (s->scroll_type == XIScrollTypeVertical) ? "vertical" : "unknown");
+                    printf("\t\t  increment: %f\n", s->increment);
+                    printf("\t\t  flags: 0x%x", s->flags);
+                    if (s->flags) {
+                        printf(" (");
+                        if (s->flags & XIScrollFlagNoEmulation)
+                            printf(" no-emulation ");
+                        if (s->flags & XIScrollFlagPreferred)
+                            printf(" preferred ");
+                        printf(")");
+                    }
+                    printf("\n");
+                }
+                break;
+#endif
         }
     }
 
diff --git a/src/test_xi2.c b/src/test_xi2.c
index 92c88da..4a6c3b6 100644
--- a/src/test_xi2.c
+++ b/src/test_xi2.c
@@ -53,11 +53,13 @@ static void print_deviceevent(XIDeviceEvent* event)
         case XI_KeyRelease:
             printf("    flags: %s\n", (event->flags & XIKeyRepeat) ?  "repeat" : "");
             break;
+#if HAVE_XI21
         case XI_ButtonPress:
         case XI_ButtonRelease:
         case XI_Motion:
             printf("    flags: %s\n", (event->flags & XIPointerEmulated) ?  "emulated" : "");
             break;
+#endif
     }
 
     printf("    root: %.2f/%.2f\n", event->root_x, event->root_y);
@@ -148,6 +150,15 @@ static void print_rawevent(XIRawEvent *event)
     printf("    device: %d\n", event->deviceid);
     printf("    detail: %d\n", event->detail);
     printf("    valuators:\n");
+#if HAVE_XI21
+    switch(event->evtype) {
+        case XI_RawButtonPress:
+        case XI_RawButtonRelease:
+        case XI_RawMotion:
+            printf("    flags: %s\n", (event->flags & XIPointerEmulated) ?  "emulated" : "");
+            break;
+    }
+#endif
 
     val = event->valuators.values;
     raw_val = event->raw_values;
-- 
1.7.6



More information about the xorg-devel mailing list