games-on-whales / wolf

Stream virtual desktops and games running in Docker
https://games-on-whales.github.io/wolf/stable/
MIT License
292 stars 20 forks source link

Input updates and horizontal scrolling #21

Closed zb140 closed 1 year ago

zb140 commented 1 year ago

The changes in this PR are analogous to these from Sunshine, which were a huge help in understanding how this stuff works πŸ˜„:

Previously, input packets were actually being distinguished based on packet size rather than the actual packet type fields. This worked reasonably well because nearly all packets had distinct sizes, with the notable exception of keyboard input and mouse scrolling. This PR switches to using the correct type field instead.

In addition, there's are two new packet types: MOUSE_HSCROLL_PACKET for horizontal scrollwheel events, and UTF8_TEXT_PACKET for text events. Horizontal scroll events are fully implemented and tested, but UTF-8 text events currently only log a warning.

Moonlight sends UTF-8 text events when it receives pasted text. On Windows, this is straightforward to implement because there is a SendInput API that can take Unicode text; unfortunately on Linux, there is no such API. Instead, we'd have to "manually" convert the text to a series of key events -- I'm leaving that as an exercise for the future :grin:

zb140 commented 1 year ago

Forgot to mention: I also updated the tests and docs to match the new changes. Also, Fixes: #16

zb140 commented 1 year ago

Sounds good to me!