()
| 7 | use MoveDirection::*; |
| 8 | |
| 9 | fn main() -> std::io::Result<()> { |
| 10 | let mut device = VirtualDevice::builder()? |
| 11 | .name("fake-mouse") |
| 12 | .with_relative_axes(&AttributeSet::from_iter([ |
| 13 | RelativeAxisCode::REL_X, |
| 14 | RelativeAxisCode::REL_Y, |
| 15 | RelativeAxisCode::REL_WHEEL, |
| 16 | RelativeAxisCode::REL_HWHEEL, |
| 17 | ]))? |
| 18 | .build() |
| 19 | .unwrap(); |
| 20 | |
| 21 | for path in device.enumerate_dev_nodes_blocking()? { |
| 22 | let path = path?; |
| 23 | println!("Available as {}", path.display()); |
| 24 | } |
| 25 | |
| 26 | println!("Waiting for Ctrl-C..."); |
| 27 | loop { |
| 28 | let ev = new_move_mouse_event(Up, 50); |
| 29 | device.emit(&[ev]).unwrap(); |
| 30 | println!("Moved mouse up"); |
| 31 | sleep(Duration::from_millis(100)); |
| 32 | |
| 33 | let ev = new_move_mouse_event(Down, 50); |
| 34 | device.emit(&[ev]).unwrap(); |
| 35 | println!("Moved mouse down"); |
| 36 | sleep(Duration::from_millis(100)); |
| 37 | |
| 38 | let ev = new_move_mouse_event(Left, 50); |
| 39 | device.emit(&[ev]).unwrap(); |
| 40 | println!("Moved mouse left"); |
| 41 | sleep(Duration::from_millis(100)); |
| 42 | |
| 43 | let ev = new_move_mouse_event(Right, 50); |
| 44 | device.emit(&[ev]).unwrap(); |
| 45 | println!("Moved mouse right"); |
| 46 | sleep(Duration::from_millis(100)); |
| 47 | |
| 48 | let ev = new_scroll_mouse_event(Up, 1); |
| 49 | device.emit(&[ev]).unwrap(); |
| 50 | println!("Scrolled mouse up"); |
| 51 | sleep(Duration::from_millis(100)); |
| 52 | |
| 53 | let ev = new_scroll_mouse_event(Down, 1); |
| 54 | device.emit(&[ev]).unwrap(); |
| 55 | println!("Scrolled mouse down"); |
| 56 | sleep(Duration::from_millis(100)); |
| 57 | |
| 58 | let ev = new_scroll_mouse_event(Left, 1); |
| 59 | device.emit(&[ev]).unwrap(); |
| 60 | println!("Scrolled mouse left"); |
| 61 | sleep(Duration::from_millis(100)); |
| 62 | |
| 63 | let ev = new_scroll_mouse_event(Right, 1); |
| 64 | device.emit(&[ev]).unwrap(); |
| 65 | println!("Scrolled mouse right"); |
| 66 | sleep(Duration::from_millis(100)); |
nothing calls this directly
no test coverage detected
searching dependent graphs…