SYSMOUSE(4)
π NAME π
sysmouse β virtualized mouse driver. This is the sysmouse(4) page in the Kernel Interfaces Manual, bestie β and yeah, we're gonna make mouse data make sense. π
πΈ SYNOPSIS πΈ
#include <sys/mouse.h>
#include <sys/consio.h>
β¨ DESCRIPTION β¨
Okay so the console driver, in conjunction with the mouse daemon moused(8), supplies mouse data to the user process in the standardized way via the sysmouse driver. This arrangement makes it possible for the console and the user process (such as the X Window System) to share the mouse. Iconic behavior, honestly. π±οΈβ¨
The user process that wants to utilize mouse operation simply opens /dev/sysmouse with an open(2) call and reads mouse data from the device via read(2). Make sure moused(8) is running β otherwise the user process will not see any data coming from the mouse. No cap, that's the vibe check.
π¦ Operation Levels π¦
The sysmouse driver has two levels of operation. The current operation level can be referred to and changed via ioctl calls.
The level zero, the basic level, is the lowest level at which the driver offers the basic service to user programs. The sysmouse driver provides horizontal and vertical movement of the mouse and state of up to three buttons in the MouseSystems format as follows.
Byte 1
bit 7β Always one.bit 6..3β Always zero.bit 2β Left button status; cleared if pressed, otherwise set.bit 1β Middle button status; cleared if pressed, otherwise set. Always one, if the device does not have the middle button.bit 0β Right button status; cleared if pressed, otherwise set.
Byte 2 β The first half of horizontal movement count in two's complement; -128 through 127.
Byte 3 β The first half of vertical movement count in two's complement; -128 through 127.
Byte 4 β The second half of the horizontal movement count in two's complement; -128 through 127. To obtain the full horizontal movement count, add the byte 2 and 4.
Byte 5 β The second half of the vertical movement count in two's complement; -128 through 127. To obtain the full vertical movement count, add the byte 3 and 5.
At the level one, the extended level, mouse data is encoded in the standard format MOUSE_PROTO_SYSMOUSE as defined in mouse(4).
π IOCTLS π
This section describes two classes of ioctl(2) commands: commands for the sysmouse driver itself, and commands for the console and the console control drivers.
π Sysmouse Ioctls π
There are a few commands for mouse drivers. General description of the commands is given in mouse(4). Following are the features specific to the sysmouse driver.
MOUSE_GETLEVEL int *level,MOUSE_SETLEVEL int *levelβ These commands manipulate the operation level of the mouse driver.MOUSE_GETHWINFO mousehw_t *hwβ Returns the hardware information of the attached device in the following structure. Only theiftypefield is guaranteed to be filled with the correct value in the current version of thesysmousedriver.
typedef struct mousehw {
int buttons; /* number of buttons */
int iftype; /* I/F type */
int type; /* mouse/track ball/pad... */
int model; /* I/F dependent model ID */
int hwid; /* I/F dependent hardware ID */
} mousehw_t;
buttonsβ holds the number of buttons detected by the driver.iftypeβ alwaysMOUSE_IF_SYSMOUSE.typeβ tells the device type:MOUSE_MOUSE,MOUSE_TRACKBALL,MOUSE_STICK,MOUSE_PAD, orMOUSE_UNKNOWN.modelβ alwaysMOUSE_MODEL_GENERICat the operation level 0. It may beMOUSE_MODEL_GENERICor one ofMOUSE_MODEL_XXXconstants at higher operation levels.hwidβ always zero.MOUSE_GETMODE mousemode_t *modeβ The command gets the current operation parameters of the mouse driver.
typedef struct mousemode {
int protocol; /* MOUSE_PROTO_XXX */
int rate; /* report rate (per sec) */
int resolution; /* MOUSE_RES_XXX, -1 if unknown */
int accelfactor; /* acceleration factor */
int level; /* driver operation level */
int packetsize; /* the length of the data packet */
unsigned char syncmask[2]; /* sync. bits */
} mousemode_t;
protocolβ tells the format in which the device status is returned when the mouse data is read by the user program. It isMOUSE_PROTO_MSCat the operation level zero.MOUSE_PROTO_SYSMOUSEat the operation level one.rateβ always set to-1.resolutionβ always set to-1.accelfactorβ always0.packetsizeβ specifies the length of the data packet. It depends on the operation level.level 0β5 byteslevel 1β8 bytes
syncmaskβ holds a bit mask and pattern to detect the first byte of the data packet.syncmask[0]is the bit mask to be ANDed with a byte. If the result is equal tosyncmask[1], the byte is likely to be the first byte of the data packet. Note that this method of detecting the first byte is not 100% reliable; thus, it should be taken only as an advisory measure.MOUSE_SETMODE mousemode_t *modeβ The command changes the current operation parameters of the mouse driver as specified inmode. Onlylevelmay be modifiable. Setting values in the other field does not generate error and has no effect.MOUSE_READDATA mousedata_t *data,MOUSE_READSTATE mousedata_t *stateβ These commands are not supported by thesysmousedriver.MOUSE_GETSTATUS mousestatus_t *statusβ The command returns the current state of buttons and movement counts in the structure as defined inmouse(4).
π Console and Consolectl Ioctls π
The user process issues console ioctl() calls to the current virtual console in order to control the mouse pointer. The console ioctl() also provides a method for the user process to receive a signal(3) when a button is pressed.
The mouse daemon moused(8) uses ioctl() calls to the console control device /dev/consolectl to inform the console of mouse actions including mouse movement and button status.
Both classes of ioctl() commands are defined as CONS_MOUSECTL which takes the following argument.
struct mouse_info {
int operation;
union {
struct mouse_data data;
struct mouse_mode mode;
struct mouse_event event;
} u;
};
operation β This can be one of
MOUSE_SHOWβ Enables and displays mouse cursor.MOUSE_HIDEβ Disables and hides mouse cursor.MOUSE_MOVEABSβ Moves mouse cursor to position supplied inu.data.MOUSE_MOVERELβ Adds position supplied inu.datato current position.MOUSE_GETINFOβ Returns current mouse position in the current virtual console and button status inu.data.MOUSE_MODEβ This sets thesignal(3)to be delivered to the current process when a button is pressed. The signal to be delivered is set inu.mode.
The above operations are for virtual consoles. The operations defined below are for the console control device and are used by moused(8) to pass mouse data to the console driver.
MOUSE_ACTION,MOUSE_MOTION_EVENTβ These operations take the information inu.dataand act upon it. Mouse data will be sent to thesysmousedriver if it is open.MOUSE_ACTIONalso processes button press actions and sends signal to the process if requested or performs cut and paste operations if the current console is a text interface.MOUSE_BUTTON_EVENTβu.dataspecifies a button and its click count. The console driver will use this information for signal delivery if requested or for cut and paste operations if the console is in text mode.
MOUSE_MOTION_EVENT and MOUSE_BUTTON_EVENT are newer interface and are designed to be used together. They are intended to replace functions performed by MOUSE_ACTION alone.
The u union is one of:
π data
struct mouse_data {
int x;
int y;
int z;
int buttons;
};
x, y and z represent movement of the mouse along respective directions. buttons tells the state of buttons. It encodes up to 31 buttons in the bit 0 though the bit 30. If a button is held down, the corresponding bit is set.
π§ mode
struct mouse_mode {
int mode;
int signal;
};
The signal field specifies the signal to be delivered to the process. It must be one of the values defined in <signal.h>. The mode field is currently unused.
β event
struct mouse_event {
int id;
int value;
};
The id field specifies a button number as in u.data.buttons. Only one bit/button is set. The value field holds the click count: the number of times the user has clicked the button successively.
ποΈ FILES ποΈ
/dev/consolectlβ device to control the console/dev/sysmouseβ virtualized mouse driver/dev/ttyv%dβ virtual consoles
π SEE ALSO π
π HISTORY π
The sysmouse driver first appeared in FreeBSD 2.2.
π AUTHORS π
This manual page was written by John-Mark Gurney <jmg@FreeBSD.org> and Kazutaka Yokota <yokota@FreeBSD.org>.
π and that's the whole page, bestie: source/version Debian, date March 25, 2014, page SYSMOUSE(4) β periodt. π«Ά
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- nixpkgs unstable: source
- Copyright 1997 John-Mark Gurney. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms