键盘和鼠标类驱动程序Keyboard and mouse class drivers

非 HID 键盘和鼠标可通过多个旧式总线进行连接,但仍使用相同的类驱动程序。Non-HID keyboards and mice can connect over multiple legacy buses but still use the same class driver. 本部分包含有关类驱动程序本身的详细信息。This section contains details on the class drivers themselves. 以下各节介绍有关控制器的详细信息。The following sections goes into details on the controllers.

本主题介绍 Microsoft Windows 2000 和更高版本中键盘和鼠标设备的典型物理配置。This topic describes the typical physical configuration of keyboard and mouse devices in Microsoft Windows 2000 and later.

下图显示了两种常用的配置,它们使用一个键盘和一个鼠标。The following figures show two common configurations that employ a single keyboard and a single mouse.

阐释使用单个键盘和鼠标的两种配置的关系图

左侧的图形显示了通过独立控制器连接到系统总线的键盘和鼠标。The figure on the left shows a keyboard and a mouse connected to a system bus through independent controllers. 典型配置包括通过 i8042 控制器操作的 PS/2 样式键盘,以及通过串行端口控制器操作的串行样式鼠标。A typical configuration consists of a PS/2-style keyboard operated through an i8042 controller, and a serial-style mouse operated through a serial port controller.

以下附加信息对于键盘和鼠标制造商非常重要:The following additional information is important for keyboard and mice manufactures:

  • 出于安全原因,操作系统堆栈按独占模式打开键盘Keyboards are opened in exclusive mode by the operating system stack for security reasons
  • Windows 支持同时连接多个键盘和鼠标设备。Windows supports the simultaneous connection of more than one keyboard and mouse device.
  • Windows 不支持将客户端独立访问到每个设备。Windows does not support independent access by a client to each device.

类驱动程序功能Class driver features

本主题介绍以下 Microsoft Windows 2000 和更高版本的系统类驱动程序的功能:This topic describes the features of the following Microsoft Windows 2000 and later system class drivers:

  • Kbdclass,GUID_类_键盘设备类的设备的类驱动程序Kbdclass, the class driver for devices of GUID_CLASS_KEYBOARD device class

  • Mouclass,GUID 的设备的类驱动程序_类_鼠标设备类Mouclass, the class driver for devices of GUID_CLASS_MOUSE device class

Kbdclass 实现了 Kbdclass 服务,其可执行映像为 Kbdclass。Kbdclass implements the Kbdclass service and its executable image is kbdclass.sys.

Mouclass 实现了 Mouclass 服务,其可执行映像为 Mouclass。Mouclass implements the Mouclass service and its executable image is mouclass.sys.

每项功能 Kbdclass 和 Mouclass:Kbdclass and Mouclass each feature:

  • 设备类的泛型和独立于硬件的操作。Generic and hardware-independent operation of the device class.

  • 即插即用、电源管理和 Windows Management Instrumentation (WMI)。Plug and Play, power management, and Windows Management Instrumentation (WMI).

  • 旧设备的操作。Operation of legacy devices.

  • 同时操作多台设备。Simultaneous operation of more than one device.

  • 类服务回调例程的连接,函数驱动程序使用它将数据从设备的输入数据缓冲区传输到类驱动程序的数据缓冲区。Connection of a class service callback routine that a function driver uses to transfer data from the input data buffer of the device to the data buffer of the class driver.

设备对象的配置Configuration of device objects

下图显示了即插即用 PS/2 样式键盘和鼠标设备的设备对象的配置。The following figure shows the configuration of device objects for a Plug and Play PS/2-style keyboard and mouse device. 每个类驱动程序创建一个上层类筛选器设备对象(筛选器),该对象通过可选的上层设备筛选器附加到函数设备对象(FDO)。Each class driver creates an upper-level class filter device object (filter DO) that is attached to a function device object (FDO) through an optional upper-level device filter DO. 上层设备筛选器驱动程序用于创建上层设备筛选器。An upper-level device filter driver creates the upper-level device filter DO. I8042prt 创建函数并将其附加到根总线驱动程序创建的物理设备对象(PDO)。I8042prt creates the function DO and attaches it to a physical device object (PDO) created by the root bus driver.

说明即插即用 ps/2 样式键盘和鼠标设备的设备对象配置的关系图

PS/2 键盘PS/2 Keyboard

键盘驱动程序堆栈包含以下各项。The keyboard driver stack consists of the following.

  • Kbdclass,上层键盘类筛选器驱动程序Kbdclass, the upper-level keyboard class filter driver
  • 一个或多个可选的高级键盘筛选器驱动程序One or more optional upper-level keyboard filter driver
  • I8042prt,函数驱动程序I8042prt, the function driver

PS/2 鼠标PS/2 Mouse

鼠标驱动程序堆栈包含以下各项。The mouse driver stack consists of the following.

  • Mouclass,上层的鼠标类筛选器驱动程序Mouclass, the upper-level mouse class filter driver
  • 一个或多个可选的上层鼠标筛选器驱动程序One or more optional upper-level mouse filter driver
  • I8042prt,函数驱动程序I8042prt, the function driver

KbdclassMouclass可支持两种不同模式下的多个设备。Kbdclass and Mouclass can support more than one device in two different modes. 一对一模式下,每个设备都有一个独立的设备堆栈。In the one-to-one mode, each device has an independent device stack. 类驱动程序创建一个独立类并将其附加到每个设备堆栈。The class driver creates and attaches an independent class DO to each device stack. 每个设备堆栈都有自己的控制状态和输入缓冲区。Each device stack has its own control state and input buffer. Microsoft Win32 子系统通过唯一的文件对象从每个设备访问输入。The Microsoft Win32 subsystem accesses input from each device through a unique file object.

grandmaster 模式下,类驱动程序将按照以下方式操作所有设备:In the grandmaster mode, the class driver operates all the devices in the following way:

  • 类驱动程序创建一个表示所有设备的grandmaster 类,并为每个设备创建一个从属类The class driver creates both a grandmaster class DO that represents all of the devices and a subordinate class DO for each device.

    类驱动程序将从属类附加到每个设备堆栈。The class driver attaches a subordinate class DO to each device stack. 在从属类的下面,设备堆栈与在一对一模式下创建的堆栈相同。Below the subordinate class DO, the device stack is same as that created in the one-to-one mode.

  • Grandmaster 类控制所有从属 DOs 的操作。The grandmaster class DO controls the operation of all the subordinate DOs.

  • Win32 子系统通过表示 grandmaster 类设备的文件对象访问所有设备输入。The Win32 subsystem accesses all device input through the file object that represents the grandmaster class device.

  • 所有设备输入都在 grandmaster 的数据队列中进行缓冲。All device input is buffered in the grandmaster's data queue.

  • Grandmaster 维护一个全局设备状态。The grandmaster maintains a single global device state.

如果 "Kbdclass" 和 "Mouclass" 的注册表项值 " ConnectMultiplePorts " 设置为0x00 (在 key HKLM\Services\CurrentControlSet\<类服务>\参数,其中,类服务是 Kbdclass 或 Mouclass),则此模式将在一对一模式下运行。Kbdclass and Mouclass operate in the one-to-one mode if their registry entry value ConnectMultiplePorts is set to 0x00 (under the key HKLM\Services\CurrentControlSet\<class service>\Parameters, where class service is Kbdclass or Mouclass). 否则,Kbdclass 和 Mouclass 将在 grandmaster 模式下运行。Otherwise Kbdclass and Mouclass operate in grandmaster mode.

通过类驱动程序打开和关闭Open and close via the class driver

Microsoft Win32 子系统将打开所有键盘和鼠标设备,以供其独占使用。The Microsoft Win32 subsystem opens all keyboard and mouse devices for its exclusive use. 对于每个设备类,Win32 子系统将从所有设备处理输入,就好像输入来自单个输入设备一样。For each device class, the Win32 subsystem treats input from all the devices as if the input came from a single input device. 应用程序不能请求仅从一个特定设备接收输入。An application cannot request to receive input from only one particular device.

Win32 子系统从即插即用管理器收到通知后,会动态打开即插即用输入设备,其中 GUID_类_键盘或 GUID_类_鼠标设备接口已启用。The Win32 subsystem dynamically opens Plug and Play input devices after it receives notification from the Plug and Play manager that a GUID_CLASS_KEYBOARD or GUID_CLASS_MOUSE device interface is enabled. Win32 子系统在收到已禁用打开的接口的通知后关闭即插即用设备。The Win32 subsystem closes Plug and Play devices after it receives notification that an opened interface is disabled. Win32 子系统还会按名称(例如,"\设备\KeyboardLegacyClass0")打开旧版设备。The Win32 subsystem also opens legacy devices by name (for example, "\Device\KeyboardLegacyClass0"). 请注意,一旦 Win32 子系统成功打开旧设备,它将无法确定该设备是否已被物理删除。Note that once the Win32 subsystem successfully opens a legacy device, it cannot determine if the device is later physically removed.

Kbdclass 和 Mouclass 接收到创建请求后,它们会执行以下操作来执行即插即用和旧操作:After Kbdclass and Mouclass receive a create request they do the following for Plug and Play and legacy operation:

  • 即插即用操作Plug and Play Operation

    如果设备处于 "已启动即插即用" 状态,则类驱动程序会将 IRP_MJ_创建请求沿驱动程序堆栈向下发送。If the device is in the Plug and Play started state, the class driver sends the IRP_MJ_CREATE request down the driver stack. 否则,类驱动程序完成请求,但不向下发送请求。Otherwise the class driver completes the request without sending the request down the driver stack. 类驱动程序设置具有设备读取访问权限的受信任文件。The class driver sets the trusted file that has read access to the device. 如果有 grandmaster 设备,则类驱动程序会将 "创建请求" 发送到与从属类设备关联的所有端口。If there is a grandmaster device, the class driver sends a create request to all the ports that are associated with the subordinate class devices.

  • 旧操作Legacy Operation

    类驱动程序将内部设备控制请求发送到端口驱动程序以启用设备。The class driver sends an internal device control request to the port driver to enable the device.

将服务回叫连接到设备Connect a service callback to a device

类驱动程序必须将其类服务连接到设备,然后才能打开设备。The class drivers must connect their class service to a device before the device can be opened. 类驱动程序在将类服务附加到设备堆栈后连接其类服务。The class drivers connect their class service after they attach a class DO to a device stack. 函数驱动程序使用类服务回调将输入数据从设备传输到设备的类数据队列。The function driver uses the class service callback to transfer input data from a device to the class data queue for the device. 设备驱动程序的 ISR 调度完成例程将调用类服务回调。The function driver's ISR dispatch completion routine for a device calls the class service callback. Kbdclass 提供类服务回调KeyboardClassServiceCallback,Mouclass 提供类服务回调MouseClassServiceCallbackKbdclass provides the class service callback KeyboardClassServiceCallback, and Mouclass provides the class service callback MouseClassServiceCallback.

供应商可以通过为设备安装上层筛选器驱动程序来修改类服务回调的操作。A vendor can modify the operation of a class service callback by installing an upper-level filter driver for a device. 示例键盘筛选器驱动程序Kbfiltr定义了KbFilter_ServiceCallback回调,并且示例鼠标筛选器驱动程序Moufiltr定义MouFilter_ServiceCallback回调。The sample keyboard filter driver Kbfiltr defines the KbFilter_ServiceCallback callback, and the sample mouse filter driver Moufiltr defines the MouFilter_ServiceCallback callback. 可以配置示例筛选器服务回调,以将从设备的端口输入缓冲区传输的输入数据修改为类数据队列。The sample filter service callbacks can be configured to modify the input data that is transferred from the port input buffer for a device to the class data queue. 例如,筛选器服务回调可以删除、转换或插入数据。For example, the filter service callback can delete, transform, or insert data.

类和筛选器服务回调按以下方式连接:The class and filter service callbacks are connected in the following way:

  • 类驱动程序按设备堆栈向下发送内部设备连接请求(IOCTL_内部_键盘_连接ioctl_内部_鼠标_连接)。The class driver sends an internal device connect request down the device stack (IOCTL_INTERNAL_KEYBOARD_CONNECT or IOCTL_INTERNAL_MOUSE_CONNECT). 类连接数据由连接_数据结构指定,该结构包含指向类设备对象的指针和指向类服务回调的指针。The class connect data is specified by a CONNECT_DATA structure that includes a pointer to the class device object, and a pointer to the class service callback.

  • 筛选器驱动程序接收到连接请求后,它会保存类连接数据的副本,并将请求的连接数据替换为筛选器连接数据。After the filter driver receives the connect request, it saves a copy of the class connect data, and replaces the request's connect data with filter connect data. 筛选器连接数据指定指向筛选器设备对象的指针和指向筛选器驱动程序服务回调的指针。The filter connect data specifies a pointer to the filter device object and a pointer to the filter driver service callback. 然后,筛选器驱动程序将筛选的连接请求发送到函数驱动程序。The filter driver then sends the filtered connect request to the function driver.

类和筛选器服务回调的调用方式如下:The class and filter service callbacks are called in the following way:

  • 函数驱动程序使用筛选器连接数据将初始回调到筛选服务回调。The function driver uses the filter connect data to make the initial callback to the filter service callback.

  • 筛选输入数据后,筛选器服务回调使用其保存的类连接数据,以回调类服务回调。After filtering the input data, the filter service callback uses the class connect data that it saved to make a callback to the class service callback.

查询和设置键盘设备Query and set a keyboard device

I8042prt 支持下列内部设备控制请求,以查询有关键盘设备的信息以及设置键盘设备的参数:I8042prt supports the following internal device control requests to query information about a keyboard device, and to set parameters on a keyboard device:

_键盘_查询_特性的 IOCTLIOCTL_KEYBOARD_QUERY_ATTRIBUTES

_键盘_查询的 IOCTL_指示器_转换IOCTL_KEYBOARD_QUERY_INDICATOR_TRANSLATION

_键盘_查询的 IOCTL_指示器IOCTL_KEYBOARD_QUERY_INDICATORS

IOCTL_键盘_查询_字符IOCTL_KEYBOARD_QUERY_TYPEMATIC

_键盘_设置_指示器的 IOCTLIOCTL_KEYBOARD_SET_INDICATORS

IOCTL_键盘_集_字符IOCTL_KEYBOARD_SET_TYPEMATIC

有关所有键盘设备控制请求的详细信息,请参阅人体学接口设备参考For more information about all keyboard device control requests, see Human Interface Devices Reference.

扫描适用于键盘的代码映射器Scan code mapper for keyboards

在 Microsoft Windows 操作系统中,输入设备提供的 PS/2 兼容的扫描代码将转换为虚拟密钥,这些密钥将以 Windows 消息形式通过系统传播。In Microsoft Windows operating systems, PS/2-compatible scan codes provided by an input device are converted into virtual keys, which are propagated through the system in the form of Windows messages. 如果设备为某个密钥生成了错误的扫描代码,则会发送错误的虚拟密钥消息。If a device produces an incorrect scan code for a certain key, the wrong virtual key message will be sent. 为此,可以编写一个筛选器驱动程序,用于分析固件生成的扫描代码,并将错误的扫描代码修改为系统可理解的代码。This can be fixed by writing a filter driver that analyzes the scan codes generated by firmware and modifies the incorrect scan code to one understood by the system. 但是,这是一个繁琐的过程,如果内核级筛选器驱动程序中存在错误,有时可能会导致严重的问题。However, this is a tedious process and can sometimes lead to severe problems, if errors exist in the kernel-level filter driver.

Windows 2000 和 Windows XP 包含一个新的扫描代码映射器,该映射器提供了一种允许映射扫描代码的方法。Windows 2000 and Windows XP include a new Scan Code Mapper, which provides a method that allows for mapping of scan codes. Windows 的扫描代码映射存储在以下注册表项中:The scan code mappings for Windows are stored in the following registry key:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout

请注意  在控制键下还有一个键盘布局键(请注意复数形式),但不应修改该键。Note  There is also a Keyboard Layouts key (notice the plural form) under the Control key, but that key should not be modified.

键盘布局键中,必须添加Scancode 映射值。In the Keyboard Layout key, the Scancode Map value must be added. 此值的类型为 REG_BINARY (小 Endian 格式),并且具有下表中指定的数据格式。This value is of type REG_BINARY (little Endian format) and has the data format specified in the following table.

起始偏移量(以字节为单位)Start offset (in bytes) 大小(以字节为单位)Size (in bytes) 数据Data
00 44 标头:版本信息Header: Version Information
44 44 标头:标志Header: Flags
88 44 标头:映射的数目Header: Number of Mappings
1212 44 单个映射Individual Mapping
...... ...... ......
最后4个字节Last 4 bytes 44 空终止符(0x00000000)Null Terminator (0x00000000)

第一个和第二个 DWORD 存储标头信息,并且对于扫描代码映射器的当前版本,它应设置为全零。The first and second DWORDS store header information and should be set to all zeroes for the current version of the Scan Code Mapper. 第三个 DWORD 项包含后面的映射的总数,包括 null 终止映射。The third DWORD entry holds a count of the total number of mappings that follow, including the null terminating mapping. 因此,最小计数为1(未指定映射)。The minimum count would therefore be 1 (no mappings specified). 每个映射都遵循标头。The individual mappings follow the header. 每个映射的长度为一个 DWORD,并分为两个单词长度字段。Each mapping is one DWORD in length and is divided into two WORD length fields. 每个 WORD 字段存储要映射的密钥的扫描代码。Each WORD field stores the scan code for a key to be mapped.

在注册表中存储映射后,必须重新启动系统才能使映射生效。Once the map is stored in the registry, the system must be rebooted for the mappings to take effect. 请注意,如果在按键上需要扫描代码的映射,则在将扫描代码转换为虚拟密钥之前,该步骤将在用户模式下执行。Note that if the mapping of a scan code is necessary on a keypress, the step is performed in user mode just before the scan code is converted to a virtual key. 在用户模式下执行此转换可能会出现某些限制,例如在终端服务下运行时映射不能正常工作。Doing this conversion in user mode can present certain limitations, such as mapping not working correctly when running under Terminal Services.

若要删除这些映射,请删除 Scancode 映射注册表值并重新启动。To remove these mappings, remove the Scancode Map registry value and reboot.

示例 1Example 1

下面显示了一个示例。The following presents an example. 若要将左 CTRL 键替换为 Caps Lock 键,请使用注册表编辑器(最好是 Scancode)修改具有以下值的映射键:To swap the left CTRL key with the CAPS LOCK key, use a registry editor (preferably Regedt32.exe) to modify the Scancode Map key with the following value:

00000000 00000000 03000000 3A001D00 1D003A00 00000000

下表包含这些条目分为 DWORD 字段和交换的字节数。The following table contains these entries broken into DWORD fields and the bytes swapped.

ValueValue 解释Interpretation
0x000000000x00000000 标头:版本。Header: Version. 设置为全零。Set to all zeroes.
0x000000000x00000000 标头:标志。Header: Flags. 设置为全零。Set to all zeroes.
0x000000030x00000003 映射中有三个条目(包括 null 条目)。Three entries in the map (including null entry).
0x001D003A0x001D003A 左 CTRL 键--> Caps Lock (0x1D--> 0x3A)。Left CTRL key --> CAPS LOCK (0x1D --> 0x3A).
0x003A001D0x003A001D Caps Lock--> 左 CTRL 键(0x3A--> 0x1D)。CAPS LOCK --> Left CTRL key (0x3A --> 0x1D).
0x000000000x00000000 空终止符。Null terminator.

示例 2Example 2

还可以添加键盘上未正式提供或删除从未使用的密钥的密钥。It is also possible to add a key not generally available on a keyboard or to remove a key that is never used. 以下示例显示了存储在Scancode 映射中的值,以删除右 CTRL 键并更改右 ALT 键的功能,使其用作静音键:The following example shows the value stored in Scancode Map to remove the right CTRL key and change the functionality of the right ALT key to work as a mute key:

00000000 00000000 03000000 00001DE0 20E038E0 00000000

下表包含这些条目分为 DWORD 字段和交换的字节数。The following table contains these entries broken into DWORD fields and the bytes swapped.

ValueValue 解释Interpretation
0x000000000x00000000 标头:版本。Header: Version. 设置为全零。Set to all zeroes.
0x000000000x00000000 标头:标志。Header: Flags. 设置为全零。Set to all zeroes.
0x000000030x00000003 映射中有三个条目(包括 null 条目)。Three entries in the map (including null entry).
0xE01D00000xE01D0000 删除右 CTRL 键(0xE01D--> 0x00)。Remove the right CTRL key (0xE01D --> 0x00).
0xE038E0200xE038E020 右 ALT 键--> 静音键(0xE038--> 0xE020)。Right ALT key --> Mute key (0xE038 --> 0xE020).
0x000000000x00000000 空终止符。Null terminator.

生成所需的数据后,可以通过多种方式将其插入注册表中。After the necessary data is generated, it can be inserted into the registry in several ways.

  • 可以生成一个 .reg 文件,该文件可以使用注册表编辑器轻松地合并到系统注册表中。A .reg file can be generated that can be easily incorporated into the system registry using a registry editor.
  • 还可以使用包含要添加的注册表信息的 [AddReg] 部分来创建 .inf 文件。An .inf file can also be created with an [AddReg] section that contains the registry information to be added.
  • 可以使用 Regedt32 将信息手动添加到注册表中。Regedt32.exe can be used to manually add the information to the registry.

扫描代码映射器具有几个优点和缺点。The Scan Code Mapper has several advantages and disadvantages.

优点包括:The advantages include:

  • 映射器可用作纠正固件错误的简单修补程序。The Mapper can be used as an easy fix to correct firmware errors.
  • 通过在注册表中修改映射,可以将常用键添加到键盘。Frequently used keys can be added to the keyboard by modifying the map in registry. 不经常使用的键(例如,右 CTRL 键)可以映射到 null (已删除)或与其他键交换。Keys that aren't often used (for example, right CTRL key) can be mapped to null (removed) or exchanged for other keys.
  • 可以轻松地更改密钥位置。Key locations can be altered easily. 用户可以轻松地自定义常用密钥的位置。Users can easily customize the location of frequently used keys for their benefit.

识别以下缺点:The following disadvantages are recognized:

  • 在注册表中存储映射后,需要重新启动系统才能激活它。Once the map is stored in the registry, a system reboot is required to activate it.
  • 注册表中存储的映射在系统级别工作,并适用于所有用户。The mappings stored in the registry work at system level and apply to all users. 根据当前用户的不同,这些映射不能设置为不同的工作方式。These mappings cannot be set to work differently depending on the current user.
  • 当前实现限制了地图的功能,以便映射始终适用于连接到系统的所有键盘。The current implementation restricts the functionality of the map such that mappings always apply to all keyboards connected to the system. 目前不能基于每个键盘创建地图。It is not currently possible to create a map on a per-keyboard basis.

查询鼠标设备Query a mouse device

I8042prt 支持使用以下内部设备控制请求来查询有关鼠标设备的信息:I8042prt supports the following internal device control request to query information about a mouse device:

IOCTL_鼠标_查询_特性IOCTL_MOUSE_QUERY_ATTRIBUTES

有关所有鼠标设备控制请求的详细信息,请参阅人体学接口设备参考For more information about all mouse device control requests, see Human Interface Devices Reference.

与鼠标类驱动程序关联的注册表设置Registry settings associated with mouse class driver

下面是与鼠标类驱动程序相关联的注册表项的列表。The following is a list of registry keys associated with the mouse class driver.

[密钥: HKLM\SYSTEM\CurrentControlSet\Services\Mouclass\参数][Key: HKLM\SYSTEM\CurrentControlSet\Services\Mouclass\Parameters]

  • MaximumPortsServiced –在 Windows XP 和更高版本上不使用。MaximumPortsServiced – Not used on Windows XP and later. 仅适用于 Windows NT4。Only for Windows NT4.
  • PointerDeviceBaseName –指定由鼠标类设备驱动程序创建的设备对象的基名称PointerDeviceBaseName – Specifies the base name for the device objects created by the mouse class device driver
  • ConnectMultiplePorts –确定每个类设备对象是否有一个或多个端口设备对象。ConnectMultiplePorts – Determines whether there is one or more than one port device object for each class device object. 此项主要由设备驱动程序使用。This entry is used primarily by device drivers.
  • MouseDataQueueSize -指定鼠标驱动程序缓冲的鼠标事件数。MouseDataQueueSize - Specifies the number of mouse events buffered by the mouse driver. 它还用于计算非分页内存池中鼠标驱动程序的内部缓冲区的大小。It also is used in calculating the size of the mouse driver's internal buffer in the nonpaged memory pool.

绝对指针设备Absolute pointing devices

对于 GUID 类型的设备 _类_鼠标、设备的函数驱动程序:For devices of type GUID_CLASS_MOUSE, a device's function driver:

  • 处理特定于设备的输入。Handles device-specific input.

  • _输入创建鼠标_ MouseClassServiceCallback所需的数据结构。Creates the MOUSE_INPUT_DATA structures required by MouseClassServiceCallback.

  • 通过在其 ISR 调度完成例程中调用MouseClassServiceCallback ,将_数据结构的鼠标_输入传输到 Mouclass 数据队列。Transfers MOUSE_INPUT_DATA structures to the Mouclass data queue by calling MouseClassServiceCallback in its ISR dispatch completion routine.

对于绝对指针设备,设备的函数驱动程序必须按以下方式_输入_数据结构来设置鼠标的LastX最后Flags成员:For an absolute pointing device, the device's function driver must set the LastX, LastY, and Flags members of the MOUSE_INPUT_DATA structures in the following way:

  • 除了按设备的最大容量划分设备输入值之外,驱动程序还可以通过0xFFFF 来缩放设备输入值:In addition to dividing the device input value by the maximum capability of the device, the driver scales the device input value by 0xFFFF:

    LastX = ((device input x value) * 0xFFFF ) / (Maximum x capability of the device)
    LastY = ((device input y value) * 0xFFFF ) / (Maximum y capability of the device)
    
  • 驱动程序将鼠标_移动_标志中的绝对标志。The driver sets the MOUSE_MOVE_ABSOLUTE flag in Flags.

  • 如果应通过窗口管理器将输入映射到整个虚拟桌面,则驱动程序会在Flags中将鼠标_虚拟_桌面标志。If the input should be mapped by Window Manager to an entire virtual desktop, the driver sets the MOUSE_VIRTUAL_DESKTOP flag in Flags. 如果未设置鼠标_虚拟_桌面标志,则窗口管理器仅将输入映射到主监视器。If the MOUSE_VIRTUAL_DESKTOP flag is not set, Window Manager maps the input to only the primary monitor.

下面按设备类型指定如何实现对绝对定位设备的特殊要求:The following specifies, by type of device, how these special requirements for an absolute pointing device are implemented:

  • HID 设备:HID devices:

    Mouhid 是 HID 鼠标设备的 Windows 函数驱动程序,自动实现这些特殊要求。Mouhid, the Windows function driver for HID mouse devices, implements these special requirements automatically.

  • PS/2 样式设备:PS/2-style devices:

    需要高级筛选器驱动程序。An upper-level filter driver is required. 筛选器驱动程序提供 IsrHook 回调和类服务回调。The filter driver supplies an IsrHook callback and a class service callback. I8042prt 调用 IsrHook 来处理原始设备输入,并调用 filter 类服务回调来筛选输入。I8042prt calls the IsrHook to handle raw device input, and calls the filter class service callback to filter the input. 然后,筛选器类服务回调调用MouseClassServiceCallbackThe filter class service callback, in turn, calls MouseClassServiceCallback. IsrHook 回调和类服务回调的组合处理特定于设备的输入,创建所需的_鼠标_数据结构,缩放设备输入数据,并将鼠标_移动_绝对标志。The combination of the IsrHook callback and the class service callback handles device-specific input, creates the required MOUSE_INPUT_DATA structures, scales the device input data, and sets the MOUSE_MOVE_ABSOLUTE flag.

  • Serenum 枚举的即插即用 COM 端口设备:Plug and Play COM port devices that are enumerated by Serenum:

    需要即插即用函数驱动程序。A Plug and Play function driver is required. 函数驱动程序创建_输入所需的鼠标_数据结构,缩放设备输入数据,并在调用MouseClassServiceCallback之前将鼠标_移动_绝对标志。The function driver creates the required MOUSE_INPUT_DATA structures, scales the device input data, and sets the MOUSE_MOVE_ABSOLUTE flag before it calls MouseClassServiceCallback.

  • 非即插即用 COM 端口设备:Non-Plug and Play COM port devices:

    需要设备特定的函数驱动程序。A device-specific function driver is required. 函数驱动程序创建_输入所需的鼠标_数据结构,缩放设备输入数据,并在调用MouseClassServiceCallback之前将鼠标_移动_绝对标志。The function driver creates the required MOUSE_INPUT_DATA structures, scales the device input data, and sets the MOUSE_MOVE_ABSOLUTE flag before it calls MouseClassServiceCallback.

  • 不受支持的总线上的设备:Device on an unsupported bus:

    需要设备特定的函数驱动程序。A device-specific function driver is required. 函数驱动程序创建_输入所需的鼠标_数据结构,缩放设备输入数据,并在调用MouseClassServiceCallback之前将鼠标_移动_绝对标志。The function driver creates the required MOUSE_INPUT_DATA structures, scales the device input data, and sets the MOUSE_MOVE_ABSOLUTE flag before it calls MouseClassServiceCallback.