~xdavidwu/motion-control

85523de2316b0d0882c5e4648ad807eb72753051 — xdavidwu 2 years ago e3036ba
add evdev::uinput
2 files changed, 32 insertions(+), 0 deletions(-)

A evdev/uinput/types.ha
A evdev/uinput/uinput.ha
A evdev/uinput/types.ha => evdev/uinput/types.ha +5 -0
@@ 0,0 1,5 @@
use io;

export type uinput = *void;

export def OPEN_MANAGED: io::file	= -2;

A evdev/uinput/uinput.ha => evdev/uinput/uinput.ha +27 -0
@@ 0,0 1,27 @@
use evdev;
use io;
use rt;

export fn create_from_device(dev: evdev::libevdev, fd: io::file)
			(uinput | rt::errno) = {
	let handle = null: uinput;
	const r = c_libevdev_uinput_create_from_device(dev, fd: int, &handle);
	if (r < 0) {
		return (-r): rt::errno;
	};
	return handle;
};

export fn write_event(uinput_dev: uinput, event_type: uint, code: uint, value: int)
		(void | rt::errno) = {
	const r = c_libevdev_uinput_write_event(uinput_dev, event_type, code, value);
	if (r < 0) {
		return (-r): rt::errno;
	};
};

@symbol("libevdev_uinput_create_from_device") fn c_libevdev_uinput_create_from_device(
	dev: evdev::libevdev, uinput_fd: int, uinput_dev: *uinput) int;
export @symbol("libevdev_uinput_destroy") fn destroy(dev: uinput) void;
@symbol("libevdev_uinput_write_event") fn c_libevdev_uinput_write_event(
	uinput_dev: uinput, etype: uint, code: uint, value: int) int;