Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 8 of 8

Thread: Teensyduino USB Joystick no-data driver problem/workaround

  1. #1

    Teensyduino USB Joystick no-data driver problem/workaround

    Hi all,

    This post reports on the Teensy++ 2.0 example Joystick/Complete not working on some machines.

    We have the guts of an analog joystick (with switches) wired to the Teensy, running the example code.

    When plugged into several different Windows desktops or laptops (mostly Win 7 pro), this works fine, for example as seen in joy.cpl, or using Joystick Tester (http://www.mcrenox.com.ar/downloads/).

    However, when plugged into a particular laptop ("The Problem Machine", Lenovo Z575 Win 7 Home), although the Teensy appears in joy.cpl, the Properties window is blank (no graph of X-Y, slides or switches).

    Another user also reported this kind of problem: http://forum.pjrc.com/threads/1319-t...topped-working

    Joystick Tester on the Problem Machine is similarly without data. Notably, the panel which shows data from the HID Report shows Max axes 6, Number of axes 0, Max buttons 32, Number of buttons 32.

    I.e., Windows sees the joystick device, can read its device info, but mysteriously the number of data items actually available is zero.

    This is the behavior when the Teensy code is compiled with the Arduino "USB Type" set to "Keyboard + Mouse + Joystick".

    If instead we switch USB Type to "Serial + Keyboard + Mouse + Joystick", then the joystick works fine on The Problem Machine.

    So is seems that there is something in the config_descriptor or joystick_hid_report_desc, when it's compiled with "K+M+J", that causes The Problem Machine to think there are no data items for the Joystick.

    Bear in mind, again, that "K+M+J" works fine when Teensy is plugged into the six different other machines that we tried.

    We also tried deleting all the serial code from example Complete (and also the examples that don't use serial), and these moves didn't result in proper behavior on The Problem Machine.

    So, we have the workaround of using SUB Type = S+K+M+J, but it's worrisome that just K+M+J didn't work.

    Other info:
    -----------
    These results (K+M+J bad, S+K+M+J good) were obtained after installing Arduino 1.0.4, Teensyduino 1.13 and teensy serial driver onto The Problem Machine. The non-working condition was encountered prior to installing Arduino etc. What we don't know is whether S+K+M+L would have worked with Arduino etc not installed (and/or whether that would prompt Windows to look for a serial driver -- doh!).

    ----------
    Ideas?

    -- Graham

  2. #2

    Joystick no-data problem solved

    Issue addressed
    ---------------
    This concerns Teensyduino USB joystick, on a particular "problem machine", showing up in joy.cpl, but with the Properties window displaying blank, as though the joystick contains no analog or digital variables. On other machines the Teensy USB joystick works fine.

    Short version of fix
    --------------------
    Delete from the registry all keys containing VID_16c0.

    Explanation
    ------------
    After a lot of inspection of Teensy USB traffic with USBLyzer, I think we have an answer and a fix for the problem. The USB activity during hot-plug indicates that on the problem machine, Windows associates driver mouhid.sys with the joystick. On machines that read the joystick properly, Windows associates the joystick with hidusb.sys.

    The registry stores a lot of keys in various places that contain the Vendor Id used by the joystick: VID_16c0. It appears that the function of some of these keys is to remember the result of the first time the device was plugged in, and a driver found. There are separate keys for the different sub device Product Ids corresponding to Mouse, Keyboard, Debug and Joystick, and possibly Serial (depending on the setting for USB type in the Arduino environment), and this info may be stored separately per USB socket.

    It seems that if that process decides on the "wrong" driver for some reason (for example, chooses the mouse driver mouhid.sys), then the system will be stuck with that choice in future. This mistaken association could perhaps happen during development with the Teensy, or perhaps due to interrupting the process of finding the right driver during initial plug-in.

    In previous attempts to fix this problem, we used USBDeview to view information that Windows was retaining for various USB devices. In USBDeview we deleted all records associated with VID_16c0. This did not resolve the problem, and we wrongly concluded that this meant it wasn't a problem of wrong info being retained.

    Prompted by inspecting the USB traffic, we tried to track down how the registry might be directing Windows to use mouhid.sys instead of hidusb.sys. However, there were far too many registry records to look at in detail (evidently more than USBDeview shows). So instead we decided to delete all keys containing VID_16c0 (probably more than a hundred deletions).

    This is problematic because some of the sub keys have ownership set to System and are not viewable or deletable by even Admins. To get around this, we discovered that regedit can be launched via psexec http://technet.microsoft.com/en-us/s.../bb897553.aspx so that it runs regedit as the System user:

    In a Run-as-admin cmd window :
    [path-to-psexec]\psexec.exe -i -s c:\windows\regedit.exe
    pause

    With all the VID_16c0 keys deleted, when we next plugged in the Teensy joystick, Windows went through the process of finding suitable drivers, and then joy.cpl worked properly.

    Hope that helps!

    -- Graham

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,227
    Wow, thanks for writing this! It's so rare there's ever any resolution to these strange Windows problems.

    Maybe I should look into making the installer able to detect these registry keys and offer an option to delete them?

  4. #4
    Hi Paul --

    Thanks for taking note of this issue and commenting. I really enjoy what you've done with Teensy and the USB functionality, so it's a pleasure to have the opportunity to send a little something back in the way of "troubleshooting from the field".

    Yes, I think it would be great to offer a way to delete all registry entries that have resulted from Windows USB driver install process. Putting that in the Teensyduino installer might not be optimum though, as the search process is liable to be s-l-o-w. I had already been considering what I'd write if I encounter this problem again, and I think it would be a separate utility that can perform two related functions:

    (a) find and list all the keys that contain VID_16C0 (or allow user to set the VID), so one can monitor the variety and proliferation (or not) of such keys. (Ie: both as diagnostic and learning-about-USB tool.)

    (b) Delete them (presumably if run as user System, using psexec or similar).

    I should also note that there are additional Teensy-USB-related keys named using a concatenation of VID and PID (ie: without the 'VID_' or 'PID_' prefixes), like this:

    HKEY_LOCAL_MACHINE\SYSTEM\[CurrentControlSet|ControlSet00[1|2]]\Control\usbflags\16C004820105

    (and one cannot simply search for 16C0, as that will hit a bunch of GUIDs that happen to contain that string).

    I'm also thinking that in the interests of reducing the proliferation of keys, and complexity of including multiple subdevices that might not be needed, it would be nice if USB Type could be set to any combo of one or more of Serial, Joystick, Mouse or Keyboard (plus the debug device). That's probably straightforward to address in the C code (add a few additional def values and ifdefs), but I haven't yet seen how these additional choices would get onto the Arduino USB Type menu. Clues?

    Hope that helps,

    -- Graham

  5. #5
    Junior Member
    Join Date
    Jan 2016
    Posts
    10
    Quote Originally Posted by gwideman View Post
    Issue addressed
    ---------------
    This concerns Teensyduino USB joystick, on a particular "problem machine", showing up in joy.cpl, but with the Properties window displaying blank, as though the joystick contains no analog or digital variables. On other machines the Teensy USB joystick works fine.

    Short version of fix
    --------------------
    Delete from the registry all keys containing VID_16c0.

    Explanation
    ------------
    After a lot of inspection of Teensy USB traffic with USBLyzer, I think we have an answer and a fix for the problem. The USB activity during hot-plug indicates that on the problem machine, Windows associates driver mouhid.sys with the joystick. On machines that read the joystick properly, Windows associates the joystick with hidusb.sys.

    The registry stores a lot of keys in various places that contain the Vendor Id used by the joystick: VID_16c0. It appears that the function of some of these keys is to remember the result of the first time the device was plugged in, and a driver found. There are separate keys for the different sub device Product Ids corresponding to Mouse, Keyboard, Debug and Joystick, and possibly Serial (depending on the setting for USB type in the Arduino environment), and this info may be stored separately per USB socket.

    It seems that if that process decides on the "wrong" driver for some reason (for example, chooses the mouse driver mouhid.sys), then the system will be stuck with that choice in future. This mistaken association could perhaps happen during development with the Teensy, or perhaps due to interrupting the process of finding the right driver during initial plug-in.

    In previous attempts to fix this problem, we used USBDeview to view information that Windows was retaining for various USB devices. In USBDeview we deleted all records associated with VID_16c0. This did not resolve the problem, and we wrongly concluded that this meant it wasn't a problem of wrong info being retained.

    Prompted by inspecting the USB traffic, we tried to track down how the registry might be directing Windows to use mouhid.sys instead of hidusb.sys. However, there were far too many registry records to look at in detail (evidently more than USBDeview shows). So instead we decided to delete all keys containing VID_16c0 (probably more than a hundred deletions).

    This is problematic because some of the sub keys have ownership set to System and are not viewable or deletable by even Admins. To get around this, we discovered that regedit can be launched via psexec http://technet.microsoft.com/en-us/s.../bb897553.aspx so that it runs regedit as the System user:

    In a Run-as-admin cmd window :
    [path-to-psexec]\psexec.exe -i -s c:\windows\regedit.exe
    pause

    With all the VID_16c0 keys deleted, when we next plugged in the Teensy joystick, Windows went through the process of finding suitable drivers, and then joy.cpl worked properly.

    Hope that helps!

    -- Graham

    thank you thank you thank you!!!!! this finally allowed me to get my controls working.

  6. #6
    Quote Originally Posted by potatomasher View Post
    thank you thank you thank you!!!!! this finally allowed me to get my controls working.
    You're welcome! Nice to hear that it helped.

    Graham

  7. #7
    Junior Member
    Join Date
    Nov 2018
    Posts
    1
    Quote Originally Posted by gwideman View Post
    You're welcome! Nice to hear that it helped.
    Graham
    I have experienced this now several times when using different Teensyduino USB Joysticks on a machine.
    Thank you Graham, for providing a fix to this problem.

    I wonder, however, whether in the meantime additional insights into the origin of the problem have been gathered.

    Is there a way to prevent this problem from occurring at all?

    Thanks,
    cramp

  8. #8
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    2,165
    Quote Originally Posted by acramp View Post

    Is there a way to prevent this problem from occurring at all?

    Thanks,
    cramp
    Just keep away from Windows. I’ve seen it growing from the beginning. There are plug and play issues not fixed since 1995. If Bill Gates was Japanese, he would have had to commit a ritual suicid for all the crap he brought to market.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •