mouse, cursor – kernel mouse interface
bind –a #m /dev
The mouse 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.
Reading the mouse 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 m followed by four decimal strings, each 11 characters wide followed by a blank: x and y, coordinates of the mouse position in the screen image; buttons, a bitmask with the 1, 2, and 4 bits set when the mouse's left, middle, and right buttons, respectively, are down; and msec, a time stamp, in units of milliseconds.
Writing the mouse file, in the same format, causes the mouse cursor to move to the position specified by the x and y coordinates of the message. The buttons and msec fields are ignored and may be omitted.
Writes to the mousein file are processed as if they were generated by the mouse hardware itself, as extra mouse events to be processed and passed back via the mouse file. The mousein file, which 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 the letter m followed by delta x, delta y, and buttons as space–separated decimal numbers.
Writing to the mousectl file configures and controls the mouse.
The messages are:
Not all mice interpret all messages; with some devices, some of the messages may be no–ops.
Cursors are described in graphics(2). When read or written from or to the cursor file, they are represented in a 72–byte binary format. The first and second four bytes are little endian 32–bit numbers specifying the x and y coordinates of the cursor offset; the next 32 bytes are the clr bitmask, and the last 32 bytes the set bitmask.
Reading from the cursor file returns the current cursor information. Writing to the cursor file sets the current cursor information. A write of fewer than 72 bytes sets the cursor to the default, an arrow.
The mouse and cursor files are multiplexed by rio(1) 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 mouse message beginning with r rather than m; see rio(4) for details.
To cope with pointing devices with only two buttons, when the
shift key is pressed, the right mouse button generates middle–button
The cursor format is big endian while the rest of the graphics
interface is little endian.