Skip to content

Commit

Permalink
Cache and directly construct BooleanEvents
Browse files Browse the repository at this point in the history
  • Loading branch information
Gold856 committed Jun 22, 2024
1 parent b89b56c commit 74806e7
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 63 deletions.
4 changes: 2 additions & 2 deletions wpilibj/src/generate/hid.java.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public class {{ ConsoleName }}Controller extends GenericHID {
* threshold, attached to the given event loop
*/
public BooleanEvent {{ trigger.name }}(double threshold, EventLoop loop) {
return new BooleanEvent(loop, () -> get{{ capitalize_first(trigger.name) }}Axis() > threshold);
return axisGreaterThan(Axis.k{{ capitalize_first(trigger.name) }}.value, threshold, loop);
}

/**
Expand Down Expand Up @@ -183,7 +183,7 @@ public class {{ ConsoleName }}Controller extends GenericHID {
* attached to the given loop.
*/
public BooleanEvent {{ button.name }}(EventLoop loop) {
return new BooleanEvent(loop, this::get{{ capitalize_first(button.name) }}Button);
return button(Button.k{{ capitalize_first(button.name) }}.value, loop);
}
{% endfor -%}
{% if ConsoleName == "Xbox" or ConsoleName == "Stadia" %}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 74806e7

Please sign in to comment.