Sunshine master
Self-hosted game stream host for Moonlight.
input.cpp File Reference

Definitions for gamepad, keyboard, and mouse input handling. More...

#include <cstdint>
#include <moonlight-common-c/src/Input.h>
#include <moonlight-common-c/src/Limelight.h>
#include <bitset>
#include <chrono>
#include <cmath>
#include <list>
#include <thread>
#include <unordered_map>
#include <boost/endian/buffers.hpp>
#include "config.h"
#include "globals.h"
#include "input.h"
#include "logging.h"
#include "platform/common.h"
#include "thread_pool.h"
#include "utility.h"
Include dependency graph for input.cpp:

Classes

class  input::deinit_t
 RAII helper that runs shutdown cleanup when destroyed. More...
 
struct  input::gamepad_t
 Per-client gamepad slot and feedback state. More...
 
struct  input::input_t
 Input emulation settings loaded from configuration. More...
 

Macros

#define DISABLE_LEFT_BUTTON_DELAY   ((thread_pool_util::ThreadPool::task_id_t) 0x01)
 Macro for DISABLE LEFT BUTTON DELAY.
 
#define ENABLE_LEFT_BUTTON_DELAY   nullptr
 Macro for ENABLE LEFT BUTTON DELAY.
 

Typedefs

typedef uint32_t input::key_press_id_t
 Packed identifier for a pressed key and its modifier flags.
 

Enumerations

enum class  input::batch_result_e { batched , not_batchable , terminate_batch }
 Enumerates supported batch result options. More...
 
enum class  input::button_state_e { NONE , DOWN , UP }
 Enumerates supported button state options. More...
 

Functions

std::shared_ptr< input_tinput::alloc (safe::mail_t mail)
 Allocate and initialize platform input state for a stream.
 
template<std::size_t N>
int input::alloc_id (std::bitset< N > &gamepad_mask)
 Allocate an available input slot identifier.
 
int input::apply_shortcut (short keyCode)
 Apply shortcut based on VKEY.
 
batch_result_e input::batch (PNV_ABS_MOUSE_MOVE_PACKET dest, PNV_ABS_MOUSE_MOVE_PACKET src)
 Batch two absolute mouse messages.
 
batch_result_e input::batch (PNV_INPUT_HEADER dest, PNV_INPUT_HEADER src)
 Batch two input messages.
 
batch_result_e input::batch (PNV_MULTI_CONTROLLER_PACKET dest, PNV_MULTI_CONTROLLER_PACKET src)
 Batch two controller state messages.
 
batch_result_e input::batch (PNV_REL_MOUSE_MOVE_PACKET dest, PNV_REL_MOUSE_MOVE_PACKET src)
 Batch two relative mouse messages.
 
batch_result_e input::batch (PNV_SCROLL_PACKET dest, PNV_SCROLL_PACKET src)
 Batch two vertical scroll messages.
 
batch_result_e input::batch (PSS_CONTROLLER_MOTION_PACKET dest, PSS_CONTROLLER_MOTION_PACKET src)
 Batch two controller motion messages.
 
batch_result_e input::batch (PSS_CONTROLLER_TOUCH_PACKET dest, PSS_CONTROLLER_TOUCH_PACKET src)
 Batch two controller touch messages.
 
batch_result_e input::batch (PSS_HSCROLL_PACKET dest, PSS_HSCROLL_PACKET src)
 Batch two horizontal scroll messages.
 
batch_result_e input::batch (PSS_PEN_PACKET dest, PSS_PEN_PACKET src)
 Batch two pen messages.
 
batch_result_e input::batch (PSS_TOUCH_PACKET dest, PSS_TOUCH_PACKET src)
 Batch two touch messages.
 
std::optional< std::pair< float, float > > input::client_to_touchport (std::shared_ptr< input_t > &input, const std::pair< float, float > &val, const std::pair< float, float > &size)
 Converts client coordinates on the specified surface into screen coordinates.
 
uint8_t input::flags_from_kpid (key_press_id_t kpid)
 Extract the modifier flags from a packed key-press identifier.
 
void input::free_gamepad (platf::input_t &platf_input, int id)
 Release all platform resources associated with a virtual gamepad.
 
template<std::size_t N>
void input::free_id (std::bitset< N > &gamepad_mask, int id)
 Release ID resources.
 
float input::from_clamped_netfloat (netfloat f, float min, float max)
 Convert a little-endian netfloat to a native float and clamp it to a range.
 
float input::from_netfloat (netfloat f)
 Convert a little-endian netfloat to a native endianness float.
 
std::unique_ptr< platf::deinit_tinput::init ()
 Initialize the platform input backend.
 
bool input::is_modifier (uint16_t keyCode)
 Check whether modifier.
 
key_press_id_t input::make_kpid (uint16_t vk, uint8_t flags)
 Create a key-press identifier from the virtual-key code and flags.
 
short input::map_keycode (short keycode)
 Apply configured keybinding remaps to a platform keycode.
 
std::optional< platf::touch_port_tinput::monitor_touch_port (const input::touch_port_t &touch_port, std::pair< float, float > &coords)
 Normalizes coordinates to monitor-local logical touch dimensions.
 
float input::multiply_polar_by_cartesian_scalar (float r, float angle, const std::pair< float, float > &scalar)
 Multiply a polar coordinate pair by a cartesian scaling factor.
 
void input::passthrough (PNV_UNICODE_PACKET packet)
 Forward a client input packet directly to the platform backend.
 
void input::passthrough (std::shared_ptr< input_t > &input, PNV_ABS_MOUSE_MOVE_PACKET packet)
 Forward a client input packet directly to the platform backend.
 
void input::passthrough (std::shared_ptr< input_t > &input, PNV_KEYBOARD_PACKET packet)
 Forward a client input packet directly to the platform backend.
 
void input::passthrough (std::shared_ptr< input_t > &input, PNV_MOUSE_BUTTON_PACKET packet)
 Called to pass a mouse button message to the platform backend.
 
void input::passthrough (std::shared_ptr< input_t > &input, PNV_MULTI_CONTROLLER_PACKET packet)
 Forward a client input packet directly to the platform backend.
 
void input::passthrough (std::shared_ptr< input_t > &input, PNV_REL_MOUSE_MOVE_PACKET packet)
 Forward a client input packet directly to the platform backend.
 
void input::passthrough (std::shared_ptr< input_t > &input, PNV_SCROLL_PACKET packet)
 Called to pass a vertical scroll message the platform backend.
 
void input::passthrough (std::shared_ptr< input_t > &input, PSS_CONTROLLER_ARRIVAL_PACKET packet)
 Called to pass a controller arrival message to the platform backend.
 
void input::passthrough (std::shared_ptr< input_t > &input, PSS_CONTROLLER_BATTERY_PACKET packet)
 Called to pass a controller battery message to the platform backend.
 
void input::passthrough (std::shared_ptr< input_t > &input, PSS_CONTROLLER_MOTION_PACKET packet)
 Called to pass a controller motion message to the platform backend.
 
void input::passthrough (std::shared_ptr< input_t > &input, PSS_CONTROLLER_TOUCH_PACKET packet)
 Called to pass a controller touch message to the platform backend.
 
void input::passthrough (std::shared_ptr< input_t > &input, PSS_HSCROLL_PACKET packet)
 Called to pass a horizontal scroll message the platform backend.
 
void input::passthrough (std::shared_ptr< input_t > &input, PSS_PEN_PACKET packet)
 Called to pass a pen message to the platform backend.
 
void input::passthrough (std::shared_ptr< input_t > &input, PSS_TOUCH_PACKET packet)
 Called to pass a touch message to the platform backend.
 
void input::passthrough (std::shared_ptr< input_t > &input, std::vector< std::uint8_t > &&input_data)
 Called on the control stream thread to queue an input message.
 
void input::passthrough_next_message (std::shared_ptr< input_t > input)
 Called on a thread pool thread to process an input message.
 
void input::print (PNV_ABS_MOUSE_MOVE_PACKET packet)
 Write a debug log representation of the input packet.
 
void input::print (PNV_KEYBOARD_PACKET packet)
 Write a debug log representation of the input packet.
 
void input::print (PNV_MOUSE_BUTTON_PACKET packet)
 Write a debug log representation of the input packet.
 
void input::print (PNV_MULTI_CONTROLLER_PACKET packet)
 Write a debug log representation of the input packet.
 
void input::print (PNV_REL_MOUSE_MOVE_PACKET packet)
 Write a debug log representation of the input packet.
 
void input::print (PNV_SCROLL_PACKET packet)
 Write a debug log representation of the input packet.
 
void input::print (PNV_UNICODE_PACKET packet)
 Write a debug log representation of the input packet.
 
void input::print (PSS_CONTROLLER_ARRIVAL_PACKET packet)
 Prints a controller arrival packet.
 
void input::print (PSS_CONTROLLER_BATTERY_PACKET packet)
 Prints a controller battery packet.
 
void input::print (PSS_CONTROLLER_MOTION_PACKET packet)
 Prints a controller motion packet.
 
void input::print (PSS_CONTROLLER_TOUCH_PACKET packet)
 Prints a controller touch packet.
 
void input::print (PSS_HSCROLL_PACKET packet)
 Write a debug log representation of the input packet.
 
void input::print (PSS_PEN_PACKET packet)
 Prints a pen packet.
 
void input::print (PSS_TOUCH_PACKET packet)
 Prints a touch packet.
 
void input::print (void *payload)
 Write a debug log representation of the input packet.
 
bool input::probe_gamepads ()
 Probe connected gamepads and update input capability state.
 
void input::repeat_key (uint16_t key_code, uint8_t flags, uint8_t synthetic_modifiers)
 Re-emit a held key until its repeat task is cancelled.
 
void input::reset (std::shared_ptr< input_t > &input)
 Reset the object to its initial empty state.
 
std::pair< float, float > input::scale_client_contact_area (const std::pair< float, float > &val, uint16_t rotation, const std::pair< float, float > &scalar)
 Scale the ellipse axes according to the provided size.
 
void input::send_key_and_modifiers (uint16_t key_code, bool release, uint8_t flags, uint8_t synthetic_modifiers)
 Send key and modifiers.
 
void input::update_shortcutFlags (int *flags, short keyCode, bool release)
 Update flags for keyboard shortcut combo's.
 
uint16_t input::vk_from_kpid (key_press_id_t kpid)
 Extract the virtual-key code from a packed key-press identifier.
 

Variables

constexpr auto input::MAX_GAMEPADS = std::min((std::size_t) platf::MAX_GAMEPADS, sizeof(std::int16_t) * 8)
 Maximum gamepads representable by the active gamepad mask.
 
constexpr auto input::VKEY_CONTROL = 0x11
 Windows virtual-key code for control.
 
constexpr auto input::VKEY_LCONTROL = 0xA2
 Windows virtual-key code for lcontrol.
 
constexpr auto input::VKEY_LMENU = 0xA4
 Windows virtual-key code for lmenu.
 
constexpr auto input::VKEY_LSHIFT = 0xA0
 Windows virtual-key code for lshift.
 
constexpr auto input::VKEY_MENU = 0x12
 Windows virtual-key code for menu.
 
constexpr auto input::VKEY_RCONTROL = 0xA3
 Windows virtual-key code for rcontrol.
 
constexpr auto input::VKEY_RMENU = 0xA5
 Windows virtual-key code for rmenu.
 
constexpr auto input::VKEY_RSHIFT = 0xA1
 Windows virtual-key code for rshift.
 
constexpr auto input::VKEY_SHIFT = 0x10
 Windows virtual-key code for shift.
 
constexpr int WHEEL_DELTA = 120
 Standard Windows wheel delta used to normalize scroll events.
 

Detailed Description

Definitions for gamepad, keyboard, and mouse input handling.

Enumeration Type Documentation

◆ batch_result_e

enum class input::batch_result_e
strong

Enumerates supported batch result options.

Enumerator
batched 

This entry was batched with the source entry.

not_batchable 

Not eligible to batch but continue attempts to batch.

terminate_batch 

Stop trying to batch with this entry.

◆ button_state_e

enum class input::button_state_e
strong

Enumerates supported button state options.

Enumerator
NONE 

No button state.

DOWN 

Button is down.

UP 

Button is up.

Function Documentation

◆ alloc()

std::shared_ptr< input_t > input::alloc ( safe::mail_t mail)

Allocate and initialize platform input state for a stream.

Parameters
mailMailbox used to exchange messages with worker threads.
Returns
Shared input state bound to the stream mailbox.

◆ alloc_id()

template<std::size_t N>
int input::alloc_id ( std::bitset< N > & gamepad_mask)

Allocate an available input slot identifier.

Parameters
gamepad_maskGamepad mask.
Returns
Allocated ID object, or null when unavailable.

◆ apply_shortcut()

int input::apply_shortcut ( short keyCode)
inline

Apply shortcut based on VKEY.

Parameters
keyCodeThe VKEY code
Returns
0 if no shortcut applied, > 0 if shortcut applied.

◆ batch() [1/10]

batch_result_e input::batch ( PNV_ABS_MOUSE_MOVE_PACKET dest,
PNV_ABS_MOUSE_MOVE_PACKET src )

Batch two absolute mouse messages.

Parameters
destThe original packet to batch into.
srcA later packet to attempt to batch.
Returns
The status of the batching operation.

◆ batch() [2/10]

batch_result_e input::batch ( PNV_INPUT_HEADER dest,
PNV_INPUT_HEADER src )

Batch two input messages.

Parameters
destThe original packet to batch into.
srcA later packet to attempt to batch.
Returns
The status of the batching operation.

◆ batch() [3/10]

batch_result_e input::batch ( PNV_MULTI_CONTROLLER_PACKET dest,
PNV_MULTI_CONTROLLER_PACKET src )

Batch two controller state messages.

Parameters
destThe original packet to batch into.
srcA later packet to attempt to batch.
Returns
The status of the batching operation.

◆ batch() [4/10]

batch_result_e input::batch ( PNV_REL_MOUSE_MOVE_PACKET dest,
PNV_REL_MOUSE_MOVE_PACKET src )

Batch two relative mouse messages.

Parameters
destThe original packet to batch into.
srcA later packet to attempt to batch.
Returns
The status of the batching operation.

◆ batch() [5/10]

batch_result_e input::batch ( PNV_SCROLL_PACKET dest,
PNV_SCROLL_PACKET src )

Batch two vertical scroll messages.

Parameters
destThe original packet to batch into.
srcA later packet to attempt to batch.
Returns
The status of the batching operation.

◆ batch() [6/10]

batch_result_e input::batch ( PSS_CONTROLLER_MOTION_PACKET dest,
PSS_CONTROLLER_MOTION_PACKET src )

Batch two controller motion messages.

Parameters
destThe original packet to batch into.
srcA later packet to attempt to batch.
Returns
The status of the batching operation.

◆ batch() [7/10]

batch_result_e input::batch ( PSS_CONTROLLER_TOUCH_PACKET dest,
PSS_CONTROLLER_TOUCH_PACKET src )

Batch two controller touch messages.

Parameters
destThe original packet to batch into.
srcA later packet to attempt to batch.
Returns
The status of the batching operation.

◆ batch() [8/10]

batch_result_e input::batch ( PSS_HSCROLL_PACKET dest,
PSS_HSCROLL_PACKET src )

Batch two horizontal scroll messages.

Parameters
destThe original packet to batch into.
srcA later packet to attempt to batch.
Returns
The status of the batching operation.

◆ batch() [9/10]

batch_result_e input::batch ( PSS_PEN_PACKET dest,
PSS_PEN_PACKET src )

Batch two pen messages.

Parameters
destThe original packet to batch into.
srcA later packet to attempt to batch.
Returns
The status of the batching operation.

◆ batch() [10/10]

batch_result_e input::batch ( PSS_TOUCH_PACKET dest,
PSS_TOUCH_PACKET src )

Batch two touch messages.

Parameters
destThe original packet to batch into.
srcA later packet to attempt to batch.
Returns
The status of the batching operation.

◆ client_to_touchport()

std::optional< std::pair< float, float > > input::client_to_touchport ( std::shared_ptr< input_t > & input,
const std::pair< float, float > & val,
const std::pair< float, float > & size )

Converts client coordinates on the specified surface into screen coordinates.

Parameters
inputThe input context.
valThe cartesian coordinate pair to convert.
sizeThe size of the client's surface containing the value.
Returns
The host-relative coordinate pair if a touchport is available.

◆ flags_from_kpid()

uint8_t input::flags_from_kpid ( key_press_id_t kpid)

Extract the modifier flags from a packed key-press identifier.

Parameters
kpidKey-press identifier containing the virtual-key code and flags.
Returns
Modifier flags stored in the low byte.

◆ free_gamepad()

void input::free_gamepad ( platf::input_t & platf_input,
int id )

Release all platform resources associated with a virtual gamepad.

Parameters
platf_inputPlatf input.
idIdentifier for the controller, session, display, or resource.

◆ free_id()

template<std::size_t N>
void input::free_id ( std::bitset< N > & gamepad_mask,
int id )

Release ID resources.

Parameters
gamepad_maskGamepad mask.
idIdentifier for the controller, session, display, or resource.

◆ from_clamped_netfloat()

float input::from_clamped_netfloat ( netfloat f,
float min,
float max )

Convert a little-endian netfloat to a native float and clamp it to a range.

Parameters
fLittle-endian network float bytes.
minThe minimium value for clamping.
maxThe maximum value for clamping.
Returns
Decoded floating-point value clamped between min and max.

◆ from_netfloat()

float input::from_netfloat ( netfloat f)

Convert a little-endian netfloat to a native endianness float.

Parameters
fLittle-endian network float bytes.
Returns
Floating-point value decoded for the host CPU.

◆ init()

std::unique_ptr< platf::deinit_t > input::init ( )
nodiscard

Initialize the platform input backend.

Initialize global input resources and platform backends.

Returns
Cleanup handle for initialized input resources, or null if none are required.

◆ is_modifier()

bool input::is_modifier ( uint16_t keyCode)

Check whether modifier.

Parameters
keyCodeMoonlight keyboard packet key code.
Returns
True when the key code is a keyboard modifier.

◆ make_kpid()

key_press_id_t input::make_kpid ( uint16_t vk,
uint8_t flags )

Create a key-press identifier from the virtual-key code and flags.

Parameters
vkVirtual-key code from the client input packet.
flagsBit flags that modify the requested operation.
Returns
Constructed kpid object.

◆ map_keycode()

short input::map_keycode ( short keycode)

Apply configured keybinding remaps to a platform keycode.

Parameters
keycodePlatform keycode being translated or emitted.
Returns
Remapped keycode when configured, otherwise the original keycode.

◆ monitor_touch_port()

std::optional< platf::touch_port_t > input::monitor_touch_port ( const input::touch_port_t & touch_port,
std::pair< float, float > & coords )

Normalizes coordinates to monitor-local logical touch dimensions.

Parameters
touch_portThe current touch port metadata.
coordsThe in/out coordinate pair to normalize.
Returns
The monitor-local touch port, or std::nullopt if dimensions are invalid.

◆ multiply_polar_by_cartesian_scalar()

float input::multiply_polar_by_cartesian_scalar ( float r,
float angle,
const std::pair< float, float > & scalar )

Multiply a polar coordinate pair by a cartesian scaling factor.

Parameters
rThe radial coordinate.
angleThe angular coordinate (radians).
scalarThe scalar cartesian coordinate pair.
Returns
The scaled radial coordinate.

◆ passthrough() [1/15]

void input::passthrough ( PNV_UNICODE_PACKET packet)

Forward a client input packet directly to the platform backend.

Parameters
packetProtocol packet being processed.

◆ passthrough() [2/15]

void input::passthrough ( std::shared_ptr< input_t > & input,
PNV_ABS_MOUSE_MOVE_PACKET packet )

Forward a client input packet directly to the platform backend.

Parameters
inputPlatform input backend that receives the event.
packetProtocol packet being processed.

◆ passthrough() [3/15]

void input::passthrough ( std::shared_ptr< input_t > & input,
PNV_KEYBOARD_PACKET packet )

Forward a client input packet directly to the platform backend.

Parameters
inputPlatform input backend that receives the event.
packetProtocol packet being processed.

◆ passthrough() [4/15]

void input::passthrough ( std::shared_ptr< input_t > & input,
PNV_MOUSE_BUTTON_PACKET packet )

Called to pass a mouse button message to the platform backend.

Parameters
inputThe input context pointer.
packetThe mouse button packet.

When Moonlight sends mouse input through absolute coordinates, it's possible that BUTTON_RIGHT is pressed down immediately after releasing BUTTON_LEFT. As a result, Sunshine will left-click on hyperlinks in the browser before right-clicking

This can be solved by delaying BUTTON_LEFT, however, any delay on input is undesirable during gaming As a compromise, Sunshine will only put delays on BUTTON_LEFT when absolute mouse coordinates have been sent.

Try to make sure BUTTON_RIGHT gets called before BUTTON_LEFT is released.

input->mouse_left_button_timeout can only be nullptr when the last mouse coordinates were absolute

◆ passthrough() [5/15]

void input::passthrough ( std::shared_ptr< input_t > & input,
PNV_MULTI_CONTROLLER_PACKET packet )

Forward a client input packet directly to the platform backend.

Parameters
inputPlatform input backend that receives the event.
packetProtocol packet being processed.

◆ passthrough() [6/15]

void input::passthrough ( std::shared_ptr< input_t > & input,
PNV_REL_MOUSE_MOVE_PACKET packet )

Forward a client input packet directly to the platform backend.

Parameters
inputPlatform input backend that receives the event.
packetProtocol packet being processed.

◆ passthrough() [7/15]

void input::passthrough ( std::shared_ptr< input_t > & input,
PNV_SCROLL_PACKET packet )

Called to pass a vertical scroll message the platform backend.

Parameters
inputThe input context pointer.
packetThe scroll packet.

◆ passthrough() [8/15]

void input::passthrough ( std::shared_ptr< input_t > & input,
PSS_CONTROLLER_ARRIVAL_PACKET packet )

Called to pass a controller arrival message to the platform backend.

Parameters
inputThe input context pointer.
packetThe controller arrival packet.

◆ passthrough() [9/15]

void input::passthrough ( std::shared_ptr< input_t > & input,
PSS_CONTROLLER_BATTERY_PACKET packet )

Called to pass a controller battery message to the platform backend.

Parameters
inputThe input context pointer.
packetThe controller battery packet.

◆ passthrough() [10/15]

void input::passthrough ( std::shared_ptr< input_t > & input,
PSS_CONTROLLER_MOTION_PACKET packet )

Called to pass a controller motion message to the platform backend.

Parameters
inputThe input context pointer.
packetThe controller motion packet.

◆ passthrough() [11/15]

void input::passthrough ( std::shared_ptr< input_t > & input,
PSS_CONTROLLER_TOUCH_PACKET packet )

Called to pass a controller touch message to the platform backend.

Parameters
inputThe input context pointer.
packetThe controller touch packet.

◆ passthrough() [12/15]

void input::passthrough ( std::shared_ptr< input_t > & input,
PSS_HSCROLL_PACKET packet )

Called to pass a horizontal scroll message the platform backend.

Parameters
inputThe input context pointer.
packetThe scroll packet.

◆ passthrough() [13/15]

void input::passthrough ( std::shared_ptr< input_t > & input,
PSS_PEN_PACKET packet )

Called to pass a pen message to the platform backend.

Parameters
inputThe input context pointer.
packetThe pen packet.

◆ passthrough() [14/15]

void input::passthrough ( std::shared_ptr< input_t > & input,
PSS_TOUCH_PACKET packet )

Called to pass a touch message to the platform backend.

Parameters
inputThe input context pointer.
packetThe touch packet.

◆ passthrough() [15/15]

void input::passthrough ( std::shared_ptr< input_t > & input,
std::vector< std::uint8_t > && input_data )

Called on the control stream thread to queue an input message.

Queue a raw input message for platform passthrough.

Parameters
inputThe input context pointer.
input_dataThe input message.

◆ passthrough_next_message()

void input::passthrough_next_message ( std::shared_ptr< input_t > input)

Called on a thread pool thread to process an input message.

Parameters
inputThe input context pointer.

◆ print() [1/15]

void input::print ( PNV_ABS_MOUSE_MOVE_PACKET packet)

Write a debug log representation of the input packet.

Parameters
packetProtocol packet being processed.

◆ print() [2/15]

void input::print ( PNV_KEYBOARD_PACKET packet)

Write a debug log representation of the input packet.

Parameters
packetProtocol packet being processed.

◆ print() [3/15]

void input::print ( PNV_MOUSE_BUTTON_PACKET packet)

Write a debug log representation of the input packet.

Parameters
packetProtocol packet being processed.

◆ print() [4/15]

void input::print ( PNV_MULTI_CONTROLLER_PACKET packet)

Write a debug log representation of the input packet.

Parameters
packetProtocol packet being processed.

◆ print() [5/15]

void input::print ( PNV_REL_MOUSE_MOVE_PACKET packet)

Write a debug log representation of the input packet.

Parameters
packetProtocol packet being processed.

◆ print() [6/15]

void input::print ( PNV_SCROLL_PACKET packet)

Write a debug log representation of the input packet.

Parameters
packetProtocol packet being processed.

◆ print() [7/15]

void input::print ( PNV_UNICODE_PACKET packet)

Write a debug log representation of the input packet.

Parameters
packetProtocol packet being processed.

◆ print() [8/15]

void input::print ( PSS_CONTROLLER_ARRIVAL_PACKET packet)

Prints a controller arrival packet.

Parameters
packetThe controller arrival packet.

◆ print() [9/15]

void input::print ( PSS_CONTROLLER_BATTERY_PACKET packet)

Prints a controller battery packet.

Parameters
packetThe controller battery packet.

◆ print() [10/15]

void input::print ( PSS_CONTROLLER_MOTION_PACKET packet)

Prints a controller motion packet.

Parameters
packetThe controller motion packet.

◆ print() [11/15]

void input::print ( PSS_CONTROLLER_TOUCH_PACKET packet)

Prints a controller touch packet.

Parameters
packetThe controller touch packet.

◆ print() [12/15]

void input::print ( PSS_HSCROLL_PACKET packet)

Write a debug log representation of the input packet.

Parameters
packetProtocol packet being processed.

◆ print() [13/15]

void input::print ( PSS_PEN_PACKET packet)

Prints a pen packet.

Parameters
packetThe pen packet.

◆ print() [14/15]

void input::print ( PSS_TOUCH_PACKET packet)

Prints a touch packet.

Parameters
packetThe touch packet.

◆ print() [15/15]

void input::print ( void * input)

Write a debug log representation of the input packet.

Parameters
inputRaw input packet to format for logging.

◆ probe_gamepads()

bool input::probe_gamepads ( )

Probe connected gamepads and update input capability state.

Probe whether the platform can create virtual gamepads.

Returns
True when at least one configured gamepad backend is available.

◆ repeat_key()

void input::repeat_key ( uint16_t key_code,
uint8_t flags,
uint8_t synthetic_modifiers )

Re-emit a held key until its repeat task is cancelled.

Parameters
key_codeMoonlight keyboard packet key code.
flagsBit flags that modify the requested operation.
synthetic_modifiersSynthetic modifiers.

◆ reset()

void input::reset ( std::shared_ptr< input_t > & input)

Reset the object to its initial empty state.

Reset stream input state after a client disconnect or shutdown.

Parameters
inputShared stream input state to reset.

◆ scale_client_contact_area()

std::pair< float, float > input::scale_client_contact_area ( const std::pair< float, float > & val,
uint16_t rotation,
const std::pair< float, float > & scalar )

Scale the ellipse axes according to the provided size.

Parameters
valThe major and minor axis pair.
rotationThe rotation value from the touch/pen event.
scalarThe scalar cartesian coordinate pair.
Returns
The major and minor axis pair.

◆ send_key_and_modifiers()

void input::send_key_and_modifiers ( uint16_t key_code,
bool release,
uint8_t flags,
uint8_t synthetic_modifiers )

Send key and modifiers.

Parameters
key_codeMoonlight keyboard packet key code.
releaseWhether the key or button event is a release.
flagsBit flags that modify the requested operation.
synthetic_modifiersSynthetic modifiers.

◆ update_shortcutFlags()

void input::update_shortcutFlags ( int * flags,
short keyCode,
bool release )
inline

Update flags for keyboard shortcut combo's.

Parameters
flagsBit flags that modify the requested operation.
keyCodeMoonlight keyboard packet key code.
releaseWhether the key or button event is a release.

◆ vk_from_kpid()

uint16_t input::vk_from_kpid ( key_press_id_t kpid)

Extract the virtual-key code from a packed key-press identifier.

Parameters
kpidKey-press identifier containing the virtual-key code and flags.
Returns
Virtual-key code stored in the high byte.