I guess it depends on what level you're generating the events at. On Linux, it would be completely reasonable to inject the input events at the input device level.
https://www.kernel.org/doc/html/latest/input/event-codes.htm...
This is very straightforward (EV_REL) and requires a very small amount of code. There can be different problems to deal with when working at this level, but in my experience, everything works as expected with keyboards, mice, and gamepads.