2024-06-08 12:59:07 -04:00
|
|
|
// 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 ./wpilibj/generate_hids.py. DO NOT MODIFY
|
|
|
|
|
{% macro capitalize_first(string) -%}
|
|
|
|
|
{{ string[0]|capitalize + string[1:] }}
|
|
|
|
|
{%- endmacro %}
|
2025-11-07 19:55:43 -05:00
|
|
|
package org.wpilib.simulation;
|
2024-06-08 12:59:07 -04:00
|
|
|
|
2025-11-07 19:55:43 -05:00
|
|
|
import org.wpilib.{{ ConsoleName }}Controller;
|
2024-06-08 12:59:07 -04:00
|
|
|
|
|
|
|
|
/** Class to control a simulated {{ ConsoleName }} controller. */
|
|
|
|
|
public class {{ ConsoleName }}ControllerSim extends GenericHIDSim {
|
|
|
|
|
/**
|
|
|
|
|
* Constructs from a {{ ConsoleName }}Controller object.
|
|
|
|
|
*
|
|
|
|
|
* @param joystick controller to simulate
|
|
|
|
|
*/
|
|
|
|
|
@SuppressWarnings("this-escape")
|
|
|
|
|
public {{ ConsoleName }}ControllerSim({{ ConsoleName }}Controller joystick) {
|
|
|
|
|
super(joystick);
|
2025-10-25 23:03:50 -07:00
|
|
|
setAxesMaximumIndex({{ sticks|length + triggers|length }});
|
|
|
|
|
setButtonsMaximumIndex({{ buttons|length }});
|
|
|
|
|
setPOVsMaximumIndex(1);
|
2024-06-08 12:59:07 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Constructs from a joystick port number.
|
|
|
|
|
*
|
|
|
|
|
* @param port port number
|
|
|
|
|
*/
|
|
|
|
|
@SuppressWarnings("this-escape")
|
|
|
|
|
public {{ ConsoleName }}ControllerSim(int port) {
|
|
|
|
|
super(port);
|
2025-10-25 23:03:50 -07:00
|
|
|
setAxesMaximumIndex({{ sticks|length + triggers|length }});
|
|
|
|
|
setButtonsMaximumIndex({{ buttons|length }});
|
|
|
|
|
setPOVsMaximumIndex(1);
|
2024-06-08 12:59:07 -04:00
|
|
|
}
|
|
|
|
|
{% for stick in sticks %}
|
|
|
|
|
/**
|
|
|
|
|
* Change the {{ stick.NameParts|join(" ") }} value of the controller's joystick.
|
|
|
|
|
*
|
|
|
|
|
* @param value the new value
|
|
|
|
|
*/
|
|
|
|
|
public void set{{ stick.NameParts|map("capitalize")|join }}(double value) {
|
|
|
|
|
setRawAxis({{ ConsoleName }}Controller.Axis.k{{ stick.NameParts|map("capitalize")|join }}.value, value);
|
|
|
|
|
}
|
|
|
|
|
{% endfor -%}
|
|
|
|
|
{% for trigger in triggers %}
|
|
|
|
|
/**
|
|
|
|
|
* Change the value of the {{ trigger.DocName }} axis on the controller.
|
|
|
|
|
*
|
|
|
|
|
* @param value the new value
|
|
|
|
|
*/
|
|
|
|
|
public void set{{ capitalize_first(trigger.name) }}Axis(double value) {
|
|
|
|
|
setRawAxis({{ ConsoleName }}Controller.Axis.k{{ capitalize_first(trigger.name) }}.value, 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
|
|
|
|
|
*/
|
|
|
|
|
public void set{{ capitalize_first(button.name) }}Button(boolean value) {
|
|
|
|
|
setRawButton({{ ConsoleName }}Controller.Button.k{{ capitalize_first(button.name) }}.value, value);
|
|
|
|
|
}
|
|
|
|
|
{% endfor -%}
|
|
|
|
|
{% if ConsoleName == "Xbox" %}
|
|
|
|
|
/**
|
|
|
|
|
* Change the value of the left bumper on the joystick.
|
|
|
|
|
*
|
|
|
|
|
* @param state the new value
|
2024-10-28 22:29:42 -04:00
|
|
|
* @deprecated Use {@link setLeftBumperButton} instead. This function is deprecated for removal
|
|
|
|
|
* to make function names consistent to allow the HID classes to be automatically generated.
|
2024-06-08 12:59:07 -04:00
|
|
|
*/
|
|
|
|
|
@Deprecated(since = "2025", forRemoval = true)
|
|
|
|
|
public void setLeftBumper(boolean state) {
|
|
|
|
|
setRawButton(XboxController.Button.kLeftBumper.value, state);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Change the value of the right bumper on the joystick.
|
|
|
|
|
*
|
|
|
|
|
* @param state the new value
|
2024-10-28 22:29:42 -04:00
|
|
|
* @deprecated Use {@link setRightBumperButton} instead. This function is deprecated for removal
|
|
|
|
|
* to make function names consistent to allow the HID classes to be automatically generated.
|
2024-06-08 12:59:07 -04:00
|
|
|
*/
|
|
|
|
|
@Deprecated(since = "2025", forRemoval = true)
|
|
|
|
|
public void setRightBumper(boolean state) {
|
|
|
|
|
setRawButton(XboxController.Button.kRightBumper.value, state);
|
|
|
|
|
}
|
|
|
|
|
{% elif ConsoleName == "PS4" %}
|
|
|
|
|
/**
|
|
|
|
|
* Change the value of the touchpad button on the controller.
|
|
|
|
|
*
|
|
|
|
|
* @param value the new value
|
2024-10-28 22:29:42 -04:00
|
|
|
* @deprecated Use {@link setTouchpadButton} instead. This function is deprecated for removal to
|
|
|
|
|
* make function names consistent to allow the HID classes to be automatically generated.
|
2024-06-08 12:59:07 -04:00
|
|
|
*/
|
|
|
|
|
@Deprecated(since = "2025", forRemoval = true)
|
|
|
|
|
public void setTouchpad(boolean value) {
|
|
|
|
|
setRawButton(PS4Controller.Button.kTouchpad.value, value);
|
|
|
|
|
}
|
|
|
|
|
{% elif ConsoleName == "PS5" %}
|
|
|
|
|
/**
|
|
|
|
|
* Change the value of the touchpad button on the controller.
|
|
|
|
|
*
|
|
|
|
|
* @param value the new value
|
2024-10-28 22:29:42 -04:00
|
|
|
* @deprecated Use {@link setTouchpadButton} instead. This function is deprecated for removal to
|
|
|
|
|
* make function names consistent to allow the HID classes to be automatically generated.
|
2024-06-08 12:59:07 -04:00
|
|
|
*/
|
|
|
|
|
@Deprecated(since = "2025", forRemoval = true)
|
|
|
|
|
public void setTouchpad(boolean value) {
|
|
|
|
|
setRawButton(PS5Controller.Button.kTouchpad.value, value);
|
|
|
|
|
}
|
|
|
|
|
{% endif -%}
|
|
|
|
|
}
|