mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-05 03:21:42 +00:00
[wpilib,commands] Use Jinja to generate HID classes (#6274)
This commit is contained in:
@@ -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 %}
|
||||
Reference in New Issue
Block a user