Skip to content

Instantly share code, notes, and snippets.

@Korvox
Last active Sep 26, 2019
Embed
What would you like to do?
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