mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-28 02:11:43 +00:00
[wpilib] Implement Sendable for HID classes (#6782)
This commit is contained in:
@@ -10,6 +10,8 @@ package edu.wpi.first.wpilibj;
|
||||
|
||||
{{ "// " if SkipReporting }}import edu.wpi.first.hal.FRCNetComm.tResourceType;
|
||||
{{ "// " if SkipReporting }}import edu.wpi.first.hal.HAL;
|
||||
import edu.wpi.first.util.sendable.Sendable;
|
||||
import edu.wpi.first.util.sendable.SendableBuilder;
|
||||
import edu.wpi.first.wpilibj.event.BooleanEvent;
|
||||
import edu.wpi.first.wpilibj.event.EventLoop;
|
||||
|
||||
@@ -24,7 +26,7 @@ import edu.wpi.first.wpilibj.event.EventLoop;
|
||||
* only through the official NI DS. Sim is not guaranteed to have the same mapping, as well as any
|
||||
* 3rd party controllers.
|
||||
*/
|
||||
public class {{ ConsoleName }}Controller extends GenericHID {
|
||||
public class {{ ConsoleName }}Controller extends GenericHID implements Sendable {
|
||||
/** Represents a digital button on a {{ ConsoleName }}Controller. */
|
||||
public enum Button {
|
||||
{%- for button in buttons %}
|
||||
@@ -252,7 +254,7 @@ public class {{ ConsoleName }}Controller extends GenericHID {
|
||||
public boolean getRightBumperReleased() {
|
||||
return getRawButtonReleased(Button.kRightBumper.value);
|
||||
}
|
||||
{% elif ConsoleName == "PS4" or ConsoleName == "PS5" %}
|
||||
{%- elif ConsoleName == "PS4" or ConsoleName == "PS5" %}
|
||||
/**
|
||||
* Read the value of the touchpad on the controller.
|
||||
*
|
||||
@@ -285,5 +287,20 @@ public class {{ ConsoleName }}Controller extends GenericHID {
|
||||
public boolean getTouchpadReleased() {
|
||||
return getRawButtonReleased(Button.kTouchpad.value);
|
||||
}
|
||||
{% endif -%}
|
||||
{%- endif %}
|
||||
|
||||
@Override
|
||||
public void initSendable(SendableBuilder builder) {
|
||||
builder.setSmartDashboardType("HID");
|
||||
builder.publishConstString("ControllerType", "{{ ConsoleName }}");
|
||||
{%- for trigger in triggers %}
|
||||
builder.addDoubleProperty("{{ capitalize_first(trigger.name) }}", this::get{{ capitalize_first(trigger.name) }}Axis, null);
|
||||
{%- endfor -%}
|
||||
{% for stick in sticks %}
|
||||
builder.addDoubleProperty("{{ stick.NameParts|map("capitalize")|join }}", this::get{{ stick.NameParts|map("capitalize")|join }}, null);
|
||||
{%- endfor -%}
|
||||
{% for button in buttons %}
|
||||
builder.addBooleanProperty("{{ capitalize_first(button.name) }}", this::get{{ capitalize_first(button.name) }}Button, null);
|
||||
{%- endfor %}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user