mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
[hal,wpilib] Use new DS available API from mrccomm (#8302)
Instead of just having a max count for joystick values, there's an available mask of values. This is because in the future we're expecting there to be holes in the list of available buttons and axes. This updates everything to support that scenario. Also, Joystick buttons, axes, and POVs all now start at 0 instead of 1.
This commit is contained in:
@@ -22,9 +22,9 @@ import edu.wpi.first.networktables.StringPublisher;
|
||||
import edu.wpi.first.networktables.StringTopic;
|
||||
import edu.wpi.first.util.EventVector;
|
||||
import edu.wpi.first.util.WPIUtilJNI;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.OptionalDouble;
|
||||
import java.util.OptionalInt;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
@@ -33,14 +33,32 @@ public final class DriverStation {
|
||||
/** Number of Joystick ports. */
|
||||
public static final int kJoystickPorts = 6;
|
||||
|
||||
private static final long[] m_metadataCache = new long[4];
|
||||
|
||||
private static int availableToCount(long available) {
|
||||
// Top bit has to be set
|
||||
if (available < 0) {
|
||||
return 64;
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
|
||||
// Top bit not set, we will eventually get a 0 bit
|
||||
while ((available & 0x1) != 0) {
|
||||
count++;
|
||||
available >>= 1;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
private static final class HALJoystickButtons {
|
||||
public int m_buttons;
|
||||
public byte m_count;
|
||||
public long m_buttons;
|
||||
public long m_available;
|
||||
}
|
||||
|
||||
private static class HALJoystickAxes {
|
||||
public final float[] m_axes;
|
||||
public int m_count;
|
||||
public int m_available;
|
||||
|
||||
HALJoystickAxes(int count) {
|
||||
m_axes = new float[count];
|
||||
@@ -51,7 +69,7 @@ public final class DriverStation {
|
||||
public final short[] m_axes;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public int m_count;
|
||||
public int m_available;
|
||||
|
||||
HALJoystickAxesRaw(int count) {
|
||||
m_axes = new short[count];
|
||||
@@ -60,7 +78,7 @@ public final class DriverStation {
|
||||
|
||||
private static class HALJoystickPOVs {
|
||||
public final byte[] m_povs;
|
||||
public int m_count;
|
||||
public int m_available;
|
||||
|
||||
HALJoystickPOVs(int count) {
|
||||
m_povs = new byte[count];
|
||||
@@ -294,18 +312,18 @@ public final class DriverStation {
|
||||
|
||||
public void send(long timestamp) {
|
||||
HALJoystickButtons buttons = m_joystickButtons[m_stick];
|
||||
if (buttons.m_count != m_prevButtons.m_count
|
||||
if (buttons.m_available != m_prevButtons.m_available
|
||||
|| buttons.m_buttons != m_prevButtons.m_buttons) {
|
||||
appendButtons(buttons, timestamp);
|
||||
}
|
||||
|
||||
HALJoystickAxes axes = m_joystickAxes[m_stick];
|
||||
int count = axes.m_count;
|
||||
int available = axes.m_available;
|
||||
boolean needToLog = false;
|
||||
if (count != m_prevAxes.m_count) {
|
||||
if (available != m_prevAxes.m_available) {
|
||||
needToLog = true;
|
||||
} else {
|
||||
for (int i = 0; i < count; i++) {
|
||||
for (int i = 0; i < m_prevAxes.m_axes.length; i++) {
|
||||
if (axes.m_axes[i] != m_prevAxes.m_axes[i]) {
|
||||
needToLog = true;
|
||||
break;
|
||||
@@ -317,12 +335,12 @@ public final class DriverStation {
|
||||
}
|
||||
|
||||
HALJoystickPOVs povs = m_joystickPOVs[m_stick];
|
||||
count = m_joystickPOVs[m_stick].m_count;
|
||||
available = m_joystickPOVs[m_stick].m_available;
|
||||
needToLog = false;
|
||||
if (count != m_prevPOVs.m_count) {
|
||||
if (available != m_prevPOVs.m_available) {
|
||||
needToLog = true;
|
||||
} else {
|
||||
for (int i = 0; i < count; i++) {
|
||||
for (int i = 0; i < m_prevPOVs.m_povs.length; i++) {
|
||||
if (povs.m_povs[i] != m_prevPOVs.m_povs[i]) {
|
||||
needToLog = true;
|
||||
break;
|
||||
@@ -335,32 +353,32 @@ public final class DriverStation {
|
||||
}
|
||||
|
||||
void appendButtons(HALJoystickButtons buttons, long timestamp) {
|
||||
byte count = buttons.m_count;
|
||||
int count = availableToCount(buttons.m_available);
|
||||
if (m_sizedButtons == null || m_sizedButtons.length != count) {
|
||||
m_sizedButtons = new boolean[count];
|
||||
}
|
||||
int buttonsValue = buttons.m_buttons;
|
||||
long buttonsValue = buttons.m_buttons;
|
||||
for (int i = 0; i < count; i++) {
|
||||
m_sizedButtons[i] = (buttonsValue & (1 << i)) != 0;
|
||||
m_sizedButtons[i] = (buttonsValue & (1L << i)) != 0;
|
||||
}
|
||||
m_logButtons.append(m_sizedButtons, timestamp);
|
||||
m_prevButtons.m_count = count;
|
||||
m_prevButtons.m_available = buttons.m_available;
|
||||
m_prevButtons.m_buttons = buttons.m_buttons;
|
||||
}
|
||||
|
||||
void appendAxes(HALJoystickAxes axes, long timestamp) {
|
||||
int count = axes.m_count;
|
||||
int count = availableToCount(axes.m_available);
|
||||
if (m_sizedAxes == null || m_sizedAxes.length != count) {
|
||||
m_sizedAxes = new float[count];
|
||||
}
|
||||
System.arraycopy(axes.m_axes, 0, m_sizedAxes, 0, count);
|
||||
m_logAxes.append(m_sizedAxes, timestamp);
|
||||
m_prevAxes.m_count = count;
|
||||
m_prevAxes.m_available = axes.m_available;
|
||||
System.arraycopy(axes.m_axes, 0, m_prevAxes.m_axes, 0, count);
|
||||
}
|
||||
|
||||
void appendPOVs(HALJoystickPOVs povs, long timestamp) {
|
||||
int count = povs.m_count;
|
||||
int count = availableToCount(povs.m_available);
|
||||
if (m_sizedPOVs == null || m_sizedPOVs.length != count) {
|
||||
m_sizedPOVs = new long[count];
|
||||
}
|
||||
@@ -368,7 +386,7 @@ public final class DriverStation {
|
||||
m_sizedPOVs[i] = povs.m_povs[i];
|
||||
}
|
||||
m_logPOVs.append(m_sizedPOVs, timestamp);
|
||||
m_prevPOVs.m_count = count;
|
||||
m_prevPOVs.m_available = povs.m_available;
|
||||
System.arraycopy(povs.m_povs, 0, m_prevPOVs.m_povs, 0, count);
|
||||
}
|
||||
|
||||
@@ -476,11 +494,8 @@ public final class DriverStation {
|
||||
private static ControlWord m_controlWordCache = new ControlWord();
|
||||
|
||||
// Joystick button rising/falling edge flags
|
||||
private static int[] m_joystickButtonsPressed = new int[kJoystickPorts];
|
||||
private static int[] m_joystickButtonsReleased = new int[kJoystickPorts];
|
||||
|
||||
// preallocated byte buffer for button count
|
||||
private static final ByteBuffer m_buttonCountBuffer = ByteBuffer.allocateDirect(1);
|
||||
private static long[] m_joystickButtonsPressed = new long[kJoystickPorts];
|
||||
private static long[] m_joystickButtonsReleased = new long[kJoystickPorts];
|
||||
|
||||
private static final MatchDataSender m_matchDataSender;
|
||||
private static DataLogSender m_dataLogSender;
|
||||
@@ -595,25 +610,26 @@ public final class DriverStation {
|
||||
}
|
||||
|
||||
/**
|
||||
* The state of one joystick button. Button indexes begin at 1.
|
||||
* The state of one joystick button.
|
||||
*
|
||||
* @param stick The joystick to read.
|
||||
* @param button The button index, beginning at 1.
|
||||
* @param button The button index.
|
||||
* @return The state of the joystick button.
|
||||
*/
|
||||
public static boolean getStickButton(final int stick, final int button) {
|
||||
if (stick < 0 || stick >= kJoystickPorts) {
|
||||
throw new IllegalArgumentException("Joystick index is out of range, should be 0-5");
|
||||
}
|
||||
if (button <= 0) {
|
||||
reportJoystickUnpluggedError("Button indexes begin at 1 in WPILib for C++ and Java\n");
|
||||
return false;
|
||||
if (button < 0 || button >= DriverStationJNI.kMaxJoystickButtons) {
|
||||
throw new IllegalArgumentException("Joystick Button is out of range");
|
||||
}
|
||||
|
||||
long mask = 1L << button;
|
||||
|
||||
m_cacheDataMutex.lock();
|
||||
try {
|
||||
if (button <= m_joystickButtons[stick].m_count) {
|
||||
return (m_joystickButtons[stick].m_buttons & 1 << (button - 1)) != 0;
|
||||
if ((m_joystickButtons[stick].m_available & mask) != 0) {
|
||||
return (m_joystickButtons[stick].m_buttons & mask) != 0;
|
||||
}
|
||||
} finally {
|
||||
m_cacheDataMutex.unlock();
|
||||
@@ -629,27 +645,56 @@ public final class DriverStation {
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether one joystick button was pressed since the last check. Button indexes begin at 1.
|
||||
* The state of one joystick button if available.
|
||||
*
|
||||
* @param stick The joystick to read.
|
||||
* @param button The button index, beginning at 1.
|
||||
* @return Whether the joystick button was pressed since the last check.
|
||||
* @param button The button index.
|
||||
* @return The state of the joystick button, or false if the button is not available.
|
||||
*/
|
||||
public static boolean getStickButtonPressed(final int stick, final int button) {
|
||||
if (button <= 0) {
|
||||
reportJoystickUnpluggedError("Button indexes begin at 1 in WPILib for C++ and Java\n");
|
||||
return false;
|
||||
}
|
||||
public static Optional<Boolean> getStickButtonIfAvailable(final int stick, final int button) {
|
||||
if (stick < 0 || stick >= kJoystickPorts) {
|
||||
throw new IllegalArgumentException("Joystick index is out of range, should be 0-5");
|
||||
}
|
||||
if (button < 0 || button >= DriverStationJNI.kMaxJoystickButtons) {
|
||||
throw new IllegalArgumentException("Joystick Button is out of range");
|
||||
}
|
||||
|
||||
long mask = 1L << button;
|
||||
|
||||
m_cacheDataMutex.lock();
|
||||
try {
|
||||
if (button <= m_joystickButtons[stick].m_count) {
|
||||
if ((m_joystickButtons[stick].m_available & mask) != 0) {
|
||||
return Optional.of((m_joystickButtons[stick].m_buttons & mask) != 0);
|
||||
}
|
||||
} finally {
|
||||
m_cacheDataMutex.unlock();
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether one joystick button was pressed since the last check.
|
||||
*
|
||||
* @param stick The joystick to read.
|
||||
* @param button The button index.
|
||||
* @return Whether the joystick button was pressed since the last check.
|
||||
*/
|
||||
public static boolean getStickButtonPressed(final int stick, final int button) {
|
||||
if (stick < 0 || stick >= kJoystickPorts) {
|
||||
throw new IllegalArgumentException("Joystick index is out of range, should be 0-5");
|
||||
}
|
||||
if (button < 0 || button >= DriverStationJNI.kMaxJoystickButtons) {
|
||||
throw new IllegalArgumentException("Joystick Button is out of range");
|
||||
}
|
||||
|
||||
long mask = 1L << button;
|
||||
|
||||
m_cacheDataMutex.lock();
|
||||
try {
|
||||
if ((m_joystickButtons[stick].m_available & mask) != 0) {
|
||||
// If button was pressed, clear flag and return true
|
||||
if ((m_joystickButtonsPressed[stick] & 1 << (button - 1)) != 0) {
|
||||
m_joystickButtonsPressed[stick] &= ~(1 << (button - 1));
|
||||
if ((m_joystickButtonsPressed[stick] & mask) != 0) {
|
||||
m_joystickButtonsPressed[stick] &= ~mask;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@@ -669,27 +714,28 @@ public final class DriverStation {
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether one joystick button was released since the last check. Button indexes begin at 1.
|
||||
* Whether one joystick button was released since the last check.
|
||||
*
|
||||
* @param stick The joystick to read.
|
||||
* @param button The button index, beginning at 1.
|
||||
* @param button The button index, beginning at 0.
|
||||
* @return Whether the joystick button was released since the last check.
|
||||
*/
|
||||
public static boolean getStickButtonReleased(final int stick, final int button) {
|
||||
if (button <= 0) {
|
||||
reportJoystickUnpluggedError("Button indexes begin at 1 in WPILib for C++ and Java\n");
|
||||
return false;
|
||||
}
|
||||
if (stick < 0 || stick >= kJoystickPorts) {
|
||||
throw new IllegalArgumentException("Joystick index is out of range, should be 0-5");
|
||||
}
|
||||
if (button < 0 || button >= DriverStationJNI.kMaxJoystickButtons) {
|
||||
throw new IllegalArgumentException("Joystick Button is out of range");
|
||||
}
|
||||
|
||||
long mask = 1L << button;
|
||||
|
||||
m_cacheDataMutex.lock();
|
||||
try {
|
||||
if (button <= m_joystickButtons[stick].m_count) {
|
||||
if ((m_joystickButtons[stick].m_available & mask) != 0) {
|
||||
// If button was released, clear flag and return true
|
||||
if ((m_joystickButtonsReleased[stick] & 1 << (button - 1)) != 0) {
|
||||
m_joystickButtonsReleased[stick] &= ~(1 << (button - 1));
|
||||
if ((m_joystickButtonsReleased[stick] & mask) != 0) {
|
||||
m_joystickButtonsReleased[stick] &= ~mask;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@@ -724,9 +770,11 @@ public final class DriverStation {
|
||||
throw new IllegalArgumentException("Joystick axis is out of range");
|
||||
}
|
||||
|
||||
int mask = 1 << axis;
|
||||
|
||||
m_cacheDataMutex.lock();
|
||||
try {
|
||||
if (axis < m_joystickAxes[stick].m_count) {
|
||||
if ((m_joystickAxes[stick].m_available & mask) != 0) {
|
||||
return m_joystickAxes[stick].m_axes[axis];
|
||||
}
|
||||
} finally {
|
||||
@@ -742,6 +790,36 @@ public final class DriverStation {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of the axis on a joystick if available. This depends on the mapping of the
|
||||
* joystick connected to the specified port.
|
||||
*
|
||||
* @param stick The joystick to read.
|
||||
* @param axis The analog axis value to read from the joystick.
|
||||
* @return The value of the axis on the joystick, or 0 if the axis is not available.
|
||||
*/
|
||||
public static OptionalDouble getStickAxisIfAvailable(int stick, int axis) {
|
||||
if (stick < 0 || stick >= kJoystickPorts) {
|
||||
throw new IllegalArgumentException("Joystick index is out of range, should be 0-5");
|
||||
}
|
||||
if (axis < 0 || axis >= DriverStationJNI.kMaxJoystickAxes) {
|
||||
throw new IllegalArgumentException("Joystick axis is out of range");
|
||||
}
|
||||
|
||||
int mask = 1 << axis;
|
||||
|
||||
m_cacheDataMutex.lock();
|
||||
try {
|
||||
if ((m_joystickAxes[stick].m_available & mask) != 0) {
|
||||
return OptionalDouble.of(m_joystickAxes[stick].m_axes[axis]);
|
||||
}
|
||||
} finally {
|
||||
m_cacheDataMutex.unlock();
|
||||
}
|
||||
|
||||
return OptionalDouble.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the state of a POV on the joystick.
|
||||
*
|
||||
@@ -757,9 +835,11 @@ public final class DriverStation {
|
||||
throw new IllegalArgumentException("Joystick POV is out of range");
|
||||
}
|
||||
|
||||
int mask = 1 << pov;
|
||||
|
||||
m_cacheDataMutex.lock();
|
||||
try {
|
||||
if (pov < m_joystickPOVs[stick].m_count) {
|
||||
if ((m_joystickPOVs[stick].m_available & mask) != 0) {
|
||||
return POVDirection.of(m_joystickPOVs[stick].m_povs[pov]);
|
||||
}
|
||||
} finally {
|
||||
@@ -781,7 +861,7 @@ public final class DriverStation {
|
||||
* @param stick The joystick to read.
|
||||
* @return The state of the buttons on the joystick.
|
||||
*/
|
||||
public static int getStickButtons(final int stick) {
|
||||
public static long getStickButtons(final int stick) {
|
||||
if (stick < 0 || stick >= kJoystickPorts) {
|
||||
throw new IllegalArgumentException("Joystick index is out of range, should be 0-5");
|
||||
}
|
||||
@@ -795,57 +875,87 @@ public final class DriverStation {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of axes on a given joystick port.
|
||||
* Gets the maximum index of axes on a given joystick port.
|
||||
*
|
||||
* @param stick The joystick port number
|
||||
* @return The number of axes on the indicated joystick
|
||||
* @return The maximum index of axes on the indicated joystick
|
||||
*/
|
||||
public static int getStickAxisCount(int stick) {
|
||||
public static int getStickAxesMaximumIndex(int stick) {
|
||||
return availableToCount(getStickAxesAvailable(stick));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the available bitmask of axes on a given joystick port.
|
||||
*
|
||||
* @param stick The joystick port number
|
||||
* @return The number of axes available on the indicated joystick
|
||||
*/
|
||||
public static int getStickAxesAvailable(int stick) {
|
||||
if (stick < 0 || stick >= kJoystickPorts) {
|
||||
throw new IllegalArgumentException("Joystick index is out of range, should be 0-5");
|
||||
}
|
||||
|
||||
m_cacheDataMutex.lock();
|
||||
try {
|
||||
return m_joystickAxes[stick].m_count;
|
||||
return m_joystickAxes[stick].m_available;
|
||||
} finally {
|
||||
m_cacheDataMutex.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of povs on a given joystick port.
|
||||
* Gets the maximum index of povs on a given joystick port.
|
||||
*
|
||||
* @param stick The joystick port number
|
||||
* @return The number of povs on the indicated joystick
|
||||
* @return The maximum index of povs on the indicated joystick
|
||||
*/
|
||||
public static int getStickPOVCount(int stick) {
|
||||
public static int getStickPOVsMaximumIndex(int stick) {
|
||||
return availableToCount(getStickPOVsAvailable(stick));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the available bitmask of povs on a given joystick port.
|
||||
*
|
||||
* @param stick The joystick port number
|
||||
* @return The number of povs available on the indicated joystick
|
||||
*/
|
||||
public static int getStickPOVsAvailable(int stick) {
|
||||
if (stick < 0 || stick >= kJoystickPorts) {
|
||||
throw new IllegalArgumentException("Joystick index is out of range, should be 0-5");
|
||||
}
|
||||
|
||||
m_cacheDataMutex.lock();
|
||||
try {
|
||||
return m_joystickPOVs[stick].m_count;
|
||||
return m_joystickPOVs[stick].m_available;
|
||||
} finally {
|
||||
m_cacheDataMutex.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the number of buttons on a joystick.
|
||||
* Gets the maximum index of buttons on a given joystick port.
|
||||
*
|
||||
* @param stick The joystick port number
|
||||
* @return The number of buttons on the indicated joystick
|
||||
* @return The maximum index of buttons on the indicated joystick
|
||||
*/
|
||||
public static int getStickButtonCount(int stick) {
|
||||
public static int getStickButtonsMaximumIndex(int stick) {
|
||||
return availableToCount(getStickButtonsAvailable(stick));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the bitmask of buttons available.
|
||||
*
|
||||
* @param stick The joystick port number
|
||||
* @return The buttons available on the indicated joystick
|
||||
*/
|
||||
public static long getStickButtonsAvailable(int stick) {
|
||||
if (stick < 0 || stick >= kJoystickPorts) {
|
||||
throw new IllegalArgumentException("Joystick index is out of range, should be 0-5");
|
||||
}
|
||||
|
||||
m_cacheDataMutex.lock();
|
||||
try {
|
||||
return m_joystickButtons[stick].m_count;
|
||||
return m_joystickButtons[stick].m_available;
|
||||
} finally {
|
||||
m_cacheDataMutex.unlock();
|
||||
}
|
||||
@@ -893,21 +1003,6 @@ public final class DriverStation {
|
||||
return DriverStationJNI.getJoystickName((byte) stick);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 static int getJoystickAxisType(int stick, int axis) {
|
||||
if (stick < 0 || stick >= kJoystickPorts) {
|
||||
throw new IllegalArgumentException("Joystick index is out of range, should be 0-5");
|
||||
}
|
||||
|
||||
return DriverStationJNI.getJoystickAxisType((byte) stick, (byte) axis);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if a joystick is connected to the Driver Station.
|
||||
*
|
||||
@@ -918,9 +1013,9 @@ public final class DriverStation {
|
||||
* @return true if a joystick is connected
|
||||
*/
|
||||
public static boolean isJoystickConnected(int stick) {
|
||||
return getStickAxisCount(stick) > 0
|
||||
|| getStickButtonCount(stick) > 0
|
||||
|| getStickPOVCount(stick) > 0;
|
||||
return getStickAxesAvailable(stick) != 0
|
||||
|| getStickButtonsAvailable(stick) != 0
|
||||
|| getStickPOVsAvailable(stick) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1284,15 +1379,17 @@ public final class DriverStation {
|
||||
|
||||
// Get the status of all the joysticks
|
||||
for (byte stick = 0; stick < kJoystickPorts; stick++) {
|
||||
m_joystickAxesCache[stick].m_count =
|
||||
DriverStationJNI.getJoystickAxes(stick, m_joystickAxesCache[stick].m_axes);
|
||||
m_joystickAxesRawCache[stick].m_count =
|
||||
DriverStationJNI.getJoystickAxesRaw(stick, m_joystickAxesRawCache[stick].m_axes);
|
||||
m_joystickPOVsCache[stick].m_count =
|
||||
DriverStationJNI.getJoystickPOVs(stick, m_joystickPOVsCache[stick].m_povs);
|
||||
m_joystickButtonsCache[stick].m_buttons =
|
||||
DriverStationJNI.getJoystickButtons(stick, m_buttonCountBuffer);
|
||||
m_joystickButtonsCache[stick].m_count = m_buttonCountBuffer.get(0);
|
||||
DriverStationJNI.getAllJoystickData(
|
||||
stick,
|
||||
m_joystickAxesCache[stick].m_axes,
|
||||
m_joystickAxesRawCache[stick].m_axes,
|
||||
m_joystickPOVsCache[stick].m_povs,
|
||||
m_metadataCache);
|
||||
m_joystickAxesCache[stick].m_available = (int) m_metadataCache[0];
|
||||
m_joystickAxesRawCache[stick].m_available = (int) m_metadataCache[0];
|
||||
m_joystickPOVsCache[stick].m_available = (int) m_metadataCache[1];
|
||||
m_joystickButtonsCache[stick].m_available = m_metadataCache[2];
|
||||
m_joystickButtonsCache[stick].m_buttons = m_metadataCache[3];
|
||||
}
|
||||
|
||||
DriverStationJNI.getMatchInfo(m_matchInfoCache);
|
||||
@@ -1369,18 +1466,6 @@ public final class DriverStation {
|
||||
m_refreshEvents.remove(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reports errors related to unplugged joysticks Throttles the errors so that they don't overwhelm
|
||||
* the DS.
|
||||
*/
|
||||
private static void reportJoystickUnpluggedError(String message) {
|
||||
double currentTime = Timer.getTimestamp();
|
||||
if (currentTime > m_nextMessageTime) {
|
||||
reportError(message, false);
|
||||
m_nextMessageTime = currentTime + JOYSTICK_UNPLUGGED_MESSAGE_INTERVAL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reports errors related to unplugged joysticks Throttles the errors so that they don't overwhelm
|
||||
* the DS.
|
||||
|
||||
1311
wpilibj/src/main/java/edu/wpi/first/wpilibj/Gamepad.java
Normal file
1311
wpilibj/src/main/java/edu/wpi/first/wpilibj/Gamepad.java
Normal file
File diff suppressed because it is too large
Load Diff
@@ -136,7 +136,7 @@ public class GenericHID {
|
||||
* time this method was called. This is useful if you only want to call a function once when you
|
||||
* press the button.
|
||||
*
|
||||
* @param button The button index, beginning at 1.
|
||||
* @param button The button index, beginning at 0.
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getRawButtonPressed(int button) {
|
||||
@@ -150,7 +150,7 @@ public class GenericHID {
|
||||
* time this method was called. This is useful if you only want to call a function once when you
|
||||
* release the button.
|
||||
*
|
||||
* @param button The button index, beginning at 1.
|
||||
* @param button The button index, beginning at 0.
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getRawButtonReleased(int button) {
|
||||
@@ -364,13 +364,31 @@ public class GenericHID {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the maximum axis index for the joystick.
|
||||
*
|
||||
* @return the maximum axis index for the joystick
|
||||
*/
|
||||
public int getAxesMaximumIndex() {
|
||||
return DriverStation.getStickAxesMaximumIndex(m_port);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of axes for the HID.
|
||||
*
|
||||
* @return the number of axis for the current HID
|
||||
*/
|
||||
public int getAxisCount() {
|
||||
return DriverStation.getStickAxisCount(m_port);
|
||||
public int getAxesAvailable() {
|
||||
return DriverStation.getStickAxesAvailable(m_port);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the maximum POV index for the joystick.
|
||||
*
|
||||
* @return the maximum POV index for the joystick
|
||||
*/
|
||||
public int getPOVsMaximumIndex() {
|
||||
return DriverStation.getStickPOVsMaximumIndex(m_port);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -378,8 +396,17 @@ public class GenericHID {
|
||||
*
|
||||
* @return the number of POVs for the current HID
|
||||
*/
|
||||
public int getPOVCount() {
|
||||
return DriverStation.getStickPOVCount(m_port);
|
||||
public int getPOVsAvailable() {
|
||||
return DriverStation.getStickPOVsAvailable(m_port);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the maximum button index for the joystick.
|
||||
*
|
||||
* @return the maximum button index for the joystick
|
||||
*/
|
||||
public int getButtonsMaximumIndex() {
|
||||
return DriverStation.getStickButtonsMaximumIndex(m_port);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -387,8 +414,8 @@ public class GenericHID {
|
||||
*
|
||||
* @return the number of buttons for the current HID
|
||||
*/
|
||||
public int getButtonCount() {
|
||||
return DriverStation.getStickButtonCount(m_port);
|
||||
public long getButtonsAvailable() {
|
||||
return DriverStation.getStickButtonsAvailable(m_port);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -418,16 +445,6 @@ public class GenericHID {
|
||||
return DriverStation.getJoystickName(m_port);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the axis type of the provided joystick axis.
|
||||
*
|
||||
* @param axis The axis to read, starting at 0.
|
||||
* @return the axis type of the given joystick axis
|
||||
*/
|
||||
public int getAxisType(int axis) {
|
||||
return DriverStation.getJoystickAxisType(m_port, axis);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the port number of the HID.
|
||||
*
|
||||
|
||||
@@ -338,10 +338,10 @@ public final class DriverStationSim {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the state of one joystick button. Button indexes begin at 1.
|
||||
* Sets the state of one joystick button. Button indexes begin at 0.
|
||||
*
|
||||
* @param stick The joystick number
|
||||
* @param button The button index, beginning at 1
|
||||
* @param button The button index, beginning at 0
|
||||
* @param state The state of the joystick button
|
||||
*/
|
||||
public static void setJoystickButton(int stick, int button, boolean state) {
|
||||
@@ -371,13 +371,13 @@ public final class DriverStationSim {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the state of all the buttons on a joystick.
|
||||
* Sets the maximum index that an axis is available at.
|
||||
*
|
||||
* @param stick The joystick number
|
||||
* @param buttons The bitmap state of the buttons on the joystick
|
||||
* @param maximumIndex The maximum index an axis is available at.
|
||||
*/
|
||||
public static void setJoystickButtons(int stick, int buttons) {
|
||||
DriverStationDataJNI.setJoystickButtonsValue(stick, buttons);
|
||||
public static void setJoystickAxesMaximumIndex(int stick, int maximumIndex) {
|
||||
setJoystickAxesAvailable(stick, (1 << maximumIndex) - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -386,8 +386,18 @@ public final class DriverStationSim {
|
||||
* @param stick The joystick number
|
||||
* @param count The number of axes on the indicated joystick
|
||||
*/
|
||||
public static void setJoystickAxisCount(int stick, int count) {
|
||||
DriverStationDataJNI.setJoystickAxisCount(stick, count);
|
||||
public static void setJoystickAxesAvailable(int stick, int count) {
|
||||
DriverStationDataJNI.setJoystickAxesAvailable(stick, count);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the maximum index that a pov is available at.
|
||||
*
|
||||
* @param stick The joystick number
|
||||
* @param maximumIndex The maximum index a pov is available at.
|
||||
*/
|
||||
public static void setJoystickPOVsMaximumIndex(int stick, int maximumIndex) {
|
||||
setJoystickPOVsAvailable(stick, (1 << maximumIndex) - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -396,8 +406,22 @@ public final class DriverStationSim {
|
||||
* @param stick The joystick number
|
||||
* @param count The number of POVs on the indicated joystick
|
||||
*/
|
||||
public static void setJoystickPOVCount(int stick, int count) {
|
||||
DriverStationDataJNI.setJoystickPOVCount(stick, count);
|
||||
public static void setJoystickPOVsAvailable(int stick, int count) {
|
||||
DriverStationDataJNI.setJoystickPOVsAvailable(stick, count);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the maximum index that a button is available at.
|
||||
*
|
||||
* @param stick The joystick number
|
||||
* @param maximumIndex The maximum index a button is available at.
|
||||
*/
|
||||
public static void setJoystickButtonsMaximumIndex(int stick, int maximumIndex) {
|
||||
if (maximumIndex >= 64) {
|
||||
setJoystickButtonsAvailable(stick, 0xFFFFFFFFFFFFFFFFL);
|
||||
} else {
|
||||
setJoystickButtonsAvailable(stick, (1L << maximumIndex) - 1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -406,8 +430,8 @@ public final class DriverStationSim {
|
||||
* @param stick The joystick number
|
||||
* @param count The number of buttons on the indicated joystick
|
||||
*/
|
||||
public static void setJoystickButtonCount(int stick, int count) {
|
||||
DriverStationDataJNI.setJoystickButtonCount(stick, count);
|
||||
public static void setJoystickButtonsAvailable(int stick, long count) {
|
||||
DriverStationDataJNI.setJoystickButtonsAvailable(stick, count);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -440,17 +464,6 @@ public final class DriverStationSim {
|
||||
DriverStationDataJNI.setJoystickName(stick, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the types of Axes for a joystick.
|
||||
*
|
||||
* @param stick The joystick number
|
||||
* @param axis The target axis
|
||||
* @param type The type of axis
|
||||
*/
|
||||
public static void setJoystickAxisType(int stick, int axis, int type) {
|
||||
DriverStationDataJNI.setJoystickAxisType(stick, axis, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the game specific message.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,324 @@
|
||||
// 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.
|
||||
|
||||
package edu.wpi.first.wpilibj.simulation;
|
||||
|
||||
import edu.wpi.first.wpilibj.Gamepad;
|
||||
|
||||
/** Class to control a simulated Gamepad controller. */
|
||||
public class GamepadSim extends GenericHIDSim {
|
||||
/**
|
||||
* Constructs from a Gamepad object.
|
||||
*
|
||||
* @param joystick controller to simulate
|
||||
*/
|
||||
@SuppressWarnings("this-escape")
|
||||
public GamepadSim(Gamepad joystick) {
|
||||
super(joystick);
|
||||
setAxesMaximumIndex(6);
|
||||
setButtonsMaximumIndex(26);
|
||||
setPOVsMaximumIndex(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs from a joystick port number.
|
||||
*
|
||||
* @param port port number
|
||||
*/
|
||||
@SuppressWarnings("this-escape")
|
||||
public GamepadSim(int port) {
|
||||
super(port);
|
||||
setAxesMaximumIndex(6);
|
||||
setButtonsMaximumIndex(26);
|
||||
setPOVsMaximumIndex(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the left X value of the controller's joystick.
|
||||
*
|
||||
* @param value the new value
|
||||
*/
|
||||
public void setLeftX(double value) {
|
||||
setRawAxis(Gamepad.Axis.kLeftX.value, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the left Y value of the controller's joystick.
|
||||
*
|
||||
* @param value the new value
|
||||
*/
|
||||
public void setLeftY(double value) {
|
||||
setRawAxis(Gamepad.Axis.kLeftY.value, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the right X value of the controller's joystick.
|
||||
*
|
||||
* @param value the new value
|
||||
*/
|
||||
public void setRightX(double value) {
|
||||
setRawAxis(Gamepad.Axis.kRightX.value, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the right Y value of the controller's joystick.
|
||||
*
|
||||
* @param value the new value
|
||||
*/
|
||||
public void setRightY(double value) {
|
||||
setRawAxis(Gamepad.Axis.kRightY.value, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the value of the left trigger axis on the controller.
|
||||
*
|
||||
* @param value the new value
|
||||
*/
|
||||
public void setLeftTriggerAxis(double value) {
|
||||
setRawAxis(Gamepad.Axis.kLeftTrigger.value, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the value of the right trigger axis on the controller.
|
||||
*
|
||||
* @param value the new value
|
||||
*/
|
||||
public void setRightTriggerAxis(double value) {
|
||||
setRawAxis(Gamepad.Axis.kRightTrigger.value, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the value of the South Face button on the controller.
|
||||
*
|
||||
* @param value the new value
|
||||
*/
|
||||
public void setSouthFaceButton(boolean value) {
|
||||
setRawButton(Gamepad.Button.kSouthFace.value, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the value of the East Face button on the controller.
|
||||
*
|
||||
* @param value the new value
|
||||
*/
|
||||
public void setEastFaceButton(boolean value) {
|
||||
setRawButton(Gamepad.Button.kEastFace.value, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the value of the West Face button on the controller.
|
||||
*
|
||||
* @param value the new value
|
||||
*/
|
||||
public void setWestFaceButton(boolean value) {
|
||||
setRawButton(Gamepad.Button.kWestFace.value, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the value of the North Face button on the controller.
|
||||
*
|
||||
* @param value the new value
|
||||
*/
|
||||
public void setNorthFacenButton(boolean value) {
|
||||
setRawButton(Gamepad.Button.kNorthFacen.value, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the value of the Back button on the controller.
|
||||
*
|
||||
* @param value the new value
|
||||
*/
|
||||
public void setBackButton(boolean value) {
|
||||
setRawButton(Gamepad.Button.kBack.value, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the value of the Guide button on the controller.
|
||||
*
|
||||
* @param value the new value
|
||||
*/
|
||||
public void setGuideButton(boolean value) {
|
||||
setRawButton(Gamepad.Button.kGuide.value, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the value of the Start button on the controller.
|
||||
*
|
||||
* @param value the new value
|
||||
*/
|
||||
public void setStartButton(boolean value) {
|
||||
setRawButton(Gamepad.Button.kStart.value, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the value of the left stick button on the controller.
|
||||
*
|
||||
* @param value the new value
|
||||
*/
|
||||
public void setLeftStickButton(boolean value) {
|
||||
setRawButton(Gamepad.Button.kLeftStick.value, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the value of the right stick button on the controller.
|
||||
*
|
||||
* @param value the new value
|
||||
*/
|
||||
public void setRightStickButton(boolean value) {
|
||||
setRawButton(Gamepad.Button.kRightStick.value, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the value of the right shoulder button on the controller.
|
||||
*
|
||||
* @param value the new value
|
||||
*/
|
||||
public void setLeftShoulderButton(boolean value) {
|
||||
setRawButton(Gamepad.Button.kLeftShoulder.value, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the value of the right shoulder button on the controller.
|
||||
*
|
||||
* @param value the new value
|
||||
*/
|
||||
public void setRightShoulderButton(boolean value) {
|
||||
setRawButton(Gamepad.Button.kRightShoulder.value, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the value of the D-pad up button on the controller.
|
||||
*
|
||||
* @param value the new value
|
||||
*/
|
||||
public void setDpadUpButton(boolean value) {
|
||||
setRawButton(Gamepad.Button.kDpadUp.value, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the value of the D-pad down button on the controller.
|
||||
*
|
||||
* @param value the new value
|
||||
*/
|
||||
public void setDpadDownButton(boolean value) {
|
||||
setRawButton(Gamepad.Button.kDpadDown.value, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the value of the D-pad left button on the controller.
|
||||
*
|
||||
* @param value the new value
|
||||
*/
|
||||
public void setDpadLeftButton(boolean value) {
|
||||
setRawButton(Gamepad.Button.kDpadLeft.value, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the value of the D-pad right button on the controller.
|
||||
*
|
||||
* @param value the new value
|
||||
*/
|
||||
public void setDpadRightButton(boolean value) {
|
||||
setRawButton(Gamepad.Button.kDpadRight.value, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the value of the Miscellaneous 1 button on the controller.
|
||||
*
|
||||
* @param value the new value
|
||||
*/
|
||||
public void setMisc1Button(boolean value) {
|
||||
setRawButton(Gamepad.Button.kMisc1.value, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the value of the Right Paddle 1 button on the controller.
|
||||
*
|
||||
* @param value the new value
|
||||
*/
|
||||
public void setRightPaddle1Button(boolean value) {
|
||||
setRawButton(Gamepad.Button.kRightPaddle1.value, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the value of the Left Paddle 1 button on the controller.
|
||||
*
|
||||
* @param value the new value
|
||||
*/
|
||||
public void setLeftPaddle1Button(boolean value) {
|
||||
setRawButton(Gamepad.Button.kLeftPaddle1.value, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the value of the Right Paddle 2 button on the controller.
|
||||
*
|
||||
* @param value the new value
|
||||
*/
|
||||
public void setRightPaddle2Button(boolean value) {
|
||||
setRawButton(Gamepad.Button.kRightPaddle2.value, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the value of the Left Paddle 2 button on the controller.
|
||||
*
|
||||
* @param value the new value
|
||||
*/
|
||||
public void setLeftPaddle2Button(boolean value) {
|
||||
setRawButton(Gamepad.Button.kLeftPaddle2.value, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the value of the Touchpad button on the controller.
|
||||
*
|
||||
* @param value the new value
|
||||
*/
|
||||
public void setTouchpadButton(boolean value) {
|
||||
setRawButton(Gamepad.Button.kTouchpad.value, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the value of the Miscellaneous 2 button on the controller.
|
||||
*
|
||||
* @param value the new value
|
||||
*/
|
||||
public void setMisc2Button(boolean value) {
|
||||
setRawButton(Gamepad.Button.kMisc2.value, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the value of the Miscellaneous 3 button on the controller.
|
||||
*
|
||||
* @param value the new value
|
||||
*/
|
||||
public void setMisc3Button(boolean value) {
|
||||
setRawButton(Gamepad.Button.kMisc3.value, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the value of the Miscellaneous 4 button on the controller.
|
||||
*
|
||||
* @param value the new value
|
||||
*/
|
||||
public void setMisc4Button(boolean value) {
|
||||
setRawButton(Gamepad.Button.kMisc4.value, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the value of the Miscellaneous 5 button on the controller.
|
||||
*
|
||||
* @param value the new value
|
||||
*/
|
||||
public void setMisc5Button(boolean value) {
|
||||
setRawButton(Gamepad.Button.kMisc5.value, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the value of the Miscellaneous 6 button on the controller.
|
||||
*
|
||||
* @param value the new value
|
||||
*/
|
||||
public void setMisc6Button(boolean value) {
|
||||
setRawButton(Gamepad.Button.kMisc6.value, value);
|
||||
}
|
||||
}
|
||||
@@ -74,13 +74,31 @@ public class GenericHIDSim {
|
||||
setPOV(0, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the maximum axis index for this device.
|
||||
*
|
||||
* @param maximumIndex the new maximum axis index
|
||||
*/
|
||||
public void setAxesMaximumIndex(int maximumIndex) {
|
||||
DriverStationSim.setJoystickAxesMaximumIndex(m_port, maximumIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the axis count of this device.
|
||||
*
|
||||
* @param count the new axis count
|
||||
*/
|
||||
public void setAxisCount(int count) {
|
||||
DriverStationSim.setJoystickAxisCount(m_port, count);
|
||||
public void setAxesAvailable(int count) {
|
||||
DriverStationSim.setJoystickAxesAvailable(m_port, count);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the maximum POV index for this device.
|
||||
*
|
||||
* @param maximumIndex the new maximum POV index
|
||||
*/
|
||||
public void setPOVsMaximumIndex(int maximumIndex) {
|
||||
DriverStationSim.setJoystickPOVsMaximumIndex(m_port, maximumIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,8 +106,17 @@ public class GenericHIDSim {
|
||||
*
|
||||
* @param count the new POV count
|
||||
*/
|
||||
public void setPOVCount(int count) {
|
||||
DriverStationSim.setJoystickPOVCount(m_port, count);
|
||||
public void setPOVsAvailable(int count) {
|
||||
DriverStationSim.setJoystickPOVsAvailable(m_port, count);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the maximum button index for this device.
|
||||
*
|
||||
* @param maximumIndex the new maximum button index
|
||||
*/
|
||||
public void setButtonsMaximumIndex(int maximumIndex) {
|
||||
DriverStationSim.setJoystickButtonsMaximumIndex(m_port, maximumIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -97,8 +124,8 @@ public class GenericHIDSim {
|
||||
*
|
||||
* @param count the new button count
|
||||
*/
|
||||
public void setButtonCount(int count) {
|
||||
DriverStationSim.setJoystickButtonCount(m_port, count);
|
||||
public void setButtonsAvailable(long count) {
|
||||
DriverStationSim.setJoystickButtonsAvailable(m_port, count);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,16 +146,6 @@ public class GenericHIDSim {
|
||||
DriverStationSim.setJoystickName(m_port, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the type of the provided axis channel.
|
||||
*
|
||||
* @param axis the axis
|
||||
* @param type the type
|
||||
*/
|
||||
public void setAxisType(int axis, int type) {
|
||||
DriverStationSim.setJoystickAxisType(m_port, axis, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the output of a button.
|
||||
*
|
||||
|
||||
@@ -20,9 +20,9 @@ public class JoystickSim extends GenericHIDSim {
|
||||
super(joystick);
|
||||
m_joystick = joystick;
|
||||
// default to a reasonable joystick configuration
|
||||
setAxisCount(5);
|
||||
setButtonCount(12);
|
||||
setPOVCount(1);
|
||||
setAxesMaximumIndex(5);
|
||||
setButtonsMaximumIndex(12);
|
||||
setPOVsMaximumIndex(1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -34,9 +34,9 @@ public class JoystickSim extends GenericHIDSim {
|
||||
public JoystickSim(int port) {
|
||||
super(port);
|
||||
// default to a reasonable joystick configuration
|
||||
setAxisCount(5);
|
||||
setButtonCount(12);
|
||||
setPOVCount(1);
|
||||
setAxesMaximumIndex(5);
|
||||
setButtonsMaximumIndex(12);
|
||||
setPOVsMaximumIndex(1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user