I know that stdin refers to standard input in linux, usually the keyboard. It can also be referred by file descriptor 0.

So, which file descriptor does the (standard input) mouse refer to? Or is it a special file which functions in a very different way, when compared to other files, or input files? So how does the mouse work and where is the input from the mouse mapped to?

The same questions apply to a touchscreen.

1 Answer 1


The mouse is normally accessible under Linux as a device under /dev/input and there is a virtual device /dev/input/mice that allows you to receive input from all mice in the system through a single device.

This mouse device is not normally connected to the standard input of any process though. If you are using a graphical environment then the X11 server is the process that opens one or more of these devices and receives mouse events. Normal applications receive mouse events using the X11 protocol (or whatever higher-level toolkit they are using) along with all other types of events (keyboard events, window drawing events, window focus events, etc...), not through stdin.

Touchscreens, like mice, also present as devices in /dev/input. The first touchscreen device in the system is called /dev/input/touchscreen0.

All of the devices in /dev/input, including touchscreens and mice, deliver events in a specific binary format defined in the C include file <linux/input.h>.

  • thank you for the explanation. Which device does the touchscreen use? Jul 24, 2014 at 5:57
  • 1
    I don't have a device with a touchscreen handy right now but I believe it's /dev/input/ts0 for the first touchscreen in the system. It works almost the same as a mouse and the format of the events you can extract from this file is the same as for mice.
    – Celada
    Jul 24, 2014 at 6:08
  • thank you for the answer. Please update your answer with this new information. Jul 24, 2014 at 6:11
  • 2
    OK, but first I would like to confirm the correct filename for the touchscreen device. I'll do that when I get the chance to check.
    – Celada
    Jul 24, 2014 at 6:14
  • 1
    @user2555595 so it turns out I was wrong about the name of the touchscreen devices :-) Edited.
    – Celada
    Jul 28, 2014 at 2:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.