コード例 #1
0
/**
 * @brief Get the distance factor that should be used for mouse movement
 * @return Distance factor that should be used for mouse movement
 */
double JoyControlStickModifierButton::getMouseDistanceFromDeadZone()
{
    return getDistanceFromDeadZone();
}
コード例 #2
0
ファイル: joycontrolstick.cpp プロジェクト: Pater1/antimicro
double JoyControlStick::calculateDirectionalDistance(JoyControlStickButton *button, JoyButton::JoyMouseMovementMode mouseMode)
{
    Q_UNUSED(mouseMode);

    double finalDistance = 0.0;

    if (currentDirection == StickUp)
    {
        finalDistance = calculateYDistanceFromDeadZone();
    }
    else if (currentDirection == StickRightUp)
    {
        if (activeButton1 && activeButton1 == button)
        {
            finalDistance = calculateXDistanceFromDeadZone();
        }
        else if (activeButton2 && activeButton2 == button)
        {
            finalDistance = calculateYDistanceFromDeadZone();
        }
        else if (activeButton3 && activeButton3 == button)
        {
            double radius = getDistanceFromDeadZone();
            double bearing = calculateBearing();
            int relativeBearing = (int)floor(bearing + 0.5) % 90;
            //bearing = round(bearing) % 90;
            int diagonalAngle = relativeBearing;
            if (relativeBearing > 45)
            {
                diagonalAngle = 90 - relativeBearing;
            }

            finalDistance = radius * (diagonalAngle / 45.0);
        }
    }
    else if (currentDirection == StickRight)
    {
        finalDistance = calculateXDistanceFromDeadZone();
    }
    else if (currentDirection  == StickRightDown)
    {
        if (activeButton1 && activeButton1 == button)
        {
            finalDistance = calculateXDistanceFromDeadZone();
        }
        else if (activeButton2 && activeButton2 == button)
        {
            finalDistance = calculateYDistanceFromDeadZone();
        }
        else if (activeButton3 && activeButton3 == button)
        {
            double radius = getDistanceFromDeadZone();
            double bearing = calculateBearing();
            int relativeBearing = (int)floor(bearing + 0.5) % 90;
            //bearing = round(bearing) % 90;
            int diagonalAngle = relativeBearing;
            if (relativeBearing > 45)
            {
                diagonalAngle = 90 - relativeBearing;
            }

            finalDistance = radius * (diagonalAngle / 45.0);
        }
    }
    else if (currentDirection == StickDown)
    {
        finalDistance = calculateYDistanceFromDeadZone();
    }
    else if (currentDirection == StickLeftDown)
    {
        if (activeButton1 && activeButton1 == button)
        {
            finalDistance = calculateXDistanceFromDeadZone();
        }
        else if (activeButton2 && activeButton2 == button)
        {
            finalDistance = calculateYDistanceFromDeadZone();
        }
        else if (activeButton3 && activeButton3 == button)
        {
            double radius = getDistanceFromDeadZone();
            double bearing = calculateBearing();
            int relativeBearing = (int)floor(bearing + 0.5) % 90;
            //bearing = round(bearing) % 90;
            int diagonalAngle = relativeBearing;
            if (relativeBearing > 45)
            {
                diagonalAngle = 90 - relativeBearing;
            }

            finalDistance = radius * (diagonalAngle / 45.0);
        }
    }
    else if (currentDirection == StickLeft)
    {
        finalDistance = calculateXDistanceFromDeadZone();
    }
    else if (currentDirection == StickLeftUp)
    {
        if (activeButton1 && activeButton1 == button)
        {
            finalDistance = calculateXDistanceFromDeadZone();
        }
        else if (activeButton2 && activeButton2 == button)
        {
            finalDistance = calculateYDistanceFromDeadZone();
        }
        else if (activeButton3 && activeButton3 == button)
        {
            double radius = getDistanceFromDeadZone();
            double bearing = calculateBearing();
            int relativeBearing = (int)floor(bearing + 0.5) % 90;
            //bearing = round(bearing) % 90;
            int diagonalAngle = relativeBearing;
            if (relativeBearing > 45)
            {
                diagonalAngle = 90 - relativeBearing;
            }

            finalDistance = radius * (diagonalAngle / 45.0);
        }
    }

    return finalDistance;
}