当前位置: 首页>>代码示例>>C++>>正文


C++ JoyDPad::getCurrentDirection方法代码示例

本文整理汇总了C++中JoyDPad::getCurrentDirection方法的典型用法代码示例。如果您正苦于以下问题:C++ JoyDPad::getCurrentDirection方法的具体用法?C++ JoyDPad::getCurrentDirection怎么用?C++ JoyDPad::getCurrentDirection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JoyDPad的用法示例。


在下文中一共展示了JoyDPad::getCurrentDirection方法的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);
//.........这里部分代码省略.........
开发者ID:Xatory,项目名称:antimicro,代码行数:101,代码来源:inputdevice.cpp


注:本文中的JoyDPad::getCurrentDirection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。