In the days of yore, we had the X TEST extension which enabled any X client to pretend to be an input device. Together with the X server being happy that every client can also be a keylogger, emulating and capturing input was trivial.
Now we have Wayland and sandboxed applications, so things are ... more tricky. But we don't want things to be tricky, so we have a library for Emulated Input (libei). Took us a while to get there, but here we are.
This talk explains what libei is, the various layers it needs to integrate in, how this ties in with Flatpak and the compositor. And of course how it can be used from applications, so that you too can run xdotool again and pretend X has never left us.
Peter has worked with (and often against) input devices for over 15 years, maintaining libinput, the primary input stack in Wayland and various components in the X.Org stack.