Hermes 0.7.0
Linux game streaming host
Loading...
Searching...
No Matches
virtualhid.cpp File Reference

Linux platform input implementation backed exclusively by libvirtualhid. More...

#include "kwin_input.h"
#include "src/config.h"
#include "src/logging.h"
#include "virtualhid_common.h"
#include "virtualhid_gamepad.h"
#include "virtualhid_keyboard.h"
#include "virtualhid_mouse.h"
#include <utility>
Include dependency graph for virtualhid.cpp:

Go to the source code of this file.

Functions

platform_caps::caps_t platf::virtualhid::input_capabilities (const lvh::BackendCapabilities &backend)
 Compute advertised protocol capabilities from backend availability and input policy.
std::unique_ptr< lvh::Runtime > platf::virtualhid::create_runtime ()
lvh::DeviceProfile platf::virtualhid::with_hermes_identity (lvh::DeviceProfile profile, const std::string &session_tag, const std::string &display_name)
void platf::virtualhid::log_failure (const char *operation, const lvh::OperationStatus &result)
input_t platf::input (const std::string &session_tag={})
std::unique_ptr< client_input_t > platf::allocate_client_input_context (input_t &input)
 Allocate a context to store per-client input data.
void platf::freeInput (void *)
void platf::move_mouse (input_t &input, int deltaX, int deltaY)
void platf::abs_mouse (input_t &input, const touch_port_t &touch_port, float x, float y)
void platf::button_mouse (input_t &input, int button, bool release)
void platf::scroll (input_t &input, int distance)
void platf::hscroll (input_t &input, int distance)
void platf::keyboard_update (input_t &input, std::uint16_t key_code, bool release, std::uint8_t flags)
void platf::unicode (input_t &input, char *utf8, int size)
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::pen_update (client_input_t *input, const touch_port_t &touch_port, const pen_input_t &pen)
 Send a pen event to the OS.
int platf::alloc_gamepad (input_t &input, const gamepad_id_t &id, const gamepad_arrival_t &metadata, feedback_queue_t feedback_queue)
 Create a new virtual gamepad.
void platf::free_gamepad (input_t &input, int nr)
void platf::release_gamepad (input_t &input, int nr)
 Release a gamepad because its stream ended, not because the client removed it. A detached desktop keeps it for the next stream to the same desktop, so the desktop's programs never see the controller leave.
void platf::forget_kept_gamepads (const std::string &session_tag)
 Remove the gamepads a session tag kept between streams.
void platf::gamepad_update (input_t &input, int nr, const gamepad_state_t &gamepad_state)
void platf::gamepad_touch (input_t &input, const gamepad_touch_t &touch)
 Send a gamepad touch event to the OS.
void platf::gamepad_motion (input_t &input, const gamepad_motion_t &motion)
 Send a gamepad motion event to the OS.
void platf::gamepad_battery (input_t &input, const gamepad_battery_t &battery)
 Send a gamepad battery event to the OS.
platform_caps::caps_t platf::get_capabilities ()
 Get the supported platform capabilities to advertise to the client.
util::point_t platf::get_mouse_loc (input_t &input)
 Get the current mouse position on screen.
std::vector< supported_gamepad_t > & platf::supported_gamepads (input_t *input)
 Gets the supported gamepads for this platform backend.

Detailed Description

Linux platform input implementation backed exclusively by libvirtualhid.

Definition in file virtualhid.cpp.

Function Documentation

◆ abs_mouse()

void platf::abs_mouse ( input_t & input,
const touch_port_t & touch_port,
float x,
float y )

Definition at line 118 of file virtualhid.cpp.

◆ alloc_gamepad()

int platf::alloc_gamepad ( input_t & input,
const gamepad_id_t & id,
const gamepad_arrival_t & metadata,
feedback_queue_t feedback_queue )

Create a new virtual gamepad.

Parameters
inputThe global input context.
idThe gamepad ID.
metadataController metadata from client (empty if none provided).
feedback_queueThe queue for posting messages back to the client.
Returns
0 on success.

Definition at line 183 of file virtualhid.cpp.

◆ allocate_client_input_context()

std::unique_ptr< client_input_t > platf::allocate_client_input_context ( input_t & input)

Allocate a context to store per-client input data.

Parameters
inputThe global input context.
Returns
A unique pointer to a per-client input data context.

Definition at line 103 of file virtualhid.cpp.

◆ button_mouse()

void platf::button_mouse ( input_t & input,
int button,
bool release )

Definition at line 125 of file virtualhid.cpp.

◆ create_runtime()

std::unique_ptr< lvh::Runtime > platf::virtualhid::create_runtime ( )

Definition at line 29 of file virtualhid.cpp.

◆ forget_kept_gamepads()

void platf::forget_kept_gamepads ( const std::string & session_tag)

Remove the gamepads a session tag kept between streams.

Parameters
session_tagThe tag of a session that has stopped.

Definition at line 201 of file virtualhid.cpp.

◆ free_gamepad()

void platf::free_gamepad ( input_t & input,
int nr )

Definition at line 193 of file virtualhid.cpp.

◆ freeInput()

void platf::freeInput ( void * pointer)

Definition at line 107 of file virtualhid.cpp.

◆ gamepad_battery()

void platf::gamepad_battery ( input_t & input,
const gamepad_battery_t & battery )

Send a gamepad battery event to the OS.

Parameters
inputThe global input context.
batteryThe battery event.

Definition at line 217 of file virtualhid.cpp.

◆ gamepad_motion()

void platf::gamepad_motion ( input_t & input,
const gamepad_motion_t & motion )

Send a gamepad motion event to the OS.

Parameters
inputThe global input context.
motionThe motion event.

Definition at line 213 of file virtualhid.cpp.

◆ gamepad_touch()

void platf::gamepad_touch ( input_t & input,
const gamepad_touch_t & touch )

Send a gamepad touch event to the OS.

Parameters
inputThe global input context.
touchThe touch event.

Definition at line 209 of file virtualhid.cpp.

◆ gamepad_update()

void platf::gamepad_update ( input_t & input,
int nr,
const gamepad_state_t & gamepad_state )

Definition at line 205 of file virtualhid.cpp.

◆ get_capabilities()

platform_caps::caps_t platf::get_capabilities ( )

Get the supported platform capabilities to advertise to the client.

Returns
Capability flags.

Definition at line 221 of file virtualhid.cpp.

◆ get_mouse_loc()

util::point_t platf::get_mouse_loc ( input_t & input)

Get the current mouse position on screen.

Parameters
inputThe input_t instance to use.
Returns
Screen coordinates of the mouse.

Examples

auto [x, y] = get_mouse_loc(input);

Definition at line 226 of file virtualhid.cpp.

◆ hscroll()

void platf::hscroll ( input_t & input,
int distance )

Definition at line 139 of file virtualhid.cpp.

◆ input()

input_t platf::input ( const std::string & session_tag = {})

Create a platform input device set. session_tag is stamped into Linux uinput phys/uniq metadata so a compositor seat can select only its client.

Definition at line 99 of file virtualhid.cpp.

◆ input_capabilities()

platform_caps::caps_t platf::virtualhid::input_capabilities ( const lvh::BackendCapabilities & backend)

Compute advertised protocol capabilities from backend availability and input policy.

Parameters
backendAvailable libvirtualhid backend features.
Returns
Only capabilities enabled in Hermes and supported by the backend.

Definition at line 18 of file virtualhid.cpp.

◆ keyboard_update()

void platf::keyboard_update ( input_t & input,
std::uint16_t key_code,
bool release,
std::uint8_t flags )

Definition at line 146 of file virtualhid.cpp.

◆ log_failure()

void platf::virtualhid::log_failure ( const char * operation,
const lvh::OperationStatus & result )

Definition at line 51 of file virtualhid.cpp.

◆ move_mouse()

void platf::move_mouse ( input_t & input,
int deltaX,
int deltaY )

Definition at line 111 of file virtualhid.cpp.

◆ pen_update()

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.

Parameters
inputThe client-specific input context.
touch_portThe current viewport for translating to screen coordinates.
penThe pen event.

Definition at line 173 of file virtualhid.cpp.

◆ release_gamepad()

void platf::release_gamepad ( input_t & input,
int nr )

Release a gamepad because its stream ended, not because the client removed it. A detached desktop keeps it for the next stream to the same desktop, so the desktop's programs never see the controller leave.

Definition at line 197 of file virtualhid.cpp.

◆ scroll()

void platf::scroll ( input_t & input,
int distance )

Definition at line 132 of file virtualhid.cpp.

◆ supported_gamepads()

std::vector< supported_gamepad_t > & platf::supported_gamepads ( input_t * input)

Gets the supported gamepads for this platform backend.

This may be called prior to platf::input()!

Parameters
inputPointer to the platform's input_t or nullptr.
Returns
Vector of gamepad options and status.

Definition at line 230 of file virtualhid.cpp.

◆ touch_update()

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.

Parameters
inputThe client-specific input context.
touch_portThe current viewport for translating to screen coordinates.
touchThe touch event.

Definition at line 160 of file virtualhid.cpp.

◆ unicode()

void platf::unicode ( input_t & input,
char * utf8,
int size )

Definition at line 153 of file virtualhid.cpp.

◆ with_hermes_identity()

lvh::DeviceProfile platf::virtualhid::with_hermes_identity ( lvh::DeviceProfile profile,
const std::string & session_tag,
const std::string & display_name )

Definition at line 42 of file virtualhid.cpp.