本文整理汇总了C++中Gamepad::GetNumberedButton方法的典型用法代码示例。如果您正苦于以下问题:C++ Gamepad::GetNumberedButton方法的具体用法?C++ Gamepad::GetNumberedButton怎么用?C++ Gamepad::GetNumberedButton使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gamepad
的用法示例。
在下文中一共展示了Gamepad::GetNumberedButton方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TeleopPeriodic
/**
* Periodic code for teleop mode should go here.
*
* Use this method for code which will be called periodically at a regular
* rate while the robot is in teleop mode.
*/
void RobotDemo::TeleopPeriodic()
{
drive->TeleopDrive(driverPad->GetLeftY() *DRIVER_LEFT_DIRECTION, driverPad->GetRightY() *DRIVER_RIGHT_DIRECTION);
shooter->handle();
shooter->debug();
//shooter->setShooterPower(operatorPad->GetRightY());
if((intakeMode == IN_INTAKE_MANUAL_MODE) && operatorPad->GetNumberedButton(INTAKE_AUTO_MODE_BUTTON))
{
intakeMode = IN_INTAKE_AUTO_MODE;
printf ("set into auto roller mode");
intake->setExtenderMode(IN_INTAKE_AUTO_MODE);
}
//sets intake mode to auto if previously in manual and operator presses auto button
else if((intakeMode == IN_INTAKE_AUTO_MODE) && operatorPad->GetNumberedButton(INTAKE_MANUAL_MODE_BUTTON))
{
intakeMode = IN_INTAKE_MANUAL_MODE;
printf ("set into manual roller mode");
intake->setExtenderMode(IN_INTAKE_MANUAL_MODE);
}
intake->handle();
if(intakeMode == IN_INTAKE_MANUAL_MODE)
{
intake->move(operatorPad->GetLeftY()*OPERATOR_LEFT_DIRECTION);
}
else
{
//Extender DPad control
curPadDir = operatorPad->GetDPad();
if(lastPadDir != curPadDir)
{
switch(curPadDir)
{
case Gamepad::kUp:
intake->setExtenderTarget(FULL_EXTEND_DISTANCE);
break;
case Gamepad::kDown:
intake->setExtenderTarget(FULL_RETRACT_DISTANCE);
break;
default:
break;
}
}
lastPadDir = curPadDir;
}
//intake->spinRoller(operatorPad->GetRightY()*OPERATOR_RIGHT_DIRECTION);
intake->getCurrentPosition();
//if operator taps in button roller continually spins inward
if(operatorPad->GetNumberedButton(ROLLER_IN_BUTTON))
{
intakeCont = INTAKE_ROLLER_IN_STATE;
}
//if operator taps stop button roller stops continually
else if(operatorPad->GetNumberedButton(ROLLER_OFF_BUTTON))
{
intakeCont = INTAKE_ROLLER_STOP_STATE;
}
//if operator holds spit button roller spins backwards no matter what
if(operatorPad->GetNumberedButton(ROLLER_OUT_BUTTON))
{
intake->spinRoller(INTAKE_ROLLER_SPIT_POWER);
}
//not holding spit button
else
{
//roller either spins or is stopped depending on previous code
if(intakeCont)
{
intake->spinRoller(INTAKE_ROLLER_IN_POWER);
}
else
{
intake->spinRoller(INTAKE_ROLLER_STOP_POWER);
}
}
if(operatorPad->GetNumberedButton(RIGHT_TRIGGER_BUTTON)) // low shot = Right Trigger
{
shooter->initShot(SHOT_LOW_ANGLE, SHOT_LOW_SPEED);
printf("test button 1 is pressed");
}
else if(operatorPad->GetNumberedButton(LEFT_TRIGGER_BUTTON)) // pass = Left Trigger
{
//.........这里部分代码省略.........
示例2: TeleopPeriodic
void TeleopPeriodic(void) {
float x = gamepad->GetLeftX();
float y = gamepad->GetLeftY();
float rot = gamepad->GetRightX();
//small gamepad values are ignored
if (x < 0.1f && x > -0.1f)
{
x = 0;
}
if (y < 0.1f && y > -0.1f)
{
y = 0;
}
if (rot < 0.1f && rot > -0.1f)
{
rot = 0;
}
drive->MecanumDrive_Cartesian(SPEED_LIMIT * x, SPEED_LIMIT * y, SPEED_LIMIT * rot);
//shoot smoke if button is pressed
if (gamepad2->GetNumberedButton(FIRE_SMOKE_BUTTON)){
//SHOOT SMOKE!
//makingSmoke = !makingSmoke;
smoke_cannon->Set(SMOKE_CANNON_SPEED);
lcd->PrintfLine(DriverStationLCD::kUser_Line5, "Shooting");
firing_smoke_timer->Start(); //measure how long we've fired smoke, so we know if it's ok to make more
}
else
{
smoke_cannon->Set(0.0f);
lcd->PrintfLine(DriverStationLCD::kUser_Line5, "Not shooting");
firing_smoke_timer->Stop(); //stop the timer, since we're not firing smoke.
//don't reset, cuz we need to how much smoke we've fired.
}
//Eye Code
// float eye_pos = gamepad2->GetLeftX();
//
// right_eye_x->Set((eye_pos * 60) + default_eye_position);
// left_eye_x->Set((eye_pos * 60) + default_eye_position - LEFT_EYE_OFFSET);
//
// //button lock code
// if(gamepad2->GetNumberedButtonPressed(EYE_LOCK_BUTTON)){
// default_eye_position = eye_pos;
// }
//
//left eye control
//If A isn't pressed the value should stay the same as before
if (!gamepad2->GetNumberedButton(1)){
float left_joystick_x = gamepad2->GetLeftX();
float left_eye_x_axis = (1 - left_joystick_x)*60;
left_eye_val = left_eye_x_axis + 50;
float right_joystick_x = gamepad2->GetRawAxis(4);//right x axis
float right_eye_x_axis = (1-right_joystick_x)*60;
right_eye_val = right_eye_x_axis+20;
}
left_eye_x->SetAngle(left_eye_val);
right_eye_x->SetAngle(right_eye_val);
//float right_joystick_y = gamepad2->GetRawAxis(4);
//float right_eye_y_axis = (right_joystick_y+1)*60;
//right_eye_y->SetAngle(right_eye_y_axis);
/*
bool rbutton = gamepad2->GetNumberedButton(HEAD_UP_BUTTON);
bool lbutton = gamepad2->Ge tNumberedButton(HEAD_DOWN_BUTTON);
if (rbutton){
lcd->PrintfLine(DriverStationLCD::kUser_Line6, "rb pressed");
jaw_motor->Set(0.2f);
}else if(lbutton){
lcd->PrintfLine(DriverStationLCD::kUser_Line6, "lb pressed");
jaw_motor->Set(-0.15f);
}else{
lcd->PrintfLine(DriverStationLCD::kUser_Line6, "no buttons");
jaw_motor->Set(0.0f);
}
*/
//REAL head & jaw code
//move head down
if(gamepad2->GetRightX()<=-0.5f && can_move_head_down() && can_move_jaw_down()){
head_motor->Set(-0.3f);
jaw_motor->Set(0.3f);
}
//move head up
else if(gamepad2->GetNumberedButton(HEAD_UP_BUTTON) && can_move_head_up()){
head_motor->Set(0.3f);
jaw_motor->Set(-0.3f);
}
//move jaw down
else if(gamepad2->GetRightX()>=0.5f && can_move_jaw_down()){
//.........这里部分代码省略.........