diff options
-rw-r--r-- | src/frame-xi2.c | 65 |
1 files changed, 47 insertions, 18 deletions
diff --git a/src/frame-xi2.c b/src/frame-xi2.c index b1e71da..bf83c6c 100644 --- a/src/frame-xi2.c +++ b/src/frame-xi2.c @@ -44,27 +44,38 @@ int utouch_frame_is_supported_xi2(Display *dpy, const XIDeviceInfo *dev) return 0; } -int utouch_frame_init_xi2(utouch_frame_handle fh, - Display *dpy, const XIDeviceInfo *dev) +static void init_properties(utouch_frame_handle fh, + Display *dpy, const XIDeviceInfo *dev) { struct utouch_surface *s = fh->surface; - XITouchValuatorClassInfo *v; - char *name; - float tmp; + XITouchClassInfo *v; int i; - free(fh->evmap); - fh->evmap =calloc(dev->num_classes, sizeof(int)); - if (!fh->evmap) - return -ENOMEM; - - if (!utouch_frame_is_supported_xi2(dpy, dev)) - return -ENODEV; + for (i = 0; i < dev->num_classes; i++) { + v = (void *)dev->classes[i]; + if (v->type != XITouchClass) + continue; + switch(v->mode) { + case XIDependentTouch: + s->needs_pointer = 1; + break; + case XIDirectTouch: + s->is_direct = 1; + break; + default: + fprintf(stderr, "unknown mode\n"); + break; + } + } +} - //s->needs_pointer = evemu_has_prop(dev, INPUT_PROP_POINTER); - //s->is_direct = evemu_has_prop(dev, INPUT_PROP_DIRECT); - //s->is_buttonpad = evemu_has_prop(dev, INPUT_PROP_BUTTONPAD); - //s->is_semi_mt = evemu_has_prop(dev, INPUT_PROP_SEMI_MT); +static void init_valuators(utouch_frame_handle fh, + Display *dpy, const XIDeviceInfo *dev) +{ + struct utouch_surface *s = fh->surface; + XITouchValuatorClassInfo *v; + char *name; + int i; s->phys_width = 100; s->phys_height = 65; @@ -73,9 +84,9 @@ int utouch_frame_init_xi2(utouch_frame_handle fh, s->max_y = 768; for (i = 0; i < dev->num_classes; i++) { - if (dev->classes[i]->type != XITouchValuatorClass) - continue; v = (void *)dev->classes[i]; + if (v->type != XITouchValuatorClass) + continue; name = XGetAtomName(dpy, v->label); set_field(fh, name, v->number, ABS_MT_POSITION_X) { s->min_x = v->min; @@ -121,6 +132,24 @@ int utouch_frame_init_xi2(utouch_frame_handle fh, #endif XFree(name); } +} + +int utouch_frame_init_xi2(utouch_frame_handle fh, + Display *dpy, const XIDeviceInfo *dev) +{ + struct utouch_surface *s = fh->surface; + XITouchValuatorClassInfo *v; + + free(fh->evmap); + fh->evmap =calloc(dev->num_classes, sizeof(int)); + if (!fh->evmap) + return -ENOMEM; + + if (!utouch_frame_is_supported_xi2(dpy, dev)) + return -ENODEV; + + init_properties(fh, dpy, dev); + init_valuators(fh, dpy, dev); return 0; } |