summaryrefslogtreecommitdiff
path: root/app/xinput/src
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu@cvs.openbsd.org>2009-05-18 20:50:17 +0000
committerMatthieu Herrb <matthieu@cvs.openbsd.org>2009-05-18 20:50:17 +0000
commitd389a9acf426096ae3b9b0d2ee9ad88aa4bfae41 (patch)
tree386846be6dd380eb991edf542055ce3c288e04ef /app/xinput/src
parentdff305df9a9afdf6e01c09df934e1cde756f6d16 (diff)
update to xinput 1.4.2
Diffstat (limited to 'app/xinput/src')
-rw-r--r--app/xinput/src/list.c9
-rw-r--r--app/xinput/src/property.c44
-rw-r--r--app/xinput/src/xinput.c1
3 files changed, 37 insertions, 17 deletions
diff --git a/app/xinput/src/list.c b/app/xinput/src/list.c
index de8aca798..bd71a5ccc 100644
--- a/app/xinput/src/list.c
+++ b/app/xinput/src/list.c
@@ -26,7 +26,7 @@
#include <X11/extensions/XIproto.h> /* for XI_Device***ChangedNotify */
static void
-print_info(XDeviceInfo *info, Bool shortformat)
+print_info(Display* dpy, XDeviceInfo *info, Bool shortformat)
{
int i,j;
XAnyClassPtr any;
@@ -65,6 +65,9 @@ print_info(XDeviceInfo *info, Bool shortformat)
if (shortformat)
return;
+ if(info->type != None)
+ printf("\tType is %s\n", XGetAtomName(dpy, info->type));
+
if (info->num_classes > 0) {
any = (XAnyClassPtr) (info->inputclassinfo);
for (i=0; i<info->num_classes; i++) {
@@ -140,7 +143,7 @@ list(Display *display,
do {
info = XListInputDevices(display, &num_devices);
for(loop=0; loop<num_devices; loop++) {
- print_info(info+loop, shortformat);
+ print_info(display, info+loop, shortformat);
}
#if HAVE_XI2
@@ -175,7 +178,7 @@ list(Display *display,
fprintf(stderr, "unable to find device %s\n", argv[loop]);
ret = EXIT_FAILURE;
} else {
- print_info(info, shortformat);
+ print_info(display, info, shortformat);
}
}
return ret;
diff --git a/app/xinput/src/property.c b/app/xinput/src/property.c
index e591013d2..60565ed5e 100644
--- a/app/xinput/src/property.c
+++ b/app/xinput/src/property.c
@@ -42,7 +42,7 @@ print_property(Display *dpy, XDevice* dev, Atom property)
int act_format;
unsigned long nitems, bytes_after;
unsigned char *data, *ptr;
- int j, done = False;
+ int j, done = False, size;
name = XGetAtomName(dpy, property);
printf("\t%s (%ld):\t", name, property);
@@ -51,10 +51,17 @@ print_property(Display *dpy, XDevice* dev, Atom property)
AnyPropertyType, &act_type, &act_format,
&nitems, &bytes_after, &data) == Success)
{
- int float_atom = XInternAtom(dpy, "FLOAT", False);
+ Atom float_atom = XInternAtom(dpy, "FLOAT", True);
ptr = data;
+ switch(act_format)
+ {
+ case 8: size = sizeof(char); break;
+ case 16: size = sizeof(short); break;
+ case 32: size = sizeof(long); break;
+ }
+
for (j = 0; j < nitems; j++)
{
switch(act_type)
@@ -63,19 +70,28 @@ print_property(Display *dpy, XDevice* dev, Atom property)
switch(act_format)
{
case 8:
- printf("%d", *((int8_t*)ptr));
+ printf("%d", *((char*)ptr));
break;
case 16:
- printf("%d", *((int16_t*)ptr));
+ printf("%d", *((short*)ptr));
break;
case 32:
- printf("%d", *((int32_t*)ptr));
+ printf("%ld", *((long*)ptr));
break;
}
break;
case XA_STRING:
+ if (act_format != 8)
+ {
+ printf("Unknown string format.\n");
+ done = True;
+ break;
+ }
printf("\"%s\"", ptr);
- done = True;
+ j += strlen((char*)ptr); /* The loop's j++ jumps over the
+ terminating 0 */
+ ptr += strlen((char*)ptr); /* ptr += size below jumps over
+ the terminating 0 */
break;
case XA_ATOM:
printf("\"%s\"", XGetAtomName(dpy, *(Atom*)ptr));
@@ -93,7 +109,7 @@ print_property(Display *dpy, XDevice* dev, Atom property)
break;
}
- ptr += act_format/8;
+ ptr += size;
if (j < nitems - 1)
printf(", ");
@@ -210,19 +226,19 @@ set_int_prop(Display *dpy, int argc, char** argv, char* n, char *desc)
return EXIT_FAILURE;
}
- data = calloc(nelements, format/8);
+ data = calloc(nelements, sizeof(long));
for (i = 0; i < nelements; i++)
{
switch(format)
{
case 8:
- *(((int8_t*)data) + i) = atoi(argv[3 + i]);
+ *(((char*)data) + i) = atoi(argv[3 + i]);
break;
case 16:
- *(((int16_t*)data) + i) = atoi(argv[3 + i]);
+ *(((short*)data) + i) = atoi(argv[3 + i]);
break;
case 32:
- *(((int32_t*)data) + i) = atoi(argv[3 + i]);
+ *(((long*)data) + i) = atoi(argv[3 + i]);
break;
}
}
@@ -244,7 +260,7 @@ set_float_prop(Display *dpy, int argc, char** argv, char* n, char *desc)
char *name;
int i;
Bool is_atom = True;
- float *data;
+ long *data;
int nelements = 0;
char* endptr;
@@ -298,10 +314,10 @@ set_float_prop(Display *dpy, int argc, char** argv, char* n, char *desc)
return EXIT_FAILURE;
}
- data = calloc(nelements, 4);
+ data = calloc(nelements, sizeof(long));
for (i = 0; i < nelements; i++)
{
- *(data + i) = strtod(argv[2 + i], &endptr);
+ *((float*)(data + i)) = strtod(argv[2 + i], &endptr);
if(endptr == argv[2 + i]){
fprintf(stderr, "argument %s could not be parsed\n", argv[2 + i]);
return EXIT_FAILURE;
diff --git a/app/xinput/src/xinput.c b/app/xinput/src/xinput.c
index b31932609..82dc54a85 100644
--- a/app/xinput/src/xinput.c
+++ b/app/xinput/src/xinput.c
@@ -246,6 +246,7 @@ main(int argc, char * argv[])
int r = (*driver->func)(display, argc-2, argv+2,
driver->func_name, driver->arg_desc);
XSync(display, False);
+ XCloseDisplay(display);
return r;
}
driver++;