IOS: Treat /dev/usb/kbd as blocking
Fixes https://bugs.dolphin-emu.org/issues/13406
This commit is contained in:
parent
e17b39b35e
commit
c7b0198154
|
@ -4,7 +4,9 @@
|
|||
#include "Core/IOS/USB/USB_KBD.h"
|
||||
|
||||
#include <array>
|
||||
#include <optional>
|
||||
#include <queue>
|
||||
#include <string>
|
||||
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Common/IniFile.h"
|
||||
|
@ -212,15 +214,21 @@ std::optional<IPCReply> USB_KBD::Write(const ReadWriteRequest& request)
|
|||
|
||||
std::optional<IPCReply> USB_KBD::IOCtl(const IOCtlRequest& request)
|
||||
{
|
||||
if (Config::Get(Config::MAIN_WII_KEYBOARD) && !Core::WantsDeterminism() &&
|
||||
ControlReference::GetInputGate() && !m_message_queue.empty())
|
||||
{
|
||||
auto& system = GetSystem();
|
||||
auto& memory = system.GetMemory();
|
||||
memory.CopyToEmu(request.buffer_out, &m_message_queue.front(), sizeof(MessageData));
|
||||
m_message_queue.pop();
|
||||
}
|
||||
return IPCReply(IPC_SUCCESS);
|
||||
if (request.request != 0)
|
||||
return IPCReply(IPC_EINVAL);
|
||||
|
||||
if (m_pending_request.has_value())
|
||||
return IPCReply(IPC_EEXIST);
|
||||
|
||||
// Blocks until a new event is available
|
||||
m_pending_request = request.address;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
void USB_KBD::DoState(PointerWrap& p)
|
||||
{
|
||||
Device::DoState(p);
|
||||
p.Do(m_pending_request);
|
||||
}
|
||||
|
||||
bool USB_KBD::IsKeyPressed(int key) const
|
||||
|
@ -309,5 +317,16 @@ void USB_KBD::Update()
|
|||
|
||||
if (got_event)
|
||||
m_message_queue.emplace(MessageType::Event, modifiers, pressed_keys);
|
||||
|
||||
if (ControlReference::GetInputGate() && !m_message_queue.empty() && m_pending_request.has_value())
|
||||
{
|
||||
auto& system = GetSystem();
|
||||
auto& memory = system.GetMemory();
|
||||
IOCtlRequest pending_request{GetSystem(), m_pending_request.value()};
|
||||
memory.CopyToEmu(pending_request.buffer_out, &m_message_queue.front(), sizeof(MessageData));
|
||||
m_message_queue.pop();
|
||||
GetEmulationKernel().EnqueueIPCReply(pending_request, IPC_SUCCESS);
|
||||
m_pending_request.reset();
|
||||
}
|
||||
}
|
||||
} // namespace IOS::HLE
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <optional>
|
||||
#include <queue>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Core/IOS/Device.h"
|
||||
|
@ -22,6 +22,7 @@ public:
|
|||
std::optional<IPCReply> Open(const OpenRequest& request) override;
|
||||
std::optional<IPCReply> Write(const ReadWriteRequest& request) override;
|
||||
std::optional<IPCReply> IOCtl(const IOCtlRequest& request) override;
|
||||
void DoState(PointerWrap& p) override;
|
||||
void Update() override;
|
||||
|
||||
private:
|
||||
|
@ -62,5 +63,7 @@ private:
|
|||
KBD_LAYOUT_AZERTY = 1
|
||||
};
|
||||
int m_keyboard_layout = KBD_LAYOUT_QWERTY;
|
||||
|
||||
std::optional<u32> m_pending_request{};
|
||||
};
|
||||
} // namespace IOS::HLE
|
||||
|
|
|
@ -98,7 +98,7 @@ static size_t s_state_writes_in_queue;
|
|||
static std::condition_variable s_state_write_queue_is_empty;
|
||||
|
||||
// Don't forget to increase this after doing changes on the savestate system
|
||||
constexpr u32 STATE_VERSION = 168; // Last changed in PR 12639
|
||||
constexpr u32 STATE_VERSION = 169; // Last changed in PR 12338
|
||||
|
||||
// Increase this if the StateExtendedHeader definition changes
|
||||
constexpr u32 EXTENDED_HEADER_VERSION = 1; // Last changed in PR 12217
|
||||
|
|
Loading…
Reference in New Issue