()
| 6 | use std::time::Duration; |
| 7 | |
| 8 | fn main() -> std::io::Result<()> { |
| 9 | let abs_setup = AbsInfo::new(256, 0, 512, 20, 20, 1); |
| 10 | let abs_x = UinputAbsSetup::new(AbsoluteAxisCode::ABS_X, abs_setup); |
| 11 | |
| 12 | let mut device = VirtualDevice::builder()? |
| 13 | .name("Fake Joystick") |
| 14 | .with_absolute_axis(&abs_x)? |
| 15 | .build() |
| 16 | .unwrap(); |
| 17 | |
| 18 | for path in device.enumerate_dev_nodes_blocking()? { |
| 19 | let path = path?; |
| 20 | println!("Available as {}", path.display()); |
| 21 | } |
| 22 | |
| 23 | // Hopefully you don't have ABS_X bound to anything important. |
| 24 | let code = AbsoluteAxisCode::ABS_X.0; |
| 25 | |
| 26 | println!("Waiting for Ctrl-C..."); |
| 27 | loop { |
| 28 | let down_event = *AbsoluteAxisEvent::new(AbsoluteAxisCode(code), 0); |
| 29 | device.emit(&[down_event]).unwrap(); |
| 30 | println!("Minned out."); |
| 31 | sleep(Duration::from_secs(2)); |
| 32 | |
| 33 | let up_event = *AbsoluteAxisEvent::new(AbsoluteAxisCode(code), 512); |
| 34 | device.emit(&[up_event]).unwrap(); |
| 35 | println!("Maxed out."); |
| 36 | sleep(Duration::from_secs(2)); |
| 37 | } |
| 38 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…