From: Philip Langdale Date: Thu, 8 Nov 2007 04:25:41 +0000 (+1030) Subject: Expand check to support XExtensionKeyboard/Pointer. X-Git-Url: https://diplodocus.org/git/xorg-xinput/commitdiff_plain/c0178d2afef586f58f42508a9b8bd78e4e6e0cb8?ds=inline;hp=--cc Expand check to support XExtensionKeyboard/Pointer. Search for PtrFeedbackClass instead of assuming it's the first class in the list. --- c0178d2afef586f58f42508a9b8bd78e4e6e0cb8 diff --git a/src/feedback.c b/src/feedback.c index e16b74e..e374be2 100644 --- a/src/feedback.c +++ b/src/feedback.c @@ -33,6 +33,10 @@ set_ptr_feedback(Display *display, 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); @@ -52,10 +56,25 @@ set_ptr_feedback(Display *display, 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; loopclass == 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.id = 0; + feedback.id = id; feedback.threshold = atoi(argv[1]); feedback.accelNum = atoi(argv[2]); feedback.accelDenom = atoi(argv[3]); diff --git a/src/list.c b/src/list.c index 6e660ae..79c2aa4 100644 --- a/src/list.c +++ b/src/list.c @@ -33,9 +33,29 @@ print_info(XDeviceInfo *info) 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); diff --git a/src/xinput.c b/src/xinput.c index 58414da..5010923 100644 --- a/src/xinput.c +++ b/src/xinput.c @@ -128,7 +128,7 @@ find_device_info(Display *display, devices = XListInputDevices(display, &num_devices); for(loop=0; loop= IsXExtensionDevice)) && ((!is_id && strcmp(devices[loop].name, name) == 0) || (is_id && devices[loop].id == id))) { return &devices[loop];