-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInputs.java
More file actions
98 lines (72 loc) · 4 KB
/
Inputs.java
File metadata and controls
98 lines (72 loc) · 4 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// 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 frc.robot;
import org.assabet.aztechs157.input.layouts.DynamicLayout;
import org.assabet.aztechs157.input.layouts.Layout;
import org.assabet.aztechs157.input.layouts.MapLayout;
import java.util.function.DoubleSupplier;
import org.assabet.aztechs157.input.models.XboxOne;
import org.assabet.aztechs157.input.values.Axis;
import org.assabet.aztechs157.input.values.Button;
import org.assabet.aztechs157.numbers.Deadzone;
import org.assabet.aztechs157.numbers.Range;
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
import frc.robot.Constants.ControllerConstants;
/** Add your docs here. */
public class Inputs extends DynamicLayout {
public static final Axis.Key precisionDrive = new Axis.Key();
//////////////////////////////////////////////////////////
// HERE'S AN EXAMPLE OF USING ADDING NEW BUTTONS/AXIS
/////////////////////////////////////////////////////////
// public static final Button.Key resetGyro = new Button.Key();
// public static final Button.Key driveToSpeaker = new Button.Key();
// public static final Button.Key driveToAmp = new Button.Key();
// public static final Button.Key autoIntake = new Button.Key();
// public static final Button.Key intake = new Button.Key();
// public static final Button.Key loadNote = new Button.Key();
// public static final Button.Key eject = new Button.Key();
// public static final Button.Key highShotSpinUp = new Button.Key();
// public static final Button.Key lowShotSpinUp = new Button.Key();
// public static final Button.Key highShot = new Button.Key();
// public static final Button.Key lowShot = new Button.Key();
// public static final Button.Key pass = new Button.Key();
// public static final Button.Key liftHanger = new Button.Key();
// public static final Button.Key retractHanger = new Button.Key();
// public static final Button.Key retractHangerPin = new Button.Key();
// public static final Button.Key extendHangerPin = new Button.Key();
public static Inputs createFromChooser() {
final SendableChooser<Layout> chooser = new SendableChooser<>();
chooser.setDefaultOption("xbox", doubleXBOXLayout());
Shuffleboard.getTab("Driver").add("Layout Choose", chooser);
return new Inputs(chooser);
}
private Inputs(final SendableChooser<Layout> chooser) {
super(chooser::getSelected);
}
private static Layout doubleXBOXLayout() {
final var layout = new MapLayout();
final var driver = new XboxOne(ControllerConstants.DRIVER_CONTROLLER_PORT);
final var operator = new XboxOne(ControllerConstants.OPERATOR_CONTROLLER_PORT);
layout.assign(precisionDrive, driver.leftTriggerHeld.map(Deadzone.forAxis(new Range(0.0, 0.05))::apply).scaledBy(0.7));
//////////////////////////////////////////////////////////
// HERE'S AN EXAMPLE OF USING CONTROLER LAYOUT OPTIONS
/////////////////////////////////////////////////////////
// layout.assign(driveToSpeaker, operator.a);
// layout.assign(driveToAmp, operator.b);
// layout.assign(resetGyro, driver.start);
// layout.assign(autoIntake, operator.leftBumper);
// layout.assign(intake, driver.leftBumper);
// layout.assign(loadNote, operator.x);
// layout.assign(highShotSpinUp, operator.rightBumper);
// layout.assign(lowShotSpinUp, operator.leftBumper);
// layout.assign(highShot, new Button(() -> driver.rightTriggerHeld.get() > 0.2));
// layout.assign(lowShot, driver.rightBumper);
// layout.assign(pass, operator.a);
// layout.assign(eject, operator.b);
// layout.assign(liftHanger, operator.pov.up);
// layout.assign(retractHanger, operator.pov.down);
return layout;
}
}