16#include <boost/core/noncopyable.hpp>
18 #include <boost/asio.hpp>
32#include <moonlight-common-c/src/Limelight.h>
35using namespace std::literals;
40struct AVHWFramesContext;
56 namespace filesystem {
60 namespace process::v1 {
63 template<
typename Char>
88 constexpr std::uint32_t
START = 0x0010;
89 constexpr std::uint32_t
BACK = 0x0020;
94 constexpr std::uint32_t
HOME = 0x0400;
95 constexpr std::uint32_t
A = 0x1000;
96 constexpr std::uint32_t
B = 0x2000;
97 constexpr std::uint32_t
X = 0x4000;
98 constexpr std::uint32_t
Y = 0x8000;
99 constexpr std::uint32_t
PADDLE1 = 0x010000;
143 msg.
data.rumble = {lowfreq, highfreq};
159 msg.
data.rumble_triggers = {left, right};
175 msg.
data.motion_event_state.motion_type = motion_type;
176 msg.
data.motion_event_state.report_rate = report_rate;
193 msg.
data.rgb_led = {r, g, b};
209 msg.
data.player_leds = {solid, flashing};
228 msg.
data.adaptive_triggers = {.event_flags = event_flags, .type_left = type_left, .type_right = type_right, .left = left, .right = right};
266 std::array<uint8_t, 10>
left;
267 std::array<uint8_t, 10>
right;
361 using namespace std::literals;
363 #define _CONVERT(x) \
399 namespace platform_caps {
530 struct img_t: std::enable_shared_from_this<img_t> {
534 img_t(img_t &&) =
delete;
535 img_t(
const img_t &) =
delete;
536 img_t &operator=(img_t &&) =
delete;
537 img_t &operator=(
const img_t &) =
delete;
630 virtual int set_frame(AVFrame *new_frame, AVBufferRef *hw_frames_ctx) {
631 BOOST_LOG(
error) <<
"Illegal call to hwdevice_t::set_frame(). Did you forget to override it?";
714 display_t() noexcept = default;
781 std::memset(&metadata, 0,
sizeof(metadata));
829 virtual ~mic_t() =
default;
856 virtual std::unique_ptr<mic_t>
microphone(
const std::uint8_t *mapping,
int channels, std::uint32_t sample_rate, std::uint32_t frame_size,
bool continuous, [[maybe_unused]]
bool host_audio_enabled) = 0;
895 std::filesystem::path
appdata();
920 std::pair<std::uint16_t, std::string>
from_sockaddr_ex(
const sockaddr *
const);
967 boost::process::v1::child
run_command(
bool elevated,
bool interactive,
const std::string &cmd, boost::filesystem::path &working_dir,
const boost::process::v1::environment &env, FILE *file, std::error_code &ec, boost::process::v1::group *group);
983 void adjust_thread_priority(thread_priority_e priority);
991 void set_thread_name(std::string_view name);
993 void enable_mouse_keys();
996 void streaming_will_start();
997 void streaming_will_stop();
1059 if (offset < desc.size) {
1061 desc.buffer + offset,
1065 offset -= desc.size;
1078 bool send_batch(
const batched_send_info_t &send_info);
1121 std::unique_ptr<deinit_t> enable_socket_qos(uintptr_t native_socket, boost::asio::ip::address &address, uint16_t port, qos_data_type_e data_type,
bool dscp_tagging);
1127 void open_url(
const std::string &url);
1134 bool request_process_group_exit(std::uintptr_t native_handle);
1141 bool process_group_running(std::uintptr_t native_handle);
1164 std::optional<util::point_t> get_mouse_loc(input_t &input);
1172 void move_mouse(input_t &input,
int deltaX,
int deltaY);
1181 void move_mouse(input_t &input,
const touch_port_t &touch_port,
int deltaX,
int deltaY);
1190 void abs_mouse(input_t &input,
const touch_port_t &touch_port,
float x,
float y);
1198 void button_mouse(input_t &input,
int button,
bool release);
1205 void scroll(input_t &input,
int distance);
1212 void hscroll(input_t &input,
int distance);
1222 void keyboard_update(input_t &input, uint16_t modcode,
bool release, uint8_t flags,
bool extended =
false);
1223 void gamepad_update(input_t &input,
int nr,
const gamepad_state_t &gamepad_state);
1231 void unicode(input_t &input,
const char *utf8,
int size);
1318 [[nodiscard]] std::unique_ptr<deinit_t> start();
1326 [[nodiscard]] std::unique_ptr<deinit_t> init();
1332 std::string get_host_name();
1341 std::string resolve_render_device();
1349 std::vector<supported_gamepad_t> &supported_gamepads(input_t *input);
1361 virtual void sleep_for(
const std::chrono::nanoseconds &duration) = 0;
1367 virtual explicit operator bool() = 0;
Includes Boost.Process while isolating third-party deprecation diagnostics.
A helper class for tracking and logging short time intervals across a period of time.
Definition logging.h:253
SDK-neutral standalone NVENC encoder interface.
Definition nvenc_encoder.h:28
Platform audio controller that manages sinks and microphone capture.
Definition common.h:835
virtual std::unique_ptr< mic_t > microphone(const std::uint8_t *mapping, int channels, std::uint32_t sample_rate, std::uint32_t frame_size, bool continuous, bool host_audio_enabled)=0
Create a microphone capture stream for the requested layout.
virtual std::optional< sink_t > sink_info()=0
Query host and virtual sink names available to Sunshine.
virtual int set_sink(const std::string &sink)=0
Update the sink value on the backend.
virtual bool is_sink_available(const std::string &sink)=0
Check if the audio sink is available in the system.
virtual ~audio_control_t()=default
Destroy the audio control.
RAII helper that runs shutdown cleanup when destroyed.
Definition common.h:519
virtual ~deinit_t()=default
Destroy the deinitializer.
Abstract display capture backend used by the streaming pipeline.
Definition common.h:694
virtual bool is_codec_supported(std::string_view name, const ::video::config_t &config)
Check that a given codec is supported by the display device.
Definition common.h:791
std::function< bool(std::shared_ptr< img_t > &&img, bool frame_captured)> push_captured_image_cb_t
Callback for when a new image is ready. When display has a new image ready or a timeout occurs,...
Definition common.h:703
virtual bool get_hdr_metadata(SS_HDR_METADATA &metadata)
Read HDR metadata for the active display mode.
Definition common.h:780
int env_height
Height of the full capture environment in physical pixels.
Definition common.h:803
int env_offset_x
Horizontal origin of the full capture environment in native desktop coordinates.
Definition common.h:800
int env_offset_y
Vertical origin of the full capture environment in native desktop coordinates.
Definition common.h:801
int env_logical_height
Height of the full capture environment after display scaling.
Definition common.h:805
std::function< bool(std::shared_ptr< img_t > &img_out)> pull_free_image_cb_t
Get free image from pool. Calls must be synchronized. Blocks until there is free image in the pool or...
Definition common.h:712
logging::time_delta_periodic_logger sleep_overshoot_logger
Periodic logger for capture sleep overshoot measurements.
Definition common.h:813
int offset_y
Vertical capture offset in physical pixels.
Definition common.h:799
virtual capture_e capture(const push_captured_image_cb_t &push_captured_image_cb, const pull_free_image_cb_t &pull_free_image_cb, bool *cursor)=0
Capture a frame.
virtual std::unique_ptr< nvenc_encode_device_t > make_nvenc_encode_device(pix_fmt_e pix_fmt)
Create NVENC encode device.
Definition common.h:761
int width
Width of the captured display in physical pixels.
Definition common.h:806
int logical_height
Height of the captured display after display scaling.
Definition common.h:809
int env_width
Width of the full capture environment in physical pixels.
Definition common.h:802
int height
Height of the captured display in physical pixels.
Definition common.h:807
virtual std::unique_ptr< avcodec_encode_device_t > make_avcodec_encode_device(pix_fmt_e pix_fmt)
Create AVCodec encode device.
Definition common.h:751
int offset_x
Horizontal capture offset in physical pixels.
Definition common.h:798
virtual bool is_hdr()
Report whether the active display mode is HDR.
Definition common.h:770
int env_logical_width
Width of the full capture environment after display scaling.
Definition common.h:804
virtual std::shared_ptr< img_t > alloc_img()=0
Allocate an image buffer compatible with this display backend.
int logical_width
Width of the captured display after display scaling.
Definition common.h:808
virtual int dummy_img(img_t *img)=0
Populate a fallback image when real capture data is unavailable.
Audio capture source used by the streaming pipeline.
Definition common.h:819
virtual capture_e sample(std::vector< float > &frame_buffer)=0
Deliver a captured audio sample to Sunshine's audio pipeline.
std::shared_ptr< post_t< queue_t< T > > > queue_t
Mailbox-backed queue wrapper for typed messages.
Definition thread_safe.h:813
mem_type_e
Enumerates supported mem type options.
Definition common.h:329
@ system
System memory.
Definition common.h:330
@ vulkan
Vulkan.
Definition common.h:335
@ unknown
Unknown.
Definition common.h:336
void free_gamepad(input_t &input, int nr)
Release gamepad resources.
Definition input.cpp:743
constexpr std::array< std::uint8_t, 2 > map_stereo
Moonlight speaker order for stereo audio.
Definition common.h:296
basic_environment< char > environment
Map of environment variable names to values.
Definition common.h:68
constexpr std::uint32_t B
Moonlight gamepad button mask bit for B.
Definition common.h:96
speaker_e
Enumerates supported speaker options.
Definition common.h:281
@ BACK_LEFT
Back left.
Definition common.h:286
@ LOW_FREQUENCY
Low frequency.
Definition common.h:285
@ SIDE_RIGHT
Side right.
Definition common.h:289
@ MAX_SPEAKERS
Maximum number of speakers.
Definition common.h:290
@ FRONT_LEFT
Front left.
Definition common.h:282
@ SIDE_LEFT
Side left.
Definition common.h:288
@ FRONT_CENTER
Front center.
Definition common.h:284
@ BACK_RIGHT
Back right.
Definition common.h:287
@ FRONT_RIGHT
Front right.
Definition common.h:283
constexpr std::uint32_t LEFT_BUTTON
Moonlight gamepad button mask bit for left shoulder.
Definition common.h:92
deinit_t client_input_t
Per-client input context allocated by a platform backend.
Definition common.h:1236
int rebind_gamepad(input_t &input, const gamepad_id_t &id, feedback_queue_t feedback_queue)
Rebind an existing virtual gamepad to a resumed client session.
Definition input.cpp:729
input_t input()
Create the platform input backend for a stream.
Definition input.cpp:561
constexpr std::uint32_t DPAD_LEFT
Moonlight gamepad button mask bit for D-pad left.
Definition common.h:86
std::string get_mac_address(const std::string_view &address)
Return the hardware MAC address associated with a network address.
Definition misc.cpp:424
constexpr std::uint32_t DPAD_UP
Moonlight gamepad button mask bit for D-pad up.
Definition common.h:84
std::shared_ptr< display_t > display(mem_type_e hwdevice_type, const std::string &display_name, const video::config_t &config)
Get the display_t instance for the given hwdevice_type. If display_name is empty, use the first monit...
Definition misc.cpp:1365
constexpr std::uint32_t PADDLE3
Moonlight gamepad button mask bit for paddle 3.
Definition common.h:101
constexpr auto SERVICE_TYPE
mDNS service type advertised for GameStream discovery.
Definition common.h:1315
std::pair< std::uint16_t, std::string > from_sockaddr_ex(const sockaddr *const)
Convert a socket address to a port and printable IP address.
Definition misc.cpp:405
pix_fmt_e
Enumerates supported pix fmt options.
Definition common.h:342
@ ayuv
AYUV.
Definition common.h:347
@ yuv420p10
YUV 4:2:0 10-bit.
Definition common.h:344
@ yuv444p
Planar 8-bit YUV 4:4:4.
Definition common.h:349
@ y410
Y410.
Definition common.h:350
@ nv12
NV12.
Definition common.h:345
@ yuv444p16
Planar 10-bit (shifted to 16-bit) YUV 4:4:4.
Definition common.h:348
@ yuv420p
YUV 4:2:0.
Definition common.h:343
@ p010
P010.
Definition common.h:346
int 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.
Definition input.cpp:666
constexpr std::uint32_t HOME
Moonlight gamepad button mask bit for Home.
Definition common.h:94
bool has_elevated_privileges(bool all_caps)
Check is the current process is running with elevated privileges (e.g. system admin/etc....
Definition misc.cpp:1623
uint32_t caps_t
Bitset containing platform capability flags.
Definition common.h:403
std::filesystem::path appdata()
Performs migration if necessary, then returns the appdata directory.
Definition misc.cpp:298
constexpr std::uint32_t TOUCHPAD_BUTTON
Moonlight gamepad button mask bit for touchpad click.
Definition common.h:103
constexpr std::uint32_t LEFT_STICK
Moonlight gamepad button mask bit for left stick press.
Definition common.h:90
constexpr std::uint32_t DPAD_RIGHT
Moonlight gamepad button mask bit for D-pad right.
Definition common.h:87
constexpr std::uint32_t PADDLE2
Moonlight gamepad button mask bit for paddle 2.
Definition common.h:100
constexpr std::uint32_t RIGHT_STICK
Moonlight gamepad button mask bit for right stick press.
Definition common.h:91
std::filesystem::path get_xdg_restore_token_path()
XDG restore token path.
Definition misc.cpp:378
qos_data_type_e
Identifies traffic classes used for socket QoS tagging.
Definition common.h:1106
std::unique_ptr< high_precision_timer > create_high_precision_timer()
Create platform-specific timer capable of high-precision sleep.
Definition misc.cpp:1550
std::string_view from_pix_fmt(pix_fmt_e pix_fmt)
Convert a Sunshine pixel format enum to its string name.
Definition common.h:360
std::unique_ptr< audio_control_t > audio_control()
Create the platform audio controller.
Definition audio.cpp:718
constexpr std::uint32_t PADDLE1
Moonlight gamepad button mask bit for paddle 1.
Definition common.h:99
std::unique_ptr< client_input_t > allocate_client_input_context(input_t &input)
Allocate a context to store per-client input data.
Definition input.cpp:658
constexpr std::uint32_t PADDLE4
Moonlight gamepad button mask bit for paddle 4.
Definition common.h:102
constexpr caps_t pen_touch
Capability bit indicating native pen and touch support.
Definition common.h:408
constexpr std::uint32_t A
Moonlight gamepad button mask bit for A.
Definition common.h:95
constexpr auto SERVICE_NAME
mDNS service instance name advertised for GameStream discovery.
Definition common.h:1314
bool send(send_info_t &send_info)
Send the serialized response over the active socket.
Definition misc.cpp:945
constexpr std::uint32_t DPAD_DOWN
Moonlight gamepad button mask bit for D-pad down.
Definition common.h:85
void pen_update(client_input_t *input, const touch_port_t &touch_port, const pen_input_t &pen)
Send a pen event to the OS.
Definition virtualhid_input.cpp:1190
void gamepad_motion(input_t &input, const gamepad_motion_t &motion)
Send a gamepad motion event to the OS.
Definition input.cpp:1219
bool needs_encoder_reenumeration()
Check if GPUs/drivers have changed since the last call to this function.
Definition misc.cpp:1352
gamepad_feedback_e
Enumerates supported gamepad feedback options.
Definition common.h:118
@ set_player_leds
Set player indicator LEDs.
Definition common.h:123
@ rumble
Rumble.
Definition common.h:119
@ rumble_triggers
Rumble triggers.
Definition common.h:120
@ set_adaptive_triggers
Set adaptive triggers.
Definition common.h:124
@ set_motion_event_state
Set motion event state.
Definition common.h:121
@ set_rgb_led
Set RGB LED.
Definition common.h:122
boost::process::v1::child run_command(bool elevated, bool interactive, const std::string &cmd, boost::filesystem::path &working_dir, const boost::process::v1::environment &env, FILE *file, std::error_code &ec, boost::process::v1::group *group)
Launch a configured preparation or application command.
constexpr std::uint32_t BACK
Moonlight gamepad button mask bit for Back.
Definition common.h:89
thread_priority_e
Enumerates supported thread priority options.
Definition common.h:972
@ low
Low priority.
Definition common.h:973
@ critical
Critical priority.
Definition common.h:976
@ high
High priority.
Definition common.h:975
@ normal
Normal priority.
Definition common.h:974
util::safe_ptr< input_raw_t, &freeInput > input_t
Owning pointer for a platform input backend.
Definition common.h:893
constexpr std::array< std::uint8_t, 8 > map_surround71
Moonlight speaker order for 7.1 surround audio.
Definition common.h:314
void drop_elevated_privileges(bool all_caps)
Drop elevated privileges (e.g. system admin/nice etc.).
Definition misc.cpp:1652
constexpr std::array< std::uint8_t, 6 > map_surround51
Moonlight speaker order for 5.1 surround audio.
Definition common.h:303
constexpr auto MAX_GAMEPADS
Maximum number of simultaneously tracked gamepads.
Definition common.h:82
std::string from_sockaddr(const sockaddr *const)
Convert a socket address to a printable IP address.
Definition misc.cpp:389
constexpr std::uint32_t RIGHT_BUTTON
Moonlight gamepad button mask bit for right shoulder.
Definition common.h:93
safe::mail_raw_t::queue_t< gamepad_feedback_msg_t > feedback_queue_t
Queue used to deliver controller feedback commands to the platform backend.
Definition common.h:275
constexpr std::uint32_t START
Moonlight gamepad button mask bit for Start.
Definition common.h:88
constexpr std::uint32_t MISC_BUTTON
Moonlight gamepad button mask bit for the miscellaneous button.
Definition common.h:104
void gamepad_battery(input_t &input, const gamepad_battery_t &battery)
Send a gamepad battery event to the OS.
Definition input.cpp:1252
constexpr std::uint32_t X
Moonlight gamepad button mask bit for X.
Definition common.h:97
platform_caps::caps_t get_capabilities()
Get the supported platform capabilities to advertise to the client.
Definition virtualhid.cpp:21
std::vector< std::string > display_names(mem_type_e hwdevice_type)
List display names accepted by the selected capture backend.
Definition misc.cpp:1312
void gamepad_touch(input_t &input, const gamepad_touch_t &touch)
Send a gamepad touch event to the OS.
Definition input.cpp:1185
void touch_update(client_input_t *input, const touch_port_t &touch_port, const touch_input_t &touch)
Send a touch event to the OS.
Definition virtualhid_input.cpp:1186
constexpr caps_t controller_touch
Capability bit indicating controller touchpad and motion support.
Definition common.h:412
capture_e
Enumerates supported capture options.
Definition common.h:683
@ capture_error
Capture failed.
Definition common.h:688
@ ok
Success.
Definition common.h:684
@ timeout
Timeout.
Definition common.h:686
@ reinit
Need to reinitialize.
Definition common.h:685
@ interrupted
Capture was interrupted.
Definition common.h:687
constexpr std::uint32_t Y
Moonlight gamepad button mask bit for Y.
Definition common.h:98
void freeInput(input_raw_t *input)
Release a platform input backend created by input().
Definition input.cpp:1280
Declarations for the configuration of Sunshine.
avahi::EntryGroup * group
Active Avahi entry group that owns the published service.
Definition publish.cpp:396
bl::sources::severity_logger< int > debug
Follow what is happening.
Definition logging.cpp:43
bl::sources::severity_logger< int > error
Recoverable errors.
Definition logging.cpp:46
boost::shared_ptr< boost::log::sinks::asynchronous_sink< boost::log::sinks::text_ostream_backend > > sink
Sink.
Definition logging.cpp:40
Declarations for logging related functions.
Standalone NVENC encoder.
Definition nvenc_base.cpp:185
AVCodec-backed encode device and frame state.
Definition common.h:594
int convert(platf::img_t &img) override
Convert a captured image into the encoder input representation.
Definition common.h:612
virtual int set_frame(AVFrame *new_frame, AVBufferRef *hw_frames_ctx)
Set the frame to be encoded.
Definition common.h:630
virtual int prepare_to_derive_context(int hw_device_type)
Prepare to derive a context.
Definition common.h:659
init_hw_device_fn_t init_hw_device
Optional backend-specific hardware device initializer.
Definition common.h:600
bool hardware
Whether this device supplies hardware frames instead of software conversion.
Definition common.h:595
virtual void init_codec_options(AVCodecContext *ctx, AVDictionary **options)
Provides a hook for allow platform-specific code to adjust codec options.
Definition common.h:650
virtual void apply_colorspace()
Apply the configured colorspace metadata to the active frame.
Definition common.h:619
ID3D11Device * d3d11_device
Native D3D11 device borrowed while the encode device is alive.
Definition common.h:602
AVFrame * frame
FFmpeg frame currently owned by the encode device.
Definition common.h:604
int(*)(avcodec_encode_device_t *encode_device, AVBufferRef **hw_device_buf) init_hw_device_fn_t
Callback signature for backend-specific FFmpeg hardware device initialization.
Definition common.h:599
virtual void init_hwframes(AVHWFramesContext *frames)
Initialize the hwframes context.
Definition common.h:641
Buffers and native metadata for one batched send operation.
Definition common.h:1029
boost::asio::ip::address & source_address
Local source IP address for outgoing packets.
Definition common.h:1050
const char * headers
Optional header bytes prepended to each payload.
Definition common.h:1031
std::vector< buffer_descriptor_t > & payload_buffers
Payload buffers containing one or more packet blocks.
Definition common.h:1037
std::uintptr_t native_socket
Platform socket handle used for the send operation.
Definition common.h:1047
size_t block_count
Number of packet blocks to send.
Definition common.h:1045
buffer_descriptor_t buffer_for_payload_offset(ptrdiff_t offset) const
Locate a payload region without changing the batch descriptor or its buffers.
Definition common.h:1057
uint16_t target_port
Destination UDP port for outgoing packets.
Definition common.h:1049
size_t block_offset
First packet block index to send.
Definition common.h:1042
size_t header_size
Header size in bytes.
Definition common.h:1032
size_t payload_size
Payload size in bytes for each packet block.
Definition common.h:1038
boost::asio::ip::address & target_address
Destination IP address for outgoing packets.
Definition common.h:1048
Platform buffer pointer and size for batched socket sends.
Definition common.h:1004
size_t size
Size of the buffer in bytes.
Definition common.h:1006
buffer_descriptor_t(const char *buffer, size_t size)
Describe a contiguous byte buffer for batched socket sending.
Definition common.h:1015
const char * buffer
Pointer to the payload buffer.
Definition common.h:1005
Base interface for hardware or software frame conversion.
Definition common.h:577
video::sunshine_colorspace_t colorspace
Colorspace metadata expected by the encoder.
Definition common.h:588
virtual int convert(platf::img_t &img)=0
Convert a captured image into the encoder input representation.
Capabilities reported when a controller is connected.
Definition common.h:445
std::uint8_t type
Protocol or controller type discriminator.
Definition common.h:446
std::uint32_t supportedButtons
Button mask supported by the connected controller.
Definition common.h:448
std::uint16_t capabilities
Capability flags advertised by the controller.
Definition common.h:447
Battery state reported by a virtual gamepad.
Definition common.h:480
std::uint8_t state
Battery state reported by the client.
Definition common.h:482
std::uint8_t percentage
Battery charge percentage.
Definition common.h:483
gamepad_id_t id
Gamepad identifier for the event.
Definition common.h:481
uint8_t type_right
Right adaptive-trigger effect type.
std::array< uint8_t, 10 > left
Left adaptive-trigger effect parameters.
uint8_t type_left
Left adaptive-trigger effect type.
std::array< uint8_t, 10 > right
Right adaptive-trigger effect parameters.
uint8_t event_flags
Flags describing which adaptive-trigger data is present.
std::uint8_t motion_type
Motion-sensor type to configure.
std::uint16_t report_rate
Requested motion-sensor report rate.
std::uint8_t solid
Bit mask of solid player indicators.
std::uint8_t flashing
Bit mask of flashing player indicators.
std::uint8_t r
Red LED channel intensity.
std::uint8_t g
Green LED channel intensity.
std::uint8_t b
Blue LED channel intensity.
std::uint16_t right_trigger
Right-trigger rumble motor intensity.
std::uint16_t left_trigger
Left-trigger rumble motor intensity.
std::uint16_t lowfreq
Low-frequency rumble motor intensity.
std::uint16_t highfreq
High-frequency rumble motor intensity.
Feedback command sent from Sunshine to a virtual gamepad.
Definition common.h:130
static gamepad_feedback_msg_t make_motion_event_state(std::uint16_t id, std::uint8_t motion_type, std::uint16_t report_rate)
Motion-event feedback command payload for a controller.
Definition common.h:171
std::uint16_t id
Controller identifier associated with this message.
Definition common.h:233
static gamepad_feedback_msg_t make_rumble(std::uint16_t id, std::uint16_t lowfreq, std::uint16_t highfreq)
Create a rumble object or message.
Definition common.h:139
static gamepad_feedback_msg_t make_player_leds(std::uint16_t id, std::uint8_t solid, std::uint8_t flashing)
Create player indicator LED state.
Definition common.h:205
static gamepad_feedback_msg_t make_rgb_led(std::uint16_t id, std::uint8_t r, std::uint8_t g, std::uint8_t b)
Create RGB led.
Definition common.h:189
static gamepad_feedback_msg_t make_rumble_triggers(std::uint16_t id, std::uint16_t left, std::uint16_t right)
Create rumble triggers.
Definition common.h:155
static gamepad_feedback_msg_t make_adaptive_triggers(std::uint16_t id, uint8_t event_flags, uint8_t type_left, uint8_t type_right, const std::array< uint8_t, 10 > &left, const std::array< uint8_t, 10 > &right)
Create adaptive triggers.
Definition common.h:224
union platf::gamepad_feedback_msg_t::@234001133101023130022260273167130254046220012376 data
Controller feedback payload for the selected feedback type.
gamepad_feedback_e type
Feedback command type stored in the union payload.
Definition common.h:232
Global and client-relative identifiers for a virtual gamepad.
Definition common.h:431
int globalIndex
Index unique across all connected clients.
Definition common.h:434
std::uint8_t clientRelativeIndex
Client relative index.
Definition common.h:439
Accelerometer or gyroscope sample from a controller.
Definition common.h:466
float z
Depth or Z-axis vector component.
Definition common.h:474
float x
Horizontal coordinate or vector component.
Definition common.h:472
gamepad_id_t id
Gamepad identifier for the event.
Definition common.h:467
float y
Vertical coordinate or vector component.
Definition common.h:473
std::uint8_t motionType
Motion type.
Definition common.h:468
Button and axis state received for a virtual gamepad.
Definition common.h:418
std::int16_t rsX
Right stick X-axis value.
Definition common.h:424
std::uint32_t buttonFlags
Moonlight button mask for the current gamepad state.
Definition common.h:419
std::uint8_t lt
Left trigger value.
Definition common.h:420
std::int16_t lsX
Left stick X-axis value.
Definition common.h:422
std::int16_t rsY
Right stick Y-axis value.
Definition common.h:425
std::uint8_t rt
Right trigger value.
Definition common.h:421
std::int16_t lsY
Left stick Y-axis value.
Definition common.h:423
Touchpad contact data reported by a controller.
Definition common.h:454
float pressure
Contact pressure reported by the client.
Definition common.h:460
std::uint32_t pointerId
Client-provided pointer identifier for a touch contact.
Definition common.h:457
float y
Vertical coordinate or vector component.
Definition common.h:459
std::uint8_t eventType
Moonlight event type for the input packet.
Definition common.h:456
float x
Horizontal coordinate or vector component.
Definition common.h:458
gamepad_id_t id
Gamepad identifier for the event.
Definition common.h:455
Platform timer object used for precise frame pacing.
Definition common.h:1354
virtual void sleep_for(const std::chrono::nanoseconds &duration)=0
Sleep for the duration.
Captured frame buffer shared between capture and encode stages.
Definition common.h:530
std::int32_t row_pitch
Bytes between consecutive image rows.
Definition common.h:543
std::uint8_t * data
Pointer to the captured image buffer.
Definition common.h:539
std::int32_t pixel_pitch
Bytes per pixel in the image buffer.
Definition common.h:542
virtual ~img_t()=default
Destroy the image.
std::int32_t height
Image height in pixels.
Definition common.h:541
std::int32_t width
Image width in pixels.
Definition common.h:540
std::optional< std::chrono::steady_clock::time_point > frame_timestamp
Capture timestamp associated with the frame.
Definition common.h:545
NVENC-backed encode device state.
Definition common.h:667
virtual bool init_encoder(const video::config_t &client_config, const video::sunshine_colorspace_t &colorspace)=0
Initialize the platform encoder for the client stream configuration.
Destination address and payload data for one UDP send.
Definition common.h:1083
const char * payload
Payload bytes to send after the header.
Definition common.h:1086
std::uintptr_t native_socket
Platform socket handle used for the send operation.
Definition common.h:1089
boost::asio::ip::address & target_address
Destination IP address for outgoing packets.
Definition common.h:1090
size_t payload_size
Payload size in bytes for each packet block.
Definition common.h:1087
uint16_t target_port
Destination UDP port for outgoing packets.
Definition common.h:1091
size_t header_size
Header size in bytes.
Definition common.h:1085
const char * header
Optional header bytes prepended to the payload.
Definition common.h:1084
boost::asio::ip::address & source_address
Local source IP address for outgoing packets.
Definition common.h:1092
Optional virtual sink names for each supported channel layout.
Definition common.h:565
std::string surround51
Virtual sink name for 5.1 surround audio.
Definition common.h:567
std::string stereo
Virtual sink name for stereo audio.
Definition common.h:566
std::string surround71
Virtual sink name for 7.1 surround audio.
Definition common.h:568
Host and virtual audio sink names for audio routing.
Definition common.h:556
std::string host
Host playback sink name.
Definition common.h:558
std::optional< null_t > null
Optional virtual sink names for monitor capture.
Definition common.h:571
Gamepad type exposed to clients and why it may be disabled.
Definition common.h:109
std::string reason_disabled
Human-readable reason the gamepad type is disabled.
Definition common.h:112
std::string name
Human-readable name for this item.
Definition common.h:110
bool is_enabled
Whether this gamepad type is currently available.
Definition common.h:111
Touchscreen coordinate bounds used to scale absolute input.
Definition common.h:387
int logical_width
Logical width after display scaling.
Definition common.h:392
int env_offset_x
Horizontal origin of the full input environment in native desktop coordinates.
Definition common.h:394
int height
Frame or display height in pixels.
Definition common.h:391
int offset_y
Vertical offset in physical pixels.
Definition common.h:389
int offset_x
Horizontal offset in physical pixels.
Definition common.h:388
int logical_height
Logical height after display scaling.
Definition common.h:393
int env_offset_y
Vertical origin of the full input environment in native desktop coordinates.
Definition common.h:395
int width
Frame or display width in pixels.
Definition common.h:390
Encoding configuration requested by a remote client.
Definition video.h:33
Sunshine colorimetry values derived from stream configuration.
Definition video_colorspace.h:36
Declarations for thread-safe data structures.
struct platf::gamepad_feedback_msg_t::@234001133101023130022260273167130254046220012376::@037021105207321207034272072146135103300350235316 rumble_triggers
Trigger-rumble payload.
struct platf::gamepad_feedback_msg_t::@234001133101023130022260273167130254046220012376::@044345256342224141102302237155264067070201106066 player_leds
Player-indicator LED payload.
struct platf::gamepad_feedback_msg_t::@234001133101023130022260273167130254046220012376::@106035267303314031173166200007272265340336012106 adaptive_triggers
Adaptive-trigger effect payload.
struct platf::gamepad_feedback_msg_t::@234001133101023130022260273167130254046220012376::@140357377176242234057270015324307025371227217003 motion_event_state
Motion-event configuration payload.
struct platf::gamepad_feedback_msg_t::@234001133101023130022260273167130254046220012376::@213310322173366006247037042350147155371343226356 rumble
Main rumble-motor payload.
struct platf::gamepad_feedback_msg_t::@234001133101023130022260273167130254046220012376::@313276062140061056216371202126064256137165137065 rgb_led
RGB LED payload.
Declarations for utility functions.
uniq_ptr< T, Destroy< T *, void, function > > safe_ptr
Unique pointer using a compile-time C-style destroy function.
Definition utility.h:1590
Declarations for colorspace functions.