package org.team2471.frc.lib.io;

import java.util.function.BooleanSupplier;
import java.util.function.Function;

@FunctionalInterface
public interface ControllerButton {
  boolean get();

  default ControllerButton map(Function<Boolean, Boolean> function) {
    return () -> function.apply(get());
  }

  default ControllerButton withInvert() {
    return map(value -> !value);
  }

  default ControllerButton and(BooleanSupplier condition) {
    return map(bool -> bool && condition.getAsBoolean());
  }

  default ControllerButton or(BooleanSupplier condition) {
    return map(bool -> bool || condition.getAsBoolean());
  }
}

@@ -27,16 +27,69 @@
 ib.io;%0A%0A
+import org.team2471.frc.lib.control.CommandTrigger;%0A%0A
 import j
@@ -673,11 +673,97 @@
 ());%0A  %7D
+%0A%0A  default CommandTrigger asTrigger() %7B%0A    return new CommandTrigger(this::get);%0A  %7D
 %0A%7D%0A

add asTrigger to ControllerButton