~xdavidwu/motion-control

8f3f04b4d083fe40db6e9106e7e44f25475874c1 — xdavidwu 2 years ago 3e0ca03
uinput-pointer: simplify use of uinput submodule
1 files changed, 5 insertions(+), 5 deletions(-)

M tools/uinput-pointer/main.ha
M tools/uinput-pointer/main.ha => tools/uinput-pointer/main.ha +5 -5
@@ 16,17 16,17 @@ export fn main() void = {
	evdev::enable_event_code(evdev, evdev::EV_KEY, evdev::BTN_MIDDLE, null)!;
	evdev::enable_event_code(evdev, evdev::EV_KEY, evdev::BTN_RIGHT, null)!;

	const uinput = match (evdev::uinput::create_from_device(evdev, evdev::uinput::OPEN_MANAGED)) {
	case let uinput: evdev::uinput::uinput =>
	const uinput = match (uinput::create_from_device(evdev, uinput::OPEN_MANAGED)) {
	case let uinput: uinput::uinput =>
		yield uinput;
	case let err: rt::errno =>
		fmt::fatalf("Failed to create uinput dev: {}", rt::strerror(err));
	};
	defer evdev::uinput::destroy(uinput);
	defer uinput::destroy(uinput);

	for (let i = 0; i < 100; i += 1) {
		evdev::uinput::write_event(uinput, evdev::EV_REL, evdev::REL_X, 1)!;
		evdev::uinput::write_event(uinput, evdev::EV_SYN, evdev::SYN_REPORT, 0)!;
		uinput::write_event(uinput, evdev::EV_REL, evdev::REL_X, 1)!;
		uinput::write_event(uinput, evdev::EV_SYN, evdev::SYN_REPORT, 0)!;
		time::sleep(10 * time::MILLISECOND);
	};
};