mouse, cursor – kernel mouse interface
bind -a #m /dev
device provides an interface to the mouse.
There is also a cursor associated with the screen;
it is always displayed at the current mouse position.
file returns the mouse status: its position and button state.
The read blocks until the state has changed since the last read.
The read returns 49 bytes: the letter
followed by four decimal strings, each 11 characters
wide followed by a blank:
coordinates of the mouse position in the screen image;
a bitmask with the
1, 2, and 4 bits set when the
mouse’s left, middle, and right buttons,
respectively, are down;
a time stamp, in units of milliseconds.
file, in the same format,
causes the mouse cursor to move to the position specified by the
coordinates of the message.
fields are ignored and may be omitted.
Writes to the
file are processed as if they were generated by the
mouse hardware itself,
as extra mouse events to be processed and passed back via
file, which is exclusive-use and may be opened
only by the host owner, is intended for controlling devices, such as USB mice,
that are managed by user-level software.
Each event should consist of
followed by delta
as space-separated decimal numbers.
Writing to the
file configures and controls the mouse.
The messages are:
sets serial port
to be the mouse port.
sets the PS2 port to be the mouse port.
uses the wheel on a Microsoft Intellimouse
as the middle button.
is equivalent to a write of
followed by a write of
turns on mouse acceleration.
is an optional acceleration factor.
turns off mouse acceleration.
sets mouse resolution to a setting between 0 and
sets whether acceleration is done in hardware or
By default, PS2 mice use hardware and serial mice use
Some laptops (notably the IBM Thinkpad T23) don’t
implement hardware acceleration for external mice.
swaps the left and right buttons on the mouse.
numbers the left, middle, and right mouse buttons
is omitted, the default map, 123, is used.
Thus in the default state writing
swaps left and right buttons
restores their usual meaning.
messages are idempotent,
clears the mouse
to its default state.
Blank the screen.
The screen also blanks after 30 minutes of inactivity.
The screen can be unblanked by moving the mouse.
Set the timeout before the
screen blanks; the default is 30 minutes.
is zero, blanking is disabled.
unblanks the screen and resets the idle timeout as if the
mouse was twitched.
Not all mice interpret all messages; with some devices,
some of the messages may be no-ops.
Cursors are described in
When read or written from or to the
file, they are represented in a 72-byte binary format.
The first and second four bytes are little endian
32-bit numbers specifying the
coordinates of the cursor
the next 32 bytes are the
and the last 32 bytes the
Reading from the
file returns the current cursor information.
Writing to the
file sets the current cursor information.
A write of fewer than 72 bytes sets the
cursor to the default, an arrow.
files are multiplexed by
to give the illusion of a private mouse to each of its clients.
The semantics are otherwise the same except that notification
of a window resize is passed to the application using a
message beginning with
To cope with pointing devices with only two buttons, when the
shift key is pressed, the right mouse button generates middle-button events.
The cursor format is big endian while the
rest of the graphics interface is little endian.