BotsBurgh / BOTSBURGH-FTC-2024-25

Code for our FTC 2024-25 season robot
https://botsburgh.github.io/BOTSBURGH-FTC-2024-25/
GNU General Public License v2.0
3 stars 0 forks source link

`Input` API (AKA `GamepadEx`) #32

Closed BD103 closed 2 days ago

BD103 commented 2 weeks ago

Closes #31!

This adds the Input API, which can be used for advanced input use-cases. Normally, you can just check if a button is pressed or not by getting opMode.gamepad1.a or opMode.gamepad1.x. This enhances that functionality by also detecting presses and releases. It works by calling the update() function within the runloop, and detecting the difference in button presses.

This is inspired by last year's GamepadEx API, but has a few major differences:

  1. Input: The main API to access these inputs. Provides shortcuts for detecting presses and releases for gamepad1.
  2. GamepadEx: A class that handles the actual change detection. You can access it by getting Input.gamepad1 or Input.gamepad2.
  3. Button: An enum that represents every single boolean button. (Note that this does not support joystick positions, the trigger buttons, the touchpad, and PS4 aliases.)
BD103 commented 2 weeks ago

I'm going to write some tests before marking this as ready for review.