|
Hermes 0.7.0
Linux game streaming host
|
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 <stdexcept>#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"Go to the source code of this file.
Classes | |
| struct | input::gamepad_t |
| struct | input::input_t |
| class | input::deinit_t |
Macros | |
| #define | WHEEL_DELTA 120 |
| #define | DISABLE_LEFT_BUTTON_DELAY ((thread_pool_util::ThreadPool::task_id_t) 0x01) |
| #define | ENABLE_LEFT_BUTTON_DELAY nullptr |
Typedefs | |
| typedef uint32_t | input::key_press_id_t |
Enumerations | |
| enum class | input::button_state_e { NONE , DOWN , UP } |
| enum class | input::batch_result_e { batched , not_batchable , terminate_batch } |
Functions | |
| template<std::size_t N> | |
| int | input::alloc_id (std::bitset< N > &gamepad_mask) |
| template<std::size_t N> | |
| void | input::free_id (std::bitset< N > &gamepad_mask, int id) |
| key_press_id_t | input::make_kpid (uint16_t vk, uint8_t flags) |
| uint16_t | input::vk_from_kpid (key_press_id_t kpid) |
| uint8_t | input::flags_from_kpid (key_press_id_t kpid) |
| float | input::from_netfloat (netfloat f) |
| Convert a little-endian netfloat to a native endianness float. | |
| float | input::from_clamped_netfloat (netfloat f, float min, float max) |
| Convert a little-endian netfloat to a native endianness float and clamps it. | |
| void | input::free_gamepad (platf::input_t &platf_input, int id) |
| void | input::release_gamepad (platf::input_t &platf_input, int id) |
| int | input::apply_shortcut (short keyCode) |
| Apply shortcut based on VKEY. | |
| void | input::print (PNV_REL_MOUSE_MOVE_PACKET packet) |
| void | input::print (PNV_ABS_MOUSE_MOVE_PACKET packet) |
| void | input::print (PNV_MOUSE_BUTTON_PACKET packet) |
| void | input::print (PNV_SCROLL_PACKET packet) |
| void | input::print (PSS_HSCROLL_PACKET packet) |
| void | input::print (PNV_KEYBOARD_PACKET packet) |
| void | input::print (PNV_UNICODE_PACKET packet) |
| void | input::print (PNV_MULTI_CONTROLLER_PACKET packet) |
| void | input::print (PSS_TOUCH_PACKET packet) |
| Prints a touch packet. | |
| void | input::print (PSS_PEN_PACKET packet) |
| Prints a pen packet. | |
| void | input::print (PSS_CONTROLLER_ARRIVAL_PACKET packet) |
| Prints a controller arrival packet. | |
| void | input::print (PSS_CONTROLLER_TOUCH_PACKET packet) |
| Prints a controller touch packet. | |
| void | input::print (PSS_CONTROLLER_MOTION_PACKET packet) |
| Prints a controller motion packet. | |
| void | input::print (PSS_CONTROLLER_BATTERY_PACKET packet) |
| Prints a controller battery packet. | |
| void | input::print (void *payload) |
| void | input::passthrough (std::shared_ptr< input_t > &input, PNV_REL_MOUSE_MOVE_PACKET packet) |
| 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. | |
| 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. | |
| 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::passthrough (std::shared_ptr< input_t > &input, PNV_ABS_MOUSE_MOVE_PACKET packet) |
| void | input::passthrough (std::shared_ptr< input_t > &input, PNV_MOUSE_BUTTON_PACKET packet) |
| short | input::map_keycode (short keycode) |
| void | input::update_shortcutFlags (int *flags, short keyCode, bool release) |
| Update flags for keyboard shortcut combo's. | |
| bool | input::is_modifier (uint16_t keyCode) |
| void | input::send_key_and_modifiers (const std::shared_ptr< input_t > &input, uint16_t key_code, bool release, uint8_t flags, uint8_t synthetic_modifiers) |
| void | input::repeat_key (std::shared_ptr< input_t > input, uint16_t key_code, uint8_t flags, uint8_t synthetic_modifiers) |
| void | input::passthrough (std::shared_ptr< input_t > &input, PNV_KEYBOARD_PACKET packet) |
| 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_HSCROLL_PACKET packet) |
| Called to pass a horizontal scroll message the platform backend. | |
| void | input::passthrough (std::shared_ptr< input_t > &input, PNV_UNICODE_PACKET packet) |
| 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. | |
| platf::touch_port_t | input::direct_device_port (int output_width, int output_height, int offset_x, int offset_y, int env_width, int env_height, bool binds_to_output) |
| The rectangle a touchscreen or a pen is addressed in. | |
| 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, PSS_PEN_PACKET packet) |
| Called to pass a pen 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_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_BATTERY_PACKET packet) |
| Called to pass a controller battery message to the platform backend. | |
| void | input::passthrough (std::shared_ptr< input_t > &input, PNV_MULTI_CONTROLLER_PACKET packet) |
| 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_ABS_MOUSE_MOVE_PACKET dest, PNV_ABS_MOUSE_MOVE_PACKET src) |
| Batch two absolute 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_HSCROLL_PACKET dest, PSS_HSCROLL_PACKET src) |
| Batch two horizontal scroll 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 (PSS_TOUCH_PACKET dest, PSS_TOUCH_PACKET src) |
| Batch two touch messages. | |
| batch_result_e | input::batch (PSS_PEN_PACKET dest, PSS_PEN_PACKET src) |
| Batch two pen 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_CONTROLLER_MOTION_PACKET dest, PSS_CONTROLLER_MOTION_PACKET src) |
| Batch two controller motion messages. | |
| batch_result_e | input::batch (PNV_INPUT_HEADER dest, PNV_INPUT_HEADER src) |
| Batch two input messages. | |
| void | input::passthrough_next_message (std::shared_ptr< input_t > input) |
| Called on a thread pool thread to process an input message. | |
| void | input::passthrough (std::shared_ptr< input_t > &input, std::vector< std::uint8_t > &&input_data, const crypto::PERM &permission) |
| Called on the control stream thread to queue an input message. | |
| void | input::reset (std::shared_ptr< input_t > &input) |
| std::unique_ptr< platf::deinit_t > | input::init () |
| bool | input::probe_gamepads () |
| void | input::attach_launch_gamepads (std::shared_ptr< input_t > &input, int mask) |
| Plug in the gamepads the client reported at launch. | |
| std::shared_ptr< input_t > | input::alloc (safe::mail_t mail, const std::string &session_tag, int launch_gamepads, const std::string &wayland_socket, const std::string &client_id) |
Variables | |
| constexpr auto | input::MAX_GAMEPADS = std::min((std::size_t) platf::MAX_GAMEPADS, sizeof(std::int16_t) * 8) |
| constexpr auto | input::VKEY_SHIFT = 0x10 |
| constexpr auto | input::VKEY_LSHIFT = 0xA0 |
| constexpr auto | input::VKEY_RSHIFT = 0xA1 |
| constexpr auto | input::VKEY_CONTROL = 0x11 |
| constexpr auto | input::VKEY_LCONTROL = 0xA2 |
| constexpr auto | input::VKEY_RCONTROL = 0xA3 |
| constexpr auto | input::VKEY_MENU = 0x12 |
| constexpr auto | input::VKEY_LMENU = 0xA4 |
| constexpr auto | input::VKEY_RMENU = 0xA5 |
Definitions for gamepad, keyboard, and mouse input handling.
Definition in file input.cpp.
| #define DISABLE_LEFT_BUTTON_DELAY ((thread_pool_util::ThreadPool::task_id_t) 0x01) |
|
strong |
|
strong |
| std::shared_ptr< input_t > input::alloc | ( | safe::mail_t | mail, |
| const std::string & | session_tag = {}, | ||
| int | launch_gamepads = 0, | ||
| const std::string & | wayland_socket = {}, | ||
| const std::string & | client_id = {} ) |
| session_tag | Seat of an isolated session; empty for the host's. |
| launch_gamepads | Gamepads to plug in now (the client's gcmap). |
| wayland_socket | Private KWin desktop to drive instead; empty for none. |
| client_id | The paired client's id, which its virtual gamepads are identified by. |
| int input::alloc_id | ( | std::bitset< N > & | gamepad_mask | ) |
|
inline |
| void input::attach_launch_gamepads | ( | std::shared_ptr< input_t > & | input, |
| int | mask ) |
| batch_result_e input::batch | ( | PNV_ABS_MOUSE_MOVE_PACKET | dest, |
| PNV_ABS_MOUSE_MOVE_PACKET | src ) |
| batch_result_e input::batch | ( | PNV_INPUT_HEADER | dest, |
| PNV_INPUT_HEADER | src ) |
| batch_result_e input::batch | ( | PNV_MULTI_CONTROLLER_PACKET | dest, |
| PNV_MULTI_CONTROLLER_PACKET | src ) |
| batch_result_e input::batch | ( | PNV_REL_MOUSE_MOVE_PACKET | dest, |
| PNV_REL_MOUSE_MOVE_PACKET | src ) |
| batch_result_e input::batch | ( | PNV_SCROLL_PACKET | dest, |
| PNV_SCROLL_PACKET | src ) |
| batch_result_e input::batch | ( | PSS_CONTROLLER_MOTION_PACKET | dest, |
| PSS_CONTROLLER_MOTION_PACKET | src ) |
| batch_result_e input::batch | ( | PSS_CONTROLLER_TOUCH_PACKET | dest, |
| PSS_CONTROLLER_TOUCH_PACKET | src ) |
| batch_result_e input::batch | ( | PSS_HSCROLL_PACKET | dest, |
| PSS_HSCROLL_PACKET | src ) |
| batch_result_e input::batch | ( | PSS_PEN_PACKET | dest, |
| PSS_PEN_PACKET | src ) |
| batch_result_e input::batch | ( | PSS_TOUCH_PACKET | dest, |
| PSS_TOUCH_PACKET | src ) |
| 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.
| input | The input context. |
| val | The cartesian coordinate pair to convert. |
| size | The size of the client's surface containing the value. |
| platf::touch_port_t input::direct_device_port | ( | int | output_width, |
| int | output_height, | ||
| int | offset_x, | ||
| int | offset_y, | ||
| int | env_width, | ||
| int | env_height, | ||
| bool | binds_to_output ) |
The rectangle a touchscreen or a pen is addressed in.
| output_width | Width of the streamed output. |
| output_height | Height of the streamed output. |
| offset_x | Horizontal offset of that output within the desktop. |
| offset_y | Vertical offset of that output within the desktop. |
| env_width | Width of the whole desktop. |
| env_height | Height of the whole desktop. |
| binds_to_output | Whether the session maps such a device onto one output, which makes its coordinates relative to that output. |
| void input::free_gamepad | ( | platf::input_t & | platf_input, |
| int | id ) |
| void input::free_id | ( | std::bitset< N > & | gamepad_mask, |
| int | id ) |
| float input::from_clamped_netfloat | ( | netfloat | f, |
| float | min, | ||
| float | max ) |
| float input::from_netfloat | ( | netfloat | f | ) |
|
nodiscard |
| key_press_id_t input::make_kpid | ( | uint16_t | vk, |
| uint8_t | flags ) |
| float input::multiply_polar_by_cartesian_scalar | ( | float | r, |
| float | angle, | ||
| const std::pair< float, float > & | scalar ) |
| void input::passthrough | ( | std::shared_ptr< input_t > & | input, |
| PNV_ABS_MOUSE_MOVE_PACKET | packet ) |
| void input::passthrough | ( | std::shared_ptr< input_t > & | input, |
| PNV_KEYBOARD_PACKET | packet ) |
| void input::passthrough | ( | std::shared_ptr< input_t > & | input, |
| PNV_MOUSE_BUTTON_PACKET | 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
| void input::passthrough | ( | std::shared_ptr< input_t > & | input, |
| PNV_MULTI_CONTROLLER_PACKET | packet ) |
| void input::passthrough | ( | std::shared_ptr< input_t > & | input, |
| PNV_REL_MOUSE_MOVE_PACKET | packet ) |
| void input::passthrough | ( | std::shared_ptr< input_t > & | input, |
| PNV_SCROLL_PACKET | packet ) |
| void input::passthrough | ( | std::shared_ptr< input_t > & | input, |
| PNV_UNICODE_PACKET | packet ) |
| void input::passthrough | ( | std::shared_ptr< input_t > & | input, |
| PSS_CONTROLLER_ARRIVAL_PACKET | packet ) |
| void input::passthrough | ( | std::shared_ptr< input_t > & | input, |
| PSS_CONTROLLER_BATTERY_PACKET | packet ) |
| void input::passthrough | ( | std::shared_ptr< input_t > & | input, |
| PSS_CONTROLLER_MOTION_PACKET | packet ) |
| void input::passthrough | ( | std::shared_ptr< input_t > & | input, |
| PSS_CONTROLLER_TOUCH_PACKET | packet ) |
| void input::passthrough | ( | std::shared_ptr< input_t > & | input, |
| PSS_HSCROLL_PACKET | packet ) |
| void input::passthrough | ( | std::shared_ptr< input_t > & | input, |
| PSS_PEN_PACKET | packet ) |
| void input::passthrough | ( | std::shared_ptr< input_t > & | input, |
| PSS_TOUCH_PACKET | packet ) |
| void input::passthrough | ( | std::shared_ptr< input_t > & | input, |
| std::vector< std::uint8_t > && | input_data, | ||
| const crypto::PERM & | permission ) |
| void input::passthrough_next_message | ( | std::shared_ptr< input_t > | input | ) |
| void input::print | ( | PSS_CONTROLLER_ARRIVAL_PACKET | packet | ) |
| void input::print | ( | PSS_CONTROLLER_BATTERY_PACKET | packet | ) |
| void input::print | ( | PSS_CONTROLLER_MOTION_PACKET | packet | ) |
| void input::print | ( | PSS_CONTROLLER_TOUCH_PACKET | packet | ) |
| void input::print | ( | PSS_PEN_PACKET | packet | ) |
| void input::print | ( | PSS_TOUCH_PACKET | packet | ) |
| void input::release_gamepad | ( | platf::input_t & | platf_input, |
| int | id ) |
| void input::repeat_key | ( | std::shared_ptr< input_t > | input, |
| uint16_t | key_code, | ||
| uint8_t | flags, | ||
| uint8_t | synthetic_modifiers ) |
| std::pair< float, float > input::scale_client_contact_area | ( | const std::pair< float, float > & | val, |
| uint16_t | rotation, | ||
| const std::pair< float, float > & | scalar ) |
| void input::send_key_and_modifiers | ( | const std::shared_ptr< input_t > & | input, |
| uint16_t | key_code, | ||
| bool | release, | ||
| uint8_t | flags, | ||
| uint8_t | synthetic_modifiers ) |
|
inline |
|
constexpr |