Skip to content

Commit

Permalink
Updated logitech controller to F310
Browse files Browse the repository at this point in the history
  • Loading branch information
briansemrau committed Feb 22, 2018
1 parent 8c6983a commit 2e974da
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 33 deletions.
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
package org.usfirst.frc.team4737.lib;

public class LogitechGamepad extends Gamepad {

private class LogitechGamepadTriggerAxis extends GamepadAxis {

private final boolean positive;

public LogitechGamepadTriggerAxis(Gamepad gamepad, String name, int axis, boolean positive) {
super(gamepad, name, axis);

this.positive = positive;
}

@Override
public double get() {
double value = super.get();
if (value > 0 && positive)
return value;
else if (value < 0 && !positive)
return -value;
else
return 0;
}

}
public class F310Gamepad extends Gamepad {

// private class LogitechGamepadTriggerAxis extends GamepadAxis {
//
// private final boolean positive;
//
// public LogitechGamepadTriggerAxis(Gamepad gamepad, String name, int axis, boolean positive) {
// super(gamepad, name, axis);
//
// this.positive = positive;
// }
//
// @Override
// public double get() {
// double value = super.get();
// if (value > 0 && positive)
// return value;
// else if (value < 0 && !positive)
// return -value;
// else
// return 0;
// }
//
// }

public final GamepadButton A;
public final GamepadButton B;
Expand All @@ -39,12 +39,14 @@ else if (value < 0 && !positive)
public final Thumbstick LS;
public final Thumbstick RS;

public final LogitechGamepadTriggerAxis LT;
public final LogitechGamepadTriggerAxis RT;
// public final LogitechGamepadTriggerAxis LT;
// public final LogitechGamepadTriggerAxis RT;
public final GamepadAxis LT;
public final GamepadAxis RT;

public final DPad DPAD;

public LogitechGamepad(int usbPort) {
public F310Gamepad(int usbPort) {
super(usbPort, "LogitechGamepad");
A = new GamepadButton(this, "A", 1);
B = new GamepadButton(this, "B", 2);
Expand All @@ -60,11 +62,13 @@ public LogitechGamepad(int usbPort) {
R3 = new GamepadButton(this, "R3", 10);
registerButton(R3, "RS");

LS = new Thumbstick(this, "LS", 1, 2);
LS = new Thumbstick(this, "LS", 0, 1);
RS = new Thumbstick(this, "RS", 4, 5);

LT = new LogitechGamepadTriggerAxis(this, "LT", 3, true);
RT = new LogitechGamepadTriggerAxis(this, "RT", 3, false);
// LT = new LogitechGamepadTriggerAxis(this, "LT", 2, true);
// RT = new LogitechGamepadTriggerAxis(this, "RT", 3, false);
LT = new GamepadAxis(this, "LT", 2);
RT = new GamepadAxis(this, "RT", 3);

DPAD = new DPad(this, "DPAD", 0);
}
Expand Down
6 changes: 3 additions & 3 deletions src/org/usfirst/frc/team4737/robot/OI.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
package org.usfirst.frc.team4737.robot;

import org.usfirst.frc.team4737.lib.Gamepad;
import org.usfirst.frc.team4737.lib.LogitechGamepad;
import org.usfirst.frc.team4737.lib.F310Gamepad;
import org.usfirst.frc.team4737.robot.commands.ControlElevator;
import org.usfirst.frc.team4737.robot.commands.ControlIntake;
import org.usfirst.frc.team4737.robot.commands.ReverseIntake;
Expand Down Expand Up @@ -54,8 +54,8 @@ public class OI {
public Gamepad operator;

public OI() {
driver = new LogitechGamepad(0);
operator = new LogitechGamepad(1);
driver = new F310Gamepad(0);
operator = new F310Gamepad(1);

// User override to take control of the intake
new Trigger() {
Expand Down

0 comments on commit 2e974da

Please sign in to comment.