[commands] HID classes: Add missing methods, tweak return types (#4557)

- Make return type of getHID reflect the specific class
- Add getX and getY to CommandJoystick
This commit is contained in:
ohowe
2022-11-02 23:51:53 -06:00
committed by GitHub
parent 1831ef3e19
commit 102344e27a
2 changed files with 20 additions and 4 deletions

View File

@@ -4,7 +4,6 @@
package edu.wpi.first.wpilibj2.command.button;
import edu.wpi.first.wpilibj.GenericHID;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.event.EventLoop;
import edu.wpi.first.wpilibj2.command.CommandScheduler;
@@ -33,7 +32,7 @@ public class CommandJoystick extends CommandGenericHID {
* @return the wrapped GenericHID object
*/
@Override
public GenericHID getHID() {
public Joystick getHID() {
return m_hid;
}
@@ -171,6 +170,24 @@ public class CommandJoystick extends CommandGenericHID {
return m_hid.getThrottleChannel();
}
/**
* Get the x position of the HID.
*
* @return the x position
*/
public double getX() {
return m_hid.getX();
}
/**
* Get the y position of the HID.
*
* @return the y position
*/
public double getY() {
return m_hid.getY();
}
/**
* Get the z position of the HID.
*

View File

@@ -4,7 +4,6 @@
package edu.wpi.first.wpilibj2.command.button;
import edu.wpi.first.wpilibj.GenericHID;
import edu.wpi.first.wpilibj.PS4Controller;
import edu.wpi.first.wpilibj.event.EventLoop;
import edu.wpi.first.wpilibj2.command.CommandScheduler;
@@ -34,7 +33,7 @@ public class CommandPS4Controller extends CommandGenericHID {
* @return the wrapped GenericHID object
*/
@Override
public GenericHID getHID() {
public PS4Controller getHID() {
return m_hid;
}