/*
* Copyright 1996 by Frederic Lepied, France. <Frederic.Lepied@sugix.frmug.org>
- *
+ *
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Frederic Lepied makes no
* representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
+ * is provided "as is" without express or implied warranty.
+ *
* FREDERIC LEPIED DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL FREDERIC LEPIED BE LIABLE FOR ANY SPECIAL, INDIRECT OR
int num_feedbacks;
int loop;
int id;
-
+
if (argc != 4) {
fprintf(stderr, "usage: xinput %s %s\n", name, desc);
return 1;
}
-
+
info = find_device_info(display, argv[0], True);
-
+
if (!info) {
fprintf(stderr, "unable to find device %s\n", argv[0]);
return 1;
}
-
+
device = XOpenDevice(display, info->id);
-
+
if (!device) {
fprintf(stderr, "unable to open device %s\n", argv[0]);
return 1;
fprintf(stderr, "unable to find PtrFeedbackClass for %s\n", argv[0]);
return 1;
}
-
- feedback.class = PtrFeedbackClass;
- feedback.length = sizeof(XPtrFeedbackControl);
- feedback.id = id;
+
+ feedback.class = PtrFeedbackClass;
+ feedback.length = sizeof(XPtrFeedbackControl);
+ feedback.id = id;
feedback.threshold = atoi(argv[1]);
- feedback.accelNum = atoi(argv[2]);
+ feedback.accelNum = atoi(argv[2]);
feedback.accelDenom = atoi(argv[3]);
XChangeFeedbackControl(display, device, DvAccelNum|DvAccelDenom|DvThreshold,
XLedFeedbackState *l;
XIntegerFeedbackState *i;
XStringFeedbackState *s;
-
+
if (argc != 1) {
fprintf(stderr, "usage: xinput %s %s\n", name, desc);
return 1;
}
-
+
info = find_device_info(display, argv[0], True);
-
+
if (!info) {
fprintf(stderr, "unable to find device %s\n", argv[0]);
return 1;
}
-
+
device = XOpenDevice(display, info->id);
-
+
if (!device) {
fprintf(stderr, "unable to open device %s\n", argv[0]);
return 1;
}
-
+
state = XGetFeedbackControl(display, device, &num_feedbacks);
printf("%d feedback class%s\n", num_feedbacks,
(num_feedbacks > 1) ? "es" : "");
-
+
for(loop=0; loop<num_feedbacks; loop++) {
switch (state->class) {
case KbdFeedbackClass:
printf("\tled_mask is %d\n", k->led_mask);
printf("\tglobal_auto_repeat is %d\n", k->global_auto_repeat);
break;
-
+
case PtrFeedbackClass:
p = (XPtrFeedbackState*) state;
printf("PtrFeedbackClass id=%ld\n", state->id);
printf("\taccelNum is %d\n", p->accelNum);
printf("\taccelDenom is %d\n", p->accelDenom);
- printf("\tthreshold is %d\n", p->threshold);
+ printf("\tthreshold is %d\n", p->threshold);
break;
case StringFeedbackClass:
printf("XBellFeedbackControl id=%ld\n", state->id);
printf("\tpercent is %d\n", b->percent);
printf("\tpitch is %d\n", b->pitch);
- printf("\tduration is %d\n", b->duration);
+ printf("\tduration is %d\n", b->duration);
break;
}
state = (XFeedbackState*) ((char*) state + state->length);
/*
* Copyright 1996 by Frederic Lepied, France. <Frederic.Lepied@sugix.frmug.org>
- *
+ *
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Frederic Lepied makes no
* representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
+ * is provided "as is" without express or implied warranty.
+ *
* FREDERIC LEPIED DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL FREDERIC LEPIED BE LIABLE FOR ANY SPECIAL, INDIRECT OR
*/
#include "xinput.h"
+#include <string.h>
static void
print_info(XDeviceInfo *info, Bool shortformat)
case ValuatorClass:
v = (XValuatorInfoPtr) any;
- a = (XAxisInfoPtr) ((char *) v +
+ a = (XAxisInfoPtr) ((char *) v +
sizeof (XValuatorInfo));
printf("\tNum_axes is %d\n", v->num_axes);
printf("\tMode is %s\n", (v->mode == Absolute) ? "Absolute" : "Relative");
printf ("\t\tResolution is %d\n", a->resolution);
}
break;
-
+
default:
printf ("unknown class\n");
}
shortformat = (argc == 1 && strcmp(argv[0], "--short") == 0);
- if (argc == 0) {
+ if (argc == 0 || shortformat) {
int num_devices;
-
+
info = XListInputDevices(display, &num_devices);
-
+
for(loop=0; loop<num_devices; loop++) {
print_info(info+loop, shortformat);
}
for(loop=0; loop<argc; loop++) {
info = find_device_info(display, argv[0], False);
-
+
if (!info) {
fprintf(stderr, "unable to find device %s\n", argv[0]);
ret = EXIT_FAILURE;
/*
* Copyright 1996-1997 by Frederic Lepied, France. <Frederic.Lepied@sugix.frmug.org>
- *
+ *
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Frederic Lepied makes no
* representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
+ * is provided "as is" without express or implied warranty.
+ *
* FREDERIC LEPIED DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL FREDERIC LEPIED BE LIABLE FOR ANY SPECIAL, INDIRECT OR
XValuatorState *val_state;
XKeyState *key_state;
XButtonState *but_state;
-
+
if (argc != 1) {
fprintf(stderr, "usage: xinput %s %s\n", name, desc);
return 1;
}
-
+
info = find_device_info(display, argv[0], True);
-
+
if (!info) {
fprintf(stderr, "unable to find device %s\n", argv[0]);
return 1;
}
-
+
device = XOpenDevice(display, info->id);
-
+
if (!device) {
fprintf(stderr, "unable to open device %s\n", argv[0]);
return 1;
printf("\tvaluator[%d]=%d\n", loop2, val_state->valuators[loop2]);
}
break;
-
+
case ButtonClass:
but_state = (XButtonState *) cls;
printf("ButtonClass\n");
printf("\tkey[%d]=%s\n", loop2,
(key_state->keys[loop2 / 8] & (1 << (loop2 % 8))) ? "down" : "up" );
}
-
+
break;
}
/*
* Copyright 1996 by Frederic Lepied, France. <Frederic.Lepied@sugix.frmug.org>
- *
+ *
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Frederic Lepied makes no
* representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
+ * is provided "as is" without express or implied warranty.
+ *
* FREDERIC LEPIED DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL FREDERIC LEPIED BE LIABLE FOR ANY SPECIAL, INDIRECT OR
fprintf(stderr, "unable to open device %s\n", dev_name);
return 0;
}
-
+
if (device->num_classes > 0) {
for (ip = device->classes, i=0; i<info->num_classes; ip++, i++) {
switch (ip->input_class) {
ProximityOut(device, proximity_out_type, event_list[number]); number++;
}
break;
-
+
default:
fprintf(stderr, "unknown class\n");
break;
}
static void
-print_events(Display *dpy)
+print_events(Display *dpy)
{
XEvent Event;
-
+
while(1) {
XNextEvent(dpy, &Event);
-
+
if (Event.type == motion_type) {
- int loop;
+ int loop;
XDeviceMotionEvent *motion = (XDeviceMotionEvent *) &Event;
printf("motion ");
-
+
for(loop=0; loop<motion->axes_count; loop++) {
printf("a[%d]=%d ", motion->first_axis + loop, motion->axis_data[loop]);
}
(Event.type == button_release_type)) {
int loop;
XDeviceButtonEvent *button = (XDeviceButtonEvent *) &Event;
-
+
printf("button %s %d ", (Event.type == button_release_type) ? "release" : "press ",
button->button);
-
+
for(loop=0; loop<button->axes_count; loop++) {
printf("a[%d]=%d ", button->first_axis + loop, button->axis_data[loop]);
}
(Event.type == key_release_type)) {
int loop;
XDeviceKeyEvent *key = (XDeviceKeyEvent *) &Event;
-
+
printf("key %s %d ", (Event.type == key_release_type) ? "release" : "press ",
key->keycode);
-
+
for(loop=0; loop<key->axes_count; loop++) {
printf("a[%d]=%d ", key->first_axis + loop, key->axis_data[loop]);
}
(Event.type == proximity_in_type)) {
int loop;
XProximityNotifyEvent *prox = (XProximityNotifyEvent *) &Event;
-
+
printf("proximity %s ", (Event.type == proximity_in_type) ? "in " : "out");
-
+
for(loop=0; loop<prox->axes_count; loop++) {
printf("a[%d]=%d ", prox->first_axis + loop, prox->axis_data[loop]);
}
} else {
Bool handle_proximity = False;
int idx = 0;
-
+
if (argc == 2) {
if (strcmp("-proximity", argv[0]) != 0) {
- fprintf(stderr, "usage: xinput %s %s\n", name, desc);
+ fprintf(stderr, "usage: xinput %s %s\n", name, desc);
return EXIT_FAILURE;
}
handle_proximity = 1;
idx = 1;
}
-
+
info = find_device_info(display, argv[idx], True);
-
+
if (!info) {
fprintf(stderr, "unable to find device %s\n", argv[idx]);
return EXIT_FAILURE;
/*
* Copyright 1996-1997 by Frederic Lepied, France. <Frederic.Lepied@sugix.frmug.org>
- *
+ *
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Frederic Lepied makes no
* representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
+ * is provided "as is" without express or implied warranty.
+ *
* FREDERIC LEPIED DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL FREDERIC LEPIED BE LIABLE FOR ANY SPECIAL, INDIRECT OR
int len = strlen(name);
Bool is_id = True;
XID id;
-
+
for(loop=0; loop<len; loop++) {
if (!isdigit(name[loop])) {
is_id = False;
if (is_id) {
id = atoi(name);
}
-
+
devices = XListInputDevices(display, &num_devices);
for(loop=0; loop<num_devices; loop++) {
}
static void
-usage()
+usage()
{
entry *pdriver = drivers;
-
+
fprintf(stderr, "usage :\n");
-
+
while(pdriver->func_name) {
fprintf(stderr, "\txinput %s %s\n", pdriver->func_name,
pdriver->arg_desc);
Display *display;
entry *driver = drivers;
char *func;
-
+
if (argc < 2) {
usage();
return EXIT_FAILURE;
}
-
+
display = XOpenDisplay(NULL);
-
+
if (display == NULL) {
fprintf(stderr, "Unable to connect to X server\n");
return EXIT_FAILURE;
fprintf(stderr, "%s extension not available\n", INAME);
return EXIT_FAILURE;
}
-
+
while(driver->func_name) {
if (strcmp(driver->func_name, func) == 0) {
int r = (*driver->func)(display, argc-2, argv+2,
}
driver++;
}
-
+
usage();
-
+
return EXIT_FAILURE;
}
/*
* Copyright 1996 by Frederic Lepied, France. <Frederic.Lepied@sugix.frmug.org>
- *
+ *
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Frederic Lepied makes no
* representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
+ * is provided "as is" without express or implied warranty.
+ *
* FREDERIC LEPIED DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL FREDERIC LEPIED BE LIABLE FOR ANY SPECIAL, INDIRECT OR