mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-27 02:01:42 +00:00
Added Joystick::GetAxisType() (#98)
This commit is contained in:
committed by
Peter Johnson
parent
62a980d3c8
commit
6ef4745d86
@@ -96,7 +96,7 @@ class Joystick : public GenericHID, public ErrorBase {
|
||||
Joystick::HIDType GetType() const;
|
||||
std::string GetName() const;
|
||||
int GetPort() const;
|
||||
int GetAxisType(uint8_t axis) const;
|
||||
int GetAxisType(int axis) const;
|
||||
|
||||
int GetAxisCount() const;
|
||||
int GetButtonCount() const;
|
||||
|
||||
@@ -284,10 +284,14 @@ std::string Joystick::GetName() const { return m_ds.GetJoystickName(m_port); }
|
||||
*/
|
||||
int Joystick::GetPort() const { return m_port; }
|
||||
|
||||
// int Joystick::GetAxisType(uint8_t axis) const
|
||||
//{
|
||||
// return m_ds.GetJoystickAxisType(m_port, axis);
|
||||
//}
|
||||
/**
|
||||
* Get the axis type of a joystick axis.
|
||||
*
|
||||
* @return the axis type of a joystick axis.
|
||||
*/
|
||||
int Joystick::GetAxisType(int axis) const {
|
||||
return m_ds.GetJoystickAxisType(m_port, axis);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of axis for a joystick.
|
||||
|
||||
@@ -436,6 +436,25 @@ public class DriverStation implements RobotState.Interface {
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the types of Axes on a given joystick port.
|
||||
*
|
||||
* @param stick The joystick port number
|
||||
* @param axis The target axis
|
||||
* @return What type of axis the axis is reporting to be
|
||||
*/
|
||||
public int getJoystickAxisType(int stick, int axis) {
|
||||
if (stick < 0 || stick >= kJoystickPorts) {
|
||||
throw new RuntimeException("Joystick index is out of range, should be 0-5");
|
||||
}
|
||||
|
||||
int retVal = -1;
|
||||
synchronized (m_joystickMutex) {
|
||||
retVal = HAL.getJoystickAxisType((byte) stick, (byte) axis);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a value indicating whether the Driver Station requires the robot to be enabled.
|
||||
*
|
||||
|
||||
@@ -387,6 +387,15 @@ public class Joystick extends GenericHID {
|
||||
return m_port;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the axis type of a joystick axis.
|
||||
*
|
||||
* @return the axis type of a joystick axis.
|
||||
*/
|
||||
public int getAxisType(int axis) {
|
||||
return m_ds.getJoystickAxisType(m_port, axis);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the rumble output for the joystick. The DS currently supports 2 rumble values, left rumble
|
||||
* and right rumble.
|
||||
|
||||
Reference in New Issue
Block a user