Search for PtrFeedbackClass instead of assuming it's the first class in the
list.
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);
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.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]);
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);
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];