本文整理汇总了C++中JoyDPadButton::getWhileHeldStatus方法的典型用法代码示例。如果您正苦于以下问题:C++ JoyDPadButton::getWhileHeldStatus方法的具体用法?C++ JoyDPadButton::getWhileHeldStatus怎么用?C++ JoyDPadButton::getWhileHeldStatus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JoyDPadButton
的用法示例。
在下文中一共展示了JoyDPadButton::getWhileHeldStatus方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setActiveSetNumber
void InputDevice::setActiveSetNumber(int index)
{
if ((index >= 0 && index < NUMBER_JOYSETS) && (index != active_set))
{
QList<bool> buttonstates;
QList<int> axesstates;
QList<int> dpadstates;
// Grab current states for all elements in old set
SetJoystick *current_set = joystick_sets.value(active_set);
SetJoystick *old_set = current_set;
for (int i = 0; i < current_set->getNumberButtons(); i++)
{
JoyButton *button = current_set->getJoyButton(i);
buttonstates.append(button->getButtonState());
}
for (int i = 0; i < current_set->getNumberAxes(); i++)
{
JoyAxis *axis = current_set->getJoyAxis(i);
axesstates.append(axis->getCurrentRawValue());
}
for (int i = 0; i < current_set->getNumberHats(); i++)
{
JoyDPad *dpad = current_set->getJoyDPad(i);
dpadstates.append(dpad->getCurrentDirection());
}
// Release all current pressed elements and change set number
joystick_sets.value(active_set)->release();
active_set = index;
// Activate all buttons in the switched set
current_set = joystick_sets.value(active_set);
for (int i = 0; i < current_set->getNumberButtons(); i++)
{
bool value = buttonstates.at(i);
bool tempignore = true;
JoyButton *button = current_set->getJoyButton(i);
JoyButton *oldButton = old_set->getJoyButton(i);
if (button->getChangeSetCondition() == JoyButton::SetChangeWhileHeld)
{
if (value)
{
if (oldButton->getChangeSetCondition() == JoyButton::SetChangeWhileHeld && oldButton->getWhileHeldStatus())
{
// Button from old set involved in a while held set
// change. Carry over to new set button to ensure
// set changes are done in the proper order.
button->setWhileHeldStatus(true);
}
else if (!button->getWhileHeldStatus())
{
// Ensure that set change events are performed if needed.
tempignore = false;
}
}
else
{
// Ensure that set change events are performed if needed.
button->setWhileHeldStatus(false);
//tempignore = false;
}
}
button->joyEvent(value, tempignore);
}
// Activate all axis buttons in the switched set
for (int i = 0; i < current_set->getNumberAxes(); i++)
{
int value = axesstates.at(i);
bool tempignore = true;
JoyAxis *axis = current_set->getJoyAxis(i);
JoyAxisButton *oldButton = old_set->getJoyAxis(i)->getAxisButtonByValue(value);
JoyAxisButton *button = axis->getAxisButtonByValue(value);
if (button && oldButton)
{
if (button->getChangeSetCondition() == JoyButton::SetChangeWhileHeld)
{
if (oldButton->getChangeSetCondition() == JoyButton::SetChangeWhileHeld && oldButton->getWhileHeldStatus())
{
// Button from old set involved in a while held set
// change. Carry over to new set button to ensure
// set changes are done in the proper order.
button->setWhileHeldStatus(true);
}
else if (!button->getWhileHeldStatus())
{
// Ensure that set change events are performed if needed.
tempignore = false;
}
}
}
else if (!button)
{
// Ensure that set change events are performed if needed.
axis->getPAxisButton()->setWhileHeldStatus(false);
//.........这里部分代码省略.........