From 2be2b2a4f1a19a21ba54e1cd9376e9c5975284bc Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 1 Aug 2016 20:52:54 -0400 Subject: [PATCH] GCKeyboard: Return input state by value --- Source/Core/Core/HW/GCKeyboard.cpp | 8 ++------ Source/Core/Core/HW/GCKeyboard.h | 2 +- Source/Core/Core/HW/GCKeyboardEmu.cpp | 19 ++++++++++++------- Source/Core/Core/HW/GCKeyboardEmu.h | 2 +- Source/Core/Core/HW/SI_DeviceKeyboard.cpp | 4 +--- 5 files changed, 17 insertions(+), 18 deletions(-) diff --git a/Source/Core/Core/HW/GCKeyboard.cpp b/Source/Core/Core/HW/GCKeyboard.cpp index 1b818bee84..a8bdd1884c 100644 --- a/Source/Core/Core/HW/GCKeyboard.cpp +++ b/Source/Core/Core/HW/GCKeyboard.cpp @@ -47,12 +47,8 @@ void LoadConfig() s_config.LoadConfig(true); } -void GetStatus(u8 port, KeyboardStatus* keyboard_status) +KeyboardStatus GetStatus(u8 port) { - memset(keyboard_status, 0, sizeof(*keyboard_status)); - keyboard_status->err = PAD_ERR_NONE; - - // Get input - static_cast(s_config.GetController(port))->GetInput(keyboard_status); + return static_cast(s_config.GetController(port))->GetInput(); } } diff --git a/Source/Core/Core/HW/GCKeyboard.h b/Source/Core/Core/HW/GCKeyboard.h index 56709a259e..f96d581c5c 100644 --- a/Source/Core/Core/HW/GCKeyboard.h +++ b/Source/Core/Core/HW/GCKeyboard.h @@ -17,5 +17,5 @@ void LoadConfig(); InputConfig* GetConfig(); -void GetStatus(u8 port, KeyboardStatus* keyboard_status); +KeyboardStatus GetStatus(u8 port); } diff --git a/Source/Core/Core/HW/GCKeyboardEmu.cpp b/Source/Core/Core/HW/GCKeyboardEmu.cpp index b022527a0d..ddf36d9350 100644 --- a/Source/Core/Core/HW/GCKeyboardEmu.cpp +++ b/Source/Core/Core/HW/GCKeyboardEmu.cpp @@ -84,15 +84,20 @@ std::string GCKeyboard::GetName() const return std::string("GCKeyboard") + char('1' + m_index); } -void GCKeyboard::GetInput(KeyboardStatus* const kb) +KeyboardStatus GCKeyboard::GetInput() const { auto lock = ControllerEmu::GetStateLock(); - m_keys0x->GetState(&kb->key0x, keys0_bitmasks); - m_keys1x->GetState(&kb->key1x, keys1_bitmasks); - m_keys2x->GetState(&kb->key2x, keys2_bitmasks); - m_keys3x->GetState(&kb->key3x, keys3_bitmasks); - m_keys4x->GetState(&kb->key4x, keys4_bitmasks); - m_keys5x->GetState(&kb->key5x, keys5_bitmasks); + + KeyboardStatus kb = {}; + + m_keys0x->GetState(&kb.key0x, keys0_bitmasks); + m_keys1x->GetState(&kb.key1x, keys1_bitmasks); + m_keys2x->GetState(&kb.key2x, keys2_bitmasks); + m_keys3x->GetState(&kb.key3x, keys3_bitmasks); + m_keys4x->GetState(&kb.key4x, keys4_bitmasks); + m_keys5x->GetState(&kb.key5x, keys5_bitmasks); + + return kb; } void GCKeyboard::LoadDefaults(const ControllerInterface& ciface) diff --git a/Source/Core/Core/HW/GCKeyboardEmu.h b/Source/Core/Core/HW/GCKeyboardEmu.h index 3f41659a1f..48451f3be2 100644 --- a/Source/Core/Core/HW/GCKeyboardEmu.h +++ b/Source/Core/Core/HW/GCKeyboardEmu.h @@ -14,7 +14,7 @@ class GCKeyboard : public ControllerEmu { public: GCKeyboard(const unsigned int index); - void GetInput(KeyboardStatus* const pad); + KeyboardStatus GetInput() const; std::string GetName() const override; void LoadDefaults(const ControllerInterface& ciface) override; diff --git a/Source/Core/Core/HW/SI_DeviceKeyboard.cpp b/Source/Core/Core/HW/SI_DeviceKeyboard.cpp index 63645be706..dc321fd859 100644 --- a/Source/Core/Core/HW/SI_DeviceKeyboard.cpp +++ b/Source/Core/Core/HW/SI_DeviceKeyboard.cpp @@ -56,9 +56,7 @@ int CSIDevice_Keyboard::RunBuffer(u8* _pBuffer, int _iLength) KeyboardStatus CSIDevice_Keyboard::GetKeyboardStatus() const { - KeyboardStatus KeyStatus = {}; - Keyboard::GetStatus(ISIDevice::m_iDeviceNumber, &KeyStatus); - return KeyStatus; + return Keyboard::GetStatus(m_iDeviceNumber); } bool CSIDevice_Keyboard::GetData(u32& _Hi, u32& _Low)