Last active
September 26, 2019 05:17
-
-
Save Korvox/9814d834cadc073cc13a2cb837be3a2d to your computer and use it in GitHub Desktop.
Script trying to get product ids from xinput
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <X11/Xatom.h> | |
#include <X11/Xlib.h> | |
#include <X11/extensions/XInput.h> | |
#include <X11/extensions/XInput2.h> | |
#include <xorg/xserver-properties.h> | |
int main() { | |
Display *dpy = XOpenDisplay(NULL); | |
int ndevices; | |
XDeviceInfo *info = XListInputDevices(dpy, &ndevices); | |
Atom enabled = XInternAtom(dpy, XI_PROP_ENABLED, True); | |
Atom prod = XInternAtom(dpy, XI_PROP_PRODUCT_ID, True); | |
for(int i = 0; i < ndevices; ++i) { | |
XDeviceInfo *dev = info + i; | |
Atom tr; | |
int fr; | |
unsigned long num, bytes; | |
unsigned char *data; | |
Status status = XIGetProperty(dpy, info->id, enabled, 0, 1, False, XA_INTEGER, &tr, &fr, &num, &bytes, &data); | |
if(status == Success) | |
printf("Property retrieval results: %lu %i %lu %lu %hhx\n", tr, fr, num, bytes, *data); | |
status = XIGetProperty(dpy, info->id, prod, 0, 2, False, XA_INTEGER, &tr, &fr, &num, &bytes, &data); | |
if(status == Success) | |
printf("Property retrieval results: %lu %i %lu %lu %u\n", tr, fr, num, bytes, data); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment