How can I know which of the /dev/input/eventX (X=0..7) have the Linux input stream?

后端 未结 5 831
清歌不尽
清歌不尽 2021-01-30 02:00

I am trying to capture linux keyboard/mouse input, and I am reading events from like /dev/input/event2. But it seems the input are sometimes directed to /dev/

5条回答
  •  余生分开走
    2021-01-30 02:19

    Run this in Terminal, it will work just fine:

    cat /proc/bus/input/devices | awk '/keyboard/{for(a=0;a>=0;a++){getline;{if(/kbd/==1){ print 
    $NF;exit 0;}}}}'
    

    Source

提交回复
热议问题