mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-01 02:41:48 +00:00
[wpilib,commands] Use Jinja to generate HID classes (#6274)
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
// 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.
|
||||
|
||||
// THIS FILE WAS AUTO-GENERATED BY ./wpilibc/generate_hids.py. DO NOT MODIFY
|
||||
{% macro capitalize_first(string) -%}
|
||||
{{ string[0]|capitalize + string[1:] }}
|
||||
{%- endmacro %}
|
||||
#pragma once
|
||||
|
||||
#include "frc/simulation/GenericHIDSim.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class {{ ConsoleName }}Controller;
|
||||
|
||||
namespace sim {
|
||||
|
||||
/**
|
||||
* Class to control a simulated {{ ConsoleName }} controller.
|
||||
*/
|
||||
class {{ ConsoleName }}ControllerSim : public GenericHIDSim {
|
||||
public:
|
||||
/**
|
||||
* Constructs from a {{ ConsoleName }}Controller object.
|
||||
*
|
||||
* @param joystick controller to simulate
|
||||
*/
|
||||
explicit {{ ConsoleName }}ControllerSim(const {{ ConsoleName }}Controller& joystick);
|
||||
|
||||
/**
|
||||
* Constructs from a joystick port number.
|
||||
*
|
||||
* @param port port number
|
||||
*/
|
||||
explicit {{ ConsoleName }}ControllerSim(int port);
|
||||
{% for stick in sticks %}
|
||||
/**
|
||||
* Change the {{ stick.NameParts|join(" ") }} value of the controller's joystick.
|
||||
*
|
||||
* @param value the new value
|
||||
*/
|
||||
void Set{{ stick.NameParts|map("capitalize")|join }}(double value);
|
||||
{% endfor -%}
|
||||
{% for trigger in triggers %}
|
||||
/**
|
||||
* Change the value of the {{ trigger.DocName }} axis on the controller.
|
||||
*
|
||||
* @param value the new value
|
||||
*/
|
||||
void Set{{ capitalize_first(trigger.name) }}Axis(double value);
|
||||
{% endfor -%}
|
||||
{% for button in buttons %}
|
||||
/**
|
||||
* Change the value of the {{ button.DocName|default(button.name) }} button on the controller.
|
||||
*
|
||||
* @param value the new value
|
||||
*/
|
||||
void Set{{ capitalize_first(button.name) }}Button(bool value);
|
||||
{% endfor -%}
|
||||
{% if ConsoleName == "Xbox" %}
|
||||
/**
|
||||
* Change the left bumper value of the joystick.
|
||||
*
|
||||
* @param value the new value
|
||||
*/
|
||||
[[deprecated("Use SetLeftBumperButton instead")]]
|
||||
void SetLeftBumper(bool value);
|
||||
|
||||
/**
|
||||
* Change the right bumper value of the joystick.
|
||||
*
|
||||
* @param value the new value
|
||||
*/
|
||||
[[deprecated("Use SetRightBumperButton instead")]]
|
||||
void SetRightBumper(bool value);
|
||||
{% elif ConsoleName == "PS4" or ConsoleName == "PS5" %}
|
||||
/**
|
||||
* Change the value of the touchpad button on the controller.
|
||||
*
|
||||
* @param value the new value
|
||||
*/
|
||||
[[deprecated("Use SetTouchpadButton instead")]]
|
||||
void SetTouchpad(bool value);
|
||||
{% endif %}
|
||||
};
|
||||
|
||||
} // namespace sim
|
||||
} // namespace frc
|
||||
Reference in New Issue
Block a user