Log in

View Full Version : InternalButton based on axis inputs


fovea1959
26-09-2013, 20:25
I remember seeing a team's nice InternalButton implementation that would take a GenericHID (or Joystick?), an exis specification, and a threshold, and produce a couple of InternalButton objects ; the idea being that commands could be trigger off the joystick (or DPAD) position.

I thought I had it safely squirreled away, but it's not coming up.

Has anyone else seen this? Don't want to write something that's already out in the wild....

Joe Ross
26-09-2013, 23:05
Here it is in C++ http://www.chiefdelphi.com/forums/showpost.php?p=1235329&postcount=6

BigJ
27-09-2013, 10:31
Here's a not-quite-generic version in Java, but could easily be modified to be generic to your needs:

https://github.com/frc1675/frc1675-2013/blob/master/src/org/frc1675/DPadButton.java

edit: looking at it again, this is such a short class that "modifying it to your needs" is basically rewriting the class, haha. I also looked at the javadoc for InternalButton, and we didn't use this as one, but I'm pretty sure it could just extend InternalButton instead if you wanted access to setPressed().

fovea1959
28-09-2013, 16:16
Thanks!

and the third answer from team 2168,very similar to both the above.

https://gist.github.com/jcorcoran/5743806

comments are not quite right around the description of the constructor, but it's also nice to use.