mouse_move/mouse_move.rs
1extern crate usbhid;
2
3use std::{thread::sleep, time::Duration};
4
5use usbhid::prelude::{Device, Mouse};
6
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}