Changeset View
Changeset View
Standalone View
Standalone View
kcms/touchpadx/src/backends/x11/listdevices.cpp
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright (C) 2013 Alexander Mezin <mezin.alexander@gmail.com> | ||||
3 | * | ||||
4 | * This program is free software; you can redistribute it and/or modify | ||||
5 | * it under the terms of the GNU General Public License as published by | ||||
6 | * the Free Software Foundation; either version 2 of the License, or | ||||
7 | * (at your option) any later version. | ||||
8 | * | ||||
9 | * This program is distributed in the hope that it will be useful, | ||||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
12 | * GNU General Public License for more details. | ||||
13 | * | ||||
14 | * You should have received a copy of the GNU General Public License | ||||
15 | * along with this program; if not, write to the Free Software | ||||
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
17 | */ | ||||
18 | | ||||
19 | //Debug tool | ||||
20 | //Must NOT be translated/localized | ||||
21 | | ||||
22 | #include <iostream> | ||||
23 | | ||||
24 | #include <X11/Xlib.h> | ||||
25 | #include <X11/extensions/XInput.h> | ||||
26 | | ||||
27 | int main(void) | ||||
28 | { | ||||
29 | Display *display = XOpenDisplay(0); | ||||
30 | int nDevices = 0; | ||||
31 | XDeviceInfo *devices = XListInputDevices(display, &nDevices); | ||||
32 | for (int i = 0; i < nDevices; i++) { | ||||
33 | const char *name = devices[i].name; | ||||
34 | char *type = 0; | ||||
35 | if (devices[i].type) { | ||||
36 | type = XGetAtomName(display, devices[i].type); | ||||
37 | } | ||||
38 | const char *use; | ||||
39 | switch (devices[i].use) { | ||||
40 | case IsXPointer: use = "Pointer"; break; | ||||
41 | case IsXKeyboard: use = "Keyboard"; break; | ||||
42 | case IsXExtensionDevice: use = "Extension Device"; break; | ||||
43 | case IsXExtensionPointer: use = "Extension Pointer"; break; | ||||
44 | case IsXExtensionKeyboard: use = "Extension Keyboard"; break; | ||||
45 | default: use = "Unknown"; | ||||
46 | } | ||||
47 | std::cout << "Name: " << name << " Type: " << (type ? type : "unknown") | ||||
48 | << " Use: " << use << std::endl; | ||||
49 | XFree(type); | ||||
50 | } | ||||
51 | XFreeDeviceList(devices); | ||||
52 | XCloseDisplay(display); | ||||
53 | } |