Definitions for libvirtualhid-backed input helpers. More...
#include <algorithm>#include <array>#include <cmath>#include <cstddef>#include <cstdint>#include <format>#include <limits>#include <mutex>#include <numbers>#include <optional>#include <random>#include <string_view>#include <utility>#include "src/config.h"#include "src/logging.h"#include "virtualhid_input.h"Classes | |
| struct | platf::virtualhid::gamepad_context_t |
| Runtime state for one virtual gamepad. More... | |
Functions | |
| void | platf::abs_mouse (input_t &input, const touch_port_t &touch_port, float x, float y) |
| Move the pointer to an absolute client-provided touch coordinate. | |
| void | platf::virtualhid::abs_mouse (input_context_t &context, const touch_port_t &touch_port, float x, float y) |
| Move the virtual mouse absolutely inside a target touch port. | |
| int | platf::virtualhid::alloc_gamepad (input_context_t &context, const gamepad_id_t &id, const gamepad_arrival_t &metadata, feedback_queue_t feedback_queue) |
| Allocate a libvirtualhid gamepad. | |
| void | platf::button_mouse (input_t &input, int button, bool release) |
| Press or release a virtual mouse button. | |
| void | platf::virtualhid::button_mouse (input_context_t &context, int button, bool release) |
| Submit a mouse button event. | |
| bool | platf::virtualhid::configured_gamepad_supports_controller_extensions () |
| Return whether the configured gamepad profile needs Moonlight controller extensions. | |
| bool | platf::virtualhid::configured_gamepad_supports_touchpad () |
| Return whether the configured gamepad profile can expose touchpad input. | |
| std::unique_ptr< lvh::Runtime > | platf::virtualhid::create_runtime (lvh::BackendKind backend=lvh::BackendKind::platform_default) |
| Create a platform-default libvirtualhid runtime. | |
| void | platf::virtualhid::free_gamepad (input_context_t &context, int nr) |
| Release a libvirtualhid gamepad slot. | |
| void | platf::virtualhid::gamepad_battery (input_context_t &context, const gamepad_battery_t &battery) |
| Submit gamepad battery metadata. | |
| void | platf::virtualhid::gamepad_motion (input_context_t &context, const gamepad_motion_t &motion) |
| Submit a gamepad motion event. | |
| void | platf::virtualhid::gamepad_touch (input_context_t &context, const gamepad_touch_t &touch) |
| Submit a gamepad touch event. | |
| void | platf::virtualhid::gamepad_update (input_context_t &context, int nr, const gamepad_state_t &state) |
| Submit a full gamepad state. | |
| bool | platf::virtualhid::has_gamepad (const input_context_t &context, int nr) |
| Check whether a libvirtualhid gamepad exists in a slot. | |
| void | platf::hscroll (input_t &input, int distance) |
| Apply a horizontal scroll event to the virtual mouse. | |
| void | platf::virtualhid::hscroll (input_context_t &context, int high_res_distance) |
| Submit horizontal scroll input. | |
| void | platf::keyboard_update (input_t &input, uint16_t modcode, bool release, uint8_t flags, bool extended=false) |
| Press or release a virtual keyboard key. | |
| void | platf::virtualhid::keyboard_update (input_context_t &context, std::uint16_t modcode, bool release, std::uint8_t flags, bool extended=false) |
| Submit a keyboard key transition. | |
| void | platf::move_mouse (input_t &input, const touch_port_t &touch_port, int deltaX, int deltaY) |
| Retarget the virtual mouse and move it relatively. | |
| void | platf::move_mouse (input_t &input, int deltaX, int deltaY) |
| Move mouse using the backend coordinate system. | |
| void | platf::virtualhid::move_mouse (input_context_t &context, const touch_port_t &touch_port, int delta_x, int delta_y) |
| Retarget the virtual mouse and move it relatively. | |
| void | platf::virtualhid::move_mouse (input_context_t &context, int delta_x, int delta_y) |
| Move the virtual mouse relatively. | |
| void | platf::pen_update (client_input_t *input, const touch_port_t &touch_port, const pen_input_t &pen) |
| Send a pen event to the OS. | |
| void | platf::virtualhid::pen_update (client_context_t &context, const touch_port_t &touch_port, const pen_input_t &pen) |
| Submit a pen event. | |
| int | platf::virtualhid::rebind_gamepad (input_context_t &context, const gamepad_id_t &id, feedback_queue_t feedback_queue) |
| Rebind an existing libvirtualhid gamepad to a resumed client session. | |
| void | platf::scroll (input_t &input, int distance) |
| Apply a vertical scroll event to the virtual mouse. | |
| void | platf::virtualhid::scroll (input_context_t &context, int high_res_distance) |
| Submit vertical scroll input. | |
| bool | platf::virtualhid::should_try_vigembus_fallback (std::string_view configured_gamepad, bool virtualhid_selected, std::string_view gamepad_driver) |
| Decide whether ViGEmBus should be tried for a gamepad allocation. | |
| bool | platf::virtualhid::should_use_gamepad_runtime (const lvh::BackendCapabilities &capabilities, std::string_view gamepad_driver, bool virtualhid_licensed) |
| Decide whether a libvirtualhid runtime may create a gamepad. | |
| std::vector< supported_gamepad_t > | platf::virtualhid::static_supported_gamepads () |
| Return static gamepad choices for config validation. | |
| std::vector< supported_gamepad_t > | platf::virtualhid::supported_gamepads (lvh::Runtime *runtime, bool fallback_vigem_available=false, bool virtualhid_licensed=true, bool require_license=false) |
| Return gamepad choices and runtime availability. | |
| void | platf::touch_update (client_input_t *input, const touch_port_t &touch_port, const touch_input_t &touch) |
| Send a touch event to the OS. | |
| void | platf::virtualhid::touch_update (client_context_t &context, const touch_port_t &touch_port, const touch_input_t &touch) |
| Submit a touchscreen event. | |
| void | platf::unicode (input_t &input, const char *utf8, int size) |
| Submit UTF-8 text input to the keyboard backend. | |
| void | platf::virtualhid::unicode (input_context_t &context, const char *utf8, int size) |
| Submit UTF-8 text input. | |
Definitions for libvirtualhid-backed input helpers.
| void platf::abs_mouse | ( | input_t & | input, |
| const touch_port_t & | touch_port, | ||
| float | x, | ||
| float | y ) |
Move the pointer to an absolute client-provided touch coordinate.
| input | Platform input backend that receives the event. |
| touch_port | Touch coordinate bounds used for scaling. |
| x | Horizontal absolute coordinate from the client. |
| y | Vertical absolute coordinate from the client. |
| void platf::virtualhid::abs_mouse | ( | input_context_t & | context, |
| const touch_port_t & | touch_port, | ||
| float | x, | ||
| float | y ) |
Move the virtual mouse absolutely inside a target touch port.
| context | Input context. |
| touch_port | Target coordinate space. |
| x | Absolute X coordinate. |
| y | Absolute Y coordinate. |
| int platf::virtualhid::alloc_gamepad | ( | input_context_t & | context, |
| const gamepad_id_t & | id, | ||
| const gamepad_arrival_t & | metadata, | ||
| feedback_queue_t | feedback_queue ) |
Allocate a libvirtualhid gamepad.
| context | Input context. |
| id | Sunshine gamepad identifiers. |
| metadata | Client-reported controller metadata. |
| feedback_queue | Queue used to return gamepad feedback to the client. |
| void platf::button_mouse | ( | input_t & | input, |
| int | button, | ||
| bool | release ) |
Press or release a virtual mouse button.
| input | Platform input backend that receives the event. |
| button | Mouse button identifier to press or release. |
| release | Whether the key or button event is a release. |
| void platf::virtualhid::button_mouse | ( | input_context_t & | context, |
| int | button, | ||
| bool | release ) |
Submit a mouse button event.
| context | Input context. |
| button | Moonlight mouse button. |
| release | Whether the button was released. |
| bool platf::virtualhid::configured_gamepad_supports_controller_extensions | ( | ) |
Return whether the configured gamepad profile needs Moonlight controller extensions.
Moonlight uses the controller-touch feature flag to authorize both controller touchpad and motion packets.
| bool platf::virtualhid::configured_gamepad_supports_touchpad | ( | ) |
Return whether the configured gamepad profile can expose touchpad input.
| std::unique_ptr< lvh::Runtime > platf::virtualhid::create_runtime | ( | lvh::BackendKind | backend = lvh::BackendKind::platform_default | ) |
Create a platform-default libvirtualhid runtime.
| backend | Backend used to create the runtime. |
| void platf::virtualhid::free_gamepad | ( | input_context_t & | context, |
| int | nr ) |
Release a libvirtualhid gamepad slot.
| context | Input context. |
| nr | Gamepad slot index. |
| void platf::virtualhid::gamepad_battery | ( | input_context_t & | context, |
| const gamepad_battery_t & | battery ) |
Submit gamepad battery metadata.
| context | Input context. |
| battery | Sunshine battery event. |
| void platf::virtualhid::gamepad_motion | ( | input_context_t & | context, |
| const gamepad_motion_t & | motion ) |
Submit a gamepad motion event.
| context | Input context. |
| motion | Sunshine motion event. |
| void platf::virtualhid::gamepad_touch | ( | input_context_t & | context, |
| const gamepad_touch_t & | touch ) |
Submit a gamepad touch event.
| context | Input context. |
| touch | Sunshine touch event. |
| void platf::virtualhid::gamepad_update | ( | input_context_t & | context, |
| int | nr, | ||
| const gamepad_state_t & | state ) |
Submit a full gamepad state.
| context | Input context. |
| nr | Gamepad slot index. |
| state | Sunshine gamepad state. |
| bool platf::virtualhid::has_gamepad | ( | const input_context_t & | context, |
| int | nr ) |
Check whether a libvirtualhid gamepad exists in a slot.
| context | Input context. |
| nr | Gamepad slot index. |
| void platf::hscroll | ( | input_t & | input, |
| int | distance ) |
Apply a horizontal scroll event to the virtual mouse.
| input | Platform input backend that receives the event. |
| distance | High-resolution scroll distance reported by the client. |
| void platf::virtualhid::hscroll | ( | input_context_t & | context, |
| int | high_res_distance ) |
Submit horizontal scroll input.
| context | Input context. |
| high_res_distance | High-resolution scroll distance. |
| void platf::keyboard_update | ( | input_t & | input, |
| uint16_t | modcode, | ||
| bool | release, | ||
| uint8_t | flags, | ||
| bool | extended = false ) |
Press or release a virtual keyboard key.
| input | Platform input backend that receives the event. |
| modcode | Portable key code to update. |
| release | Whether the key or button event is a release. |
| flags | Bit flags that modify the requested operation. |
| extended | Whether the client positively identified an extended key. |
| void platf::virtualhid::keyboard_update | ( | input_context_t & | context, |
| std::uint16_t | modcode, | ||
| bool | release, | ||
| std::uint8_t | flags, | ||
| bool | extended = false ) |
Submit a keyboard key transition.
| context | Input context. |
| modcode | Portable key code. |
| release | Whether the key was released. |
| flags | Bit flags that modify the requested operation. |
| extended | Whether the client positively identified an extended key. |
| void platf::move_mouse | ( | input_t & | input, |
| const touch_port_t & | touch_port, | ||
| int | deltaX, | ||
| int | deltaY ) |
Retarget the virtual mouse and move it relatively.
| input | Platform input backend that receives the event. |
| touch_port | Desktop and streamed-display bounds for the pointer. |
| deltaX | Delta x. |
| deltaY | Delta y. |
| void platf::move_mouse | ( | input_t & | input, |
| int | deltaX, | ||
| int | deltaY ) |
Move mouse using the backend coordinate system.
| input | Platform input backend that receives the event. |
| deltaX | Delta x. |
| deltaY | Delta y. |
| void platf::virtualhid::move_mouse | ( | input_context_t & | context, |
| const touch_port_t & | touch_port, | ||
| int | delta_x, | ||
| int | delta_y ) |
Retarget the virtual mouse and move it relatively.
| context | Input context. |
| touch_port | Desktop and streamed-display bounds for the pointer. |
| delta_x | Horizontal delta. |
| delta_y | Vertical delta. |
| void platf::virtualhid::move_mouse | ( | input_context_t & | context, |
| int | delta_x, | ||
| int | delta_y ) |
Move the virtual mouse relatively.
| context | Input context. |
| delta_x | Horizontal delta. |
| delta_y | Vertical delta. |
| void platf::pen_update | ( | client_input_t * | input, |
| const touch_port_t & | touch_port, | ||
| const pen_input_t & | pen ) |
Send a pen event to the OS.
| input | The client-specific input context. |
| touch_port | The current viewport for translating to screen coordinates. |
| pen | The pen event. |
| void platf::virtualhid::pen_update | ( | client_context_t & | context, |
| const touch_port_t & | touch_port, | ||
| const pen_input_t & | pen ) |
Submit a pen event.
| context | Client context. |
| touch_port | Touch coordinate bounds used for scaling. |
| pen | Pen event. |
| int platf::virtualhid::rebind_gamepad | ( | input_context_t & | context, |
| const gamepad_id_t & | id, | ||
| feedback_queue_t | feedback_queue ) |
Rebind an existing libvirtualhid gamepad to a resumed client session.
| context | Input context. |
| id | Sunshine gamepad identifiers for the resumed client. |
| feedback_queue | Queue used to return gamepad feedback to the resumed client. |
| void platf::scroll | ( | input_t & | input, |
| int | distance ) |
Apply a vertical scroll event to the virtual mouse.
| input | Platform input backend that receives the event. |
| distance | High-resolution scroll distance reported by the client. |
| void platf::virtualhid::scroll | ( | input_context_t & | context, |
| int | high_res_distance ) |
Submit vertical scroll input.
| context | Input context. |
| high_res_distance | High-resolution scroll distance. |
| bool platf::virtualhid::should_try_vigembus_fallback | ( | std::string_view | configured_gamepad, |
| bool | virtualhid_selected, | ||
| std::string_view | gamepad_driver ) |
Decide whether ViGEmBus should be tried for a gamepad allocation.
When Virtual HID Driver is unavailable or deliberately bypassed, ViGEmBus uses automatic selection for profiles it cannot represent directly.
| configured_gamepad | Configured virtual gamepad profile. |
| virtualhid_selected | Whether Virtual HID Driver was selected for the allocation. |
| gamepad_driver | Configured Windows virtual gamepad driver policy. |
| bool platf::virtualhid::should_use_gamepad_runtime | ( | const lvh::BackendCapabilities & | capabilities, |
| std::string_view | gamepad_driver, | ||
| bool | virtualhid_licensed ) |
Decide whether a libvirtualhid runtime may create a gamepad.
| capabilities | Runtime backend capabilities. |
| gamepad_driver | Configured Windows virtual gamepad driver policy. |
| virtualhid_licensed | Whether the Virtual HID Driver machine license is valid. |
| std::vector< supported_gamepad_t > platf::virtualhid::static_supported_gamepads | ( | ) |
Return static gamepad choices for config validation.
| std::vector< supported_gamepad_t > platf::virtualhid::supported_gamepads | ( | lvh::Runtime * | runtime, |
| bool | fallback_vigem_available = false, | ||
| bool | virtualhid_licensed = true, | ||
| bool | require_license = false ) |
Return gamepad choices and runtime availability.
| runtime | Runtime to probe. |
| fallback_vigem_available | Whether Windows ViGEm fallback can create gamepads. |
| virtualhid_licensed | Whether the broker has a valid license. |
| require_license | Whether this platform requires a broker license for gamepads. |
| void platf::touch_update | ( | client_input_t * | input, |
| const touch_port_t & | touch_port, | ||
| const touch_input_t & | touch ) |
Send a touch event to the OS.
| input | The client-specific input context. |
| touch_port | The current viewport for translating to screen coordinates. |
| touch | The touch event. |
| void platf::virtualhid::touch_update | ( | client_context_t & | context, |
| const touch_port_t & | touch_port, | ||
| const touch_input_t & | touch ) |
Submit a touchscreen event.
| context | Client context. |
| touch_port | Touch coordinate bounds used for scaling. |
| touch | Touch event. |
| void platf::unicode | ( | input_t & | input, |
| const char * | utf8, | ||
| int | size ) |
Submit UTF-8 text input to the keyboard backend.
| input | Platform input backend that receives the event. |
| utf8 | UTF-8 text submitted by the client. |
| size | Number of bytes or elements requested. |
| void platf::virtualhid::unicode | ( | input_context_t & | context, |
| const char * | utf8, | ||
| int | size ) |
Submit UTF-8 text input.
| context | Input context. |
| utf8 | UTF-8 text buffer. |
| size | Text buffer size. |