Skip to content

Commit

Permalink
Add the file I forgot
Browse files Browse the repository at this point in the history
  • Loading branch information
CoffeeCoder1 committed May 22, 2024
1 parent 3b98a40 commit 03413e5
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/main/java/frc/robot/commands/HapticController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package frc.robot.commands;

import edu.wpi.first.wpilibj.XboxController;
import edu.wpi.first.wpilibj.GenericHID.RumbleType;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.Commands;

public class HapticController {
private final XboxController controller;

/**
* Creates a new HapticController
*
* @param controller
* controller
*/
public HapticController(XboxController controller) {
this.controller = controller;
}

/**
* Trigger rumble on the controller for a specified amount of time.
*
* @param type
* rumble type
* @param strength
* rumble strength (0 to 1)
* @param length
* rumble time (seconds)
*/
public Command HapticTap(RumbleType type, double strength, double length) {
return Commands.runOnce(() -> controller.setRumble(type, strength))
.andThen(Commands.waitSeconds(length))
.finallyDo(() -> controller.setRumble(RumbleType.kBothRumble, 0))
.ignoringDisable(true);
}
}

0 comments on commit 03413e5

Please sign in to comment.