diff --git a/sunshine/input.cpp b/sunshine/input.cpp index f8ba308d..6e4c092e 100644 --- a/sunshine/input.cpp +++ b/sunshine/input.cpp @@ -222,14 +222,20 @@ void passthrough(std::shared_ptr &input, PNV_ABS_MOUSE_MOVE_PACKET pack return; } - int width = util::endian::big(packet->width); - int height = util::endian::big(packet->height); + auto width = (float)util::endian::big(packet->width); + auto height = (float)util::endian::big(packet->height); - auto offsetX = (width - (float)touch_port.width) * 0.5f; - auto offsetY = (height - (float)touch_port.height) * 0.5f; + auto scalarX = touch_port.width / width; + auto scalarY = touch_port.height / height; + + x *= scalarX; + y *= scalarY; + + auto offsetX = touch_port.client_offsetX; + auto offsetY = touch_port.client_offsetY; std::clamp(x, offsetX, width - offsetX); - std::clamp(y, offsetX, height - offsetY); + std::clamp(y, offsetY, height - offsetY); platf::touch_port_t abs_port { touch_port.offset_x, touch_port.offset_y, diff --git a/sunshine/input.h b/sunshine/input.h index 285828d9..bde14c6d 100644 --- a/sunshine/input.h +++ b/sunshine/input.h @@ -24,7 +24,9 @@ std::shared_ptr alloc(safe::mail_t mail); struct touch_port_t : public platf::touch_port_t { int env_width, env_height; - // inverse of scalar used for aspect ratio + // Offset x and y coordinates of the client + float client_offsetX, client_offsetY; + float scalar_inv; }; } // namespace input diff --git a/sunshine/video.cpp b/sunshine/video.cpp index 59f3a1ec..9d52a0b8 100644 --- a/sunshine/video.cpp +++ b/sunshine/video.cpp @@ -409,11 +409,13 @@ static encoder_t nvenc { #ifdef _WIN32 AV_HWDEVICE_TYPE_D3D11VA, AV_PIX_FMT_D3D11, + AV_PIX_FMT_NV12, AV_PIX_FMT_P010, #else AV_HWDEVICE_TYPE_CUDA, AV_PIX_FMT_CUDA, + // Fully planar YUV formats are more efficient for sws_scale() + AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV420P10, #endif - AV_PIX_FMT_NV12, AV_PIX_FMT_P010, { { { "forced-idr"s, 1 }, @@ -1071,13 +1073,18 @@ input::touch_port_t make_port(platf::display_t *display, const config_t &config) auto w2 = scalar * wd; auto h2 = scalar * hd; + auto offsetX = (config.width - w2) * 0.5f; + auto offsetY = (config.height - h2) * 0.5f; + return input::touch_port_t { display->offset_x, display->offset_y, - (int)w2, - (int)h2, + config.width, + config.height, display->env_width, display->env_height, + offsetX, + offsetY, 1.0f / scalar, }; } @@ -1794,4 +1801,4 @@ color_t colors[] { make_color_matrix(0.2126f, 0.0722f, 0.436f, 0.615f, 0.0625, 0.5f, { 16.0f, 235.0f }, { 16.0f, 240.0f }), // BT701 MPEG make_color_matrix(0.2126f, 0.0722f, 0.5f, 0.5f, 0.0f, 0.5f, { 0.0f, 255.0f }, { 0.0f, 255.0f }), // BT701 JPEG }; -} +} // namespace video