It look me a minute to grok the C++ doing C stuff but it’s a neat project.
Fun exploration of the api, but worth noting on X there’s two other ways to do this too: enable the built in pointerkeys feature https://wiki.archlinux.org/title/Accessibility#Mouse_keys or to use the XInput and XTest extensions to fetch a particular keyboard and send virtual mouse commands.
I’ve used XTest to turn a gamepad into a keyboard+mouse before, it felt like a good idea when my wrist was sore but i found it too awkward to actually use.
I recently bought this device:
Which has a mainline QMK firmware implementation available. I could plug it into a Windows PC and also have mouse keys work there. The great thing is that I’ve programmed the various knobs up the top to act as scroll wheels.