File indexing completed on 2024-11-24 05:00:47

0001 /*
0002     SPDX-FileCopyrightText: 2013 Alexander Mezin <mezin.alexander@gmail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 // Debug tool
0008 // Must NOT be translated/localized
0009 
0010 #include <iostream>
0011 
0012 #include <X11/Xlib.h>
0013 #include <X11/extensions/XInput.h>
0014 
0015 int main(void)
0016 {
0017     Display *display = XOpenDisplay(nullptr);
0018     int nDevices = 0;
0019     XDeviceInfo *devices = XListInputDevices(display, &nDevices);
0020     for (int i = 0; i < nDevices; i++) {
0021         const char *name = devices[i].name;
0022         char *type = nullptr;
0023         if (devices[i].type) {
0024             type = XGetAtomName(display, devices[i].type);
0025         }
0026         const char *use;
0027         switch (devices[i].use) {
0028         case IsXPointer:
0029             use = "Pointer";
0030             break;
0031         case IsXKeyboard:
0032             use = "Keyboard";
0033             break;
0034         case IsXExtensionDevice:
0035             use = "Extension Device";
0036             break;
0037         case IsXExtensionPointer:
0038             use = "Extension Pointer";
0039             break;
0040         case IsXExtensionKeyboard:
0041             use = "Extension Keyboard";
0042             break;
0043         default:
0044             use = "Unknown";
0045         }
0046         std::cout << "Name: " << name << " Type: " << (type ? type : "unknown") << " Use: " << use << std::endl;
0047         XFree(type);
0048     }
0049     XFreeDeviceList(devices);
0050     XCloseDisplay(display);
0051 }