diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp b/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp index 41697a22e8..9ec6b1d594 100644 --- a/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp +++ b/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp @@ -1,3 +1,5 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: 2016 Citra Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -49,19 +51,23 @@ InputCommon::MouseButton EmuWindow_SDL2::SDLButtonToMouseButton(u32 button) cons } } -std::pair EmuWindow_SDL2::MouseToTouchPos(s32 touch_x, s32 touch_y) const { - int w, h; +/// @brief Translates pixel position to float position +EmuWindow_SDL2::FloatPairNonHFA EmuWindow_SDL2::MouseToTouchPos(s32 touch_x, s32 touch_y) const { + int w = 0, h = 0; SDL_GetWindowSize(render_window, &w, &h); - const float fx = static_cast(touch_x) / w; - const float fy = static_cast(touch_y) / h; - - return {std::clamp(fx, 0.0f, 1.0f), std::clamp(fy, 0.0f, 1.0f)}; + const float fx = float(touch_x) / w; + const float fy = float(touch_y) / h; + return { + std::clamp(fx, 0.0f, 1.0f), + std::clamp(fy, 0.0f, 1.0f), + 0 + }; } void EmuWindow_SDL2::OnMouseButton(u32 button, u8 state, s32 x, s32 y) { const auto mouse_button = SDLButtonToMouseButton(button); if (state == SDL_PRESSED) { - const auto [touch_x, touch_y] = MouseToTouchPos(x, y); + auto const [touch_x, touch_y, _] = MouseToTouchPos(x, y); input_subsystem->GetMouse()->PressButton(x, y, mouse_button); input_subsystem->GetMouse()->PressMouseButton(mouse_button); input_subsystem->GetMouse()->PressTouchButton(touch_x, touch_y, mouse_button); @@ -71,7 +77,7 @@ void EmuWindow_SDL2::OnMouseButton(u32 button, u8 state, s32 x, s32 y) { } void EmuWindow_SDL2::OnMouseMotion(s32 x, s32 y) { - const auto [touch_x, touch_y] = MouseToTouchPos(x, y); + auto const [touch_x, touch_y, _] = MouseToTouchPos(x, y); input_subsystem->GetMouse()->Move(x, y, 0, 0); input_subsystem->GetMouse()->MouseMove(touch_x, touch_y); input_subsystem->GetMouse()->TouchMove(touch_x, touch_y); diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2.h b/src/yuzu_cmd/emu_window/emu_window_sdl2.h index 4ad05e0e16..8aec1efda0 100644 --- a/src/yuzu_cmd/emu_window/emu_window_sdl2.h +++ b/src/yuzu_cmd/emu_window/emu_window_sdl2.h @@ -1,8 +1,11 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: 2016 Citra Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #pragma once +#include #include #include "core/frontend/emu_window.h" @@ -43,8 +46,11 @@ protected: /// Converts a SDL mouse button into MouseInput mouse button InputCommon::MouseButton SDLButtonToMouseButton(u32 button) const; - /// Translates pixel position to float position - std::pair MouseToTouchPos(s32 touch_x, s32 touch_y) const; + // Using std::pair will invoke HFA miscompilation bug on g++10 + // on newer versions it emits an annoying warning, so just not use an HFA + // https://stackoverflow.com/questions/77729813/parameter-passing-for-argument-when-c17-is-enabled-changed-to-match-c14 + using FloatPairNonHFA = std::tuple; + FloatPairNonHFA MouseToTouchPos(s32 touch_x, s32 touch_y) const; /// Called by WaitEvent when a mouse button is pressed or released void OnMouseButton(u32 button, u8 state, s32 x, s32 y);