diff --git a/Source/Core/InputCommon/ControllerInterface/Quartz/Quartz.mm b/Source/Core/InputCommon/ControllerInterface/Quartz/Quartz.mm index 99b31bf3ef..6fdac0e798 100644 --- a/Source/Core/InputCommon/ControllerInterface/Quartz/Quartz.mm +++ b/Source/Core/InputCommon/ControllerInterface/Quartz/Quartz.mm @@ -2,8 +2,8 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. -#include "InputCommon/ControllerInterface/ControllerInterface.h" #include "InputCommon/ControllerInterface/Quartz/Quartz.h" +#include "InputCommon/ControllerInterface/ControllerInterface.h" #include "InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.h" namespace ciface @@ -18,5 +18,5 @@ void Init(void* window) void DeInit() { } -} // namespace Quartz -} // namespace ciface +} // namespace Quartz +} // namespace ciface diff --git a/Source/Core/InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.h b/Source/Core/InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.h index 209e6d8436..0f5eafc895 100644 --- a/Source/Core/InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.h +++ b/Source/Core/InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.h @@ -24,7 +24,6 @@ private: private: CGKeyCode m_keycode; - std::string m_name; }; class Cursor : public Input @@ -71,5 +70,5 @@ private: uint32_t m_windowid; }; -} // namespace Quartz -} // namespace ciface +} // namespace Quartz +} // namespace ciface diff --git a/Source/Core/InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.mm b/Source/Core/InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.mm index d3a8b8d535..0a00337a00 100644 --- a/Source/Core/InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.mm +++ b/Source/Core/InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.mm @@ -13,10 +13,18 @@ namespace ciface { namespace Quartz { - KeyboardAndMouse::Key::Key(CGKeyCode keycode) : m_keycode(keycode) { - static const struct PrettyKeys +} + +ControlState KeyboardAndMouse::Key::GetState() const +{ + return CGEventSourceKeyState(kCGEventSourceStateHIDSystemState, m_keycode) != 0; +} + +std::string KeyboardAndMouse::Key::GetName() const +{ + static const struct { const CGKeyCode code; const char* const name; @@ -122,27 +130,12 @@ KeyboardAndMouse::Key::Key(CGKeyCode keycode) : m_keycode(keycode) }; for (auto& named_key : named_keys) - { if (named_key.code == m_keycode) - { - m_name = named_key.name; - return; - } - } + return named_key.name; std::stringstream ss; - ss << "Key " << keycode; - m_name = ss.str(); -} - -ControlState KeyboardAndMouse::Key::GetState() const -{ - return CGEventSourceKeyState(kCGEventSourceStateHIDSystemState, m_keycode) != 0; -} - -std::string KeyboardAndMouse::Key::GetName() const -{ - return m_name; + ss << "Key " << m_keycode; + return ss.str(); } KeyboardAndMouse::KeyboardAndMouse(void* window) @@ -231,5 +224,5 @@ std::string KeyboardAndMouse::Button::GetName() const return "Right Click"; return std::string("Click ") + char('0' + m_button); } -} // namespace Quartz -} // namespace ciface +} // namespace Quartz +} // namespace ciface