early-access version 2387

This commit is contained in:
pineappleEA 2022-01-12 00:42:53 +01:00
parent 65a23edcfb
commit 0744a1c7b6
6 changed files with 15 additions and 46 deletions

View file

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

View file

@ -191,6 +191,7 @@ void HidBus::IsExternalDeviceConnected(Kernel::HLERequestContext& ctx) {
IPC::ResponseBuilder rb{ctx, 3}; IPC::ResponseBuilder rb{ctx, 3};
rb.Push(ResultSuccess); rb.Push(ResultSuccess);
rb.Push(is_attached); rb.Push(is_attached);
return;
} }
LOG_ERROR(Service_HID, "Invalid handle"); LOG_ERROR(Service_HID, "Invalid handle");

View file

@ -12,7 +12,7 @@ namespace Service::HID {
HidbusBase::HidbusBase(KernelHelpers::ServiceContext& service_context_) HidbusBase::HidbusBase(KernelHelpers::ServiceContext& service_context_)
: service_context(service_context_) { : service_context(service_context_) {
send_command_asyc_event = service_context.CreateEvent("hidbus:SendCommandAsycEvent"); send_command_async_event = service_context.CreateEvent("hidbus:SendCommandAsyncEvent");
} }
HidbusBase::~HidbusBase() = default; HidbusBase::~HidbusBase() = default;
@ -66,7 +66,7 @@ void HidbusBase::SetTransferMemoryPointer(u8* t_mem) {
} }
Kernel::KReadableEvent& HidbusBase::GetSendCommandAsycEvent() const { Kernel::KReadableEvent& HidbusBase::GetSendCommandAsycEvent() const {
return send_command_asyc_event->GetReadableEvent(); return send_command_async_event->GetReadableEvent();
} }
} // namespace Service::HID } // namespace Service::HID

View file

@ -173,7 +173,7 @@ protected:
u8* transfer_memory{nullptr}; u8* transfer_memory{nullptr};
bool is_transfer_memory_set{}; bool is_transfer_memory_set{};
Kernel::KEvent* send_command_asyc_event; Kernel::KEvent* send_command_async_event;
KernelHelpers::ServiceContext& service_context; KernelHelpers::ServiceContext& service_context;
}; };
} // namespace Service::HID } // namespace Service::HID

View file

@ -120,37 +120,9 @@ bool RingController::SetCommand(const std::vector<u8>& data) {
return false; return false;
} }
// There must be a better way to do this std::memcpy(&command, data.data(), sizeof(RingConCommands));
const u32 command_id =
u32{data[0]} + (u32{data[1]} << 8) + (u32{data[2]} << 16) + (u32{data[3]} << 24);
static constexpr std::array supported_commands = {
RingConCommands::GetFirmwareVersion,
RingConCommands::ReadId,
RingConCommands::c20105,
RingConCommands::ReadUnkCal,
RingConCommands::ReadFactoryCal,
RingConCommands::ReadUserCal,
RingConCommands::ReadRepCount,
RingConCommands::ReadTotalPushCount,
RingConCommands::ResetRepCount,
RingConCommands::SaveCalData,
};
for (RingConCommands cmd : supported_commands) { switch (command) {
if (command_id == static_cast<u32>(cmd)) {
return ExcecuteCommand(cmd, data);
}
}
LOG_ERROR(Service_HID, "Command not supported {}", command_id);
command = RingConCommands::Error;
// Signal a reply to avoid softlocking the game
send_command_asyc_event->GetWritableEvent().Signal();
return false;
}
bool RingController::ExcecuteCommand(RingConCommands cmd, const std::vector<u8>& data) {
switch (cmd) {
case RingConCommands::GetFirmwareVersion: case RingConCommands::GetFirmwareVersion:
case RingConCommands::ReadId: case RingConCommands::ReadId:
case RingConCommands::c20105: case RingConCommands::c20105:
@ -160,28 +132,27 @@ bool RingController::ExcecuteCommand(RingConCommands cmd, const std::vector<u8>&
case RingConCommands::ReadRepCount: case RingConCommands::ReadRepCount:
case RingConCommands::ReadTotalPushCount: case RingConCommands::ReadTotalPushCount:
ASSERT_MSG(data.size() == 0x4, "data.size is not 0x4 bytes"); ASSERT_MSG(data.size() == 0x4, "data.size is not 0x4 bytes");
command = cmd; send_command_async_event->GetWritableEvent().Signal();
send_command_asyc_event->GetWritableEvent().Signal();
return true; return true;
case RingConCommands::ResetRepCount: case RingConCommands::ResetRepCount:
ASSERT_MSG(data.size() == 0x4, "data.size is not 0x4 bytes");
total_rep_count = 0; total_rep_count = 0;
command = cmd; send_command_async_event->GetWritableEvent().Signal();
send_command_asyc_event->GetWritableEvent().Signal();
return true; return true;
case RingConCommands::SaveCalData: { case RingConCommands::SaveCalData: {
ASSERT_MSG(data.size() == 0x14, "data.size is not 0x14 bytes"); ASSERT_MSG(data.size() == 0x14, "data.size is not 0x14 bytes");
SaveCalData save_info{}; SaveCalData save_info{};
std::memcpy(&save_info, &data, sizeof(SaveCalData)); std::memcpy(&save_info, data.data(), sizeof(SaveCalData));
user_calibration = save_info.calibration; user_calibration = save_info.calibration;
send_command_async_event->GetWritableEvent().Signal();
command = cmd;
send_command_asyc_event->GetWritableEvent().Signal();
return true; return true;
} }
default: default:
LOG_ERROR(Service_HID, "Command not implemented {}", cmd); LOG_ERROR(Service_HID, "Command not implemented {}", command);
command = RingConCommands::Error; command = RingConCommands::Error;
// Signal a reply to avoid softlocking the game
send_command_async_event->GetWritableEvent().Signal();
return false; return false;
} }
} }

View file

@ -181,9 +181,6 @@ private:
}; };
static_assert(sizeof(RingConData) == 0x8, "RingConData is an invalid size"); static_assert(sizeof(RingConData) == 0x8, "RingConData is an invalid size");
// Executes the command requested
bool ExcecuteCommand(RingConCommands cmd, const std::vector<u8>& data);
// Returns RingConData struct with pressure sensor values // Returns RingConData struct with pressure sensor values
RingConData GetSensorValue() const; RingConData GetSensorValue() const;