IOS HLE: Deduplicate request code in USB_KBD

This commit is contained in:
Léo Lam 2017-01-15 11:45:53 +01:00
parent d536082e42
commit d4de87a973
2 changed files with 8 additions and 32 deletions

View File

@ -38,17 +38,14 @@ CWII_IPC_HLE_Device_usb_kbd::CWII_IPC_HLE_Device_usb_kbd(u32 _DeviceID,
{ {
} }
CWII_IPC_HLE_Device_usb_kbd::~CWII_IPC_HLE_Device_usb_kbd() IOSReturnCode CWII_IPC_HLE_Device_usb_kbd::Open(const IOSOpenRequest& request)
{
}
IPCCommandResult CWII_IPC_HLE_Device_usb_kbd::Open(u32 _CommandAddress, u32 _Mode)
{ {
INFO_LOG(WII_IPC_HLE, "CWII_IPC_HLE_Device_usb_kbd: Open"); INFO_LOG(WII_IPC_HLE, "CWII_IPC_HLE_Device_usb_kbd: Open");
IniFile ini; IniFile ini;
ini.Load(File::GetUserPath(F_DOLPHINCONFIG_IDX)); ini.Load(File::GetUserPath(F_DOLPHINCONFIG_IDX));
ini.GetOrCreateSection("USB Keyboard")->Get("Layout", &m_KeyboardLayout, KBD_LAYOUT_QWERTY); ini.GetOrCreateSection("USB Keyboard")->Get("Layout", &m_KeyboardLayout, KBD_LAYOUT_QWERTY);
m_MessageQueue = std::queue<SMessageData>();
for (bool& pressed : m_OldKeyBuffer) for (bool& pressed : m_OldKeyBuffer)
{ {
pressed = false; pressed = false;
@ -58,35 +55,17 @@ IPCCommandResult CWII_IPC_HLE_Device_usb_kbd::Open(u32 _CommandAddress, u32 _Mod
// m_MessageQueue.push(SMessageData(MSG_KBD_CONNECT, 0, nullptr)); // m_MessageQueue.push(SMessageData(MSG_KBD_CONNECT, 0, nullptr));
m_is_active = true; m_is_active = true;
return GetDefaultReply(); return IPC_SUCCESS;
} }
IPCCommandResult CWII_IPC_HLE_Device_usb_kbd::Close(u32 _CommandAddress, bool _bForce) IPCCommandResult CWII_IPC_HLE_Device_usb_kbd::IOCtl(const IOSIOCtlRequest& request)
{ {
INFO_LOG(WII_IPC_HLE, "CWII_IPC_HLE_Device_usb_kbd: Close");
while (!m_MessageQueue.empty())
m_MessageQueue.pop();
m_is_active = false;
return GetDefaultReply();
}
IPCCommandResult CWII_IPC_HLE_Device_usb_kbd::Write(u32 _CommandAddress)
{
DEBUG_LOG(WII_IPC_HLE, "Ignoring write to CWII_IPC_HLE_Device_usb_kbd");
return GetDefaultReply();
}
IPCCommandResult CWII_IPC_HLE_Device_usb_kbd::IOCtl(u32 _CommandAddress)
{
u32 BufferOut = Memory::Read_U32(_CommandAddress + 0x18);
if (SConfig::GetInstance().m_WiiKeyboard && !Core::g_want_determinism && !m_MessageQueue.empty()) if (SConfig::GetInstance().m_WiiKeyboard && !Core::g_want_determinism && !m_MessageQueue.empty())
{ {
Memory::CopyToEmu(BufferOut, &m_MessageQueue.front(), sizeof(SMessageData)); Memory::CopyToEmu(request.buffer_out, &m_MessageQueue.front(), sizeof(SMessageData));
m_MessageQueue.pop(); m_MessageQueue.pop();
} }
request.SetReturnValue(IPC_SUCCESS);
Memory::Write_U32(0, _CommandAddress + 0x4);
return GetDefaultReply(); return GetDefaultReply();
} }

View File

@ -15,12 +15,9 @@ class CWII_IPC_HLE_Device_usb_kbd : public IWII_IPC_HLE_Device
{ {
public: public:
CWII_IPC_HLE_Device_usb_kbd(u32 _DeviceID, const std::string& _rDeviceName); CWII_IPC_HLE_Device_usb_kbd(u32 _DeviceID, const std::string& _rDeviceName);
virtual ~CWII_IPC_HLE_Device_usb_kbd();
IPCCommandResult Open(u32 _CommandAddress, u32 _Mode) override; IOSReturnCode Open(const IOSOpenRequest& request) override;
IPCCommandResult Close(u32 _CommandAddress, bool _bForce) override; IPCCommandResult IOCtl(const IOSIOCtlRequest& request) override;
IPCCommandResult Write(u32 _CommandAddress) override;
IPCCommandResult IOCtl(u32 _CommandAddress) override;
void Update() override; void Update() override;
private: private: