26 lines
584 B
Rust
26 lines
584 B
Rust
#[derive (Clone, Copy, Default)]
|
|
pub struct VirtualGamepad {
|
|
pub jump: VirtualButton,
|
|
pub d_left: VirtualButton,
|
|
pub d_right: VirtualButton,
|
|
pub d_up: VirtualButton,
|
|
pub d_down: VirtualButton,
|
|
}
|
|
|
|
#[derive (Clone, Copy, Default)]
|
|
pub struct VirtualButton {
|
|
/// True iff the button is down now
|
|
pub held: bool,
|
|
|
|
/// True if the button was pressed at any point since the last frame,
|
|
/// even if it's up now.
|
|
/// This is needed to make really fast clicks air-tight.
|
|
pub pressed: bool,
|
|
}
|
|
|
|
impl VirtualButton {
|
|
pub fn any_press (self) -> bool {
|
|
self.held || self.pressed
|
|
}
|
|
}
|