early-access version 3945

This commit is contained in:
pineappleEA 2023-10-24 01:08:39 +02:00
parent b8e39b295e
commit 0c99ec30a6
4 changed files with 26 additions and 3 deletions

View File

@ -1,7 +1,7 @@
yuzu emulator early access yuzu emulator early access
============= =============
This is the source code for early-access 3944. This is the source code for early-access 3945.
## Legal Notice ## Legal Notice

View File

@ -27,10 +27,12 @@ namespace {
static thread_local std::array read_buffer_data_a{ static thread_local std::array read_buffer_data_a{
Common::ScratchBuffer<u8>(), Common::ScratchBuffer<u8>(),
Common::ScratchBuffer<u8>(), Common::ScratchBuffer<u8>(),
Common::ScratchBuffer<u8>(),
}; };
static thread_local std::array read_buffer_data_x{ static thread_local std::array read_buffer_data_x{
Common::ScratchBuffer<u8>(), Common::ScratchBuffer<u8>(),
Common::ScratchBuffer<u8>(), Common::ScratchBuffer<u8>(),
Common::ScratchBuffer<u8>(),
}; };
} // Anonymous namespace } // Anonymous namespace
@ -343,6 +345,7 @@ std::span<const u8> HLERequestContext::ReadBufferA(std::size_t buffer_index) con
static thread_local std::array read_buffer_a{ static thread_local std::array read_buffer_a{
Core::Memory::CpuGuestMemory<u8, Core::Memory::GuestMemoryFlags::SafeRead>(memory, 0, 0), Core::Memory::CpuGuestMemory<u8, Core::Memory::GuestMemoryFlags::SafeRead>(memory, 0, 0),
Core::Memory::CpuGuestMemory<u8, Core::Memory::GuestMemoryFlags::SafeRead>(memory, 0, 0), Core::Memory::CpuGuestMemory<u8, Core::Memory::GuestMemoryFlags::SafeRead>(memory, 0, 0),
Core::Memory::CpuGuestMemory<u8, Core::Memory::GuestMemoryFlags::SafeRead>(memory, 0, 0),
}; };
ASSERT_OR_EXECUTE_MSG( ASSERT_OR_EXECUTE_MSG(
@ -358,6 +361,7 @@ std::span<const u8> HLERequestContext::ReadBufferX(std::size_t buffer_index) con
static thread_local std::array read_buffer_x{ static thread_local std::array read_buffer_x{
Core::Memory::CpuGuestMemory<u8, Core::Memory::GuestMemoryFlags::SafeRead>(memory, 0, 0), Core::Memory::CpuGuestMemory<u8, Core::Memory::GuestMemoryFlags::SafeRead>(memory, 0, 0),
Core::Memory::CpuGuestMemory<u8, Core::Memory::GuestMemoryFlags::SafeRead>(memory, 0, 0), Core::Memory::CpuGuestMemory<u8, Core::Memory::GuestMemoryFlags::SafeRead>(memory, 0, 0),
Core::Memory::CpuGuestMemory<u8, Core::Memory::GuestMemoryFlags::SafeRead>(memory, 0, 0),
}; };
ASSERT_OR_EXECUTE_MSG( ASSERT_OR_EXECUTE_MSG(
@ -373,10 +377,12 @@ std::span<const u8> HLERequestContext::ReadBuffer(std::size_t buffer_index) cons
static thread_local std::array read_buffer_a{ static thread_local std::array read_buffer_a{
Core::Memory::CpuGuestMemory<u8, Core::Memory::GuestMemoryFlags::SafeRead>(memory, 0, 0), Core::Memory::CpuGuestMemory<u8, Core::Memory::GuestMemoryFlags::SafeRead>(memory, 0, 0),
Core::Memory::CpuGuestMemory<u8, Core::Memory::GuestMemoryFlags::SafeRead>(memory, 0, 0), Core::Memory::CpuGuestMemory<u8, Core::Memory::GuestMemoryFlags::SafeRead>(memory, 0, 0),
Core::Memory::CpuGuestMemory<u8, Core::Memory::GuestMemoryFlags::SafeRead>(memory, 0, 0),
}; };
static thread_local std::array read_buffer_x{ static thread_local std::array read_buffer_x{
Core::Memory::CpuGuestMemory<u8, Core::Memory::GuestMemoryFlags::SafeRead>(memory, 0, 0), Core::Memory::CpuGuestMemory<u8, Core::Memory::GuestMemoryFlags::SafeRead>(memory, 0, 0),
Core::Memory::CpuGuestMemory<u8, Core::Memory::GuestMemoryFlags::SafeRead>(memory, 0, 0), Core::Memory::CpuGuestMemory<u8, Core::Memory::GuestMemoryFlags::SafeRead>(memory, 0, 0),
Core::Memory::CpuGuestMemory<u8, Core::Memory::GuestMemoryFlags::SafeRead>(memory, 0, 0),
}; };
const bool is_buffer_a{BufferDescriptorA().size() > buffer_index && const bool is_buffer_a{BufferDescriptorA().size() > buffer_index &&

View File

@ -139,7 +139,7 @@ void JoyconDriver::InputThread(std::stop_token stop_token) {
input_thread_running = true; input_thread_running = true;
// Max update rate is 5ms, ensure we are always able to read a bit faster // Max update rate is 5ms, ensure we are always able to read a bit faster
constexpr int ThreadDelay = 2; constexpr int ThreadDelay = 3;
std::vector<u8> buffer(MaxBufferSize); std::vector<u8> buffer(MaxBufferSize);
while (!stop_token.stop_requested()) { while (!stop_token.stop_requested()) {
@ -163,6 +163,17 @@ void JoyconDriver::InputThread(std::stop_token stop_token) {
OnNewData(buffer); OnNewData(buffer);
} }
if (!vibration_queue.Empty()) {
VibrationValue vibration_value;
vibration_queue.Pop(vibration_value);
last_vibration_result = rumble_protocol->SendVibration(vibration_value);
}
// We can't keep up with vibrations. Start skipping.
while (vibration_queue.Size() > 6) {
vibration_queue.Pop();
}
std::this_thread::yield(); std::this_thread::yield();
} }
@ -402,7 +413,8 @@ Common::Input::DriverResult JoyconDriver::SetVibration(const VibrationValue& vib
if (disable_input_thread) { if (disable_input_thread) {
return Common::Input::DriverResult::HandleInUse; return Common::Input::DriverResult::HandleInUse;
} }
return rumble_protocol->SendVibration(vibration); vibration_queue.Push(vibration);
return last_vibration_result;
} }
Common::Input::DriverResult JoyconDriver::SetLedConfig(u8 led_pattern) { Common::Input::DriverResult JoyconDriver::SetLedConfig(u8 led_pattern) {

View File

@ -9,6 +9,7 @@
#include <span> #include <span>
#include <thread> #include <thread>
#include "common/threadsafe_queue.h"
#include "input_common/helpers/joycon_protocol/joycon_types.h" #include "input_common/helpers/joycon_protocol/joycon_types.h"
namespace Common::Input { namespace Common::Input {
@ -152,6 +153,10 @@ private:
SerialNumber handle_serial_number{}; // Serial number type reported by hidapi SerialNumber handle_serial_number{}; // Serial number type reported by hidapi
SupportedFeatures supported_features{}; SupportedFeatures supported_features{};
/// Queue of vibration request to controllers
Common::Input::DriverResult last_vibration_result{Common::Input::DriverResult::Success};
Common::SPSCQueue<VibrationValue> vibration_queue;
// Thread related // Thread related
mutable std::mutex mutex; mutable std::mutex mutex;
std::jthread input_thread; std::jthread input_thread;