2020-07-15 00:33:57 -07:00
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
|
|
|
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
|
|
|
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
|
|
|
|
/* the project. */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2020-07-15 23:48:09 -07:00
|
|
|
#include <stdint.h>
|
|
|
|
|
|
2020-07-15 00:33:57 -07:00
|
|
|
#include "frc/GenericHID.h"
|
|
|
|
|
|
|
|
|
|
namespace frc {
|
2020-07-15 23:48:09 -07:00
|
|
|
|
|
|
|
|
class GenericHID;
|
|
|
|
|
|
2020-07-15 00:33:57 -07:00
|
|
|
namespace sim {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class to control a simulated generic joystick.
|
|
|
|
|
*/
|
|
|
|
|
class GenericHIDSim {
|
|
|
|
|
public:
|
|
|
|
|
/**
|
|
|
|
|
* Constructs from a GenericHID object.
|
|
|
|
|
*
|
|
|
|
|
* @param joystick joystick to simulate
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
explicit GenericHIDSim(const GenericHID& 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 GenericHIDSim(int port);
|
2020-07-15 00:33:57 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Updates joystick data so that new values are visible to the user program.
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
void NotifyNewData();
|
2020-07-15 00:33:57 -07:00
|
|
|
|
2020-07-15 23:48:09 -07:00
|
|
|
void SetRawButton(int button, bool value);
|
2020-07-15 00:33:57 -07:00
|
|
|
|
2020-07-15 23:48:09 -07:00
|
|
|
void SetRawAxis(int axis, double value);
|
2020-07-15 00:33:57 -07:00
|
|
|
|
2020-07-15 23:48:09 -07:00
|
|
|
void SetPOV(int pov, int value);
|
2020-07-15 00:33:57 -07:00
|
|
|
|
2020-07-15 23:48:09 -07:00
|
|
|
void SetPOV(int value);
|
2020-07-15 00:33:57 -07:00
|
|
|
|
2020-07-15 23:48:09 -07:00
|
|
|
void SetAxisCount(int count);
|
2020-07-15 00:33:57 -07:00
|
|
|
|
2020-07-15 23:48:09 -07:00
|
|
|
void SetPOVCount(int count);
|
2020-07-15 00:33:57 -07:00
|
|
|
|
2020-07-15 23:48:09 -07:00
|
|
|
void SetButtonCount(int count);
|
2020-07-15 00:33:57 -07:00
|
|
|
|
2020-07-15 23:48:09 -07:00
|
|
|
void SetType(GenericHID::HIDType type);
|
2020-07-15 00:33:57 -07:00
|
|
|
|
2020-07-15 23:48:09 -07:00
|
|
|
void SetName(const char* name);
|
2020-07-15 00:33:57 -07:00
|
|
|
|
2020-07-15 23:48:09 -07:00
|
|
|
void SetAxisType(int axis, int type);
|
2020-07-15 00:33:57 -07:00
|
|
|
|
2020-07-15 23:48:09 -07:00
|
|
|
bool GetOutput(int outputNumber);
|
2020-07-15 00:33:57 -07:00
|
|
|
|
2020-07-15 23:48:09 -07:00
|
|
|
int64_t GetOutputs();
|
2020-07-15 00:33:57 -07:00
|
|
|
|
2020-07-15 23:48:09 -07:00
|
|
|
double GetRumble(GenericHID::RumbleType type);
|
2020-07-15 00:33:57 -07:00
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
int m_port;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace sim
|
|
|
|
|
} // namespace frc
|