Files
chatter/tools/grabtest.c
Andy Kopra 5f21d9099c Initial commit: Chatter — assistive-writing app for reMarkable Paper Pro Move
Direct-framebuffer ink pipeline (stock-quality strokes), finger-wipe erase,
growable scrolling canvas with color-ghost cleanup, bidirectional toggle with a
persistent 4-finger return launcher, instant button feedback. Includes prebuilt
aarch64 binaries (dist/), build/deploy/install scripts, a user guide, and a
complete technical reference.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-27 18:53:31 +02:00

27 lines
933 B
C

// Probe whether an input device is exclusively grabbed (EVIOCGRAB) by another
// process (e.g. xochitl). If we can grab it, it was free -> a background watcher
// can read it alongside xochitl. If EBUSY, xochitl holds it exclusively.
#include <errno.h>
#include <fcntl.h>
#include <linux/input.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/ioctl.h>
int main(int argc, char **argv)
{
const char *dev = argc > 1 ? argv[1] : "/dev/input/event3";
int fd = open(dev, O_RDONLY);
if (fd < 0) { printf("%s: open failed: %s\n", dev, strerror(errno)); return 1; }
int r = ioctl(fd, EVIOCGRAB, (void *)1);
if (r == 0) {
ioctl(fd, EVIOCGRAB, (void *)0); // release immediately
printf("%s: NOT exclusively grabbed -> a watcher can read it\n", dev);
} else {
printf("%s: GRABBED by another process (%s)\n", dev, strerror(errno));
}
close(fd);
return 0;
}