clang-format and cleaning up Key::GetName

This commit is contained in:
Michael Maltese 2016-08-09 17:23:30 -07:00
parent 3889e4d4b2
commit 6097d30288
3 changed files with 20 additions and 28 deletions

View File

@ -2,8 +2,8 @@
// Licensed under GPLv2+ // Licensed under GPLv2+
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include "InputCommon/ControllerInterface/ControllerInterface.h"
#include "InputCommon/ControllerInterface/Quartz/Quartz.h" #include "InputCommon/ControllerInterface/Quartz/Quartz.h"
#include "InputCommon/ControllerInterface/ControllerInterface.h"
#include "InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.h" #include "InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.h"
namespace ciface namespace ciface

View File

@ -24,7 +24,6 @@ private:
private: private:
CGKeyCode m_keycode; CGKeyCode m_keycode;
std::string m_name;
}; };
class Cursor : public Input class Cursor : public Input

View File

@ -13,10 +13,18 @@ namespace ciface
{ {
namespace Quartz namespace Quartz
{ {
KeyboardAndMouse::Key::Key(CGKeyCode keycode) : m_keycode(keycode) 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 CGKeyCode code;
const char* const name; const char* const name;
@ -122,27 +130,12 @@ KeyboardAndMouse::Key::Key(CGKeyCode keycode) : m_keycode(keycode)
}; };
for (auto& named_key : named_keys) for (auto& named_key : named_keys)
{
if (named_key.code == m_keycode) if (named_key.code == m_keycode)
{ return named_key.name;
m_name = named_key.name;
return;
}
}
std::stringstream ss; std::stringstream ss;
ss << "Key " << keycode; ss << "Key " << m_keycode;
m_name = ss.str(); return ss.str();
}
ControlState KeyboardAndMouse::Key::GetState() const
{
return CGEventSourceKeyState(kCGEventSourceStateHIDSystemState, m_keycode) != 0;
}
std::string KeyboardAndMouse::Key::GetName() const
{
return m_name;
} }
KeyboardAndMouse::KeyboardAndMouse(void* window) KeyboardAndMouse::KeyboardAndMouse(void* window)