early-access version 2504

This commit is contained in:
pineappleEA 2022-02-24 21:46:43 +01:00
parent 566fc94adb
commit 80162600c2
9 changed files with 50 additions and 36 deletions

View file

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

View file

@ -175,22 +175,23 @@ public:
return false; return false;
} }
BatteryLevel GetBatteryLevel() { Common::Input::BatteryLevel GetBatteryLevel() {
const auto level = SDL_JoystickCurrentPowerLevel(sdl_joystick.get()); const auto level = SDL_JoystickCurrentPowerLevel(sdl_joystick.get());
switch (level) { switch (level) {
case SDL_JOYSTICK_POWER_EMPTY: case SDL_JOYSTICK_POWER_EMPTY:
return BatteryLevel::Empty; return Common::Input::BatteryLevel::Empty;
case SDL_JOYSTICK_POWER_LOW: case SDL_JOYSTICK_POWER_LOW:
return BatteryLevel::Low; return Common::Input::BatteryLevel::Low;
case SDL_JOYSTICK_POWER_MEDIUM: case SDL_JOYSTICK_POWER_MEDIUM:
return BatteryLevel::Medium; return Common::Input::BatteryLevel::Medium;
case SDL_JOYSTICK_POWER_FULL: case SDL_JOYSTICK_POWER_FULL:
case SDL_JOYSTICK_POWER_MAX: case SDL_JOYSTICK_POWER_MAX:
return BatteryLevel::Full; return Common::Input::BatteryLevel::Full;
case SDL_JOYSTICK_POWER_UNKNOWN:
case SDL_JOYSTICK_POWER_WIRED: case SDL_JOYSTICK_POWER_WIRED:
return Common::Input::BatteryLevel::Charging;
case SDL_JOYSTICK_POWER_UNKNOWN:
default: default:
return BatteryLevel::Charging; return Common::Input::BatteryLevel::None;
} }
} }
@ -351,6 +352,8 @@ void SDLDriver::HandleGameControllerEvent(const SDL_Event& event) {
if (const auto joystick = GetSDLJoystickBySDLID(event.jbutton.which)) { if (const auto joystick = GetSDLJoystickBySDLID(event.jbutton.which)) {
const PadIdentifier identifier = joystick->GetPadIdentifier(); const PadIdentifier identifier = joystick->GetPadIdentifier();
SetButton(identifier, event.jbutton.button, true); SetButton(identifier, event.jbutton.button, true);
// Battery doesn't trigger an event so just update every button press
SetBattery(identifier, joystick->GetBatteryLevel());
} }
break; break;
} }

View file

@ -192,22 +192,22 @@ std::size_t UDPClient::GetClientNumber(std::string_view host, u16 port) const {
return MAX_UDP_CLIENTS; return MAX_UDP_CLIENTS;
} }
BatteryLevel UDPClient::GetBatteryLevel(Response::Battery battery) const { Common::Input::BatteryLevel UDPClient::GetBatteryLevel(Response::Battery battery) const {
switch (battery) { switch (battery) {
case Response::Battery::Dying: case Response::Battery::Dying:
return BatteryLevel::Empty; return Common::Input::BatteryLevel::Empty;
case Response::Battery::Low: case Response::Battery::Low:
return BatteryLevel::Critical; return Common::Input::BatteryLevel::Critical;
case Response::Battery::Medium: case Response::Battery::Medium:
return BatteryLevel::Low; return Common::Input::BatteryLevel::Low;
case Response::Battery::High: case Response::Battery::High:
return BatteryLevel::Medium; return Common::Input::BatteryLevel::Medium;
case Response::Battery::Full: case Response::Battery::Full:
case Response::Battery::Charged: case Response::Battery::Charged:
return BatteryLevel::Full; return Common::Input::BatteryLevel::Full;
case Response::Battery::Charging: case Response::Battery::Charging:
default: default:
return BatteryLevel::Charging; return Common::Input::BatteryLevel::Charging;
} }
} }

View file

@ -141,7 +141,7 @@ private:
std::size_t GetClientNumber(std::string_view host, u16 port) const; std::size_t GetClientNumber(std::string_view host, u16 port) const;
// Translates UDP battery level to input engine battery level // Translates UDP battery level to input engine battery level
BatteryLevel GetBatteryLevel(Response::Battery battery) const; Common::Input::BatteryLevel GetBatteryLevel(Response::Battery battery) const;
void OnVersion(Response::Version); void OnVersion(Response::Version);
void OnPortInfo(Response::PortInfo); void OnPortInfo(Response::PortInfo);

View file

@ -70,7 +70,7 @@ void InputEngine::SetAxis(const PadIdentifier& identifier, int axis, f32 value)
TriggerOnAxisChange(identifier, axis, value); TriggerOnAxisChange(identifier, axis, value);
} }
void InputEngine::SetBattery(const PadIdentifier& identifier, BatteryLevel value) { void InputEngine::SetBattery(const PadIdentifier& identifier, Common::Input::BatteryLevel value) {
{ {
std::lock_guard lock{mutex}; std::lock_guard lock{mutex};
ControllerData& controller = controller_list.at(identifier); ControllerData& controller = controller_list.at(identifier);
@ -143,13 +143,13 @@ f32 InputEngine::GetAxis(const PadIdentifier& identifier, int axis) const {
return axis_iter->second; return axis_iter->second;
} }
BatteryLevel InputEngine::GetBattery(const PadIdentifier& identifier) const { Common::Input::BatteryLevel InputEngine::GetBattery(const PadIdentifier& identifier) const {
std::lock_guard lock{mutex}; std::lock_guard lock{mutex};
const auto controller_iter = controller_list.find(identifier); const auto controller_iter = controller_list.find(identifier);
if (controller_iter == controller_list.cend()) { if (controller_iter == controller_list.cend()) {
LOG_ERROR(Input, "Invalid identifier guid={}, pad={}, port={}", identifier.guid.RawString(), LOG_ERROR(Input, "Invalid identifier guid={}, pad={}, port={}", identifier.guid.RawString(),
identifier.pad, identifier.port); identifier.pad, identifier.port);
return BatteryLevel::Charging; return Common::Input::BatteryLevel::Charging;
} }
const ControllerData& controller = controller_iter->second; const ControllerData& controller = controller_iter->second;
return controller.battery; return controller.battery;
@ -270,7 +270,7 @@ void InputEngine::TriggerOnAxisChange(const PadIdentifier& identifier, int axis,
} }
void InputEngine::TriggerOnBatteryChange(const PadIdentifier& identifier, void InputEngine::TriggerOnBatteryChange(const PadIdentifier& identifier,
[[maybe_unused]] BatteryLevel value) { [[maybe_unused]] Common::Input::BatteryLevel value) {
std::lock_guard lock{mutex_callback}; std::lock_guard lock{mutex_callback};
for (const auto& poller_pair : callback_list) { for (const auto& poller_pair : callback_list) {
const InputIdentifier& poller = poller_pair.second; const InputIdentifier& poller = poller_pair.second;

View file

@ -34,16 +34,6 @@ struct BasicMotion {
u64 delta_timestamp{}; u64 delta_timestamp{};
}; };
// Stages of a battery charge
enum class BatteryLevel {
Empty,
Critical,
Low,
Medium,
Full,
Charging,
};
// Types of input that are stored in the engine // Types of input that are stored in the engine
enum class EngineInputType { enum class EngineInputType {
None, None,
@ -178,7 +168,7 @@ public:
bool GetButton(const PadIdentifier& identifier, int button) const; bool GetButton(const PadIdentifier& identifier, int button) const;
bool GetHatButton(const PadIdentifier& identifier, int button, u8 direction) const; bool GetHatButton(const PadIdentifier& identifier, int button, u8 direction) const;
f32 GetAxis(const PadIdentifier& identifier, int axis) const; f32 GetAxis(const PadIdentifier& identifier, int axis) const;
BatteryLevel GetBattery(const PadIdentifier& identifier) const; Common::Input::BatteryLevel GetBattery(const PadIdentifier& identifier) const;
BasicMotion GetMotion(const PadIdentifier& identifier, int motion) const; BasicMotion GetMotion(const PadIdentifier& identifier, int motion) const;
int SetCallback(InputIdentifier input_identifier); int SetCallback(InputIdentifier input_identifier);
@ -189,7 +179,7 @@ protected:
void SetButton(const PadIdentifier& identifier, int button, bool value); void SetButton(const PadIdentifier& identifier, int button, bool value);
void SetHatButton(const PadIdentifier& identifier, int button, u8 value); void SetHatButton(const PadIdentifier& identifier, int button, u8 value);
void SetAxis(const PadIdentifier& identifier, int axis, f32 value); void SetAxis(const PadIdentifier& identifier, int axis, f32 value);
void SetBattery(const PadIdentifier& identifier, BatteryLevel value); void SetBattery(const PadIdentifier& identifier, Common::Input::BatteryLevel value);
void SetMotion(const PadIdentifier& identifier, int motion, const BasicMotion& value); void SetMotion(const PadIdentifier& identifier, int motion, const BasicMotion& value);
virtual std::string GetHatButtonName([[maybe_unused]] u8 direction_value) const { virtual std::string GetHatButtonName([[maybe_unused]] u8 direction_value) const {
@ -202,13 +192,13 @@ private:
std::unordered_map<int, u8> hat_buttons; std::unordered_map<int, u8> hat_buttons;
std::unordered_map<int, float> axes; std::unordered_map<int, float> axes;
std::unordered_map<int, BasicMotion> motions; std::unordered_map<int, BasicMotion> motions;
BatteryLevel battery{}; Common::Input::BatteryLevel battery{};
}; };
void TriggerOnButtonChange(const PadIdentifier& identifier, int button, bool value); void TriggerOnButtonChange(const PadIdentifier& identifier, int button, bool value);
void TriggerOnHatButtonChange(const PadIdentifier& identifier, int button, u8 value); void TriggerOnHatButtonChange(const PadIdentifier& identifier, int button, u8 value);
void TriggerOnAxisChange(const PadIdentifier& identifier, int axis, f32 value); void TriggerOnAxisChange(const PadIdentifier& identifier, int axis, f32 value);
void TriggerOnBatteryChange(const PadIdentifier& identifier, BatteryLevel value); void TriggerOnBatteryChange(const PadIdentifier& identifier, Common::Input::BatteryLevel value);
void TriggerOnMotionChange(const PadIdentifier& identifier, int motion, void TriggerOnMotionChange(const PadIdentifier& identifier, int motion,
const BasicMotion& value); const BasicMotion& value);

View file

@ -470,7 +470,7 @@ public:
} }
Common::Input::BatteryStatus GetStatus() const { Common::Input::BatteryStatus GetStatus() const {
return static_cast<Common::Input::BatteryLevel>(input_engine->GetBattery(identifier)); return input_engine->GetBattery(identifier);
} }
void ForceUpdate() override { void ForceUpdate() override {

View file

@ -53,7 +53,6 @@ void MaxwellDMA::Launch() {
// TODO(Subv): Perform more research and implement all features of this engine. // TODO(Subv): Perform more research and implement all features of this engine.
const LaunchDMA& launch = regs.launch_dma; const LaunchDMA& launch = regs.launch_dma;
ASSERT(launch.semaphore_type == LaunchDMA::SemaphoreType::NONE);
ASSERT(launch.interrupt_type == LaunchDMA::InterruptType::NONE); ASSERT(launch.interrupt_type == LaunchDMA::InterruptType::NONE);
ASSERT(launch.data_transfer_type == LaunchDMA::DataTransferType::NON_PIPELINED); ASSERT(launch.data_transfer_type == LaunchDMA::DataTransferType::NON_PIPELINED);
ASSERT(regs.dst_params.origin.x == 0); ASSERT(regs.dst_params.origin.x == 0);
@ -79,6 +78,7 @@ void MaxwellDMA::Launch() {
CopyPitchToBlockLinear(); CopyPitchToBlockLinear();
} }
} }
ReleaseSemaphore();
} }
void MaxwellDMA::CopyPitchToPitch() { void MaxwellDMA::CopyPitchToPitch() {
@ -244,4 +244,23 @@ void MaxwellDMA::FastCopyBlockLinearToPitch() {
memory_manager.WriteBlock(regs.offset_out, write_buffer.data(), dst_size); memory_manager.WriteBlock(regs.offset_out, write_buffer.data(), dst_size);
} }
void MaxwellDMA::ReleaseSemaphore() {
const auto type = regs.launch_dma.semaphore_type;
if (type == LaunchDMA::SemaphoreType::NONE) {
return;
}
const GPUVAddr address = regs.semaphore.address;
switch (type) {
case LaunchDMA::SemaphoreType::RELEASE_ONE_WORD_SEMAPHORE:
memory_manager.Write<u32>(address, regs.semaphore.payload);
break;
case LaunchDMA::SemaphoreType::RELEASE_FOUR_WORD_SEMAPHORE:
memory_manager.Write<u64>(address, static_cast<u64>(regs.semaphore.payload));
memory_manager.Write<u64>(address + 8, system.GPU().GetTicks());
break;
default:
UNREACHABLE_MSG("Unknown semaphore type: {}", static_cast<u32>(type.Value()));
}
}
} // namespace Tegra::Engines } // namespace Tegra::Engines

View file

@ -224,6 +224,8 @@ private:
void FastCopyBlockLinearToPitch(); void FastCopyBlockLinearToPitch();
void ReleaseSemaphore();
Core::System& system; Core::System& system;
MemoryManager& memory_manager; MemoryManager& memory_manager;