-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAttackJoystick.java
More file actions
74 lines (63 loc) · 1.48 KB
/
AttackJoystick.java
File metadata and controls
74 lines (63 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package org.scotsbots.robotbase.utils;
import edu.wpi.first.wpilibj.Joystick;
public class AttackJoystick
{
private Joystick joystick;
private static int AXIS_X = 0;
private static int AXIS_Y = 1;
private static int AXIS_Z = 2;
private static int BUTTON_TRIGGER = 1;
//TODO add the rest of the buttons
public AttackJoystick(int port)
{
joystick = new Joystick(port);
}
/**
* Returns the value of the trigger with a deadzone.
*
* @return
*/
public static double createDeadzone(double triggerValue)
{
return Math.abs(triggerValue) < 0.15 ? 0 : triggerValue;
}
/**
* Corresponds to HORIZONTAL input on the joystick.
*
* @return The X coordinate of the left joystick (-1 is LEFT, 1 is RIGHT)
*/
public double getX()
{
return createDeadzone(joystick.getRawAxis(AXIS_X));
}
/**
* Corresponds to VERTICAL input on the joystick.
*
* @return The Y coordinate of the left joystick (-1 is DOWN, 1 is UP)
*/
public double getY()
{
return createDeadzone(joystick.getRawAxis(AXIS_Y));
}
/**
* Corresponds to SPINNY THING input on the joystick.
*
* @return The Z coordinate of the left joystick (-1 is DOWN, 1 is UP)
*/
public double getZ()
{
return createDeadzone(joystick.getRawAxis(AXIS_Z));
}
/**
* Corresponds to the TRIGGER button on the joystick.
* @return
*/
public boolean getTrigger()
{
return joystick.getRawButton(BUTTON_TRIGGER);
}
public boolean getButton(int button)
{
return joystick.getRawButton(button);
}
}