mirror of
https://github.com/Team4388/2022NoWayHome.git
synced 2026-06-09 00:38:05 -06:00
integrated xboxraw
This commit is contained in:
@@ -18,4 +18,6 @@ public interface IHandController {
|
||||
public double getRightTriggerAxis();
|
||||
|
||||
public int getDpadAngle();
|
||||
|
||||
public void updateInput();
|
||||
}
|
||||
|
||||
@@ -53,6 +53,8 @@ public class XboxController implements IHandController
|
||||
|
||||
private Joystick m_stick;
|
||||
|
||||
public void updateInput() {}
|
||||
|
||||
public static double[] ClampJoystickAxis(double x, double y) {
|
||||
double square_mag = x * x + y * y;
|
||||
double[] ret = {x,y};
|
||||
|
||||
@@ -25,15 +25,22 @@ public class XboxControllerRaw implements IHandController {
|
||||
public static final int LEFT_JOYSTICK_BUTTON = 8;
|
||||
public static final int RIGHT_JOYSTICK_BUTTON = 9;
|
||||
|
||||
private static final double DEADZONE = 0.1;
|
||||
private static final double DEADZONE = 0.08;
|
||||
|
||||
private int m_ID;
|
||||
private int m_buttons = 0;
|
||||
private int m_numButtons;
|
||||
private ByteBuffer m_buttonCountBuffer = ByteBuffer.allocateDirect(1);
|
||||
float[] m_axes = new float[HAL.kMaxJoystickAxes];
|
||||
|
||||
public XboxControllerRaw(int id) {
|
||||
m_ID = id;
|
||||
}
|
||||
|
||||
|
||||
public void updateInput() {
|
||||
HAL.getJoystickAxes((byte) 0, m_axes);
|
||||
m_buttons = HAL.getJoystickButtons((byte) 0, m_buttonCountBuffer);
|
||||
HAL.getJoystickAxes((byte) m_ID, m_axes);
|
||||
m_buttons = HAL.getJoystickButtons((byte) m_ID, m_buttonCountBuffer);
|
||||
m_numButtons = m_buttonCountBuffer.get(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package frc4388.utility.controller;
|
||||
|
||||
import edu.wpi.first.wpilibj2.command.button.Button;
|
||||
|
||||
public class XboxControllerRawButton extends Button {
|
||||
private final XboxControllerRaw m_controller;
|
||||
private final int m_buttonNumber;
|
||||
|
||||
public XboxControllerRawButton(XboxControllerRaw controller, int buttonNumber) {
|
||||
m_controller = controller;
|
||||
m_buttonNumber = buttonNumber;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean get() {
|
||||
return m_controller.getButton(m_buttonNumber);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user