Struct Input

Source
pub struct Input(/* private fields */);
Expand description

This structure is used by send_inputs to store information for synthesizing input events such as keystrokes, mouse movement, and mouse clicks.

§Example

use winput::{Input, Action};

let input = Input::from_char('A', Action::Press);
winput::send_inputs(&[input]);

Implementations§

Source§

impl Input

Source

pub fn from_char(c: char, action: Action) -> Option<Input>

Creates an Input that causes the given action to be taken on the given character. If the given character is above 0x0000ffff, None is returned.

§Example
use winput::{Input, Action};

let input = Input::from_char('A', Action::Press).unwrap();
winput::send_inputs(&[input]);
Source

pub fn from_vk(vk: Vk, action: Action) -> Input

Creates an Input that causes the given action to be taken on the given Virtual-Key Code.

§Example
use winput::{Input, Action, Vk};

let input = Input::from_vk(Vk::Enter, Action::Press);
winput::send_inputs(&[input]);
Source

pub fn from_button(button: Button, action: Action) -> Input

Creates an Input that causes the given action to be taken on the given mouse button.

§Example
use winput::{Button, Action, Input};

let input = Input::from_button(Button::Left, Action::Press);
winput::send_inputs(&[input]);
Source

pub fn from_motion(motion: MouseMotion) -> Self

Creates an Input that causes the mouse to move according to the given MouseMotion.

§Example
use winput::{MouseMotion, Input};

let motion = MouseMotion::Relative {
    dx: 100, // 100 pixels right
    dy: 50, // 50 pixels down
};

let input = Input::from_motion(motion);

winput::send_inputs(&[input]);
Source

pub fn from_wheel(motion: f32, direction: WheelDirection) -> Self

Creates an Input that causes the mouse wheel to rotate by the given amount and in the given WheelDirection.

When the given direction is vertical, a positive motion means the wheel rotates forward, away from the user; a negative value means the wheel rotates backward, toward the user.

When the given direction is horizontal, a positive motion means the wheel rotates to the right; a negative value means the wheel rotates to the left.

§Example
use winput::{WheelDirection, Input};

let input = Input::from_wheel(100.0, WheelDirection::Vertical);
winput::send_inputs(&[input]);

Trait Implementations§

Source§

impl Clone for Input

Source§

fn clone(&self) -> Input

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl Freeze for Input

§

impl RefUnwindSafe for Input

§

impl Send for Input

§

impl Sync for Input

§

impl Unpin for Input

§

impl UnwindSafe for Input

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.