📄 keyboardmgr_t.cpp
字号:
// KeyboardMgr_t.cpp: implementation of the KeyboardMgr_t class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "KeyboardMgr_t.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
KeyboardMgr_t::KeyboardMgr_t()
{
m_KeyboardMap.clear();
}
KeyboardMgr_t::~KeyboardMgr_t()
{
KeyboardMap_t::iterator theIterator;
for (theIterator = m_KeyboardMap.begin(); theIterator != m_KeyboardMap.end(); theIterator++)
{
delete (*theIterator).second;
(*theIterator).second = NULL;
}
m_KeyboardMap.clear();
}
void KeyboardMgr_t::SetKeyboardMap(Hot_Key * HotKey)
{
if ( m_KeyboardMap.find(HotKey->m_Key) == m_KeyboardMap.end() )
{
m_KeyboardMap[HotKey->m_Key]= HotKey;
}
}
void KeyboardMgr_t::FireEvent(const KeyVector_t& JustPressedKeys,const KeyVector_t& PressedKeys,
const KeyVector_t& JustUnPressedKeys)
{
KeyboardMap_t::iterator theHotKeyIterator;
KeyVector_t::const_iterator theKeyIterator;
/* loop through the just pressed keys */
for (theKeyIterator = JustPressedKeys.begin(); theKeyIterator != JustPressedKeys.end(); theKeyIterator++)
{
/* this is a fast lookup since it is a map. if we find a hotkey for the
* key press, fire the event. */
theHotKeyIterator = m_KeyboardMap.find((*theKeyIterator));
if (theHotKeyIterator != m_KeyboardMap.end())
(*theHotKeyIterator).second->FireJustPressedEvent();
}
/* loop through the pressed keys */
for (theKeyIterator = PressedKeys.begin(); theKeyIterator != PressedKeys.end(); theKeyIterator++)
{
/* this is a fast lookup since it is a map. if we find a hotkey for the
* key press, fire the event. */
theHotKeyIterator = this->m_KeyboardMap.find((*theKeyIterator));
if (theHotKeyIterator != this->m_KeyboardMap.end())
(*theHotKeyIterator).second->FirePressedEvent();
}
/* loop through the just unpressed keys */
for (theKeyIterator = JustUnPressedKeys.begin(); theKeyIterator != JustUnPressedKeys.end(); theKeyIterator++)
{
/* this is a fast lookup since it is a map. if we find a hotkey for the
* key press, fire the event. */
theHotKeyIterator = this->m_KeyboardMap.find((*theKeyIterator));
if (theHotKeyIterator != this->m_KeyboardMap.end())
(*theHotKeyIterator).second->FireJustUnPressedEvent();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -