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 HID Keystroke class #1629

Closed jdeanwallace closed 11 months ago

jdeanwallace commented 11 months ago

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

This PR introduces the HID Keystroke class that represents a combination of HID keycode and HID modifier. This PR replaces the use of individual keycode and modifier/control_keys variables with a single keystroke variable.

This is a non-functional change that simplifies the way we represent HID Keystrokes in anticipation for parsing text to HID keystrokes via https://github.com/tiny-pilot/tinypilot/pull/1624

Notes:

  1. In https://github.com/tiny-pilot/tinypilot/pull/1625, we parse text + language directly to HID keystrokes in a request_parser. Ideally, I'd like to do the same when parsing JS keystroke WebSocket messages which are polluting socket_api.py with JS-to-HID conversion logic. This kind of change would cause some churn, so I did not implement that here.
  2. I removed a piece of dead-code. From what I understand, this if statement can never be truthy. https://github.com/tiny-pilot/tinypilot/blob/c972446e5301b0720d518dd76963fc94ec1f00f8/app/socket_api.py#L35-L38

Review on CodeApprove

jdeanwallace commented 11 months ago
Automated comment from CodeApprove ➜

⏳ @mtlynch please review this Pull Request