本文整理汇总了C++中KeyPress::getPressed方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyPress::getPressed方法的具体用法?C++ KeyPress::getPressed怎么用?C++ KeyPress::getPressed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KeyPress
的用法示例。
在下文中一共展示了KeyPress::getPressed方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getAction
Uint32 KeyboardManager::getAction(const KeyPress& key)
{
//This is to solve a bug due to the system recieving the key-up event
//which is not included in multiple-key sequences
if(key.getPressed() || lastPresses.empty())
lastPresses.push_back(key);
int matches = 0;
KeyboardShortcut lastMatch;
for(std::list<KeyboardShortcut>::iterator i = shortcuts.begin(); i!=shortcuts.end(); ++i)
{
if(lastPresses.size() > i->getKeyPressCount())
continue;
bool matched=true;
for(size_t j=0; j<lastPresses.size(); ++j)
{
if(i->getKeyPress(j) != lastPresses[j])
{
matched=false;
break;
}
}
if(matched == true)
{
lastMatch = *i;
matches += 1;
}
}
if(matches == 0)
{
lastPresses.clear();
return GameGUIKeyActions::DoNothing;
}
else if(matches == 1)
{
lastPresses.clear();
return lastMatch.getAction();
}
return GameGUIKeyActions::DoNothing;
}