|
Sunshine master
Self-hosted game stream host for Moonlight.
|
Definitions for macOS input handling. More...
#include <algorithm>#include <chrono>#include <cmath>#include <cstdint>#include <iostream>#include <thread>#include <ApplicationServices/ApplicationServices.h>import <Carbon/Carbon.h>#include <CoreFoundation/CoreFoundation.h>#include <IOKit/hidsystem/IOLLEvent.h>#include <mach/mach.h>#include "src/display_device.h"#include "src/input.h"#include "src/logging.h"#include "src/platform/common.h"#include "src/utility.h"Classes | |
| struct | platf::KeyCodeMap |
| Mapping from Sunshine key symbols to macOS virtual key codes. More... | |
| struct | platf::macos_input_t |
| macOS input source and target display state. More... | |
| struct | platf::modifier_flags_t |
| macOS modifier flags split into generic and device-specific bits. More... | |
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_t > | platf::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. | |
| CGEventType | platf::event_type_mouse (input_t &input) |
| Choose the CoreGraphics mouse event type for the current button action. | |
| 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. | |
| int | platf::get_scroll_lines_per_detent (double &scrollwheel_scaling) |
| Get scroll lines per detent. | |
| 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. | |
| int | platf::keysym (int keycode) |
| Translate a platform keycode to a Sunshine key symbol. | |
| bool | platf::modifier_flags_for_key (int key, modifier_flags_t &flags) |
| Resolve the CoreGraphics modifier masks associated with a key code. | |
| void | platf::move_mouse (input_t &input, int deltaX, int deltaY) |
| Move mouse using the backend coordinate system. | |
| bool | platf::operator< (const KeyCodeMap &a, const KeyCodeMap &b) |
| Order key mappings by Sunshine key code for binary search. | |
| 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::post_mouse (input_t &input, const CGMouseButton button, const CGEventType type, const util::point_t raw_location, const util::point_t previous_location, const int click_count) |
| Post a mouse event at the clamped display location. | |
| void | platf::post_scroll (input_t &input, const int wheelY, const int wheelX) |
| Post a macOS scroll event to the target display. | |
| void | platf::scroll (input_t &input, int distance) |
| Apply a vertical scroll event to the virtual mouse. | |
| int | platf::scroll_pixels (const macos_input_t *macos_input, const int high_res_distance) |
| Convert a high-resolution wheel delta to CoreGraphics scroll pixels. | |
| 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. | |
Variables | |
| constexpr int | platf::DEFAULT_SCROLL_LINES_PER_DETENT = 5 |
| Protocol or platform constant for default scroll lines per detent. | |
| constexpr double | platf::DEFAULT_SCROLLWHEEL_SCALING = 0.3125 |
| Protocol or platform constant for default scrollwheel scaling. | |
| const KeyCodeMap | platf::kKeyCodesMap [] |
| Key codes map. | |
| constexpr auto | MULTICLICK_DELAY_MS = std::chrono::milliseconds(500) |
| Maximum gap between clicks that macOS should treat as a double click. | |
| constexpr int | platf::WHEEL_DELTA = 120 |
| Protocol or platform constant for wheel delta. | |
Definitions for macOS input handling.
| 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.
| input | Platform input backend that receives the event. |
| touch_port | Touch coordinate bounds used for scaling. |
| x | Horizontal absolute coordinate from the client. |
| y | Vertical absolute coordinate from the client. |
| 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.
| input | The global input context. |
| id | The gamepad ID. |
| metadata | Controller metadata from client (empty if none provided). |
| feedback_queue | The queue for posting messages back to the client. |
| 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.
| input | The global input context. |
| void platf::button_mouse | ( | input_t & | input, |
| int | button, | ||
| bool | release ) |
Press or release a virtual mouse button.
| input | Platform input backend that receives the event. |
| button | Mouse button identifier to press or release. |
| release | Whether the key or button event is a release. |
|
inline |
Choose the CoreGraphics mouse event type for the current button action.
| input | Platform input backend that receives the event. |
| void platf::free_gamepad | ( | input_t & | input, |
| int | nr ) |
Release gamepad resources.
| input | Platform input backend that receives the event. |
| nr | Controller index assigned by the client. |
| void platf::freeInput | ( | void * | p | ) |
Release a platform input backend created by input().
| p | Pointer passed to the deleter or conversion helper. |
| 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.
| input | The global input context. |
| battery | The battery event. |
| 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.
| input | The global input context. |
| motion | The motion event. |
| 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.
| input | The global input context. |
| touch | The touch event. |
| void platf::gamepad_update | ( | input_t & | input, |
| int | nr, | ||
| const gamepad_state_t & | gamepad_state ) |
Submit updated Sunshine gamepad state to the virtual device.
| input | The input context. |
| nr | The gamepad index to update. |
| gamepad_state | The gamepad button/axis state sent from the client. |
| 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.
| util::point_t platf::get_mouse_loc | ( | input_t & | input | ) |
Get the current mouse position on screen.
| input | The input_t instance to use. |
*Examples**
| int platf::get_scroll_lines_per_detent | ( | double & | scrollwheel_scaling | ) |
Get scroll lines per detent.
| scrollwheel_scaling | Scrollwheel scaling. |
| void platf::hscroll | ( | input_t & | input, |
| int | distance ) |
Apply a horizontal scroll event to the virtual mouse.
| input | Platform input backend that receives the event. |
| distance | High-resolution scroll distance reported by the client. |
| 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.
| input | Platform input backend that receives the event. |
| modcode | Modifier key code to update. |
| release | Whether the key or button event is a release. |
| flags | Bit flags that modify the requested operation. |
| int platf::keysym | ( | int | keycode | ) |
Translate a platform keycode to a Sunshine key symbol.
| keycode | Platform keycode being translated or emitted. |
| bool platf::modifier_flags_for_key | ( | int | key, |
| modifier_flags_t & | flags ) |
Resolve the CoreGraphics modifier masks associated with a key code.
| key | Sunshine key code that may represent a modifier key. |
| flags | Output masks for the matching CoreGraphics modifier. |
| void platf::move_mouse | ( | input_t & | input, |
| int | deltaX, | ||
| int | deltaY ) |
Move mouse using the backend coordinate system.
| input | Platform input backend that receives the event. |
| deltaX | Delta x. |
| deltaY | Delta y. |
| bool platf::operator< | ( | const KeyCodeMap & | a, |
| const KeyCodeMap & | b ) |
Order key mappings by Sunshine key code for binary search.
| a | Left-hand mapping being compared. |
| b | Right-hand mapping being compared. |
a has a lower Sunshine key code than b. | 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.
| input | The client-specific input context. |
| touch_port | The current viewport for translating to screen coordinates. |
| pen | The pen event. |
| void platf::post_mouse | ( | input_t & | input, |
| const CGMouseButton | button, | ||
| const CGEventType | type, | ||
| const util::point_t | raw_location, | ||
| const util::point_t | previous_location, | ||
| const int | click_count ) |
Post a mouse event at the clamped display location.
| input | Platform input context. |
| button | Mouse button. |
| type | CoreGraphics mouse event type. |
| raw_location | Requested mouse location. |
| previous_location | Previous mouse location. |
| click_count | Click count for the event. |
| void platf::post_scroll | ( | input_t & | input, |
| const int | wheelY, | ||
| const int | wheelX ) |
Post a macOS scroll event to the target display.
| input | Platform input backend that receives the event. |
| wheelY | Wheel y. |
| wheelX | Wheel x. |
| void platf::scroll | ( | input_t & | input, |
| int | distance ) |
Apply a vertical scroll event to the virtual mouse.
| input | Platform input backend that receives the event. |
| distance | High-resolution scroll distance reported by the client. |
| int platf::scroll_pixels | ( | const macos_input_t * | macos_input, |
| const int | high_res_distance ) |
Convert a high-resolution wheel delta to CoreGraphics scroll pixels.
| macos_input | macOS input state containing scroll scaling settings. |
| high_res_distance | Wheel delta in Windows high-resolution units. |
| 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()!
| input | Pointer to the platform's input_t or nullptr. |
| 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.
| input | The client-specific input context. |
| touch_port | The current viewport for translating to screen coordinates. |
| touch | The touch event. |
| void platf::unicode | ( | input_t & | input, |
| char * | utf8, | ||
| int | size ) |
Submit UTF-8 text input to the keyboard backend.
| input | Platform input backend that receives the event. |
| utf8 | UTF-8 text submitted by the client. |
| size | Number of bytes or elements requested. |