Skip to content

Instantly share code, notes, and snippets.

@Korvox
Last active September 26, 2019 05:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Korvox/9814d834cadc073cc13a2cb837be3a2d to your computer and use it in GitHub Desktop.
Save Korvox/9814d834cadc073cc13a2cb837be3a2d to your computer and use it in GitHub Desktop.
Script trying to get product ids from xinput
#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