[Linux] only receiving 1365 events when reading from /dev/input

I’m trying to read keyboard input events from dev/input/eventN, but after reading exactly 1365 events the file is reported as empty and never receives any more data. MWE:

dev_num = 6 # my keyboard is event6, use `cat /proc/bus/input/devices` to find yours
kbd = open("/dev/input/event$dev_num", "r")
num_events = 0; event = zeros(UInt8, 24);
while !eof(kbd)
    num_events += 1
    readbytes!(kbd, event; all=true)
end
num_events
eof(kbd)
close(kbd)

By typing the lines after the while loop we should have more events to read but eof is always true for me and num_events is always 1365.

Not sure if this is a problem with Julia’s I/O but any help would be appreciated.

Note: all my programs work fine so the keyboard events are being received by elsewhere. Also, this works fine for /dev/input/mouse0 or /dev/input/mice.

Also, this approach seems to work fine for logkeys.cc - read which makes me suspect either I’m doing something wrong here or Julia is.

2 Likes