[wpilib,commands] Use Jinja to generate HID classes (#6274)

This commit is contained in:
Gold856
2024-06-08 12:59:07 -04:00
committed by GitHub
parent a0efc9ca31
commit 65c6306047
75 changed files with 7622 additions and 4546 deletions

View File

@@ -0,0 +1,42 @@
// 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 %}
#include "frc/simulation/{{ ConsoleName }}ControllerSim.h"
#include "frc/{{ ConsoleName }}Controller.h"
using namespace frc;
using namespace frc::sim;
{{ ConsoleName }}ControllerSim::{{ ConsoleName }}ControllerSim(const {{ ConsoleName }}Controller& joystick)
: GenericHIDSim{joystick} {
SetAxisCount({{ sticks|length + triggers|length }});
SetButtonCount({{ buttons|length }});
SetPOVCount(1);
}
{{ ConsoleName }}ControllerSim::{{ ConsoleName }}ControllerSim(int port) : GenericHIDSim{port} {
SetAxisCount({{ sticks|length + triggers|length }});
SetButtonCount({{ buttons|length }});
SetPOVCount(1);
}
{% for stick in sticks %}
void {{ ConsoleName }}ControllerSim::Set{{ stick.NameParts|map("capitalize")|join }}(double value) {
SetRawAxis({{ ConsoleName }}Controller::Axis::k{{ stick.NameParts|map("capitalize")|join }}, value);
}
{% endfor -%}
{% for trigger in triggers %}
void {{ ConsoleName }}ControllerSim::Set{{ capitalize_first(trigger.name) }}Axis(double value) {
SetRawAxis({{ ConsoleName }}Controller::Axis::k{{ capitalize_first(trigger.name) }}, value);
}
{% endfor -%}
{% for button in buttons %}
void {{ ConsoleName }}ControllerSim::Set{{ capitalize_first(button.name) }}Button(bool value) {
SetRawButton({{ ConsoleName }}Controller::Button::k{{ capitalize_first(button.name) }}, value);
}
{% endfor %}