diff options
| author | Michael Maltese <michael.joseph.maltese@gmail.com> | 2016-08-09 19:59:45 -0700 |
|---|---|---|
| committer | Michael Maltese <michael.joseph.maltese@gmail.com> | 2016-08-09 19:59:45 -0700 |
| commit | 0f5951e324f2685e25f04c353d14b348fc6ba6f6 (patch) | |
| tree | 0c3ef5500f9a348db9cbcdbba9c2696506f3c205 /Source/Core/InputCommon/ControllerInterface/Quartz | |
| parent | d1594f9529a99f56d7ed3fb4267efe3b893c9ce0 (diff) | |
And pull KeycodeToName into its own function
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/Quartz')
| -rw-r--r-- | Source/Core/InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.h | 3 | ||||
| -rw-r--r-- | Source/Core/InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.mm | 14 |
2 files changed, 12 insertions, 5 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.h b/Source/Core/InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.h index 3dd352a003..5c0daa6846 100644 --- a/Source/Core/InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.h +++ b/Source/Core/InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.h @@ -12,6 +12,9 @@ namespace ciface { namespace Quartz { + +std::string KeycodeToName(const CGKeyCode keycode); + class KeyboardAndMouse : public Core::Device { private: diff --git a/Source/Core/InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.mm b/Source/Core/InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.mm index 6827353913..18f3e553f3 100644 --- a/Source/Core/InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.mm +++ b/Source/Core/InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.mm @@ -11,8 +11,8 @@ namespace ciface { namespace Quartz { -KeyboardAndMouse::Key::Key(CGKeyCode keycode) : m_keycode(keycode) -{ + +std::string KeycodeToName(const CGKeyCode keycode) { static const std::map<CGKeyCode, std::string> named_keys = { {kVK_ANSI_A, "A"}, {kVK_ANSI_B, "B"}, @@ -114,10 +114,14 @@ KeyboardAndMouse::Key::Key(CGKeyCode keycode) : m_keycode(keycode) {kVK_RightOption, "Right Alt"}, }; - if (named_keys.find(m_keycode) != named_keys.end()) - m_name = named_keys.at(m_keycode); + if (named_keys.find(keycode) != named_keys.end()) + return named_keys.at(keycode); else - m_name = "Key " + std::to_string(m_keycode); + return "Key " + std::to_string(keycode); +} + +KeyboardAndMouse::Key::Key(CGKeyCode keycode) : m_keycode(keycode), m_name(KeycodeToName(keycode)) +{ } ControlState KeyboardAndMouse::Key::GetState() const |
