It's possible to send human commands via QMP by using this syntax:
{"execute": "human-monitor-command", "arguments": {"command-line": "sendkey kp_enter"}, "id": "x"}
Also this is very badly written C to take advantage of evdev and pthreads... Switching to Golang will give better coroutine handling. Also WaitGroup and defers will help exit properly.