1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//! Provides mechanisms for receiving input from the screen.

#[cfg(feature = "desktop_gl")]
mod glutin;
#[cfg(feature = "desktop_gl")]
pub use self::glutin::GlutinInput as input_impl;

#[cfg(feature = "raspberry_pi")]
mod pi;
#[cfg(feature = "raspberry_pi")]
pub use self::pi::PiInput as input_impl;

use crate::render::Drawer;

/// Handles basic input
pub trait Input {
    type Window: Drawer;

    /// Updates input
    fn update(&mut self, drawer: &mut Self::Window);

    /// Checks to see if the mouse/pointer is down
    fn is_mouse_down(&self) -> bool;

    /// Returns the current mouse position in a (x, y) tuple.
    fn get_mouse_pos(&self) -> (usize, usize);

    /// Checks to see if execution should be continued
    fn do_continue(&self) -> bool;

    /// Creates a new Input instance.
    fn new() -> Self;
}