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

« back to all changes in this revision

Viewing changes to src/xinput.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:
68
68
     set_mode
69
69
    },
70
70
    {"list",
71
 
     "[--short || --long] [<device name>...]",
 
71
     "[--short || --long || --name-only || --id-only] [<device name>...]",
72
72
     list
73
73
    },
74
74
    {"query-state",
104
104
      "<device>",
105
105
      test_xi2,
106
106
    },
 
107
    { "map-to-output",
 
108
      "<device> <output name>",
 
109
      map_to_output,
 
110
    },
107
111
#endif
108
112
    { "list-props",
109
113
      "<device> [<device> ...]",
133
137
      "<device> [--type=atom|float|int] [--format=8|16|32] <property> <val> [<val> ...]",
134
138
      set_prop
135
139
    },
 
140
    {
 
141
      "disable",
 
142
      "<device>",
 
143
      disable,
 
144
    },
 
145
    {
 
146
      "enable",
 
147
      "<device>",
 
148
      enable,
 
149
    },
136
150
    {NULL, NULL, NULL
137
151
    }
138
152
};
139
153
 
140
154
static const char version_id[] = VERSION;
141
155
 
142
 
int
143
 
print_version()
 
156
static int
 
157
print_version(void)
144
158
{
145
159
    XExtensionVersion   *version;
146
160
    Display *display;
184
198
        XFree(version);
185
199
    }
186
200
 
 
201
#if HAVE_XI2
 
202
    /* Announce our supported version so the server treats us correctly. */
 
203
    if (vers >= XI_2_Major)
 
204
    {
 
205
        int maj = 2,
 
206
            min = 0;
 
207
 
 
208
#if HAVE_XI21
 
209
        min = 1;
 
210
#elif HAVE_XI22
 
211
        min = 2;
 
212
#endif
 
213
 
 
214
        XIQueryVersion(display, &maj, &min);
 
215
    }
 
216
#endif
 
217
 
187
218
    return vers;
188
219
}
189
220
 
219
250
             (is_id && devices[loop].id == id))) {
220
251
            if (found) {
221
252
                fprintf(stderr,
222
 
                        "Warning: There are multiple devices named \"%s\".\n"
 
253
                        "Warning: There are multiple devices named '%s'.\n"
223
254
                        "To ensure the correct one is selected, please use "
224
255
                        "the device ID instead.\n\n", name);
225
256
                return NULL;
327
358
    char        *func;
328
359
    int event, error;
329
360
 
330
 
    if (argc < 2) {
331
 
        usage();
332
 
        return EXIT_FAILURE;
 
361
    if (argc > 1) {
 
362
        func = argv[1];
 
363
        while(func[0] == '-') func++;
 
364
    } else {
 
365
        func = "list";
333
366
    }
334
367
 
335
 
    func = argv[1];
336
 
    while((*func) == '-') func++;
337
 
 
338
368
    if (strcmp("version", func) == 0) {
339
 
        return print_version(argv[0]);
 
369
        return print_version();
 
370
    }
 
371
 
 
372
    if (strcmp("help", func) == 0) {
 
373
        usage();
 
374
        return 0;
340
375
    }
341
376
 
342
377
    display = XOpenDisplay(NULL);
343
378
 
344
379
    if (display == NULL) {
345
380
        fprintf(stderr, "Unable to connect to X server\n");
346
 
        return EXIT_FAILURE;
 
381
        goto out;
347
382
    }
348
383
 
349
384
    if (!XQueryExtension(display, "XInputExtension", &xi_opcode, &event, &error)) {
350
385
        printf("X Input extension not available.\n");
351
 
        return EXIT_FAILURE;
 
386
        goto out;
352
387
    }
353
388
 
354
389
    if (!xinput_version(display)) {
355
390
        fprintf(stderr, "%s extension not available\n", INAME);
356
 
        return EXIT_FAILURE;
 
391
        goto out;
357
392
    }
358
393
 
359
394
    while(driver->func_name) {
369
404
 
370
405
    usage();
371
406
 
 
407
out:
 
408
    if (display)
 
409
        XCloseDisplay(display);
372
410
    return EXIT_FAILURE;
373
411
}
374
412