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

Definitions for the inputtino Linux input handling. More...

#include <inputtino/input.hpp>
#include <libevdev/libevdev.h>
#include "inputtino_common.h"
#include "inputtino_gamepad.h"
#include "inputtino_keyboard.h"
#include "inputtino_mouse.h"
#include "inputtino_pen.h"
#include "inputtino_touch.h"
#include "src/config.h"
#include "src/platform/common.h"
#include "src/utility.h"
Include dependency graph for inputtino.cpp:

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.
 
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.
 
std::unique_ptr< client_input_tplatf::allocate_client_input_context (input_t &input)
 Allocate a context to store per-client input data.
 
void platf::button_mouse (input_t &input, int button, bool release)
 Press or release a virtual mouse button.
 
void platf::free_gamepad (input_t &input, int nr)
 Release gamepad resources.
 
void platf::freeInput (void *)
 Release a platform input backend created by input().
 
void platf::gamepad_battery (input_t &input, const gamepad_battery_t &battery)
 Send a gamepad battery 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_touch (input_t &input, const gamepad_touch_t &touch)
 Send a gamepad touch event to the OS.
 
void platf::gamepad_update (input_t &input, int nr, const gamepad_state_t &gamepad_state)
 Submit updated Sunshine gamepad state to the virtual device.
 
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.
 
void platf::hscroll (input_t &input, int distance)
 Apply a horizontal scroll event to the virtual mouse.
 
input_t platf::input ()
 Create the platform input backend for a stream.
 
void platf::keyboard_update (input_t &input, uint16_t modcode, bool release, uint8_t flags)
 Press or release a virtual keyboard key.
 
void platf::move_mouse (input_t &input, int deltaX, int deltaY)
 Move mouse using the backend coordinate system.
 
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::scroll (input_t &input, int distance)
 Apply a vertical scroll event to the virtual mouse.
 
std::vector< supported_gamepad_t > & platf::supported_gamepads (input_t *input)
 Gets the supported gamepads for this platform backend.
 
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::unicode (input_t &input, char *utf8, int size)
 Submit UTF-8 text input to the keyboard backend.
 

Detailed Description

Definitions for the inputtino Linux input handling.

Function Documentation

◆ abs_mouse()

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.

Parameters
inputPlatform input backend that receives the event.
touch_portTouch coordinate bounds used for scaling.
xHorizontal absolute coordinate from the client.
yVertical absolute coordinate from the client.

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

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

Allocates a context to store per-client input data.

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

◆ button_mouse()

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

Press or release a virtual mouse button.

Parameters
inputPlatform input backend that receives the event.
buttonMouse button identifier to press or release.
releaseWhether the key or button event is a release.

◆ free_gamepad()

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

Release gamepad resources.

Parameters
inputPlatform input backend that receives the event.
nrController index assigned by the client.

◆ freeInput()

void platf::freeInput ( void * p)

Release a platform input backend created by input().

Parameters
pPointer passed to the deleter or conversion helper.

◆ gamepad_battery()

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

Send a gamepad battery event to the OS.

Sends a gamepad battery event to the OS.

Parameters
inputThe global input context.
batteryThe battery event.

◆ gamepad_motion()

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

Send a gamepad motion event to the OS.

Sends a gamepad motion event to the OS.

Parameters
inputThe global input context.
motionThe motion event.

◆ gamepad_touch()

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

Send a gamepad touch event to the OS.

Sends a gamepad touch event to the OS.

Parameters
inputThe global input context.
touchThe touch event.

◆ gamepad_update()

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

Submit updated Sunshine gamepad state to the virtual device.

Parameters
inputThe input context.
nrThe gamepad index to update.
gamepad_stateThe gamepad button/axis state sent from the client.

◆ get_capabilities()

platform_caps::caps_t platf::get_capabilities ( )

Get the supported platform capabilities to advertise to the client.

Returns the supported platform capabilities to advertise to the client.

Returns
Capability flags.

◆ 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);

◆ hscroll()

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

Apply a horizontal scroll event to the virtual mouse.

Parameters
inputPlatform input backend that receives the event.
distanceHigh-resolution scroll distance reported by the client.

◆ input()

input_t platf::input ( )

Create the platform input backend for a stream.

Returns
Platform-specific input backend for the active stream.

◆ keyboard_update()

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

Press or release a virtual keyboard key.

Parameters
inputPlatform input backend that receives the event.
modcodeModifier key code to update.
releaseWhether the key or button event is a release.
flagsBit flags that modify the requested operation.

◆ move_mouse()

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

Move mouse using the backend coordinate system.

Parameters
inputPlatform input backend that receives the event.
deltaXDelta x.
deltaYDelta y.

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

Sends a pen event to the OS.

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

◆ scroll()

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

Apply a vertical scroll event to the virtual mouse.

Parameters
inputPlatform input backend that receives the event.
distanceHigh-resolution scroll distance reported by the client.

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

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

Sends a touch event to the OS.

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

◆ unicode()

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

Submit UTF-8 text input to the keyboard backend.

Parameters
inputPlatform input backend that receives the event.
utf8UTF-8 text submitted by the client.
sizeNumber of bytes or elements requested.