コード例 #1
0
void Joydrive::drive(void)
{
    int trans, rot;
    int pan, tilt;
    int zoom, nothing;

    // if both buttons are pushed, zoom the joystick
    if (myJoyHandler.haveJoystick() && myJoyHandler.getButton(1) &&
            myJoyHandler.getButton(2))
    {
        // set its speed so we get desired value range, we only care about y
        myJoyHandler.setSpeeds(0, myZoomValCamera);
        // get the values
        myJoyHandler.getAdjusted(&nothing, &zoom);
        // zoom the camera
        myCam.zoomRel(zoom);
    }
    // if both buttons aren't pushed, see if one button is pushed
    else
    {
        // if button one is pushed, drive the robot
        if (myJoyHandler.haveJoystick() && myJoyHandler.getButton(1))
        {
            // set the speed on the joystick so we get the values we want
            myJoyHandler.setSpeeds(myRotValRobot, myTransValRobot);
            // get the values
            myJoyHandler.getAdjusted(&rot, &trans);
            // set the robots speed
            myRobot->setVel(trans);
            myRobot->setRotVel(-rot);
        }
        // if button one isn't pushed, stop the robot
        else
        {
            myRobot->setVel(0);
            myRobot->setRotVel(0);
        }
        // if button two is pushed, move the camera
        if (myJoyHandler.haveJoystick() && myJoyHandler.getButton(2))
        {
            // set the speeds on the joystick so we get desired value range
            myJoyHandler.setSpeeds(myPanValCamera, myTiltValCamera);
            // get the values
            myJoyHandler.getAdjusted(&pan, &tilt);
            // drive the camera
            myCam.panTiltRel(pan, tilt);
        }
    }

}
コード例 #2
0
void Joydrive::down(void)
{
    myCam.panTiltRel(0, -myUDAmount);
}
コード例 #3
0
void Joydrive::right(void)
{
    myCam.panTiltRel(myLRAmount, 0);
}
コード例 #4
0
void Joydrive::up(void)
{
    myCam.panTiltRel(0, myUDAmount);
}
コード例 #5
0
void Joydrive::left(void)
{
    myCam.panTiltRel(-myLRAmount, 0);
}