Joystick equivalent of MouseClassServiceCallback and/or IOCTL_INTERNAL_MOUSE_CONN

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:

  1. In EvtDriverDeviceAdd, it adds a default I/O queue in order to receive IOCTL_INTERNAL_MOUSE_CONNECT
  2. When IOCTL_INTERNAL_MOUSE_CONNECT is received, the driver overrides the MouseClassServiceCallback routine so that it will receive MOUSE_INPUT_DATA packets
  3. 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?

There is no such callback for joysticks. Only keyboards and mice have the service callback. All other HID devices just use the HID IOCTLs (and maybe read/write) to talk to the device. If you want to filter a keyboard, attach an upper filter to the raw PDO HID enumerates for the joystick (the one with the hardware ID starting with "HID", not the one starting with "USB"). Now the 360 joystick makes life even more complicated. IIRC, the common controller is not HID, but XID and the XID device io interface (ie the IOCTLs and IRPs you would filter) is not documented. For the 3 devices you listed below, are any controlled by hidusb? Or some other driver like xidusb.sys or xnacc.sys?

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@countlessprojects.com
Sent: Sunday, May 15, 2011 3:09 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Joystick equivalent of MouseClassServiceCallback and/or IOCTL_INTERNAL_MOUSE_CONN

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:

  1. In EvtDriverDeviceAdd, it adds a default I/O queue in order to receive IOCTL_INTERNAL_MOUSE_CONNECT 2. When IOCTL_INTERNAL_MOUSE_CONNECT is received, the driver overrides the MouseClassServiceCallback routine so that it will receive MOUSE_INPUT_DATA packets 3. 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?


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer