]> diplodocus.org Git - xorg-xinput/commitdiff
Expand check to support XExtensionKeyboard/Pointer.
authorPhilip Langdale <plangdale@vmware.com>
Thu, 8 Nov 2007 04:25:41 +0000 (14:55 +1030)
committerPeter Hutterer <peter@cs.unisa.edu.au>
Thu, 8 Nov 2007 04:25:57 +0000 (14:55 +1030)
Search for PtrFeedbackClass instead of assuming it's the first class in the
list.

src/feedback.c
src/list.c
src/xinput.c

index e16b74ebf44ace699da87b9448f52914595ce4ba..e374be2d0c562d3ddf55a599b09e12718eb45aca 100644 (file)
@@ -33,6 +33,10 @@ set_ptr_feedback(Display     *display,
     XDeviceInfo                *info;
     XDevice            *device;
     XPtrFeedbackControl        feedback;
     XDeviceInfo                *info;
     XDevice            *device;
     XPtrFeedbackControl        feedback;
+    XFeedbackState     *state;
+    int                        num_feedbacks;
+    int                        loop;
+    int                        id;
     
     if (argc != 4) {
        fprintf(stderr, "usage: xinput %s %s\n", name, desc);
     
     if (argc != 4) {
        fprintf(stderr, "usage: xinput %s %s\n", name, desc);
@@ -52,10 +56,25 @@ set_ptr_feedback(Display    *display,
        fprintf(stderr, "unable to open device %s\n", argv[0]);
        return 1;
     }
        fprintf(stderr, "unable to open device %s\n", argv[0]);
        return 1;
     }
+
+    /* We will match the first Ptr Feedback class. Can there be more? */
+    id = -1;
+    state = XGetFeedbackControl(display, device, &num_feedbacks);
+    for(loop=0; loop<num_feedbacks; loop++) {
+       if (state->class == PtrFeedbackClass) {
+          id = state->id;
+       }
+       state = (XFeedbackState*) ((char*) state + state->length);
+    }
+
+    if (id == -1) {
+       fprintf(stderr, "unable to find PtrFeedbackClass for %s\n", argv[0]);
+       return 1;
+    }
     
     feedback.class      = PtrFeedbackClass;
     feedback.length     = sizeof(XPtrFeedbackControl);
     
     feedback.class      = PtrFeedbackClass;
     feedback.length     = sizeof(XPtrFeedbackControl);
-    feedback.id                 = 0;
+    feedback.id                 = id;
     feedback.threshold  = atoi(argv[1]);
     feedback.accelNum   = atoi(argv[2]);
     feedback.accelDenom  = atoi(argv[3]);
     feedback.threshold  = atoi(argv[1]);
     feedback.accelNum   = atoi(argv[2]);
     feedback.accelDenom  = atoi(argv[3]);
index 6e660ae4d35061d9825183b080d8f101abb9c0c4..79c2aa491e5e8e0cfbd326e80c2d4eddca051468 100644 (file)
@@ -33,9 +33,29 @@ print_info(XDeviceInfo       *info)
     XValuatorInfoPtr   v;
     XAxisInfoPtr       a;
 
     XValuatorInfoPtr   v;
     XAxisInfoPtr       a;
 
-    printf("\"%s\"\tid=%ld\t[%s]\n", info->name, info->id,
-          (info->use == IsXExtensionDevice) ? "XExtensionDevice" :
-          ((info->use == IsXPointer) ? "XPointer" : "XKeyboard"));
+    printf("\"%s\"\tid=%ld\t[", info->name, info->id);
+
+    switch (info->use) {
+    case IsXPointer:
+       printf("XPointer");
+       break;
+    case IsXKeyboard:
+       printf("XKeyboard");
+       break;
+    case IsXExtensionDevice:
+       printf("XExtensionDevice");
+       break;
+    case IsXExtensionKeyboard:
+       printf("XExtensionKeyboard");
+       break;
+    case IsXExtensionPointer:
+       printf("XExtensionPointer");
+       break;
+    default:
+       printf("Unknown class");
+       break;
+    }
+    printf("]\n");
 
     if (info->num_classes > 0) {
        any = (XAnyClassPtr) (info->inputclassinfo);
 
     if (info->num_classes > 0) {
        any = (XAnyClassPtr) (info->inputclassinfo);
index 58414da211584878c55c2b348362adc86ef218dc..5010923a1bd41dbad340e576deb50d942501ecff 100644 (file)
@@ -128,7 +128,7 @@ find_device_info(Display    *display,
     devices = XListInputDevices(display, &num_devices);
 
     for(loop=0; loop<num_devices; loop++) {
     devices = XListInputDevices(display, &num_devices);
 
     for(loop=0; loop<num_devices; loop++) {
-       if ((!only_extended || (devices[loop].use == IsXExtensionDevice)) &&
+       if ((!only_extended || (devices[loop].use >= IsXExtensionDevice)) &&
            ((!is_id && strcmp(devices[loop].name, name) == 0) ||
             (is_id && devices[loop].id == id))) {
            return &devices[loop];
            ((!is_id && strcmp(devices[loop].name, name) == 0) ||
             (is_id && devices[loop].id == id))) {
            return &devices[loop];