mirror of
https://github.com/Team4388/2024AcrossTheRidgebotiverse.git
synced 2026-06-09 00:38:02 -06:00
Java doc my NEO auto joystick system.
This commit is contained in:
@@ -2,22 +2,39 @@ package frc4388.utility.controller;
|
||||
|
||||
import edu.wpi.first.wpilibj.GenericHID;
|
||||
|
||||
/**
|
||||
* A virtual controller that can be bound like an standard controller.
|
||||
* @author Zachary Wilke
|
||||
*/
|
||||
public class VirtualController extends GenericHID {
|
||||
private short m_buttonStates = 0;
|
||||
private short m_buttonStatesLastFrame = 0;
|
||||
private double[] m_axes = new double[6];
|
||||
private short[] m_pov = new short[1];
|
||||
|
||||
/**
|
||||
* Create an virtual controller
|
||||
* @param port virtual port (merely a formality).
|
||||
*/
|
||||
public VirtualController(int port) {
|
||||
super(port);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the curent inputs to the new frames.
|
||||
* @param axes joystick axes, (i.e. joysticks and triggers).
|
||||
* @param buttonFlags the bit packed button states.
|
||||
* @param pov the array of dpads.
|
||||
*/
|
||||
public void setFrame(double[] axes, short buttonFlags, short[] pov) {
|
||||
m_axes = axes;
|
||||
setOutputs(buttonFlags);
|
||||
m_pov = pov;
|
||||
}
|
||||
|
||||
/**
|
||||
* Zero outs the controls.
|
||||
*/
|
||||
public void zeroControls() {
|
||||
m_axes = new double[6];
|
||||
m_buttonStates = 0;
|
||||
@@ -25,6 +42,12 @@ public class VirtualController extends GenericHID {
|
||||
m_pov = new short[1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of a bitflag from an int
|
||||
* @param value int to search
|
||||
* @param index index of bit
|
||||
* @return if the bit is set
|
||||
*/
|
||||
public static boolean getFlag(int value, int index) {
|
||||
return ((value & 1 << index) != 0);
|
||||
}
|
||||
@@ -90,6 +113,10 @@ public class VirtualController extends GenericHID {
|
||||
Hopefully this isn't a problem */
|
||||
}
|
||||
|
||||
/**
|
||||
* Use {@link VirtualController#setFrame} or {@link VirtualController#setOutputs}.
|
||||
* this is an no-op overide.
|
||||
*/
|
||||
@Override
|
||||
public void setOutput(int outputNumber, boolean value) {
|
||||
// do not use
|
||||
@@ -97,12 +124,20 @@ public class VirtualController extends GenericHID {
|
||||
//m_buttonStates[outputNumber - 1] = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set buttons from a packed int, if you want to set joysticks and dpad use {@link VirtualController#SetFrame}
|
||||
*/
|
||||
@Override
|
||||
public void setOutputs(int value) {
|
||||
m_buttonStatesLastFrame = m_buttonStates;
|
||||
m_buttonStates = (short) value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Why are you Setting rumble on an virtual controller?
|
||||
* @param type the rumble type (even though it won't do anything)
|
||||
* @param value the rumble strength (always multiplyed by 0.0)
|
||||
*/
|
||||
@Override
|
||||
public void setRumble(RumbleType type, double value) {
|
||||
System.out.println("Why are you Setting rumble on an virtual controller?");
|
||||
|
||||
Reference in New Issue
Block a user