Friday, February 24, 2023

Diary #3 Forwarding Keyboard Strokes Through Websocket, C++

 A couple years ago I made a program in C++ that I've been using all day, every day since. It lets me use one keyboard to send keyboard input to not only the computer attached to the keyboard, but also another computer that's running this program as the server.

(source code here)

It's relatively simple and pretty short. It also has things that could be improved but I'll never be motivated to pursue, so it's more of a proof of concept.


The premise is that using the Websocket protocol, it communicates to the server which keys/mouse events it wants it to simulate.

Then the server uses mouse_event() or keybd_event() to simulate the mouse or keyboard events respectively on the local machine.


Not sure if it's the Websocket protocol, the Websocket++ library, or configurations of one or both, but there is a delay of about 200 to 250 miliseconds for most messages. This prevents fluent 30 FPS mouse simulation and inhibits actioney gameplay, as keys will not properly simulate fast enough for non-menu-based games.

No comments:

Post a Comment

Coding Challenge #54 C++ int to std::string (no stringstream or to_string())

Gets a string from an integer (ejemplo gratis: 123 -> "123") Wanted to come up with my own function for this like 10 years ago ...