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

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

#include <functional>
#include "platform/common.h"
#include "thread_safe.h"
Include dependency graph for input.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  input::touch_port_t
 Touchscreen coordinate bounds used to scale absolute input. More...
 

Functions

std::shared_ptr< input_tinput::alloc (safe::mail_t mail)
 Allocate and initialize platform input state for a stream.
 
std::unique_ptr< platf::deinit_tinput::init ()
 Initialize the platform input 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::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::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.
 

Detailed Description

Declarations for gamepad, keyboard, and mouse input handling.

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.

◆ 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.

◆ passthrough()

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.

◆ print()

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.

◆ 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.