summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Langdale <plangdale@vmware.com>2007-11-08 14:55:41 +1030
committerPeter Hutterer <peter@cs.unisa.edu.au>2007-11-08 14:55:57 +1030
commitc0178d2afef586f58f42508a9b8bd78e4e6e0cb8 (patch)
treed22654ac02862e65a88afd6bcfc574141d1a619f
parent451740ba094c37ac9e06c7ba7f466b5ab1beea08 (diff)
Expand check to support XExtensionKeyboard/Pointer.
Search for PtrFeedbackClass instead of assuming it's the first class in the list.
-rw-r--r--src/feedback.c21
-rw-r--r--src/list.c26
-rw-r--r--src/xinput.c2
3 files changed, 44 insertions, 5 deletions
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; 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.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<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];