USB HID filter or minidriver for custom mouse/keyboard?

Discussion in 'Windows Vista Drivers' started by skillzero, Apr 15, 2006.

  1. skillzero

    skillzero Guest

    I need to suport a custom USB mouse-like device and I'm not sure
    whether to write a filter driver or a minidriver (class driver?). The
    built-in Windows XP USB driver works with this device (I can move the
    pointer around, click, etc.). One problem is that the hardware needs to
    be put into a special low power mode when there is no activity.

    Is there a way I can let the Microsoft USB driver handle the USB HID
    stuff and my code can do power management? If so, is there sample code
    I can look at for doing any of this? I've seen some sample code for USB
    devices, but it was a ton of code for managing the whole device and I'm
    hoping I can let the built-in HID driver do most of the work so that
    I'd only need to do the parts that aren't handled by the built-in
    Microsoft HID driver.

    Similarly, this device also has a keyboard built into it (shows up
    separately as a keyboard to USB, but physically part of the same
    device). It also works with the built-in Microsoft driver, but I need
    to handle a few special buttons to write to some IO ports (that's the
    way the hardware works). I also need to do some power management for it
    so I wasn't sure if it should be a filter driver or not. Are there any
    examples showing how to do this kind of stuff?
     
    skillzero, Apr 15, 2006
    #1
    1. Advertisements

  2. a filter driver cannot be the power policy owner for the HID FDO stack,
    sorry. by power down, do you mean by sending a cmd to the hardware itself
    or by putting the actual hardware into D2 by sending a power irp to the hub
    PDO?

    as for the keyboard, can you put your special buttons in a separate top
    level collection? if so, they you can write a HID mapper driver and read
    those buttons. as for putting it into low power, the same questions apply
    as before.

    even as a HID miniport, you don't control the power state, hidclass.sys is
    the power policy owner and decides when to send power irps.

    d
     
    Doron Holan [MS], Apr 16, 2006
    #2
    1. Advertisements

  3. I envision 2 drivers here - 1 functional HID driver for the additional
    buttons (are they a separate HID collection?) and 1 lower filter between HIDUSB
    and the USB stack to held USBHID in power management.
     
    Maxim S. Shatskih, Apr 16, 2006
    #3
  4. skillzero

    skillzero Guest

    When I say power down, I really just mean sending a command to the
    hardware to reduce its power consumption, but not actually changing its
    power state per say. It basically just tells it to not read its sensors
    so often if nothing has happened in a while (which I hope to detect by
    polling it periodically from a timer in my driver).

    Regarding the keyboard, can I use a separate top level collection
    without changing the device's firmware or hardware? I'm not able to
    change the hardware or firmware so I have to go with a software-only
    solution. Sorry, but I'm not very well versed with USB HID devices. I'm
    trying to learn though so if you know anything I can read, I'd
    appreciate any references.
     
    skillzero, Apr 17, 2006
    #4
  5. yes, you need to change the firmware. whomever made your firmware didn't
    udnerstand HID if they didn't split out the special buttons.

    OK, so let's assume you can send your command to reduce power consumption.
    in this mode, does your device still report data? if not, how will you know
    to turn the device back on so that the user still has a functioning HID?

    to be able to determine when to send the power down cmd, I would assume you
    are looking for a period of time where the device has not reported any data
    back to the host. You can do this by installing a lower filter to hidusb
    and setting a completion routine on the URBs that HIDCLASS sends to read the
    data. You reset your timer when the completion routine runs. If the timer
    fires, you then send the command. If the device can still report data, you
    have nothing left to do. If the device now needs to be manually powered on,
    i have no idea how you are going to repower on the device.

    are the special keys you need to filter out in the keyboard top level
    collection?

    d
     
    Doron Holan [MS], Apr 17, 2006
    #5
  6. skillzero

    skillzero Guest

    The buttons are on the same interface as the keyboard and act as normal
    F-keys in some situations. For example, if another key is held down
    when one of these special keys is pressed, software is supposed to make
    it generate an F-key (e.g. F6).

    Is there a way for my driver to load and process these special keys,
    but pass all the other USB stuff on to the Microsoft HID keyboard
    driver?

    Regarding the power management stuff...I have to poll the device every
    few seconds to read its activity counter and if there hasn't been any
    activity in a while, I'll send it a command to reduce how often it
    samples its sensors. Even in this reduced power state, it will generate
    interrupt pipe transactions as needed...it effectively just reduces its
    duty cycle to conserve power.
     
    skillzero, Apr 17, 2006
    #6
  7. hopefully the endpoint you are polling on can handle traffic that is also
    sent by HIDCLASS if you are sharing an endpoint.

    as fro the f key stuff, you can sit as a lower filter to kbdhid and trap the
    IRP_MJ_READs that are coming up from the device, use hidparse.sys to parse
    the data and then maintain state and chnage the buffer as needed.
    firefly.sys shows you how to get a preparsed data for the PDO.

    d
     
    Doron Holan [MS], Apr 17, 2006
    #7
  8. Regarding the power management stuff...I have to poll the device every
    Then this is not Windows power management. Do this in your own way.
     
    Maxim S. Shatskih, Apr 18, 2006
    #8
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.