Struct babalcore::InputSteer [−][src]
An object to tract steering, that is, going left, or going right. This does not actually poll/reacts to the physical controllers, it just collects "go right" or "go left" informations then aggregates and consolidates them.
Fields
mouse_sensibility: f64
keyboard_sensibility: f64
Implementations
impl InputSteer
[src]
pub fn new() -> InputSteer
[src]
pub fn mouse_move(&mut self, delta_px: f64)
[src]
Register a move of N pixels of the mouse.
Examples
use babalcore::*; let mut input_steer = InputSteer::new(); // Player moved the mouse of 42 pixels to the left. input_steer.mouse_move(-42.0);
pub fn right_key(
&mut self,
id: i64,
intensity: f64,
state: bool,
now: Option<Instant>
)
[src]
&mut self,
id: i64,
intensity: f64,
state: bool,
now: Option<Instant>
)
Register a change on a key handling the "move to the right".
One needs to provide an ID (typically, a scancode, but it can be anything) as the manager is stateful and keeps track of what is pressed or released.
The intensity can be used to make in account the fact that a key could be "half pressed". It could typically be used for an analog joystick, which does not act as a mouse, it is rather a virtual key which can be pressed from 0 to 100%.
A true state means pressed, to be called on key down events. A false state means released, to be called on key up events.
The timestamp is used to handle repeats and polling properly, by passing None, the current timestamp, AKA now(), is used.
Examples
use babalcore::*; let mut input_steer = InputSteer::new(); // Player press arrow right key, pretending keycode is 42. input_steer.right_key(42, 0.5, true, None);
pub fn left_key(
&mut self,
id: i64,
intensity: f64,
state: bool,
now: Option<Instant>
)
[src]
&mut self,
id: i64,
intensity: f64,
state: bool,
now: Option<Instant>
)
Register a change on a key handling the "move to the left".
One needs to provide an ID (typically, a scancode, but it can be anything) as the manager is stateful and keeps track of what is pressed or released.
The intensity can be used to make in account the fact that a key could be "half pressed". It could typically be used for an analog joystick, which does not act as a mouse, it is rather a virtual key which can be pressed from 0 to 100%.
A true state means pressed, to be called on key down events. A false state means released, to be called on key up events.
The timestamp is used to handle repeats and polling properly, by passing None, the current timestamp, AKA now(), is used.
Examples
use babalcore::*; let mut input_steer = InputSteer::new(); // Player moved joystick half-way to the left, pretending keycode is 17. input_steer.left_key(17, 0.5, true, None);
pub fn pop_steer(&mut self, now: Option<Instant>) -> f64
[src]
Get the information about steering.
The information returned accumulates all the informations from the mouse, the keys, and outputs a read-to-use, all-in-one number which can be used to figure out "should I go right or should I go left".
The timestamp is used to handle repeats and polling properly, by passing None, the current timestamp, AKA now(), is used.
Examples
use babalcore::*; let mut input_steer = InputSteer::new(); // Player pressed left arrow, pretending keycode is 41. input_steer.left_key(41, 1.0, true, None); let steer = input_steer.pop_steer(None); assert!(steer < 0.0);
Trait Implementations
impl Debug for InputSteer
[src]
impl Default for InputSteer
[src]
Auto Trait Implementations
impl RefUnwindSafe for InputSteer
[src]
impl Send for InputSteer
[src]
impl Sync for InputSteer
[src]
impl Unpin for InputSteer
[src]
impl UnwindSafe for InputSteer
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,