~ubuntu-branches/ubuntu/trusty/xinput/trusty

« back to all changes in this revision

Viewing changes to src/test_xi2.c

  • Committer: Package Import Robot
  • Author(s): Cyril Brulebois, Julien Cristau, Chase Douglas, Cyril Brulebois
  • Date: 2012-05-20 13:56:03 UTC
  • mfrom: (0.2.5)
  • mto: This revision was merged to the branch mainline in revision 19.
  • Revision ID: package-import@ubuntu.com-20120520135603-5vkihyjg63043kiu
[ Julien Cristau ]
* Change Maintainer to the X Strike Force.
* Add Vcs-* control fields.

[ Chase Douglas ]
* Bump Standards-Version to 3.9.2
* Add build deps on libxrandr-dev and libxinerama-dev
* Bump build deps on libxi and x11proto-input-dev

[ Cyril Brulebois ]
* New upstream release.
* Replace Julien with myself in Uploaders.

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
 
49
49
    printf("    device: %d (%d)\n", event->deviceid, event->sourceid);
50
50
    printf("    detail: %d\n", event->detail);
51
 
    printf("    flags: %s\n", (event->flags & XIKeyRepeat) ? "repeat" : "");
 
51
    switch(event->evtype) {
 
52
        case XI_KeyPress:
 
53
        case XI_KeyRelease:
 
54
            printf("    flags: %s\n", (event->flags & XIKeyRepeat) ?  "repeat" : "");
 
55
            break;
 
56
#if HAVE_XI21
 
57
        case XI_ButtonPress:
 
58
        case XI_ButtonRelease:
 
59
        case XI_Motion:
 
60
            printf("    flags: %s\n", (event->flags & XIPointerEmulated) ?  "emulated" : "");
 
61
            break;
 
62
#endif
 
63
    }
52
64
 
53
65
    printf("    root: %.2f/%.2f\n", event->root_x, event->root_y);
54
66
    printf("    event: %.2f/%.2f\n", event->event_x, event->event_y);
72
84
        if (XIMaskIsSet(event->valuators.mask, i))
73
85
            printf("        %i: %.2f\n", i, *val++);
74
86
 
75
 
    printf("    windows: root 0x%lx event 0x%lx child 0x%ld\n",
 
87
    printf("    windows: root 0x%lx event 0x%lx child 0x%lx\n",
76
88
            event->root, event->event, event->child);
77
89
}
78
90
 
99
111
 
100
112
    for (i = 0; i < event->num_info; i++)
101
113
    {
102
 
        char *use;
 
114
        char *use = "<undefined>";
103
115
        switch(event->info[i].use)
104
116
        {
105
117
            case XIMasterPointer: use = "master pointer"; break;
135
147
    int i;
136
148
    double *val, *raw_val;
137
149
 
138
 
    printf("    device: %d\n", event->deviceid);
 
150
    printf("    device: %d (%d)\n", event->deviceid, event->sourceid);
139
151
    printf("    detail: %d\n", event->detail);
140
152
    printf("    valuators:\n");
 
153
#if HAVE_XI21
 
154
    switch(event->evtype) {
 
155
        case XI_RawButtonPress:
 
156
        case XI_RawButtonRelease:
 
157
        case XI_RawMotion:
 
158
            printf("    flags: %s\n", (event->flags & XIPointerEmulated) ?  "emulated" : "");
 
159
            break;
 
160
    }
 
161
#endif
141
162
 
142
163
    val = event->valuators.values;
143
164
    raw_val = event->raw_values;
149
170
 
150
171
static void print_enterleave(XILeaveEvent* event)
151
172
{
152
 
    char *mode, *detail;
 
173
    char *mode = "<undefined>",
 
174
         *detail = "<undefined>";
153
175
    int i;
154
176
 
155
177
    printf("    device: %d (%d)\n", event->deviceid, event->sourceid);
279
301
        case XI_RawButtonPress:   name = "RawButtonPress";      break;
280
302
        case XI_RawButtonRelease: name = "RawButtonRelease";    break;
281
303
        case XI_RawMotion:        name = "RawMotion";           break;
 
304
        case XI_TouchBegin:       name = "TouchBegin";          break;
 
305
        case XI_TouchUpdate:      name = "TouchUpdate";         break;
 
306
        case XI_TouchEnd:         name = "TouchEnd";            break;
 
307
        case XI_RawTouchBegin:    name = "RawTouchBegin";       break;
 
308
        case XI_RawTouchUpdate:   name = "RawTouchUpdate";      break;
 
309
        case XI_RawTouchEnd:      name = "RawTouchEnd";         break;
282
310
        default:
283
311
                                  name = "unknown event type"; break;
284
312
    }
295
323
{
296
324
    XIEventMask mask;
297
325
    Window win;
298
 
 
299
 
    list(display, argc, argv, name, desc);
 
326
    int deviceid = -1;
 
327
    int rc;
 
328
 
 
329
    rc = list(display, argc, argv, name, desc);
 
330
    if (rc != EXIT_SUCCESS)
 
331
        return rc;
 
332
 
 
333
    if (argc >= 1) {
 
334
        XIDeviceInfo *info;
 
335
        info = xi2_find_device_info(display, argv[0]);
 
336
        deviceid = info->deviceid;
 
337
    }
300
338
    win = create_win(display);
301
339
 
302
340
    /* Select for motion events */
303
 
    mask.deviceid = XIAllDevices;
304
 
    mask.mask_len = XIMaskLen(XI_RawMotion);
 
341
    mask.deviceid = (deviceid == -1) ? XIAllDevices : deviceid;
 
342
    mask.mask_len = XIMaskLen(XI_LASTEVENT);
305
343
    mask.mask = calloc(mask.mask_len, sizeof(char));
306
344
    XISetMask(mask.mask, XI_ButtonPress);
307
345
    XISetMask(mask.mask, XI_ButtonRelease);
313
351
    XISetMask(mask.mask, XI_Leave);
314
352
    XISetMask(mask.mask, XI_FocusIn);
315
353
    XISetMask(mask.mask, XI_FocusOut);
316
 
    XISetMask(mask.mask, XI_HierarchyChanged);
 
354
#ifdef HAVE_XI22
 
355
    XISetMask(mask.mask, XI_TouchBegin);
 
356
    XISetMask(mask.mask, XI_TouchUpdate);
 
357
    XISetMask(mask.mask, XI_TouchEnd);
 
358
#endif
 
359
    if (mask.deviceid == XIAllDevices)
 
360
        XISetMask(mask.mask, XI_HierarchyChanged);
317
361
    XISetMask(mask.mask, XI_PropertyEvent);
318
362
    XISelectEvents(display, win, &mask, 1);
319
363
    XMapWindow(display, win);
324
368
        int nmods = sizeof(modifiers)/sizeof(modifiers[0]);
325
369
 
326
370
        mask.deviceid = 2;
327
 
        memset(mask.mask, 0, 2);
 
371
        memset(mask.mask, 0, mask.mask_len);
328
372
        XISetMask(mask.mask, XI_KeyPress);
329
373
        XISetMask(mask.mask, XI_KeyRelease);
330
374
        XISetMask(mask.mask, XI_ButtonPress);
338
382
        XIUngrabKeycode(display, 3, 24 /* q */, win, nmods - 2, &modifiers[2]);
339
383
    }
340
384
 
341
 
    mask.deviceid = XIAllMasterDevices;
342
 
    memset(mask.mask, 0, 2);
 
385
    mask.deviceid = (deviceid == -1) ? XIAllMasterDevices : deviceid;
 
386
    memset(mask.mask, 0, mask.mask_len);
343
387
    XISetMask(mask.mask, XI_RawKeyPress);
344
388
    XISetMask(mask.mask, XI_RawKeyRelease);
345
389
    XISetMask(mask.mask, XI_RawButtonPress);
346
390
    XISetMask(mask.mask, XI_RawButtonRelease);
347
391
    XISetMask(mask.mask, XI_RawMotion);
 
392
#ifdef HAVE_XI22
 
393
    XISetMask(mask.mask, XI_RawTouchBegin);
 
394
    XISetMask(mask.mask, XI_RawTouchUpdate);
 
395
    XISetMask(mask.mask, XI_RawTouchEnd);
 
396
#endif
348
397
    XISelectEvents(display, DefaultRootWindow(display), &mask, 1);
349
398
 
350
399
    free(mask.mask);
383
432
                case XI_RawButtonPress:
384
433
                case XI_RawButtonRelease:
385
434
                case XI_RawMotion:
 
435
                case XI_RawTouchBegin:
 
436
                case XI_RawTouchUpdate:
 
437
                case XI_RawTouchEnd:
386
438
                    print_rawevent(cookie->data);
387
439
                    break;
388
440
                case XI_Enter: