I’m trying to write a filter driver for my joystick which swaps a couple of the buttons, but I’m running into some problems. This is my first attempt at writing a device driver (on windows, at least) so it could be that I’m just missing something fundamental.
I started by modifying the firefly and moufiltr samples to make an upper filter driver that swaps the left and right mouse buttons. Here’s what it does:
- In EvtDriverDeviceAdd, it adds a default I/O queue in order to receive IOCTL_INTERNAL_MOUSE_CONNECT
- When IOCTL_INTERNAL_MOUSE_CONNECT is received, the driver overrides the MouseClassServiceCallback routine so that it will receive MOUSE_INPUT_DATA packets
- When a MOUSE_INPUT_DATA packet is received, the driver swaps the button flags (if any) before passing the event along.
This works great. I’m having trouble converting it to work for my joystick though. I can’t figure out what the joystick equivalents to IOCTL_INTERNAL_MOUSE_CONNECT and MouseClassServiceCallback are.
The joystick I’m trying to use here is an xbox 360 controller. It shows up as a multi-axis joystick, with 3 different entries in device manager:
* Human Interface Devices/HID-compliant game controller
* Human Interface Devices/USB Human Interface Device
* Common Controller for Windows Class/Xbox 360 Controller for Windows
For each of these, I added a filter driver to sniff the IOCTL events. For the “USB Human Interface Device” my filter received no IOCTLs.
For the HID-compliant game controller, it received:
* IOCTL_HID_GET_COLLECTION_INFORMATION (multiple times)
* IOCTL_HID_GET_COLLECTION_DESCRIPTOR (multiple times)
* IOCTL_GET_SYS_BUTTON_CAPS
For the Xbox 360 Controller for Windows, it receive a bunch of IOCTLs that I can’t track down a symbolic name for:
* 0x80006000 (multiple times)
* 0x8000e00c (multiple times)
* 0x8000e008
* 0x8000a010
* 0x8000e018
* 0x8000e014
None of these look like a “device connect” event, so now I’m at a loss. Any ideas what I’m missing? I had assumed that since both the mouse & joystick are HID devices, it would be easy to convert the mouse filter driver, but maybe that was naively optimistic. Am I taking completely the wrong approach in trying to use the same pattern as worked for the mouse?