From fcd34e75d7c2d74ea7ded36a67a6486539f90499 Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Wed, 8 Mar 2023 04:41:37 +0100 Subject: [PATCH] early-access version 3440 --- README.md | 2 +- .../renderer/adsp/audio_renderer.cpp | 2 +- src/common/input.h | 2 +- src/common/steady_clock.cpp | 25 +++++++ src/common/steady_clock.h | 11 +++ src/common/x64/native_clock.cpp | 38 ++++++++-- src/common/x64/native_clock.h | 5 ++ src/core/core_timing.cpp | 2 +- src/core/cpu_manager.cpp | 2 +- src/core/hle/kernel/k_thread.cpp | 24 ++++++- src/core/hle/kernel/k_thread.h | 2 + src/core/hle/kernel/svc/svc_thread.cpp | 3 + .../hle/service/hid/controllers/stubbed.cpp | 2 +- .../service/hid/controllers/touchscreen.cpp | 8 +-- src/input_common/drivers/joycon.cpp | 4 +- src/input_common/drivers/mouse.cpp | 2 +- src/input_common/drivers/virtual_amiibo.h | 2 +- src/input_common/helpers/joycon_driver.cpp | 2 +- src/input_common/helpers/joycon_driver.h | 2 +- .../helpers/joycon_protocol/joycon_types.h | 4 +- .../helpers/joycon_protocol/poller.cpp | 72 +++++++++---------- .../helpers/joycon_protocol/poller.h | 8 +-- src/video_core/gpu_thread.cpp | 2 +- 23 files changed, 159 insertions(+), 67 deletions(-) diff --git a/README.md b/README.md index c44247b2e..893dc9b48 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 3439. +This is the source code for early-access 3440. ## Legal Notice diff --git a/src/audio_core/renderer/adsp/audio_renderer.cpp b/src/audio_core/renderer/adsp/audio_renderer.cpp index 733bf34ac..7bf4c30d6 100755 --- a/src/audio_core/renderer/adsp/audio_renderer.cpp +++ b/src/audio_core/renderer/adsp/audio_renderer.cpp @@ -135,7 +135,7 @@ void AudioRenderer::ThreadFunc() { static constexpr char name[]{"AudioRenderer"}; MicroProfileOnThreadCreate(name); Common::SetCurrentThreadName(name); - Common::SetCurrentThreadPriority(Common::ThreadPriority::Critical); + Common::SetCurrentThreadPriority(Common::ThreadPriority::High); if (mailbox->ADSPWaitMessage() != RenderMessage::AudioRenderer_InitializeOK) { LOG_ERROR(Service_Audio, "ADSP Audio Renderer -- Failed to receive initialize message from host!"); diff --git a/src/common/input.h b/src/common/input.h index 5cfacc307..865d6a4a2 100755 --- a/src/common/input.h +++ b/src/common/input.h @@ -46,7 +46,7 @@ enum class PollingMode { // Constant polling of buttons, analogs and motion data Active, // Only update on button change, digital analogs - Pasive, + Passive, // Enable near field communication polling NFC, // Enable infrared camera polling diff --git a/src/common/steady_clock.cpp b/src/common/steady_clock.cpp index 0d5908aa7..782859196 100755 --- a/src/common/steady_clock.cpp +++ b/src/common/steady_clock.cpp @@ -23,6 +23,19 @@ static s64 WindowsQueryPerformanceCounter() { QueryPerformanceCounter(&counter); return counter.QuadPart; } + +static s64 GetSystemTimeNS() { + // GetSystemTimePreciseAsFileTime returns the file time in 100ns units. + static constexpr s64 Multiplier = 100; + // Convert Windows epoch to Unix epoch. + static constexpr s64 WindowsEpochToUnixEpochNS = 0x19DB1DED53E8000LL; + + FILETIME filetime; + GetSystemTimePreciseAsFileTime(&filetime); + return Multiplier * ((static_cast(filetime.dwHighDateTime) << 32) + + static_cast(filetime.dwLowDateTime)) - + WindowsEpochToUnixEpochNS; +} #endif SteadyClock::time_point SteadyClock::Now() noexcept { @@ -53,4 +66,16 @@ SteadyClock::time_point SteadyClock::Now() noexcept { #endif } +RealTimeClock::time_point RealTimeClock::Now() noexcept { +#if defined(_WIN32) + return time_point{duration{GetSystemTimeNS()}}; +#elif defined(__APPLE__) + return time_point{duration{clock_gettime_nsec_np(CLOCK_REALTIME)}}; +#else + timespec ts; + clock_gettime(CLOCK_REALTIME, &ts); + return time_point{std::chrono::seconds{ts.tv_sec} + std::chrono::nanoseconds{ts.tv_nsec}}; +#endif +} + }; // namespace Common diff --git a/src/common/steady_clock.h b/src/common/steady_clock.h index 9497cf865..dbd0e2513 100755 --- a/src/common/steady_clock.h +++ b/src/common/steady_clock.h @@ -20,4 +20,15 @@ struct SteadyClock { [[nodiscard]] static time_point Now() noexcept; }; +struct RealTimeClock { + using rep = s64; + using period = std::nano; + using duration = std::chrono::nanoseconds; + using time_point = std::chrono::time_point; + + static constexpr bool is_steady = false; + + [[nodiscard]] static time_point Now() noexcept; +}; + } // namespace Common diff --git a/src/common/x64/native_clock.cpp b/src/common/x64/native_clock.cpp index 82ef09c98..cf3fd0a3d 100755 --- a/src/common/x64/native_clock.cpp +++ b/src/common/x64/native_clock.cpp @@ -53,11 +53,11 @@ u64 EstimateRDTSCFrequency() { FencedRDTSC(); // Get the current time. - const auto start_time = Common::SteadyClock::Now(); + const auto start_time = Common::RealTimeClock::Now(); const u64 tsc_start = FencedRDTSC(); // Wait for 250 milliseconds. std::this_thread::sleep_for(std::chrono::milliseconds{250}); - const auto end_time = Common::SteadyClock::Now(); + const auto end_time = Common::RealTimeClock::Now(); const u64 tsc_end = FencedRDTSC(); // Calculate differences. const u64 timer_diff = static_cast( @@ -72,13 +72,29 @@ NativeClock::NativeClock(u64 emulated_cpu_frequency_, u64 emulated_clock_frequen u64 rtsc_frequency_) : WallClock(emulated_cpu_frequency_, emulated_clock_frequency_, true), rtsc_frequency{ rtsc_frequency_} { + // Thread to re-adjust the RDTSC frequency after 10 seconds has elapsed. + time_sync_thread = std::jthread{[this](std::stop_token token) { + // Get the current time. + const auto start_time = Common::RealTimeClock::Now(); + const u64 tsc_start = FencedRDTSC(); + // Wait for 10 seconds. + if (!Common::StoppableTimedWait(token, std::chrono::seconds{10})) { + return; + } + const auto end_time = Common::RealTimeClock::Now(); + const u64 tsc_end = FencedRDTSC(); + // Calculate differences. + const u64 timer_diff = static_cast( + std::chrono::duration_cast(end_time - start_time).count()); + const u64 tsc_diff = tsc_end - tsc_start; + const u64 tsc_freq = MultiplyAndDivide64(tsc_diff, 1000000000ULL, timer_diff); + rtsc_frequency = tsc_freq; + CalculateAndSetFactors(); + }}; + time_point.inner.last_measure = FencedRDTSC(); time_point.inner.accumulated_ticks = 0U; - ns_rtsc_factor = GetFixedPoint64Factor(NS_RATIO, rtsc_frequency); - us_rtsc_factor = GetFixedPoint64Factor(US_RATIO, rtsc_frequency); - ms_rtsc_factor = GetFixedPoint64Factor(MS_RATIO, rtsc_frequency); - clock_rtsc_factor = GetFixedPoint64Factor(emulated_clock_frequency, rtsc_frequency); - cpu_rtsc_factor = GetFixedPoint64Factor(emulated_cpu_frequency, rtsc_frequency); + CalculateAndSetFactors(); } u64 NativeClock::GetRTSC() { @@ -138,6 +154,14 @@ u64 NativeClock::GetCPUCycles() { return MultiplyHigh(rtsc_value, cpu_rtsc_factor); } +void NativeClock::CalculateAndSetFactors() { + ns_rtsc_factor = GetFixedPoint64Factor(NS_RATIO, rtsc_frequency); + us_rtsc_factor = GetFixedPoint64Factor(US_RATIO, rtsc_frequency); + ms_rtsc_factor = GetFixedPoint64Factor(MS_RATIO, rtsc_frequency); + clock_rtsc_factor = GetFixedPoint64Factor(emulated_clock_frequency, rtsc_frequency); + cpu_rtsc_factor = GetFixedPoint64Factor(emulated_cpu_frequency, rtsc_frequency); +} + } // namespace X64 } // namespace Common diff --git a/src/common/x64/native_clock.h b/src/common/x64/native_clock.h index cb8d2bbe3..5504eb3c1 100755 --- a/src/common/x64/native_clock.h +++ b/src/common/x64/native_clock.h @@ -3,6 +3,7 @@ #pragma once +#include "common/polyfill_thread.h" #include "common/wall_clock.h" namespace Common { @@ -28,6 +29,8 @@ public: private: u64 GetRTSC(); + void CalculateAndSetFactors(); + union alignas(16) TimePoint { TimePoint() : pack{} {} u128 pack{}; @@ -47,6 +50,8 @@ private: u64 ms_rtsc_factor{}; u64 rtsc_frequency; + + std::jthread time_sync_thread; }; } // namespace X64 diff --git a/src/core/core_timing.cpp b/src/core/core_timing.cpp index 5b88916ef..79bd7c0d1 100755 --- a/src/core/core_timing.cpp +++ b/src/core/core_timing.cpp @@ -53,7 +53,7 @@ void CoreTiming::ThreadEntry(CoreTiming& instance) { static constexpr char name[] = "HostTiming"; MicroProfileOnThreadCreate(name); Common::SetCurrentThreadName(name); - Common::SetCurrentThreadPriority(Common::ThreadPriority::Critical); + Common::SetCurrentThreadPriority(Common::ThreadPriority::High); instance.on_thread_init(); instance.ThreadLoop(); MicroProfileOnThreadExit(); diff --git a/src/core/cpu_manager.cpp b/src/core/cpu_manager.cpp index 88784c16a..60f2566bf 100755 --- a/src/core/cpu_manager.cpp +++ b/src/core/cpu_manager.cpp @@ -192,7 +192,7 @@ void CpuManager::RunThread(std::stop_token token, std::size_t core) { } MicroProfileOnThreadCreate(name.c_str()); Common::SetCurrentThreadName(name.c_str()); - Common::SetCurrentThreadPriority(Common::ThreadPriority::High); + Common::SetCurrentThreadPriority(Common::ThreadPriority::Critical); auto& data = core_data[core]; data.host_context = Common::Fiber::ThreadToFiber(); diff --git a/src/core/hle/kernel/k_thread.cpp b/src/core/hle/kernel/k_thread.cpp index 497fe69d9..4de318eec 100755 --- a/src/core/hle/kernel/k_thread.cpp +++ b/src/core/hle/kernel/k_thread.cpp @@ -49,6 +49,7 @@ static void ResetThreadContext32(Core::ARM_Interface::ThreadContext32& context, context.cpu_registers[0] = arg; context.cpu_registers[15] = entry_point; context.cpu_registers[13] = stack_top; + context.fpscr = 0; } static void ResetThreadContext64(Core::ARM_Interface::ThreadContext64& context, VAddr stack_top, @@ -58,8 +59,8 @@ static void ResetThreadContext64(Core::ARM_Interface::ThreadContext64& context, context.cpu_registers[18] = Kernel::KSystemControl::GenerateRandomU64() | 1; context.pc = entry_point; context.sp = stack_top; - // TODO(merry): Perform a hardware test to determine the below value. context.fpcr = 0; + context.fpsr = 0; } } // namespace @@ -815,6 +816,27 @@ void KThread::Continue() { KScheduler::OnThreadStateChanged(kernel, this, old_state); } +void KThread::CloneFpuStatus() { + // We shouldn't reach here when starting kernel threads. + ASSERT(this->GetOwnerProcess() != nullptr); + ASSERT(this->GetOwnerProcess() == GetCurrentProcessPointer(kernel)); + + if (this->GetOwnerProcess()->Is64BitProcess()) { + // Clone FPSR and FPCR. + ThreadContext64 cur_ctx{}; + kernel.System().CurrentArmInterface().SaveContext(cur_ctx); + + this->GetContext64().fpcr = cur_ctx.fpcr; + this->GetContext64().fpsr = cur_ctx.fpsr; + } else { + // Clone FPSCR. + ThreadContext32 cur_ctx{}; + kernel.System().CurrentArmInterface().SaveContext(cur_ctx); + + this->GetContext32().fpscr = cur_ctx.fpscr; + } +} + Result KThread::SetActivity(Svc::ThreadActivity activity) { // Lock ourselves. KScopedLightLock lk(activity_pause_lock); diff --git a/src/core/hle/kernel/k_thread.h b/src/core/hle/kernel/k_thread.h index 644583fd8..11ad623c1 100755 --- a/src/core/hle/kernel/k_thread.h +++ b/src/core/hle/kernel/k_thread.h @@ -254,6 +254,8 @@ public: thread_context_32.tpidr = static_cast(value); } + void CloneFpuStatus(); + [[nodiscard]] ThreadContext32& GetContext32() { return thread_context_32; } diff --git a/src/core/hle/kernel/svc/svc_thread.cpp b/src/core/hle/kernel/svc/svc_thread.cpp index b39807841..9bc1ebe74 100755 --- a/src/core/hle/kernel/svc/svc_thread.cpp +++ b/src/core/hle/kernel/svc/svc_thread.cpp @@ -82,6 +82,9 @@ Result CreateThread(Core::System& system, Handle* out_handle, VAddr entry_point, // Commit the thread reservation. thread_reservation.Commit(); + // Clone the current fpu status to the new thread. + thread->CloneFpuStatus(); + // Register the new thread. KThread::Register(kernel, thread); diff --git a/src/core/hle/service/hid/controllers/stubbed.cpp b/src/core/hle/service/hid/controllers/stubbed.cpp index c30cb7d11..3203229a8 100755 --- a/src/core/hle/service/hid/controllers/stubbed.cpp +++ b/src/core/hle/service/hid/controllers/stubbed.cpp @@ -26,7 +26,7 @@ void Controller_Stubbed::OnUpdate(const Core::Timing::CoreTiming& core_timing) { } CommonHeader header{}; - header.timestamp = core_timing.GetCPUTicks(); + header.timestamp = core_timing.GetGlobalTimeNs().count(); header.total_entry_count = 17; header.entry_count = 0; header.last_entry_index = 0; diff --git a/src/core/hle/service/hid/controllers/touchscreen.cpp b/src/core/hle/service/hid/controllers/touchscreen.cpp index 6868345f0..4d564fe40 100755 --- a/src/core/hle/service/hid/controllers/touchscreen.cpp +++ b/src/core/hle/service/hid/controllers/touchscreen.cpp @@ -32,7 +32,7 @@ void Controller_Touchscreen::OnInit() {} void Controller_Touchscreen::OnRelease() {} void Controller_Touchscreen::OnUpdate(const Core::Timing::CoreTiming& core_timing) { - shared_memory->touch_screen_lifo.timestamp = core_timing.GetCPUTicks(); + shared_memory->touch_screen_lifo.timestamp = core_timing.GetGlobalTimeNs().count(); if (!IsControllerActivated()) { shared_memory->touch_screen_lifo.buffer_count = 0; @@ -85,7 +85,7 @@ void Controller_Touchscreen::OnUpdate(const Core::Timing::CoreTiming& core_timin const auto active_fingers_count = static_cast(std::distance(active_fingers.begin(), end_iter)); - const u64 tick = core_timing.GetCPUTicks(); + const u64 timestamp = static_cast(core_timing.GetGlobalTimeNs().count()); const auto& last_entry = shared_memory->touch_screen_lifo.ReadCurrentEntry().state; next_state.sampling_number = last_entry.sampling_number + 1; @@ -102,8 +102,8 @@ void Controller_Touchscreen::OnUpdate(const Core::Timing::CoreTiming& core_timin touch_entry.diameter_x = Settings::values.touchscreen.diameter_x; touch_entry.diameter_y = Settings::values.touchscreen.diameter_y; touch_entry.rotation_angle = Settings::values.touchscreen.rotation_angle; - touch_entry.delta_time = tick - active_fingers[id].last_touch; - fingers[active_fingers[id].id].last_touch = tick; + touch_entry.delta_time = timestamp - active_fingers[id].last_touch; + fingers[active_fingers[id].id].last_touch = timestamp; touch_entry.finger = active_fingers[id].id; touch_entry.attribute.raw = active_fingers[id].attribute.raw; } else { diff --git a/src/input_common/drivers/joycon.cpp b/src/input_common/drivers/joycon.cpp index b4cd39a20..8b57ebe07 100755 --- a/src/input_common/drivers/joycon.cpp +++ b/src/input_common/drivers/joycon.cpp @@ -307,8 +307,8 @@ Common::Input::DriverResult Joycons::SetPollingMode(const PadIdentifier& identif switch (polling_mode) { case Common::Input::PollingMode::Active: return static_cast(handle->SetActiveMode()); - case Common::Input::PollingMode::Pasive: - return static_cast(handle->SetPasiveMode()); + case Common::Input::PollingMode::Passive: + return static_cast(handle->SetPassiveMode()); case Common::Input::PollingMode::IR: return static_cast(handle->SetIrMode()); case Common::Input::PollingMode::NFC: diff --git a/src/input_common/drivers/mouse.cpp b/src/input_common/drivers/mouse.cpp index a52af7220..a91a072d2 100755 --- a/src/input_common/drivers/mouse.cpp +++ b/src/input_common/drivers/mouse.cpp @@ -14,7 +14,7 @@ namespace InputCommon { constexpr int update_time = 10; constexpr float default_stick_sensitivity = 0.0044f; constexpr float default_motion_sensitivity = 0.0003f; -constexpr float maximum_rotation_speed = 1.0f; +constexpr float maximum_rotation_speed = 2.0f; constexpr int mouse_axis_x = 0; constexpr int mouse_axis_y = 1; constexpr int wheel_axis_x = 2; diff --git a/src/input_common/drivers/virtual_amiibo.h b/src/input_common/drivers/virtual_amiibo.h index 4d0073294..084b5e4e7 100755 --- a/src/input_common/drivers/virtual_amiibo.h +++ b/src/input_common/drivers/virtual_amiibo.h @@ -60,6 +60,6 @@ private: std::string file_path{}; State state{State::Initialized}; std::vector nfc_data; - Common::Input::PollingMode polling_mode{Common::Input::PollingMode::Pasive}; + Common::Input::PollingMode polling_mode{Common::Input::PollingMode::Passive}; }; } // namespace InputCommon diff --git a/src/input_common/helpers/joycon_driver.cpp b/src/input_common/helpers/joycon_driver.cpp index e65b6b845..78cc5893c 100755 --- a/src/input_common/helpers/joycon_driver.cpp +++ b/src/input_common/helpers/joycon_driver.cpp @@ -410,7 +410,7 @@ DriverResult JoyconDriver::SetIrsConfig(IrsMode mode_, IrsResolution format_) { return result; } -DriverResult JoyconDriver::SetPasiveMode() { +DriverResult JoyconDriver::SetPassiveMode() { std::scoped_lock lock{mutex}; motion_enabled = false; hidbus_enabled = false; diff --git a/src/input_common/helpers/joycon_driver.h b/src/input_common/helpers/joycon_driver.h index c1e189fa5..b52a13ecf 100755 --- a/src/input_common/helpers/joycon_driver.h +++ b/src/input_common/helpers/joycon_driver.h @@ -44,7 +44,7 @@ public: DriverResult SetVibration(const VibrationValue& vibration); DriverResult SetLedConfig(u8 led_pattern); DriverResult SetIrsConfig(IrsMode mode_, IrsResolution format_); - DriverResult SetPasiveMode(); + DriverResult SetPassiveMode(); DriverResult SetActiveMode(); DriverResult SetIrMode(); DriverResult SetNfcMode(); diff --git a/src/input_common/helpers/joycon_protocol/joycon_types.h b/src/input_common/helpers/joycon_protocol/joycon_types.h index 2e50a99a8..dcac0e422 100755 --- a/src/input_common/helpers/joycon_protocol/joycon_types.h +++ b/src/input_common/helpers/joycon_protocol/joycon_types.h @@ -78,7 +78,7 @@ enum class PadButton : u32 { Capture = 0x200000, }; -enum class PasivePadButton : u32 { +enum class PassivePadButton : u32 { Down_A = 0x0001, Right_X = 0x0002, Left_B = 0x0004, @@ -95,7 +95,7 @@ enum class PasivePadButton : u32 { ZL_ZR = 0x8000, }; -enum class PasivePadStick : u8 { +enum class PassivePadStick : u8 { Right = 0x00, RightDown = 0x01, Down = 0x02, diff --git a/src/input_common/helpers/joycon_protocol/poller.cpp b/src/input_common/helpers/joycon_protocol/poller.cpp index ab48352b8..dca797f7a 100755 --- a/src/input_common/helpers/joycon_protocol/poller.cpp +++ b/src/input_common/helpers/joycon_protocol/poller.cpp @@ -48,13 +48,13 @@ void JoyconPoller::ReadPassiveMode(std::span buffer) { switch (device_type) { case ControllerType::Left: - UpdatePasiveLeftPadInput(data); + UpdatePassiveLeftPadInput(data); break; case ControllerType::Right: - UpdatePasiveRightPadInput(data); + UpdatePassiveRightPadInput(data); break; case ControllerType::Pro: - UpdatePasiveProPadInput(data); + UpdatePassiveProPadInput(data); break; default: break; @@ -210,12 +210,12 @@ void JoyconPoller::UpdateActiveProPadInput(const InputReportActive& input, } } -void JoyconPoller::UpdatePasiveLeftPadInput(const InputReportPassive& input) { - static constexpr std::array left_buttons{ - PasivePadButton::Down_A, PasivePadButton::Right_X, PasivePadButton::Left_B, - PasivePadButton::Up_Y, PasivePadButton::SL, PasivePadButton::SR, - PasivePadButton::L_R, PasivePadButton::ZL_ZR, PasivePadButton::Minus, - PasivePadButton::Capture, PasivePadButton::StickL, +void JoyconPoller::UpdatePassiveLeftPadInput(const InputReportPassive& input) { + static constexpr std::array left_buttons{ + PassivePadButton::Down_A, PassivePadButton::Right_X, PassivePadButton::Left_B, + PassivePadButton::Up_Y, PassivePadButton::SL, PassivePadButton::SR, + PassivePadButton::L_R, PassivePadButton::ZL_ZR, PassivePadButton::Minus, + PassivePadButton::Capture, PassivePadButton::StickL, }; for (auto left_button : left_buttons) { @@ -225,17 +225,17 @@ void JoyconPoller::UpdatePasiveLeftPadInput(const InputReportPassive& input) { } const auto [left_axis_x, left_axis_y] = - GetPassiveAxisValue(static_cast(input.stick_state)); + GetPassiveAxisValue(static_cast(input.stick_state)); callbacks.on_stick_data(static_cast(PadAxes::LeftStickX), left_axis_x); callbacks.on_stick_data(static_cast(PadAxes::LeftStickY), left_axis_y); } -void JoyconPoller::UpdatePasiveRightPadInput(const InputReportPassive& input) { - static constexpr std::array right_buttons{ - PasivePadButton::Down_A, PasivePadButton::Right_X, PasivePadButton::Left_B, - PasivePadButton::Up_Y, PasivePadButton::SL, PasivePadButton::SR, - PasivePadButton::L_R, PasivePadButton::ZL_ZR, PasivePadButton::Plus, - PasivePadButton::Home, PasivePadButton::StickR, +void JoyconPoller::UpdatePassiveRightPadInput(const InputReportPassive& input) { + static constexpr std::array right_buttons{ + PassivePadButton::Down_A, PassivePadButton::Right_X, PassivePadButton::Left_B, + PassivePadButton::Up_Y, PassivePadButton::SL, PassivePadButton::SR, + PassivePadButton::L_R, PassivePadButton::ZL_ZR, PassivePadButton::Plus, + PassivePadButton::Home, PassivePadButton::StickR, }; for (auto right_button : right_buttons) { @@ -245,18 +245,18 @@ void JoyconPoller::UpdatePasiveRightPadInput(const InputReportPassive& input) { } const auto [right_axis_x, right_axis_y] = - GetPassiveAxisValue(static_cast(input.stick_state)); + GetPassiveAxisValue(static_cast(input.stick_state)); callbacks.on_stick_data(static_cast(PadAxes::RightStickX), right_axis_x); callbacks.on_stick_data(static_cast(PadAxes::RightStickY), right_axis_y); } -void JoyconPoller::UpdatePasiveProPadInput(const InputReportPassive& input) { - static constexpr std::array pro_buttons{ - PasivePadButton::Down_A, PasivePadButton::Right_X, PasivePadButton::Left_B, - PasivePadButton::Up_Y, PasivePadButton::SL, PasivePadButton::SR, - PasivePadButton::L_R, PasivePadButton::ZL_ZR, PasivePadButton::Minus, - PasivePadButton::Plus, PasivePadButton::Capture, PasivePadButton::Home, - PasivePadButton::StickL, PasivePadButton::StickR, +void JoyconPoller::UpdatePassiveProPadInput(const InputReportPassive& input) { + static constexpr std::array pro_buttons{ + PassivePadButton::Down_A, PassivePadButton::Right_X, PassivePadButton::Left_B, + PassivePadButton::Up_Y, PassivePadButton::SL, PassivePadButton::SR, + PassivePadButton::L_R, PassivePadButton::ZL_ZR, PassivePadButton::Minus, + PassivePadButton::Plus, PassivePadButton::Capture, PassivePadButton::Home, + PassivePadButton::StickL, PassivePadButton::StickR, }; for (auto pro_button : pro_buttons) { @@ -266,9 +266,9 @@ void JoyconPoller::UpdatePasiveProPadInput(const InputReportPassive& input) { } const auto [left_axis_x, left_axis_y] = - GetPassiveAxisValue(static_cast(input.stick_state && 0xf)); + GetPassiveAxisValue(static_cast(input.stick_state & 0xf)); const auto [right_axis_x, right_axis_y] = - GetPassiveAxisValue(static_cast(input.stick_state >> 4)); + GetPassiveAxisValue(static_cast(input.stick_state >> 4)); callbacks.on_stick_data(static_cast(PadAxes::LeftStickX), left_axis_x); callbacks.on_stick_data(static_cast(PadAxes::LeftStickY), left_axis_y); callbacks.on_stick_data(static_cast(PadAxes::RightStickX), right_axis_x); @@ -283,25 +283,25 @@ f32 JoyconPoller::GetAxisValue(u16 raw_value, Joycon::JoyStickAxisCalibration ca return value / calibration.min; } -std::pair JoyconPoller::GetPassiveAxisValue(PasivePadStick raw_value) const { +std::pair JoyconPoller::GetPassiveAxisValue(PassivePadStick raw_value) const { switch (raw_value) { - case PasivePadStick::Right: + case PassivePadStick::Right: return {1.0f, 0.0f}; - case PasivePadStick::RightDown: + case PassivePadStick::RightDown: return {1.0f, -1.0f}; - case PasivePadStick::Down: + case PassivePadStick::Down: return {0.0f, -1.0f}; - case PasivePadStick::DownLeft: + case PassivePadStick::DownLeft: return {-1.0f, -1.0f}; - case PasivePadStick::Left: + case PassivePadStick::Left: return {-1.0f, 0.0f}; - case PasivePadStick::LeftUp: + case PassivePadStick::LeftUp: return {-1.0f, 1.0f}; - case PasivePadStick::Up: + case PassivePadStick::Up: return {0.0f, 1.0f}; - case PasivePadStick::UpRight: + case PassivePadStick::UpRight: return {1.0f, 1.0f}; - case PasivePadStick::Neutral: + case PassivePadStick::Neutral: default: return {0.0f, 0.0f}; } diff --git a/src/input_common/helpers/joycon_protocol/poller.h b/src/input_common/helpers/joycon_protocol/poller.h index 5c897f070..0fa72c6db 100755 --- a/src/input_common/helpers/joycon_protocol/poller.h +++ b/src/input_common/helpers/joycon_protocol/poller.h @@ -46,15 +46,15 @@ private: const MotionStatus& motion_status); void UpdateActiveProPadInput(const InputReportActive& input, const MotionStatus& motion_status); - void UpdatePasiveLeftPadInput(const InputReportPassive& buffer); - void UpdatePasiveRightPadInput(const InputReportPassive& buffer); - void UpdatePasiveProPadInput(const InputReportPassive& buffer); + void UpdatePassiveLeftPadInput(const InputReportPassive& buffer); + void UpdatePassiveRightPadInput(const InputReportPassive& buffer); + void UpdatePassiveProPadInput(const InputReportPassive& buffer); /// Returns a calibrated joystick axis from raw axis data f32 GetAxisValue(u16 raw_value, JoyStickAxisCalibration calibration) const; /// Returns a digital joystick axis from passive axis data - std::pair GetPassiveAxisValue(PasivePadStick raw_value) const; + std::pair GetPassiveAxisValue(PassivePadStick raw_value) const; /// Returns a calibrated accelerometer axis from raw motion data f32 GetAccelerometerValue(s16 raw, const MotionSensorCalibration& cal, diff --git a/src/video_core/gpu_thread.cpp b/src/video_core/gpu_thread.cpp index 33f9acf6c..3083f273a 100755 --- a/src/video_core/gpu_thread.cpp +++ b/src/video_core/gpu_thread.cpp @@ -25,7 +25,7 @@ static void RunThread(std::stop_token stop_token, Core::System& system, SCOPE_EXIT({ MicroProfileOnThreadExit(); }); Common::SetCurrentThreadName(name.c_str()); - Common::SetCurrentThreadPriority(Common::ThreadPriority::High); + Common::SetCurrentThreadPriority(Common::ThreadPriority::Critical); system.RegisterHostThread(); auto current_context = context.Acquire();