[yuzu_cmd] fix HFA Wpsabi warning on aarch64
Some checks failed
eden-license / license-header (pull_request) Failing after 17s
Some checks failed
eden-license / license-header (pull_request) Failing after 17s
Signed-off-by: lizzie <lizzie@eden-emu.dev>
This commit is contained in:
parent
7050b92d61
commit
8ee0dcdf49
2 changed files with 18 additions and 10 deletions
|
@ -49,19 +49,23 @@ InputCommon::MouseButton EmuWindow_SDL2::SDLButtonToMouseButton(u32 button) cons
|
|||
}
|
||||
}
|
||||
|
||||
std::pair<float, float> 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<float>(touch_x) / w;
|
||||
const float fy = static_cast<float>(touch_y) / h;
|
||||
|
||||
return {std::clamp<float>(fx, 0.0f, 1.0f), std::clamp<float>(fy, 0.0f, 1.0f)};
|
||||
const float fx = float(touch_x) / w;
|
||||
const float fy = float(touch_y) / h;
|
||||
return {
|
||||
std::clamp<float>(fx, 0.0f, 1.0f),
|
||||
std::clamp<float>(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 +75,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);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
|
||||
#include "core/frontend/emu_window.h"
|
||||
|
@ -43,8 +44,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<float, float> MouseToTouchPos(s32 touch_x, s32 touch_y) const;
|
||||
// Using std::pair<float,float> 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<float, float, char>;
|
||||
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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue