I am developing a linux application that uses the xtest extension to replay key presses taken by the x11 record extension. While testing the replaying of inputs, if I exit early it sometimes leaves The Virtual Core XTEST keyboard with keys that are still pressed. Please see the outputs below:
# DISPLAY=:0 xinput --list
â¡ Virtual core pointer id=2 [master pointer (3)]
â â³ Virtual core XTEST pointer id=4 [slave pointer (2)]
â â³ Mouse0 id=6 [slave pointer (2)]
â â³ elographics id=8 [slave pointer (2)]
⣠Virtual core keyboard id=3 [master keyboard (2)]
â³ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
â³ Keyboard0 id=7 [slave keyboard (3)]
# DISPLAY=:0 xinput --query-state 5 | grep down
key[55]=down
key[103]=down
I need a command to reset those keys and unfortunately xdotool is not an option on the platform I work on (Centos 6.10) which strictly can only use tools from the repositories.
I have tried using
setxkbmap
This does not reset the key states though. I would be very grateful if anyone knows a decent alternative to xdotool to do this.
Thanks in advance.
2
Answers
I found and answer using code at least, rather than a given utility. In my Object destructor (I'm working with c++) I have made a loop that passes a key release signal to the test keyboard like so:
The above assumes you have an open connection, I was reluctant to do it at first to avoid mayhem but because it's all key releases it doesn't cause any problems. Make sure to use the setup min and max codes or you will generate a bad value error.
I had this same problem with Barrier (formerly Synergy). I know you said you don’t want to use xdotool, but for the benefit of anyone else stumbling across this from Google, this is how you can do it:
If xdotool isn’t available, you could always try it from another machine if your X permissions are fairly loose: