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
|
|
|
|
|
|
2020-07-15 23:48:09 -07:00
|
|
|
#include <stdint.h>
|
|
|
|
|
|
2025-11-07 19:56:21 -05:00
|
|
|
#include "wpi/driverstation/GenericHID.hpp"
|
2026-04-18 19:56:45 -07:00
|
|
|
#include "wpi/driverstation/internal/DriverStationBackend.hpp"
|
2020-07-15 00:33:57 -07:00
|
|
|
|
2025-11-07 20:00:05 -05:00
|
|
|
namespace wpi {
|
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
|
|
|
|
2021-01-11 21:55:45 -08:00
|
|
|
/**
|
|
|
|
|
* Set the value of a given button.
|
|
|
|
|
*
|
|
|
|
|
* @param button the button to set
|
|
|
|
|
* @param value the new value
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
void SetRawButton(int button, bool value);
|
2020-07-15 00:33:57 -07:00
|
|
|
|
2021-01-11 21:55:45 -08:00
|
|
|
/**
|
|
|
|
|
* Set the value of a given axis.
|
|
|
|
|
*
|
|
|
|
|
* @param axis the axis to set
|
|
|
|
|
* @param value the new value
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
void SetRawAxis(int axis, double value);
|
2020-07-15 00:33:57 -07:00
|
|
|
|
2021-01-11 21:55:45 -08:00
|
|
|
/**
|
|
|
|
|
* Set the value of a given POV.
|
|
|
|
|
*
|
|
|
|
|
* @param pov the POV to set
|
|
|
|
|
* @param value the new value
|
|
|
|
|
*/
|
2026-04-18 19:56:45 -07:00
|
|
|
void SetPOV(int pov, POVDirection value);
|
2020-07-15 00:33:57 -07:00
|
|
|
|
2021-01-11 21:55:45 -08:00
|
|
|
/**
|
|
|
|
|
* Set the value of the default POV (port 0).
|
|
|
|
|
*
|
|
|
|
|
* @param value the new value
|
|
|
|
|
*/
|
2026-04-18 19:56:45 -07:00
|
|
|
void SetPOV(POVDirection value);
|
2020-07-15 00:33:57 -07:00
|
|
|
|
2025-10-25 23:03:50 -07:00
|
|
|
void SetAxesMaximumIndex(int maximumIndex);
|
|
|
|
|
|
2021-01-11 21:55:45 -08:00
|
|
|
/**
|
|
|
|
|
* Set the axis count of this device.
|
|
|
|
|
*
|
|
|
|
|
* @param count the new axis count
|
|
|
|
|
*/
|
2025-10-25 23:03:50 -07:00
|
|
|
void SetAxesAvailable(int count);
|
|
|
|
|
|
|
|
|
|
void SetPOVsMaximumIndex(int maximumIndex);
|
2020-07-15 00:33:57 -07:00
|
|
|
|
2021-01-11 21:55:45 -08:00
|
|
|
/**
|
|
|
|
|
* Set the POV count of this device.
|
|
|
|
|
*
|
|
|
|
|
* @param count the new POV count
|
|
|
|
|
*/
|
2025-10-25 23:03:50 -07:00
|
|
|
void SetPOVsAvailable(int count);
|
|
|
|
|
|
|
|
|
|
void SetButtonsMaximumIndex(int maximumIndex);
|
2020-07-15 00:33:57 -07:00
|
|
|
|
2021-01-11 21:55:45 -08:00
|
|
|
/**
|
|
|
|
|
* Set the button count of this device.
|
|
|
|
|
*
|
|
|
|
|
* @param count the new button count
|
|
|
|
|
*/
|
2025-10-25 23:03:50 -07:00
|
|
|
void SetButtonsAvailable(uint64_t count);
|
2020-07-15 00:33:57 -07:00
|
|
|
|
2021-01-11 21:55:45 -08:00
|
|
|
/**
|
|
|
|
|
* Set the type of this device.
|
|
|
|
|
*
|
|
|
|
|
* @param type the new device type
|
|
|
|
|
*/
|
2025-11-17 14:36:14 -08:00
|
|
|
void SetGamepadType(GenericHID::HIDType type);
|
|
|
|
|
|
|
|
|
|
void SetSupportedOutputs(GenericHID::SupportedOutputs supportedOutputs);
|
2020-07-15 00:33:57 -07:00
|
|
|
|
2021-01-11 21:55:45 -08:00
|
|
|
/**
|
|
|
|
|
* Set the name of this device.
|
|
|
|
|
*
|
|
|
|
|
* @param name the new device name
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
void SetName(const char* name);
|
2020-07-15 00:33:57 -07:00
|
|
|
|
2021-01-11 21:55:45 -08:00
|
|
|
/**
|
2025-11-17 14:36:14 -08:00
|
|
|
* Get the value of set LEDs.
|
2021-01-11 21:55:45 -08:00
|
|
|
*
|
2025-11-17 14:36:14 -08:00
|
|
|
* @return the led color
|
2021-01-11 21:55:45 -08:00
|
|
|
*/
|
2025-11-17 14:36:14 -08:00
|
|
|
int32_t GetLeds();
|
2020-07-15 00:33:57 -07:00
|
|
|
|
2021-01-11 21:55:45 -08:00
|
|
|
/**
|
|
|
|
|
* Get the joystick rumble.
|
|
|
|
|
*
|
|
|
|
|
* @param type the rumble to read
|
|
|
|
|
* @return the rumble value
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
double GetRumble(GenericHID::RumbleType type);
|
2020-07-15 00:33:57 -07:00
|
|
|
|
|
|
|
|
protected:
|
2024-01-05 07:35:59 -08:00
|
|
|
/// GenericHID port.
|
2020-07-15 00:33:57 -07:00
|
|
|
int m_port;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace sim
|
2025-11-07 20:00:05 -05:00
|
|
|
} // namespace wpi
|