generated from vexide/vexide-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: automatically terminate ui task on controller interaction
- Loading branch information
Showing
2 changed files
with
44 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use vexide_devices::controller::Controller; | ||
|
||
pub fn has_interaction(controller: &Controller) -> bool { | ||
let state = controller.state().unwrap_or_default(); | ||
state.button_a.is_pressed() | ||
|| state.button_b.is_pressed() | ||
|| state.button_x.is_pressed() | ||
|| state.button_y.is_pressed() | ||
|| state.button_up.is_pressed() | ||
|| state.button_down.is_pressed() | ||
|| state.button_left.is_pressed() | ||
|| state.button_right.is_pressed() | ||
|| state.button_l1.is_pressed() | ||
|| state.button_l2.is_pressed() | ||
|| state.button_r1.is_pressed() | ||
|| state.button_r2.is_pressed() | ||
|| state.left_stick.x() > 0.05 | ||
|| state.left_stick.x() < -0.05 | ||
|| state.left_stick.y() > 0.05 | ||
|| state.left_stick.y() < -0.05 | ||
|| state.right_stick.x() > 0.05 | ||
|| state.right_stick.x() < -0.05 | ||
|| state.right_stick.y() > 0.05 | ||
|| state.right_stick.y() < -0.05 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters