2020-12-26 14:12:05 -08:00
|
|
|
// Copyright (c) FIRST and other WPILib contributors.
|
|
|
|
|
// Open Source Software; you can modify and/or share it under the terms of
|
|
|
|
|
// the WPILib BSD license file in the root directory of this project.
|
2020-07-15 00:33:57 -07:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "frc/simulation/GenericHIDSim.h"
|
|
|
|
|
|
|
|
|
|
namespace frc {
|
2020-07-15 23:48:09 -07:00
|
|
|
|
|
|
|
|
class XboxController;
|
|
|
|
|
|
2020-07-15 00:33:57 -07:00
|
|
|
namespace sim {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class to control a simulated Xbox 360 or Xbox One controller.
|
|
|
|
|
*/
|
|
|
|
|
class XboxControllerSim : public GenericHIDSim {
|
|
|
|
|
public:
|
|
|
|
|
/**
|
|
|
|
|
* Constructs from a XboxController object.
|
|
|
|
|
*
|
|
|
|
|
* @param joystick controller to simulate
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
explicit XboxControllerSim(const XboxController& joystick);
|
2020-07-15 00:33:57 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Constructs from a joystick port number.
|
|
|
|
|
*
|
|
|
|
|
* @param port port number
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
explicit XboxControllerSim(int port);
|
|
|
|
|
|
2021-01-11 21:55:45 -08:00
|
|
|
/**
|
|
|
|
|
* Change the X value of the joystick.
|
|
|
|
|
*
|
|
|
|
|
* @param hand the joystick hand
|
|
|
|
|
* @param value the new value
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
void SetX(GenericHID::JoystickHand hand, double value);
|
|
|
|
|
|
2021-01-11 21:55:45 -08:00
|
|
|
/**
|
|
|
|
|
* Change the Y value of the joystick.
|
|
|
|
|
*
|
|
|
|
|
* @param hand the joystick hand
|
|
|
|
|
* @param value the new value
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
void SetY(GenericHID::JoystickHand hand, double value);
|
|
|
|
|
|
2021-01-11 21:55:45 -08:00
|
|
|
/**
|
|
|
|
|
* Change the value of a trigger axis on the joystick.
|
|
|
|
|
*
|
|
|
|
|
* @param hand the joystick hand
|
|
|
|
|
* @param value the new value
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
void SetTriggerAxis(GenericHID::JoystickHand hand, double value);
|
|
|
|
|
|
2021-01-11 21:55:45 -08:00
|
|
|
/**
|
|
|
|
|
* Change the value of a bumper on the joystick.
|
|
|
|
|
*
|
|
|
|
|
* @param hand the joystick hand
|
|
|
|
|
* @param state the new value
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
void SetBumper(GenericHID::JoystickHand hand, bool state);
|
|
|
|
|
|
2021-01-11 21:55:45 -08:00
|
|
|
/**
|
|
|
|
|
* Change the value of a button on the joystick.
|
|
|
|
|
*
|
|
|
|
|
* @param hand the joystick hand
|
|
|
|
|
* @param state the new value
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
void SetStickButton(GenericHID::JoystickHand hand, bool state);
|
|
|
|
|
|
2021-01-11 21:55:45 -08:00
|
|
|
/**
|
|
|
|
|
* Change the value of the A button.
|
|
|
|
|
*
|
|
|
|
|
* @param state the new value
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
void SetAButton(bool state);
|
|
|
|
|
|
2021-01-11 21:55:45 -08:00
|
|
|
/**
|
|
|
|
|
* Change the value of the B button.
|
|
|
|
|
*
|
|
|
|
|
* @param state the new value
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
void SetBButton(bool state);
|
|
|
|
|
|
2021-01-11 21:55:45 -08:00
|
|
|
/**
|
|
|
|
|
* Change the value of the X button.
|
|
|
|
|
*
|
|
|
|
|
* @param state the new value
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
void SetXButton(bool state);
|
|
|
|
|
|
2021-01-11 21:55:45 -08:00
|
|
|
/**
|
|
|
|
|
* Change the value of the Y button.
|
|
|
|
|
*
|
|
|
|
|
* @param state the new value
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
void SetYButton(bool state);
|
|
|
|
|
|
2021-01-11 21:55:45 -08:00
|
|
|
/**
|
|
|
|
|
* Change the value of the Back button.
|
|
|
|
|
*
|
|
|
|
|
* @param state the new value
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
void SetBackButton(bool state);
|
|
|
|
|
|
2021-01-11 21:55:45 -08:00
|
|
|
/**
|
|
|
|
|
* Change the value of the Start button.
|
|
|
|
|
*
|
|
|
|
|
* @param state the new value
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
void SetStartButton(bool state);
|
2020-07-15 00:33:57 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace sim
|
|
|
|
|
} // namespace frc
|