Read /dev/input/event* via IO.binread ?

,

Hi,

Is there is any simple way to read binary stream from /dev/input/event file (e.g mouse event) without any extra libs (like input_event)? Just with loop + File.open and (?) IO.binstream for example. I have tried different IO functions but without success.

I have equivalent snippet in golang:

func main() {
	buff := make([]byte, 64)

	f, err := os.Open("/dev/input/event5")

	if err != nil {
		panic(err)
	}

	defer f.Close()

	for {
		fmt.Println(f.Read(buff))
	}

}

Thanks!

Something like this should yield a simliar result as your sample code:

"/dev/input/event5"
|> File.stream!([], 64)
|> Stream.each(&IO.inspect/1)
|> Stream.run()

Thanks, but unfortunately it doesn’t help - I get nothing and after the while it throws ** (IO.StreamError) error during streaming: invalid argument