diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/audio_core/renderer/system.cpp | 5 | ||||
| -rw-r--r-- | src/audio_core/sink/sdl2_sink.cpp | 11 | ||||
| -rw-r--r-- | src/common/address_space.inc | 2 | ||||
| -rw-r--r-- | src/common/input.h | 2 | ||||
| -rw-r--r-- | src/common/vector_math.h | 14 | ||||
| -rw-r--r-- | src/core/hid/emulated_controller.cpp | 10 | ||||
| -rw-r--r-- | src/core/hid/emulated_controller.h | 1 | ||||
| -rw-r--r-- | src/core/hid/input_converter.cpp | 1 | ||||
| -rw-r--r-- | src/core/hid/motion_input.cpp | 36 | ||||
| -rw-r--r-- | src/core/hid/motion_input.h | 2 | ||||
| -rw-r--r-- | src/input_common/input_engine.cpp | 2 | ||||
| -rw-r--r-- | src/input_common/input_poller.cpp | 1 | ||||
| -rw-r--r-- | src/video_core/shader_cache.cpp | 4 | ||||
| -rw-r--r-- | src/video_core/shader_environment.cpp | 16 | ||||
| -rw-r--r-- | src/video_core/shader_environment.h | 6 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_input_player.cpp | 10 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_input_player_widget.cpp | 91 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_input_player_widget.h | 5 | ||||
| -rw-r--r-- | src/yuzu_cmd/config.cpp | 12 |
19 files changed, 189 insertions, 42 deletions
diff --git a/src/audio_core/renderer/system.cpp b/src/audio_core/renderer/system.cpp index ad869facb..53b258c4f 100644 --- a/src/audio_core/renderer/system.cpp +++ b/src/audio_core/renderer/system.cpp | |||
| @@ -436,10 +436,7 @@ void System::Stop() { | |||
| 436 | } | 436 | } |
| 437 | 437 | ||
| 438 | if (execution_mode == ExecutionMode::Auto) { | 438 | if (execution_mode == ExecutionMode::Auto) { |
| 439 | // Should wait for the system to terminate here, but core timing (should have) already | 439 | terminate_event.Wait(); |
| 440 | // stopped, so this isn't needed. Find a way to make this definite. | ||
| 441 | |||
| 442 | // terminate_event.Wait(); | ||
| 443 | } | 440 | } |
| 444 | } | 441 | } |
| 445 | 442 | ||
diff --git a/src/audio_core/sink/sdl2_sink.cpp b/src/audio_core/sink/sdl2_sink.cpp index ee1a0652f..c1529d1f9 100644 --- a/src/audio_core/sink/sdl2_sink.cpp +++ b/src/audio_core/sink/sdl2_sink.cpp | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | 3 | ||
| 4 | #include <span> | 4 | #include <span> |
| 5 | #include <vector> | 5 | #include <vector> |
| 6 | #include <SDL.h> | ||
| 6 | 7 | ||
| 7 | #include "audio_core/common/common.h" | 8 | #include "audio_core/common/common.h" |
| 8 | #include "audio_core/sink/sdl2_sink.h" | 9 | #include "audio_core/sink/sdl2_sink.h" |
| @@ -10,16 +11,6 @@ | |||
| 10 | #include "common/logging/log.h" | 11 | #include "common/logging/log.h" |
| 11 | #include "core/core.h" | 12 | #include "core/core.h" |
| 12 | 13 | ||
| 13 | // Ignore -Wimplicit-fallthrough due to https://github.com/libsdl-org/SDL/issues/4307 | ||
| 14 | #ifdef __clang__ | ||
| 15 | #pragma clang diagnostic push | ||
| 16 | #pragma clang diagnostic ignored "-Wimplicit-fallthrough" | ||
| 17 | #endif | ||
| 18 | #include <SDL.h> | ||
| 19 | #ifdef __clang__ | ||
| 20 | #pragma clang diagnostic pop | ||
| 21 | #endif | ||
| 22 | |||
| 23 | namespace AudioCore::Sink { | 14 | namespace AudioCore::Sink { |
| 24 | /** | 15 | /** |
| 25 | * SDL sink stream, responsible for sinking samples to hardware. | 16 | * SDL sink stream, responsible for sinking samples to hardware. |
diff --git a/src/common/address_space.inc b/src/common/address_space.inc index 2195dabd5..c97dc8651 100644 --- a/src/common/address_space.inc +++ b/src/common/address_space.inc | |||
| @@ -72,7 +72,7 @@ MAP_MEMBER(void)::MapLocked(VaType virt, PaType phys, VaType size, ExtraBlockInf | |||
| 72 | } | 72 | } |
| 73 | }()}; | 73 | }()}; |
| 74 | 74 | ||
| 75 | if (block_end_predecessor->virt >= virt) { | 75 | if (block_end_predecessor != blocks.begin() && block_end_predecessor->virt >= virt) { |
| 76 | // If this block's start would be overlapped by the map then reuse it as a tail | 76 | // If this block's start would be overlapped by the map then reuse it as a tail |
| 77 | // block | 77 | // block |
| 78 | block_end_predecessor->virt = virt_end; | 78 | block_end_predecessor->virt = virt_end; |
diff --git a/src/common/input.h b/src/common/input.h index 51b277c1f..66fb15f0a 100644 --- a/src/common/input.h +++ b/src/common/input.h | |||
| @@ -111,6 +111,8 @@ struct AnalogProperties { | |||
| 111 | float offset{}; | 111 | float offset{}; |
| 112 | // Invert direction of the sensor data | 112 | // Invert direction of the sensor data |
| 113 | bool inverted{}; | 113 | bool inverted{}; |
| 114 | // Invert the state if it's converted to a button | ||
| 115 | bool inverted_button{}; | ||
| 114 | // Press once to activate, press again to release | 116 | // Press once to activate, press again to release |
| 115 | bool toggle{}; | 117 | bool toggle{}; |
| 116 | }; | 118 | }; |
diff --git a/src/common/vector_math.h b/src/common/vector_math.h index 0e2095c45..b4885835d 100644 --- a/src/common/vector_math.h +++ b/src/common/vector_math.h | |||
| @@ -259,6 +259,20 @@ public: | |||
| 259 | return *this; | 259 | return *this; |
| 260 | } | 260 | } |
| 261 | 261 | ||
| 262 | void RotateFromOrigin(float roll, float pitch, float yaw) { | ||
| 263 | float temp = y; | ||
| 264 | y = std::cos(roll) * y - std::sin(roll) * z; | ||
| 265 | z = std::sin(roll) * temp + std::cos(roll) * z; | ||
| 266 | |||
| 267 | temp = x; | ||
| 268 | x = std::cos(pitch) * x + std::sin(pitch) * z; | ||
| 269 | z = -std::sin(pitch) * temp + std::cos(pitch) * z; | ||
| 270 | |||
| 271 | temp = x; | ||
| 272 | x = std::cos(yaw) * x - std::sin(yaw) * y; | ||
| 273 | y = std::sin(yaw) * temp + std::cos(yaw) * y; | ||
| 274 | } | ||
| 275 | |||
| 262 | [[nodiscard]] constexpr T Length2() const { | 276 | [[nodiscard]] constexpr T Length2() const { |
| 263 | return x * x + y * y + z * z; | 277 | return x * x + y * y + z * z; |
| 264 | } | 278 | } |
diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp index a70f8807c..ecab85893 100644 --- a/src/core/hid/emulated_controller.cpp +++ b/src/core/hid/emulated_controller.cpp | |||
| @@ -376,6 +376,7 @@ void EmulatedController::ReloadInput() { | |||
| 376 | motion.accel = emulated_motion.GetAcceleration(); | 376 | motion.accel = emulated_motion.GetAcceleration(); |
| 377 | motion.gyro = emulated_motion.GetGyroscope(); | 377 | motion.gyro = emulated_motion.GetGyroscope(); |
| 378 | motion.rotation = emulated_motion.GetRotations(); | 378 | motion.rotation = emulated_motion.GetRotations(); |
| 379 | motion.euler = emulated_motion.GetEulerAngles(); | ||
| 379 | motion.orientation = emulated_motion.GetOrientation(); | 380 | motion.orientation = emulated_motion.GetOrientation(); |
| 380 | motion.is_at_rest = !emulated_motion.IsMoving(motion_sensitivity); | 381 | motion.is_at_rest = !emulated_motion.IsMoving(motion_sensitivity); |
| 381 | } | 382 | } |
| @@ -551,6 +552,8 @@ void EmulatedController::EnableSystemButtons() { | |||
| 551 | void EmulatedController::DisableSystemButtons() { | 552 | void EmulatedController::DisableSystemButtons() { |
| 552 | std::scoped_lock lock{mutex}; | 553 | std::scoped_lock lock{mutex}; |
| 553 | system_buttons_enabled = false; | 554 | system_buttons_enabled = false; |
| 555 | controller.home_button_state.raw = 0; | ||
| 556 | controller.capture_button_state.raw = 0; | ||
| 554 | } | 557 | } |
| 555 | 558 | ||
| 556 | void EmulatedController::ResetSystemButtons() { | 559 | void EmulatedController::ResetSystemButtons() { |
| @@ -734,6 +737,8 @@ void EmulatedController::SetButton(const Common::Input::CallbackStatus& callback | |||
| 734 | if (is_configuring) { | 737 | if (is_configuring) { |
| 735 | controller.npad_button_state.raw = NpadButton::None; | 738 | controller.npad_button_state.raw = NpadButton::None; |
| 736 | controller.debug_pad_button_state.raw = 0; | 739 | controller.debug_pad_button_state.raw = 0; |
| 740 | controller.home_button_state.raw = 0; | ||
| 741 | controller.capture_button_state.raw = 0; | ||
| 737 | lock.unlock(); | 742 | lock.unlock(); |
| 738 | TriggerOnChange(ControllerTriggerType::Button, false); | 743 | TriggerOnChange(ControllerTriggerType::Button, false); |
| 739 | return; | 744 | return; |
| @@ -976,14 +981,11 @@ void EmulatedController::SetMotion(const Common::Input::CallbackStatus& callback | |||
| 976 | emulated.UpdateOrientation(raw_status.delta_timestamp); | 981 | emulated.UpdateOrientation(raw_status.delta_timestamp); |
| 977 | force_update_motion = raw_status.force_update; | 982 | force_update_motion = raw_status.force_update; |
| 978 | 983 | ||
| 979 | if (is_configuring) { | ||
| 980 | return; | ||
| 981 | } | ||
| 982 | |||
| 983 | auto& motion = controller.motion_state[index]; | 984 | auto& motion = controller.motion_state[index]; |
| 984 | motion.accel = emulated.GetAcceleration(); | 985 | motion.accel = emulated.GetAcceleration(); |
| 985 | motion.gyro = emulated.GetGyroscope(); | 986 | motion.gyro = emulated.GetGyroscope(); |
| 986 | motion.rotation = emulated.GetRotations(); | 987 | motion.rotation = emulated.GetRotations(); |
| 988 | motion.euler = emulated.GetEulerAngles(); | ||
| 987 | motion.orientation = emulated.GetOrientation(); | 989 | motion.orientation = emulated.GetOrientation(); |
| 988 | motion.is_at_rest = !emulated.IsMoving(motion_sensitivity); | 990 | motion.is_at_rest = !emulated.IsMoving(motion_sensitivity); |
| 989 | } | 991 | } |
diff --git a/src/core/hid/emulated_controller.h b/src/core/hid/emulated_controller.h index 429655355..6e01f4e12 100644 --- a/src/core/hid/emulated_controller.h +++ b/src/core/hid/emulated_controller.h | |||
| @@ -106,6 +106,7 @@ struct ControllerMotion { | |||
| 106 | Common::Vec3f accel{}; | 106 | Common::Vec3f accel{}; |
| 107 | Common::Vec3f gyro{}; | 107 | Common::Vec3f gyro{}; |
| 108 | Common::Vec3f rotation{}; | 108 | Common::Vec3f rotation{}; |
| 109 | Common::Vec3f euler{}; | ||
| 109 | std::array<Common::Vec3f, 3> orientation{}; | 110 | std::array<Common::Vec3f, 3> orientation{}; |
| 110 | bool is_at_rest{}; | 111 | bool is_at_rest{}; |
| 111 | }; | 112 | }; |
diff --git a/src/core/hid/input_converter.cpp b/src/core/hid/input_converter.cpp index 2772bc012..53b00b1f9 100644 --- a/src/core/hid/input_converter.cpp +++ b/src/core/hid/input_converter.cpp | |||
| @@ -54,6 +54,7 @@ Common::Input::ButtonStatus TransformToButton(const Common::Input::CallbackStatu | |||
| 54 | case Common::Input::InputType::Analog: | 54 | case Common::Input::InputType::Analog: |
| 55 | status.value = TransformToTrigger(callback).pressed.value; | 55 | status.value = TransformToTrigger(callback).pressed.value; |
| 56 | status.toggle = callback.analog_status.properties.toggle; | 56 | status.toggle = callback.analog_status.properties.toggle; |
| 57 | status.inverted = callback.analog_status.properties.inverted_button; | ||
| 57 | break; | 58 | break; |
| 58 | case Common::Input::InputType::Trigger: | 59 | case Common::Input::InputType::Trigger: |
| 59 | status.value = TransformToTrigger(callback).pressed.value; | 60 | status.value = TransformToTrigger(callback).pressed.value; |
diff --git a/src/core/hid/motion_input.cpp b/src/core/hid/motion_input.cpp index 0dd66c1cc..b60478dbb 100644 --- a/src/core/hid/motion_input.cpp +++ b/src/core/hid/motion_input.cpp | |||
| @@ -1,6 +1,8 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include <cmath> | ||
| 5 | |||
| 4 | #include "common/math_util.h" | 6 | #include "common/math_util.h" |
| 5 | #include "core/hid/motion_input.h" | 7 | #include "core/hid/motion_input.h" |
| 6 | 8 | ||
| @@ -51,6 +53,20 @@ void MotionInput::SetQuaternion(const Common::Quaternion<f32>& quaternion) { | |||
| 51 | quat = quaternion; | 53 | quat = quaternion; |
| 52 | } | 54 | } |
| 53 | 55 | ||
| 56 | void MotionInput::SetEulerAngles(const Common::Vec3f& euler_angles) { | ||
| 57 | const float cr = std::cos(euler_angles.x * 0.5f); | ||
| 58 | const float sr = std::sin(euler_angles.x * 0.5f); | ||
| 59 | const float cp = std::cos(euler_angles.y * 0.5f); | ||
| 60 | const float sp = std::sin(euler_angles.y * 0.5f); | ||
| 61 | const float cy = std::cos(euler_angles.z * 0.5f); | ||
| 62 | const float sy = std::sin(euler_angles.z * 0.5f); | ||
| 63 | |||
| 64 | quat.w = cr * cp * cy + sr * sp * sy; | ||
| 65 | quat.xyz.x = sr * cp * cy - cr * sp * sy; | ||
| 66 | quat.xyz.y = cr * sp * cy + sr * cp * sy; | ||
| 67 | quat.xyz.z = cr * cp * sy - sr * sp * cy; | ||
| 68 | } | ||
| 69 | |||
| 54 | void MotionInput::SetGyroBias(const Common::Vec3f& bias) { | 70 | void MotionInput::SetGyroBias(const Common::Vec3f& bias) { |
| 55 | gyro_bias = bias; | 71 | gyro_bias = bias; |
| 56 | } | 72 | } |
| @@ -222,6 +238,26 @@ Common::Vec3f MotionInput::GetRotations() const { | |||
| 222 | return rotations; | 238 | return rotations; |
| 223 | } | 239 | } |
| 224 | 240 | ||
| 241 | Common::Vec3f MotionInput::GetEulerAngles() const { | ||
| 242 | // roll (x-axis rotation) | ||
| 243 | const float sinr_cosp = 2 * (quat.w * quat.xyz.x + quat.xyz.y * quat.xyz.z); | ||
| 244 | const float cosr_cosp = 1 - 2 * (quat.xyz.x * quat.xyz.x + quat.xyz.y * quat.xyz.y); | ||
| 245 | |||
| 246 | // pitch (y-axis rotation) | ||
| 247 | const float sinp = std::sqrt(1 + 2 * (quat.w * quat.xyz.y - quat.xyz.x * quat.xyz.z)); | ||
| 248 | const float cosp = std::sqrt(1 - 2 * (quat.w * quat.xyz.y - quat.xyz.x * quat.xyz.z)); | ||
| 249 | |||
| 250 | // yaw (z-axis rotation) | ||
| 251 | const float siny_cosp = 2 * (quat.w * quat.xyz.z + quat.xyz.x * quat.xyz.y); | ||
| 252 | const float cosy_cosp = 1 - 2 * (quat.xyz.y * quat.xyz.y + quat.xyz.z * quat.xyz.z); | ||
| 253 | |||
| 254 | return { | ||
| 255 | std::atan2(sinr_cosp, cosr_cosp), | ||
| 256 | 2 * std::atan2(sinp, cosp) - Common::PI / 2, | ||
| 257 | std::atan2(siny_cosp, cosy_cosp), | ||
| 258 | }; | ||
| 259 | } | ||
| 260 | |||
| 225 | void MotionInput::ResetOrientation() { | 261 | void MotionInput::ResetOrientation() { |
| 226 | if (!reset_enabled || only_accelerometer) { | 262 | if (!reset_enabled || only_accelerometer) { |
| 227 | return; | 263 | return; |
diff --git a/src/core/hid/motion_input.h b/src/core/hid/motion_input.h index 9f3fc1cf7..482719359 100644 --- a/src/core/hid/motion_input.h +++ b/src/core/hid/motion_input.h | |||
| @@ -35,6 +35,7 @@ public: | |||
| 35 | void SetAcceleration(const Common::Vec3f& acceleration); | 35 | void SetAcceleration(const Common::Vec3f& acceleration); |
| 36 | void SetGyroscope(const Common::Vec3f& gyroscope); | 36 | void SetGyroscope(const Common::Vec3f& gyroscope); |
| 37 | void SetQuaternion(const Common::Quaternion<f32>& quaternion); | 37 | void SetQuaternion(const Common::Quaternion<f32>& quaternion); |
| 38 | void SetEulerAngles(const Common::Vec3f& euler_angles); | ||
| 38 | void SetGyroBias(const Common::Vec3f& bias); | 39 | void SetGyroBias(const Common::Vec3f& bias); |
| 39 | void SetGyroThreshold(f32 threshold); | 40 | void SetGyroThreshold(f32 threshold); |
| 40 | 41 | ||
| @@ -54,6 +55,7 @@ public: | |||
| 54 | [[nodiscard]] Common::Vec3f GetGyroBias() const; | 55 | [[nodiscard]] Common::Vec3f GetGyroBias() const; |
| 55 | [[nodiscard]] Common::Vec3f GetRotations() const; | 56 | [[nodiscard]] Common::Vec3f GetRotations() const; |
| 56 | [[nodiscard]] Common::Quaternion<f32> GetQuaternion() const; | 57 | [[nodiscard]] Common::Quaternion<f32> GetQuaternion() const; |
| 58 | [[nodiscard]] Common::Vec3f GetEulerAngles() const; | ||
| 57 | 59 | ||
| 58 | [[nodiscard]] bool IsMoving(f32 sensitivity) const; | 60 | [[nodiscard]] bool IsMoving(f32 sensitivity) const; |
| 59 | [[nodiscard]] bool IsCalibrated(f32 sensitivity) const; | 61 | [[nodiscard]] bool IsCalibrated(f32 sensitivity) const; |
diff --git a/src/input_common/input_engine.cpp b/src/input_common/input_engine.cpp index 91aa96aa7..49f5e7f54 100644 --- a/src/input_common/input_engine.cpp +++ b/src/input_common/input_engine.cpp | |||
| @@ -58,6 +58,8 @@ void InputEngine::SetHatButton(const PadIdentifier& identifier, int button, u8 v | |||
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | void InputEngine::SetAxis(const PadIdentifier& identifier, int axis, f32 value) { | 60 | void InputEngine::SetAxis(const PadIdentifier& identifier, int axis, f32 value) { |
| 61 | value /= 2.0f; | ||
| 62 | value -= 0.5f; | ||
| 61 | { | 63 | { |
| 62 | std::scoped_lock lock{mutex}; | 64 | std::scoped_lock lock{mutex}; |
| 63 | ControllerData& controller = controller_list.at(identifier); | 65 | ControllerData& controller = controller_list.at(identifier); |
diff --git a/src/input_common/input_poller.cpp b/src/input_common/input_poller.cpp index 8c6a6521a..5c2c4a463 100644 --- a/src/input_common/input_poller.cpp +++ b/src/input_common/input_poller.cpp | |||
| @@ -939,6 +939,7 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateAnalogDevice( | |||
| 939 | .threshold = std::clamp(params.Get("threshold", 0.5f), 0.0f, 1.0f), | 939 | .threshold = std::clamp(params.Get("threshold", 0.5f), 0.0f, 1.0f), |
| 940 | .offset = std::clamp(params.Get("offset", 0.0f), -1.0f, 1.0f), | 940 | .offset = std::clamp(params.Get("offset", 0.0f), -1.0f, 1.0f), |
| 941 | .inverted = params.Get("invert", "+") == "-", | 941 | .inverted = params.Get("invert", "+") == "-", |
| 942 | .inverted_button = params.Get("inverted", false) != 0, | ||
| 942 | .toggle = params.Get("toggle", false) != 0, | 943 | .toggle = params.Get("toggle", false) != 0, |
| 943 | }; | 944 | }; |
| 944 | input_engine->PreSetController(identifier); | 945 | input_engine->PreSetController(identifier); |
diff --git a/src/video_core/shader_cache.cpp b/src/video_core/shader_cache.cpp index d9482371b..c5213875b 100644 --- a/src/video_core/shader_cache.cpp +++ b/src/video_core/shader_cache.cpp | |||
| @@ -228,14 +228,14 @@ const ShaderInfo* ShaderCache::MakeShaderInfo(GenericEnvironment& env, VAddr cpu | |||
| 228 | auto info = std::make_unique<ShaderInfo>(); | 228 | auto info = std::make_unique<ShaderInfo>(); |
| 229 | if (const std::optional<u64> cached_hash{env.Analyze()}) { | 229 | if (const std::optional<u64> cached_hash{env.Analyze()}) { |
| 230 | info->unique_hash = *cached_hash; | 230 | info->unique_hash = *cached_hash; |
| 231 | info->size_bytes = env.CachedSize(); | 231 | info->size_bytes = env.CachedSizeBytes(); |
| 232 | } else { | 232 | } else { |
| 233 | // Slow path, not really hit on commercial games | 233 | // Slow path, not really hit on commercial games |
| 234 | // Build a control flow graph to get the real shader size | 234 | // Build a control flow graph to get the real shader size |
| 235 | Shader::ObjectPool<Shader::Maxwell::Flow::Block> flow_block; | 235 | Shader::ObjectPool<Shader::Maxwell::Flow::Block> flow_block; |
| 236 | Shader::Maxwell::Flow::CFG cfg{env, flow_block, env.StartAddress()}; | 236 | Shader::Maxwell::Flow::CFG cfg{env, flow_block, env.StartAddress()}; |
| 237 | info->unique_hash = env.CalculateHash(); | 237 | info->unique_hash = env.CalculateHash(); |
| 238 | info->size_bytes = env.ReadSize(); | 238 | info->size_bytes = env.ReadSizeBytes(); |
| 239 | } | 239 | } |
| 240 | const size_t size_bytes{info->size_bytes}; | 240 | const size_t size_bytes{info->size_bytes}; |
| 241 | const ShaderInfo* const result{info.get()}; | 241 | const ShaderInfo* const result{info.get()}; |
diff --git a/src/video_core/shader_environment.cpp b/src/video_core/shader_environment.cpp index 574760f80..c7cb56243 100644 --- a/src/video_core/shader_environment.cpp +++ b/src/video_core/shader_environment.cpp | |||
| @@ -170,15 +170,19 @@ std::optional<u64> GenericEnvironment::Analyze() { | |||
| 170 | void GenericEnvironment::SetCachedSize(size_t size_bytes) { | 170 | void GenericEnvironment::SetCachedSize(size_t size_bytes) { |
| 171 | cached_lowest = start_address; | 171 | cached_lowest = start_address; |
| 172 | cached_highest = start_address + static_cast<u32>(size_bytes); | 172 | cached_highest = start_address + static_cast<u32>(size_bytes); |
| 173 | code.resize(CachedSize()); | 173 | code.resize(CachedSizeWords()); |
| 174 | gpu_memory->ReadBlock(program_base + cached_lowest, code.data(), code.size() * sizeof(u64)); | 174 | gpu_memory->ReadBlock(program_base + cached_lowest, code.data(), code.size() * sizeof(u64)); |
| 175 | } | 175 | } |
| 176 | 176 | ||
| 177 | size_t GenericEnvironment::CachedSize() const noexcept { | 177 | size_t GenericEnvironment::CachedSizeWords() const noexcept { |
| 178 | return cached_highest - cached_lowest + INST_SIZE; | 178 | return CachedSizeBytes() / INST_SIZE; |
| 179 | } | 179 | } |
| 180 | 180 | ||
| 181 | size_t GenericEnvironment::ReadSize() const noexcept { | 181 | size_t GenericEnvironment::CachedSizeBytes() const noexcept { |
| 182 | return static_cast<size_t>(cached_highest) - cached_lowest + INST_SIZE; | ||
| 183 | } | ||
| 184 | |||
| 185 | size_t GenericEnvironment::ReadSizeBytes() const noexcept { | ||
| 182 | return read_highest - read_lowest + INST_SIZE; | 186 | return read_highest - read_lowest + INST_SIZE; |
| 183 | } | 187 | } |
| 184 | 188 | ||
| @@ -187,7 +191,7 @@ bool GenericEnvironment::CanBeSerialized() const noexcept { | |||
| 187 | } | 191 | } |
| 188 | 192 | ||
| 189 | u64 GenericEnvironment::CalculateHash() const { | 193 | u64 GenericEnvironment::CalculateHash() const { |
| 190 | const size_t size{ReadSize()}; | 194 | const size_t size{ReadSizeBytes()}; |
| 191 | const auto data{std::make_unique<char[]>(size)}; | 195 | const auto data{std::make_unique<char[]>(size)}; |
| 192 | gpu_memory->ReadBlock(program_base + read_lowest, data.get(), size); | 196 | gpu_memory->ReadBlock(program_base + read_lowest, data.get(), size); |
| 193 | return Common::CityHash64(data.get(), size); | 197 | return Common::CityHash64(data.get(), size); |
| @@ -198,7 +202,7 @@ void GenericEnvironment::Dump(u64 hash) { | |||
| 198 | } | 202 | } |
| 199 | 203 | ||
| 200 | void GenericEnvironment::Serialize(std::ofstream& file) const { | 204 | void GenericEnvironment::Serialize(std::ofstream& file) const { |
| 201 | const u64 code_size{static_cast<u64>(CachedSize())}; | 205 | const u64 code_size{static_cast<u64>(CachedSizeBytes())}; |
| 202 | const u64 num_texture_types{static_cast<u64>(texture_types.size())}; | 206 | const u64 num_texture_types{static_cast<u64>(texture_types.size())}; |
| 203 | const u64 num_texture_pixel_formats{static_cast<u64>(texture_pixel_formats.size())}; | 207 | const u64 num_texture_pixel_formats{static_cast<u64>(texture_pixel_formats.size())}; |
| 204 | const u64 num_cbuf_values{static_cast<u64>(cbuf_values.size())}; | 208 | const u64 num_cbuf_values{static_cast<u64>(cbuf_values.size())}; |
diff --git a/src/video_core/shader_environment.h b/src/video_core/shader_environment.h index d75987a52..a0f61cbda 100644 --- a/src/video_core/shader_environment.h +++ b/src/video_core/shader_environment.h | |||
| @@ -48,9 +48,11 @@ public: | |||
| 48 | 48 | ||
| 49 | void SetCachedSize(size_t size_bytes); | 49 | void SetCachedSize(size_t size_bytes); |
| 50 | 50 | ||
| 51 | [[nodiscard]] size_t CachedSize() const noexcept; | 51 | [[nodiscard]] size_t CachedSizeWords() const noexcept; |
| 52 | 52 | ||
| 53 | [[nodiscard]] size_t ReadSize() const noexcept; | 53 | [[nodiscard]] size_t CachedSizeBytes() const noexcept; |
| 54 | |||
| 55 | [[nodiscard]] size_t ReadSizeBytes() const noexcept; | ||
| 54 | 56 | ||
| 55 | [[nodiscard]] bool CanBeSerialized() const noexcept; | 57 | [[nodiscard]] bool CanBeSerialized() const noexcept; |
| 56 | 58 | ||
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp index 50b62293e..54f42e0c9 100644 --- a/src/yuzu/configuration/configure_input_player.cpp +++ b/src/yuzu/configuration/configure_input_player.cpp | |||
| @@ -206,7 +206,7 @@ QString ConfigureInputPlayer::ButtonToText(const Common::ParamPackage& param) { | |||
| 206 | } | 206 | } |
| 207 | if (param.Has("axis")) { | 207 | if (param.Has("axis")) { |
| 208 | const QString axis = QString::fromStdString(param.Get("axis", "")); | 208 | const QString axis = QString::fromStdString(param.Get("axis", "")); |
| 209 | return QObject::tr("%1%2Axis %3").arg(toggle, invert, axis); | 209 | return QObject::tr("%1%2%3Axis %4").arg(toggle, inverted, invert, axis); |
| 210 | } | 210 | } |
| 211 | if (param.Has("axis_x") && param.Has("axis_y") && param.Has("axis_z")) { | 211 | if (param.Has("axis_x") && param.Has("axis_y") && param.Has("axis_z")) { |
| 212 | const QString axis_x = QString::fromStdString(param.Get("axis_x", "")); | 212 | const QString axis_x = QString::fromStdString(param.Get("axis_x", "")); |
| @@ -229,7 +229,7 @@ QString ConfigureInputPlayer::ButtonToText(const Common::ParamPackage& param) { | |||
| 229 | return QObject::tr("%1%2%3Hat %4").arg(turbo, toggle, inverted, button_name); | 229 | return QObject::tr("%1%2%3Hat %4").arg(turbo, toggle, inverted, button_name); |
| 230 | } | 230 | } |
| 231 | if (param.Has("axis")) { | 231 | if (param.Has("axis")) { |
| 232 | return QObject::tr("%1%2Axis %3").arg(toggle, inverted, button_name); | 232 | return QObject::tr("%1%2%3Axis %4").arg(toggle, inverted, invert, button_name); |
| 233 | } | 233 | } |
| 234 | if (param.Has("motion")) { | 234 | if (param.Has("motion")) { |
| 235 | return QObject::tr("%1%2Axis %3").arg(toggle, inverted, button_name); | 235 | return QObject::tr("%1%2Axis %3").arg(toggle, inverted, button_name); |
| @@ -410,6 +410,12 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i | |||
| 410 | button_map[button_id]->setText(ButtonToText(param)); | 410 | button_map[button_id]->setText(ButtonToText(param)); |
| 411 | emulated_controller->SetButtonParam(button_id, param); | 411 | emulated_controller->SetButtonParam(button_id, param); |
| 412 | }); | 412 | }); |
| 413 | context_menu.addAction(tr("Invert button"), [&] { | ||
| 414 | const bool invert_value = !param.Get("inverted", false); | ||
| 415 | param.Set("inverted", invert_value); | ||
| 416 | button_map[button_id]->setText(ButtonToText(param)); | ||
| 417 | emulated_controller->SetButtonParam(button_id, param); | ||
| 418 | }); | ||
| 413 | context_menu.addAction(tr("Set threshold"), [&] { | 419 | context_menu.addAction(tr("Set threshold"), [&] { |
| 414 | const int button_threshold = | 420 | const int button_threshold = |
| 415 | static_cast<int>(param.Get("threshold", 0.5f) * 100.0f); | 421 | static_cast<int>(param.Get("threshold", 0.5f) * 100.0f); |
diff --git a/src/yuzu/configuration/configure_input_player_widget.cpp b/src/yuzu/configuration/configure_input_player_widget.cpp index c287220fc..fe1ee2289 100644 --- a/src/yuzu/configuration/configure_input_player_widget.cpp +++ b/src/yuzu/configuration/configure_input_player_widget.cpp | |||
| @@ -180,6 +180,10 @@ void PlayerControlPreview::ControllerUpdate(Core::HID::ControllerTriggerType typ | |||
| 180 | battery_values = controller->GetBatteryValues(); | 180 | battery_values = controller->GetBatteryValues(); |
| 181 | needs_redraw = true; | 181 | needs_redraw = true; |
| 182 | break; | 182 | break; |
| 183 | case Core::HID::ControllerTriggerType::Motion: | ||
| 184 | motion_values = controller->GetMotions(); | ||
| 185 | needs_redraw = true; | ||
| 186 | break; | ||
| 183 | default: | 187 | default: |
| 184 | break; | 188 | break; |
| 185 | } | 189 | } |
| @@ -313,6 +317,15 @@ void PlayerControlPreview::DrawLeftController(QPainter& p, const QPointF center) | |||
| 313 | DrawRawJoystick(p, center + QPointF(-140, 90), QPointF(0, 0)); | 317 | DrawRawJoystick(p, center + QPointF(-140, 90), QPointF(0, 0)); |
| 314 | } | 318 | } |
| 315 | 319 | ||
| 320 | { | ||
| 321 | // Draw motion cubes | ||
| 322 | using namespace Settings::NativeMotion; | ||
| 323 | p.setPen(colors.outline); | ||
| 324 | p.setBrush(colors.transparent); | ||
| 325 | Draw3dCube(p, center + QPointF(-140, 90), | ||
| 326 | motion_values[Settings::NativeMotion::MotionLeft].euler, 20.0f); | ||
| 327 | } | ||
| 328 | |||
| 316 | using namespace Settings::NativeButton; | 329 | using namespace Settings::NativeButton; |
| 317 | 330 | ||
| 318 | // D-pad constants | 331 | // D-pad constants |
| @@ -435,6 +448,15 @@ void PlayerControlPreview::DrawRightController(QPainter& p, const QPointF center | |||
| 435 | DrawRawJoystick(p, QPointF(0, 0), center + QPointF(140, 90)); | 448 | DrawRawJoystick(p, QPointF(0, 0), center + QPointF(140, 90)); |
| 436 | } | 449 | } |
| 437 | 450 | ||
| 451 | { | ||
| 452 | // Draw motion cubes | ||
| 453 | using namespace Settings::NativeMotion; | ||
| 454 | p.setPen(colors.outline); | ||
| 455 | p.setBrush(colors.transparent); | ||
| 456 | Draw3dCube(p, center + QPointF(140, 90), | ||
| 457 | motion_values[Settings::NativeMotion::MotionRight].euler, 20.0f); | ||
| 458 | } | ||
| 459 | |||
| 438 | using namespace Settings::NativeButton; | 460 | using namespace Settings::NativeButton; |
| 439 | 461 | ||
| 440 | // Face buttons constants | 462 | // Face buttons constants |
| @@ -555,6 +577,17 @@ void PlayerControlPreview::DrawDualController(QPainter& p, const QPointF center) | |||
| 555 | DrawRawJoystick(p, center + QPointF(-180, 90), center + QPointF(180, 90)); | 577 | DrawRawJoystick(p, center + QPointF(-180, 90), center + QPointF(180, 90)); |
| 556 | } | 578 | } |
| 557 | 579 | ||
| 580 | { | ||
| 581 | // Draw motion cubes | ||
| 582 | using namespace Settings::NativeMotion; | ||
| 583 | p.setPen(colors.outline); | ||
| 584 | p.setBrush(colors.transparent); | ||
| 585 | Draw3dCube(p, center + QPointF(-180, -5), | ||
| 586 | motion_values[Settings::NativeMotion::MotionLeft].euler, 20.0f); | ||
| 587 | Draw3dCube(p, center + QPointF(180, -5), | ||
| 588 | motion_values[Settings::NativeMotion::MotionRight].euler, 20.0f); | ||
| 589 | } | ||
| 590 | |||
| 558 | using namespace Settings::NativeButton; | 591 | using namespace Settings::NativeButton; |
| 559 | 592 | ||
| 560 | // Face buttons constants | 593 | // Face buttons constants |
| @@ -647,6 +680,15 @@ void PlayerControlPreview::DrawHandheldController(QPainter& p, const QPointF cen | |||
| 647 | DrawRawJoystick(p, center + QPointF(-50, 0), center + QPointF(50, 0)); | 680 | DrawRawJoystick(p, center + QPointF(-50, 0), center + QPointF(50, 0)); |
| 648 | } | 681 | } |
| 649 | 682 | ||
| 683 | { | ||
| 684 | // Draw motion cubes | ||
| 685 | using namespace Settings::NativeMotion; | ||
| 686 | p.setPen(colors.outline); | ||
| 687 | p.setBrush(colors.transparent); | ||
| 688 | Draw3dCube(p, center + QPointF(0, -115), | ||
| 689 | motion_values[Settings::NativeMotion::MotionLeft].euler, 15.0f); | ||
| 690 | } | ||
| 691 | |||
| 650 | using namespace Settings::NativeButton; | 692 | using namespace Settings::NativeButton; |
| 651 | 693 | ||
| 652 | // Face buttons constants | 694 | // Face buttons constants |
| @@ -750,6 +792,15 @@ void PlayerControlPreview::DrawProController(QPainter& p, const QPointF center) | |||
| 750 | DrawRawJoystick(p, center + QPointF(-50, 105), center + QPointF(50, 105)); | 792 | DrawRawJoystick(p, center + QPointF(-50, 105), center + QPointF(50, 105)); |
| 751 | } | 793 | } |
| 752 | 794 | ||
| 795 | { | ||
| 796 | // Draw motion cubes | ||
| 797 | using namespace Settings::NativeMotion; | ||
| 798 | p.setPen(colors.button); | ||
| 799 | p.setBrush(colors.transparent); | ||
| 800 | Draw3dCube(p, center + QPointF(0, -100), | ||
| 801 | motion_values[Settings::NativeMotion::MotionLeft].euler, 15.0f); | ||
| 802 | } | ||
| 803 | |||
| 753 | using namespace Settings::NativeButton; | 804 | using namespace Settings::NativeButton; |
| 754 | 805 | ||
| 755 | // Face buttons constants | 806 | // Face buttons constants |
| @@ -2871,6 +2922,46 @@ void PlayerControlPreview::DrawArrow(QPainter& p, const QPointF center, const Di | |||
| 2871 | DrawPolygon(p, arrow_symbol); | 2922 | DrawPolygon(p, arrow_symbol); |
| 2872 | } | 2923 | } |
| 2873 | 2924 | ||
| 2925 | // Draw motion functions | ||
| 2926 | void PlayerControlPreview::Draw3dCube(QPainter& p, QPointF center, const Common::Vec3f& euler, | ||
| 2927 | float size) { | ||
| 2928 | std::array<Common::Vec3f, 8> cube{ | ||
| 2929 | Common::Vec3f{-1, -1, -1}, | ||
| 2930 | {-1, 1, -1}, | ||
| 2931 | {1, 1, -1}, | ||
| 2932 | {1, -1, -1}, | ||
| 2933 | {-1, -1, 1}, | ||
| 2934 | {-1, 1, 1}, | ||
| 2935 | {1, 1, 1}, | ||
| 2936 | {1, -1, 1}, | ||
| 2937 | }; | ||
| 2938 | |||
| 2939 | for (Common::Vec3f& point : cube) { | ||
| 2940 | point.RotateFromOrigin(euler.x, euler.y, euler.z); | ||
| 2941 | point *= size; | ||
| 2942 | } | ||
| 2943 | |||
| 2944 | const std::array<QPointF, 4> front_face{ | ||
| 2945 | center + QPointF{cube[0].x, cube[0].y}, | ||
| 2946 | center + QPointF{cube[1].x, cube[1].y}, | ||
| 2947 | center + QPointF{cube[2].x, cube[2].y}, | ||
| 2948 | center + QPointF{cube[3].x, cube[3].y}, | ||
| 2949 | }; | ||
| 2950 | const std::array<QPointF, 4> back_face{ | ||
| 2951 | center + QPointF{cube[4].x, cube[4].y}, | ||
| 2952 | center + QPointF{cube[5].x, cube[5].y}, | ||
| 2953 | center + QPointF{cube[6].x, cube[6].y}, | ||
| 2954 | center + QPointF{cube[7].x, cube[7].y}, | ||
| 2955 | }; | ||
| 2956 | |||
| 2957 | DrawPolygon(p, front_face); | ||
| 2958 | DrawPolygon(p, back_face); | ||
| 2959 | p.drawLine(center + QPointF{cube[0].x, cube[0].y}, center + QPointF{cube[4].x, cube[4].y}); | ||
| 2960 | p.drawLine(center + QPointF{cube[1].x, cube[1].y}, center + QPointF{cube[5].x, cube[5].y}); | ||
| 2961 | p.drawLine(center + QPointF{cube[2].x, cube[2].y}, center + QPointF{cube[6].x, cube[6].y}); | ||
| 2962 | p.drawLine(center + QPointF{cube[3].x, cube[3].y}, center + QPointF{cube[7].x, cube[7].y}); | ||
| 2963 | } | ||
| 2964 | |||
| 2874 | template <size_t N> | 2965 | template <size_t N> |
| 2875 | void PlayerControlPreview::DrawPolygon(QPainter& p, const std::array<QPointF, N>& polygon) { | 2966 | void PlayerControlPreview::DrawPolygon(QPainter& p, const std::array<QPointF, N>& polygon) { |
| 2876 | p.drawPolygon(polygon.data(), static_cast<int>(polygon.size())); | 2967 | p.drawPolygon(polygon.data(), static_cast<int>(polygon.size())); |
diff --git a/src/yuzu/configuration/configure_input_player_widget.h b/src/yuzu/configuration/configure_input_player_widget.h index 267d134de..a16943c3c 100644 --- a/src/yuzu/configuration/configure_input_player_widget.h +++ b/src/yuzu/configuration/configure_input_player_widget.h | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | 9 | ||
| 10 | #include "common/input.h" | 10 | #include "common/input.h" |
| 11 | #include "common/settings_input.h" | 11 | #include "common/settings_input.h" |
| 12 | #include "common/vector_math.h" | ||
| 12 | #include "core/hid/emulated_controller.h" | 13 | #include "core/hid/emulated_controller.h" |
| 13 | #include "core/hid/hid_types.h" | 14 | #include "core/hid/hid_types.h" |
| 14 | 15 | ||
| @@ -193,6 +194,9 @@ private: | |||
| 193 | void DrawSymbol(QPainter& p, QPointF center, Symbol symbol, float icon_size); | 194 | void DrawSymbol(QPainter& p, QPointF center, Symbol symbol, float icon_size); |
| 194 | void DrawArrow(QPainter& p, QPointF center, Direction direction, float size); | 195 | void DrawArrow(QPainter& p, QPointF center, Direction direction, float size); |
| 195 | 196 | ||
| 197 | // Draw motion functions | ||
| 198 | void Draw3dCube(QPainter& p, QPointF center, const Common::Vec3f& euler, float size); | ||
| 199 | |||
| 196 | // Draw primitive types | 200 | // Draw primitive types |
| 197 | template <size_t N> | 201 | template <size_t N> |
| 198 | void DrawPolygon(QPainter& p, const std::array<QPointF, N>& polygon); | 202 | void DrawPolygon(QPainter& p, const std::array<QPointF, N>& polygon); |
| @@ -222,4 +226,5 @@ private: | |||
| 222 | Core::HID::SticksValues stick_values{}; | 226 | Core::HID::SticksValues stick_values{}; |
| 223 | Core::HID::TriggerValues trigger_values{}; | 227 | Core::HID::TriggerValues trigger_values{}; |
| 224 | Core::HID::BatteryValues battery_values{}; | 228 | Core::HID::BatteryValues battery_values{}; |
| 229 | Core::HID::MotionState motion_values{}; | ||
| 225 | }; | 230 | }; |
diff --git a/src/yuzu_cmd/config.cpp b/src/yuzu_cmd/config.cpp index 605280949..352e6a4c7 100644 --- a/src/yuzu_cmd/config.cpp +++ b/src/yuzu_cmd/config.cpp | |||
| @@ -4,18 +4,8 @@ | |||
| 4 | #include <memory> | 4 | #include <memory> |
| 5 | #include <optional> | 5 | #include <optional> |
| 6 | #include <sstream> | 6 | #include <sstream> |
| 7 | |||
| 8 | // Ignore -Wimplicit-fallthrough due to https://github.com/libsdl-org/SDL/issues/4307 | ||
| 9 | #ifdef __clang__ | ||
| 10 | #pragma clang diagnostic push | ||
| 11 | #pragma clang diagnostic ignored "-Wimplicit-fallthrough" | ||
| 12 | #endif | ||
| 13 | #include <SDL.h> | ||
| 14 | #ifdef __clang__ | ||
| 15 | #pragma clang diagnostic pop | ||
| 16 | #endif | ||
| 17 | |||
| 18 | #include <INIReader.h> | 7 | #include <INIReader.h> |
| 8 | #include <SDL.h> | ||
| 19 | #include "common/fs/file.h" | 9 | #include "common/fs/file.h" |
| 20 | #include "common/fs/fs.h" | 10 | #include "common/fs/fs.h" |
| 21 | #include "common/fs/path_util.h" | 11 | #include "common/fs/path_util.h" |