mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
93 lines
3.4 KiB
Django/Jinja
93 lines
3.4 KiB
Django/Jinja
// 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/{{ ConsoleName }}Controller.h"
|
|
|
|
#include <hal/FRCUsageReporting.h>
|
|
|
|
#include "frc/event/BooleanEvent.h"
|
|
|
|
using namespace frc;
|
|
|
|
{{ ConsoleName }}Controller::{{ ConsoleName }}Controller(int port) : GenericHID(port) {
|
|
{{ "// " if SkipReporting }}HAL_Report(HALUsageReporting::kResourceType_{{ ConsoleName }}Controller, port + 1);
|
|
}
|
|
{% for stick in sticks %}
|
|
double {{ ConsoleName }}Controller::Get{{ stick.NameParts|map("capitalize")|join }}() const {
|
|
return GetRawAxis(Axis::k{{ stick.NameParts|map("capitalize")|join }});
|
|
}
|
|
{% endfor -%}
|
|
{% for trigger in triggers %}
|
|
double {{ ConsoleName }}Controller::Get{{ capitalize_first(trigger.name) }}Axis() const {
|
|
return GetRawAxis(Axis::k{{ capitalize_first(trigger.name) }});
|
|
}
|
|
{% if trigger.UseThresholdMethods %}
|
|
BooleanEvent {{ ConsoleName }}Controller::{{ capitalize_first(trigger.name) }}(double threshold, EventLoop* loop) const {
|
|
return BooleanEvent(loop, [this, threshold] { return this->Get{{ capitalize_first(trigger.name) }}Axis() > threshold; });
|
|
}
|
|
|
|
BooleanEvent {{ ConsoleName }}Controller::{{ capitalize_first(trigger.name) }}(EventLoop* loop) const {
|
|
return this->{{ capitalize_first(trigger.name) }}(0.5, loop);
|
|
}
|
|
{% endif -%}
|
|
{% endfor -%}
|
|
{% for button in buttons %}
|
|
bool {{ ConsoleName }}Controller::Get{{ capitalize_first(button.name) }}Button() const {
|
|
return GetRawButton(Button::k{{ capitalize_first(button.name) }});
|
|
}
|
|
|
|
bool {{ ConsoleName }}Controller::Get{{ capitalize_first(button.name) }}ButtonPressed() {
|
|
return GetRawButtonPressed(Button::k{{ capitalize_first(button.name) }});
|
|
}
|
|
|
|
bool {{ ConsoleName }}Controller::Get{{ capitalize_first(button.name) }}ButtonReleased() {
|
|
return GetRawButtonReleased(Button::k{{ capitalize_first(button.name) }});
|
|
}
|
|
|
|
BooleanEvent {{ ConsoleName }}Controller::{{ capitalize_first(button.name) }}(EventLoop* loop) const {
|
|
return BooleanEvent(loop, [this]() { return this->Get{{ capitalize_first(button.name) }}Button(); });
|
|
}
|
|
{% endfor -%}
|
|
{% if ConsoleName == "Xbox" or ConsoleName == "Stadia"%}
|
|
bool {{ ConsoleName }}Controller::GetLeftBumper() const {
|
|
return GetRawButton(Button::kLeftBumper);
|
|
}
|
|
|
|
bool {{ ConsoleName }}Controller::GetRightBumper() const {
|
|
return GetRawButton(Button::kRightBumper);
|
|
}
|
|
|
|
bool {{ ConsoleName }}Controller::GetLeftBumperPressed() {
|
|
return GetRawButtonPressed(Button::kLeftBumper);
|
|
}
|
|
|
|
bool {{ ConsoleName }}Controller::GetRightBumperPressed() {
|
|
return GetRawButtonPressed(Button::kRightBumper);
|
|
}
|
|
|
|
bool {{ ConsoleName }}Controller::GetLeftBumperReleased() {
|
|
return GetRawButtonReleased(Button::kLeftBumper);
|
|
}
|
|
|
|
bool {{ ConsoleName }}Controller::GetRightBumperReleased() {
|
|
return GetRawButtonReleased(Button::kRightBumper);
|
|
}
|
|
{% elif ConsoleName == "PS4" or ConsoleName == "PS5" %}
|
|
bool {{ ConsoleName }}Controller::GetTouchpad() const {
|
|
return GetRawButton(Button::kTouchpad);
|
|
}
|
|
|
|
bool {{ ConsoleName }}Controller::GetTouchpadPressed() {
|
|
return GetRawButtonPressed(Button::kTouchpad);
|
|
}
|
|
|
|
bool {{ ConsoleName }}Controller::GetTouchpadReleased() {
|
|
return GetRawButtonReleased(Button::kTouchpad);
|
|
}
|
|
{% endif %}
|