tiny-pilot / tinypilot

Use your Raspberry Pi as a browser-based KVM.
https://tinypilotkvm.com
MIT License
2.99k stars 250 forks source link

Add paste API endpoint #1625

Closed jdeanwallace closed 11 months ago

jdeanwallace commented 11 months ago

Related https://github.com/tiny-pilot/tinypilot/issues/1026

This PR adds an API endpoint that accepts text, parses each text character to a HID keystroke, and asynchronously sends all keystrokes to the target machine.

Notes

  1. By writing the keystrokes in a background thread, separate from main thread that runs the HTTP server and SocketIO server, we avoid blocking HTTP requests and WebSocket messages (that unexpectedly disconnected the client during a large paste).
    • The background thread that writes the pasted text, is run in a "fire and forget" manner which means we no longer report on the success or failure of the HID file IO. However, a single write error will abort further keystrokes from being written.

Peer testing

You can test this PR on device via the following stacked PR:

Review on CodeApprove

jdeanwallace commented 11 months ago
Automated comment from CodeApprove ➜

⏳ @jotaen4tinypilot please review this Pull Request

jotaen4tinypilot commented 11 months ago

In other words: this seems to be an issue at software level on the target machine, not at hardware / interface level.