1

I'm playing with Linux input events and devices. I wrote a simple toy C program that opens /dev/input/event* and writes Linux multi-touch events to the opened file. It worked well and I was able to mimic customer's swipe event. (I know I can use evemu-* for this, but wanted to test with my own code).

But I found that if I try to write recorded events directly to the file in command line shell, it doesn't work with this error. Now I'm wondering why I can't write the events directly to the file. My toy program doesn't do anything special but open a file and write events to it. I think I should be able to do the same thing with cat and redirect. Am I doing something wrong in this command?

# cat ./swipe_events > /dev/input/event2
/system/bin/sh: cat: <stdout>: Invalid argument

Thanks,

joybro
  • 205
  • 1
  • 12
  • 1
    Check the difference with `strace`. It might be due to write lengths. – that other guy Mar 23 '21 at 19:56
  • @that-other-guy thanks, I think you're right. I can see the last write syscall returns different length (1312 vs 1319). I'll investigate more with the hint. `write(1, "\nE: 1616526181.476142 0000 0000 "..., 1319) = 1312 write(1, "0000 0\n", 7) = -1 EINVAL (Invalid argument)` vs `write(1, "\nE: 1616526181.476142 0000 0000 "..., 1319) = 1319` – joybro Mar 23 '21 at 21:14

0 Answers0