Mouse

Struct Mouse 

Source
pub struct Mouse { /* private fields */ }

Implementations§

Source§

impl Mouse

Source

pub fn new(device: Device) -> Mouse

Examples found in repository?
examples/mouse_move.rs (line 9)
7fn main() {
8    let device = Device::new("/dev/hidg1");
9    let mouse = Mouse::new(device);
10
11    // Move the mouse to the top left corner
12    mouse.move_zero();
13    sleep(Duration::from_millis(1000));
14
15    // Move the mouse to x100 y100
16    mouse.move_to(100, 100);
17    sleep(Duration::from_millis(1000));
18
19    // Move the mouse relative
20    mouse.move_relative(127, 127);
21    sleep(Duration::from_millis(1000));
22
23    // Perform a right click
24    mouse.right_click();
25    sleep(Duration::from_millis(200));
26}
Source

pub fn send_mouse_event( &self, buttons: u8, relative_x: u8, relative_y: u8, vertical_wheel_delta: u8, horizontal_wheel_delta: u8, )

Source

pub fn left_click(&self)

Source

pub fn right_click(&self)

Examples found in repository?
examples/mouse_move.rs (line 24)
7fn main() {
8    let device = Device::new("/dev/hidg1");
9    let mouse = Mouse::new(device);
10
11    // Move the mouse to the top left corner
12    mouse.move_zero();
13    sleep(Duration::from_millis(1000));
14
15    // Move the mouse to x100 y100
16    mouse.move_to(100, 100);
17    sleep(Duration::from_millis(1000));
18
19    // Move the mouse relative
20    mouse.move_relative(127, 127);
21    sleep(Duration::from_millis(1000));
22
23    // Perform a right click
24    mouse.right_click();
25    sleep(Duration::from_millis(200));
26}
Source

pub fn move_relative(&self, x: i8, y: i8)

Examples found in repository?
examples/mouse_move.rs (line 20)
7fn main() {
8    let device = Device::new("/dev/hidg1");
9    let mouse = Mouse::new(device);
10
11    // Move the mouse to the top left corner
12    mouse.move_zero();
13    sleep(Duration::from_millis(1000));
14
15    // Move the mouse to x100 y100
16    mouse.move_to(100, 100);
17    sleep(Duration::from_millis(1000));
18
19    // Move the mouse relative
20    mouse.move_relative(127, 127);
21    sleep(Duration::from_millis(1000));
22
23    // Perform a right click
24    mouse.right_click();
25    sleep(Duration::from_millis(200));
26}
Source

pub fn move_zero(&self)

Examples found in repository?
examples/mouse_move.rs (line 12)
7fn main() {
8    let device = Device::new("/dev/hidg1");
9    let mouse = Mouse::new(device);
10
11    // Move the mouse to the top left corner
12    mouse.move_zero();
13    sleep(Duration::from_millis(1000));
14
15    // Move the mouse to x100 y100
16    mouse.move_to(100, 100);
17    sleep(Duration::from_millis(1000));
18
19    // Move the mouse relative
20    mouse.move_relative(127, 127);
21    sleep(Duration::from_millis(1000));
22
23    // Perform a right click
24    mouse.right_click();
25    sleep(Duration::from_millis(200));
26}
Source

pub fn move_to(&self, x: u16, y: u16)

Examples found in repository?
examples/mouse_move.rs (line 16)
7fn main() {
8    let device = Device::new("/dev/hidg1");
9    let mouse = Mouse::new(device);
10
11    // Move the mouse to the top left corner
12    mouse.move_zero();
13    sleep(Duration::from_millis(1000));
14
15    // Move the mouse to x100 y100
16    mouse.move_to(100, 100);
17    sleep(Duration::from_millis(1000));
18
19    // Move the mouse relative
20    mouse.move_relative(127, 127);
21    sleep(Duration::from_millis(1000));
22
23    // Perform a right click
24    mouse.right_click();
25    sleep(Duration::from_millis(200));
26}

Auto Trait Implementations§

§

impl Freeze for Mouse

§

impl RefUnwindSafe for Mouse

§

impl Send for Mouse

§

impl Sync for Mouse

§

impl Unpin for Mouse

§

impl UnwindSafe for Mouse

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> 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, 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.