diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/arm/arm_interface.cpp | 2 | ||||
-rw-r--r-- | src/core/file_sys/vfs_real.cpp | 3 | ||||
-rw-r--r-- | src/core/hid/emulated_controller.cpp | 12 | ||||
-rw-r--r-- | src/core/hid/emulated_controller.h | 8 | ||||
-rw-r--r-- | src/core/hle/service/nfc/common/device.cpp | 32 |
5 files changed, 44 insertions, 13 deletions
diff --git a/src/core/arm/arm_interface.cpp b/src/core/arm/arm_interface.cpp index beaea64b3..aa0eb9791 100644 --- a/src/core/arm/arm_interface.cpp +++ b/src/core/arm/arm_interface.cpp @@ -185,7 +185,7 @@ void ARM_Interface::Run() { // Notify the debugger and go to sleep if a breakpoint was hit, // or if the thread is unable to continue for any reason. if (True(hr & HaltReason::InstructionBreakpoint) || True(hr & HaltReason::PrefetchAbort)) { - if (!True(hr & HaltReason::InstructionBreakpoint)) { + if (!True(hr & HaltReason::PrefetchAbort)) { RewindBreakpointInstruction(); } if (system.DebuggerEnabled()) { diff --git a/src/core/file_sys/vfs_real.cpp b/src/core/file_sys/vfs_real.cpp index b0515ec05..1c706e4d8 100644 --- a/src/core/file_sys/vfs_real.cpp +++ b/src/core/file_sys/vfs_real.cpp @@ -283,7 +283,8 @@ std::size_t RealVfsFile::GetSize() const { if (size) { return *size; } - return FS::GetSize(path); + auto lk = base.RefreshReference(path, perms, *reference); + return reference->file ? reference->file->GetSize() : 0; } bool RealVfsFile::Resize(std::size_t new_size) { diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp index 1ebc32c1e..94bd656fe 100644 --- a/src/core/hid/emulated_controller.cpp +++ b/src/core/hid/emulated_controller.cpp @@ -1243,10 +1243,12 @@ Common::Input::DriverResult EmulatedController::SetPollingMode( auto& nfc_output_device = output_devices[3]; if (device_index == EmulatedDeviceIndex::LeftIndex) { + controller.left_polling_mode = polling_mode; return left_output_device->SetPollingMode(polling_mode); } if (device_index == EmulatedDeviceIndex::RightIndex) { + controller.right_polling_mode = polling_mode; const auto virtual_nfc_result = nfc_output_device->SetPollingMode(polling_mode); const auto mapped_nfc_result = right_output_device->SetPollingMode(polling_mode); @@ -1261,12 +1263,22 @@ Common::Input::DriverResult EmulatedController::SetPollingMode( return mapped_nfc_result; } + controller.left_polling_mode = polling_mode; + controller.right_polling_mode = polling_mode; left_output_device->SetPollingMode(polling_mode); right_output_device->SetPollingMode(polling_mode); nfc_output_device->SetPollingMode(polling_mode); return Common::Input::DriverResult::Success; } +Common::Input::PollingMode EmulatedController::GetPollingMode( + EmulatedDeviceIndex device_index) const { + if (device_index == EmulatedDeviceIndex::LeftIndex) { + return controller.left_polling_mode; + } + return controller.right_polling_mode; +} + bool EmulatedController::SetCameraFormat( Core::IrSensor::ImageTransferProcessorFormat camera_format) { LOG_INFO(Service_HID, "Set camera format {}", camera_format); diff --git a/src/core/hid/emulated_controller.h b/src/core/hid/emulated_controller.h index d511e5fac..88d77db8d 100644 --- a/src/core/hid/emulated_controller.h +++ b/src/core/hid/emulated_controller.h @@ -143,6 +143,8 @@ struct ControllerStatus { CameraState camera_state{}; RingSensorForce ring_analog_state{}; NfcState nfc_state{}; + Common::Input::PollingMode left_polling_mode{}; + Common::Input::PollingMode right_polling_mode{}; }; enum class ControllerTriggerType { @@ -370,6 +372,12 @@ public: */ Common::Input::DriverResult SetPollingMode(EmulatedDeviceIndex device_index, Common::Input::PollingMode polling_mode); + /** + * Get the current polling mode from a controller + * @param device_index index of the controller to set the polling mode + * @return current polling mode + */ + Common::Input::PollingMode GetPollingMode(EmulatedDeviceIndex device_index) const; /** * Sets the desired camera format to be polled from a controller diff --git a/src/core/hle/service/nfc/common/device.cpp b/src/core/hle/service/nfc/common/device.cpp index 5bf289818..2d633b03f 100644 --- a/src/core/hle/service/nfc/common/device.cpp +++ b/src/core/hle/service/nfc/common/device.cpp @@ -66,10 +66,6 @@ NfcDevice::~NfcDevice() { }; void NfcDevice::NpadUpdate(Core::HID::ControllerTriggerType type) { - if (!is_initalized) { - return; - } - if (type == Core::HID::ControllerTriggerType::Connected) { Initialize(); availability_change_event->Signal(); @@ -77,12 +73,12 @@ void NfcDevice::NpadUpdate(Core::HID::ControllerTriggerType type) { } if (type == Core::HID::ControllerTriggerType::Disconnected) { - device_state = DeviceState::Unavailable; + Finalize(); availability_change_event->Signal(); return; } - if (type != Core::HID::ControllerTriggerType::Nfc) { + if (!is_initalized) { return; } @@ -90,6 +86,17 @@ void NfcDevice::NpadUpdate(Core::HID::ControllerTriggerType type) { return; } + // Ensure nfc mode is always active + if (npad_device->GetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex) == + Common::Input::PollingMode::Active) { + npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex, + Common::Input::PollingMode::NFC); + } + + if (type != Core::HID::ControllerTriggerType::Nfc) { + return; + } + const auto nfc_status = npad_device->GetNfc(); switch (nfc_status.state) { case Common::Input::NfcState::NewAmiibo: @@ -207,11 +214,14 @@ void NfcDevice::Initialize() { } void NfcDevice::Finalize() { - if (device_state == DeviceState::TagMounted) { - Unmount(); - } - if (device_state == DeviceState::SearchingForTag || device_state == DeviceState::TagRemoved) { - StopDetection(); + if (npad_device->IsConnected()) { + if (device_state == DeviceState::TagMounted) { + Unmount(); + } + if (device_state == DeviceState::SearchingForTag || + device_state == DeviceState::TagRemoved) { + StopDetection(); + } } if (device_state != DeviceState::Unavailable) { |