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:
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, andUTF8_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: