将过滤器驱动程序连接到Xbox 360控制器的设备是什么?

时间:2011-05-11 04:08:25

标签: filter driver wdk joystick

作为一项学习练习,我正在尝试在Windows 7 64位上为有线XBox 360控制器编写过滤器驱动程序。该控制器显示为HID操纵杆,因此它看起来应该是直截了当的。

我为我的鼠标制作了一个示例过滤器驱动程序,用于交换左右鼠标按钮。这是基于WDK附带的moufiltr和firefly样本。但是,我无法将此示例转换为XBox 360控制器。

当我插入控制器时,设备管理器中会出现3个不同的设备:

  • 人机接口设备/符合HID标准的游戏控制器
  • 人机接口设备/ USB人机接口设备
  • 适用于Windows的Windows Class / Xbox 360 Controller的通用控制器

我应该将我的驱动程序中的哪一个附加到?

使用鼠标过滤器驱动程序,我可以关注firefly示例中的installation directions:右键单击设备管理器中的鼠标,选择“更新驱动程序”。使用XBox 360控制器,我不确定我应该为哪个设备安装驱动程序。或者他们是否都独立与硬件交谈,我需要为每一个安装一个过滤器?

我应该注意,我已经尝试将过滤器驱动程序附加到3个设备中的每个设备,以便打印出我的过滤器驱动程序可用的IOCTL。对于“USB人机接口设备”,我的过滤器没有收到IOCTL。

对于符合HID标准的游戏控制器,它收到了:

  • IOCTL_HID_GET_COLLECTION_INFORMATION(多次)
  • IOCTL_HID_GET_COLLECTION_DESCRIPTOR(多次)
  • IOCTL_GET_SYS_BUTTON_CAPS

对于适用于Windows的Xbox 360控制器,它会收到一堆我无法追踪符号名称的IOCTL:

  • 0x80006000(多次)
  • 0x8000e00c(多次)
  • 0x8000e008
  • 0x8000a010
  • 0x8000e018
  • 0x8000e014

不幸的是,我仍然不知道我应该尝试过滤哪个设备。 (我希望他们中的一个会收到相当于IOCTL_INTERNAL_MOUSE_CONNECT的操纵杆,但情况似乎并非如此。)

2 个答案:

答案 0 :(得分:0)

我认为你想过滤内部IOCTL(特别是IOCTL_HID_GET_INPUT_REPORT / IOCTL_HID_READ_REPORT)

您可能已经过滤了EvtIoDeviceControl尝试EvtIoInternalDeviceControl并查找读取/获取输入报告ioctl,这将来自任何想要读取操纵杆事件的系统服务。

一旦你设法过滤了正确的ioctl,你需要查看该操纵杆的报告描述符,以找出如何解释(然后修改)数据。

答案 1 :(得分:0)

从xusb22.sys XInputRequestDispatcher :: Dispatch():

0x80006000 DispatchGetInformation((XInputRequestServicers *)this, (WDFREQUEST)request, (RequestBuffers*)buffer, (ULONG)ioctlCode);
0x8000A010 DispatchSetState((XInputRequestServicers *)this, (WDFREQUEST)request, (RequestBuffers*)buffer);
0x8000A01C DispatchPowerDownDevice((XInputRequestServicers *)this, (WDFREQUEST)request, (RequestBuffers*)buffer);
0x8000E004 DispatchGetCapabilities((XInputRequestServicers *)this, (WDFREQUEST)request, (RequestBuffers*)buffer);
0x8000E008 DispatchGetLedState((XInputRequestServicers *)this, (WDFREQUEST)request, (RequestBuffers*)buffer)
0x8000E00C DispatchGetState((XInputRequestServicers *)this, (WDFREQUEST)request, (RequestBuffers*)buffer);
0x8000E014 DispatchWaitForGuideButton((XInputRequestServicers *)this, (WDFREQUEST)request, (RequestBuffers*)buffer)
0x8000E018 DispatchGetBatteryInformation((XInputRequestServicers *)this, (WDFREQUEST)request, (RequestBuffers*)buffer);
0x8000E020 DispatchGetAudioDeviceInformation((XInputRequestServicers *)this, (WDFREQUEST)request, (RequestBuffers*)buffer);
0x8000E3AC DispatchWaitForInput((XInputRequestServicers *)this, (struct XenonBusInformation *)&v6, (RequestBuffers*)buffer);
0x8000E3FC DispatchGetInformationEx((XInputRequestServicers *)this, (WDFREQUEST)request, (RequestBuffers*)buffer);

因此,我们可以反转工程师代码:

#include <windows.h>

// https://docs.microsoft.com/windows-hardware/drivers/kernel/defining-i-o-control-codes
// {EC87F1E3-C13B-4100-B5F7-8B84D54260CB}
DEFINE_GUID(XUSB_INTERFACE_CLASS_GUID, 0xEC87F1E3, 0xC13B, 0x4100, 0xB5, 0xF7, 0x8B, 0x84, 0xD5, 0x42, 0x60, 0xCB);

// xusb22.sys IOCTLs
#define FILE_DEVICE_XUSB    0x8000
#define IOCTL_INDEX_XUSB    0x0800

#define IOCTL_XUSB_GET_INFORMATION              /*0x80006000*/ CTL_CODE(FILE_DEVICE_XUSB, IOCTL_INDEX_XUSB + 0, METHOD_BUFFERED, FILE_READ_ACCESS)
#define IOCTL_XUSB_GET_CAPABILITIES             /*0x8000E004*/ CTL_CODE(FILE_DEVICE_XUSB, IOCTL_INDEX_XUSB + 1, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
#define IOCTL_XUSB_GET_LED_STATE                /*0x8000E008*/ CTL_CODE(FILE_DEVICE_XUSB, IOCTL_INDEX_XUSB + 2, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
#define IOCTL_XUSB_GET_STATE                    /*0x8000E00C*/ CTL_CODE(FILE_DEVICE_XUSB, IOCTL_INDEX_XUSB + 3, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
#define IOCTL_XUSB_SET_STATE                    /*0x8000A010*/ CTL_CODE(FILE_DEVICE_XUSB, IOCTL_INDEX_XUSB + 4, METHOD_BUFFERED, FILE_WRITE_ACCESS)
#define IOCTL_XUSB_WAIT_GUIDE_BUTTON            /*0x8000E014*/ CTL_CODE(FILE_DEVICE_XUSB, IOCTL_INDEX_XUSB + 5, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
#define IOCTL_XUSB_GET_BATTERY_INFORMATION      /*0x8000E018*/ CTL_CODE(FILE_DEVICE_XUSB, IOCTL_INDEX_XUSB + 6, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
#define IOCTL_XUSB_POWER_DOWN                   /*0x8000A01C*/ CTL_CODE(FILE_DEVICE_XUSB, IOCTL_INDEX_XUSB + 7, METHOD_BUFFERED, FILE_WRITE_ACCESS)
#define IOCTL_XUSB_GET_AUDIO_DEVICE_INFORMATION /*0x8000E020*/ CTL_CODE(FILE_DEVICE_XUSB, IOCTL_INDEX_XUSB + 8, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
#define IOCTL_XUSB_WAIT_FOR_INPUT               /*0x8000E3AC*/ CTL_CODE(FILE_DEVICE_XUSB, IOCTL_INDEX_XUSB + 235, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
#define IOCTL_XUSB_GET_INFORMATION_EX           /*0x8000E3FC*/ CTL_CODE(FILE_DEVICE_XUSB, IOCTL_INDEX_XUSB + 255, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)