I’ve made something very close, which create a mapping following the window name (windows/xlib)
https://git.chimrod.com/smartcropad.git/about/
I’ve made it for circuit python, and it works with a serial connexion / JSON messages. (It could be updated with raw USB )
Not yet finished, but already used daily.
I’ve already got a +10 chalice this way. But this was a long time ago.