USB HID on Photon. Failure to Launch/Enumerate

Hi Folks,

Trying to get the basics of USB HID working on a spare Photon I’ve got lying around, and I’m getting absolutely nowhere.

I’ve cut everything back to what I think is the absolute bare minimum test case, which is basically a cut-and-paste from the Mouse class reference docs:

// Use STARTUP() macro to avoid USB disconnect/reconnect (see begin() documentation)
STARTUP(Mouse.begin());
SYSTEM_THREAD(ENABLED);

void setup() {
  // Set screen size to 1920x1080 (to scale [0, 32767] absolute Mouse coordinates)
  Mouse.screenSize(1920, 1080);
  // Move mouse to the center of the screen and click left button
  Mouse.moveTo(1920 / 2, 1080 / 2);
  Mouse.click(MOUSE_LEFT);
  // Move mouse from the current position by 100 points (not pixels) left
  Mouse.move(-100, 0);
  // Press right mouse button (and leave it pressed)
  Mouse.press(MOUSE_RIGHT);
  // Scroll wheel in the negative direction
  Mouse.scroll(-127);
  // Release right mouse button
  Mouse.release(MOUSE_RIGHT);
}

void loop() {
  // Move mouse from the current position by 100 points (not pixels) left
  Mouse.move(-100, 0);
  delay(100);
}

The result - nothing. No mouse movement at all. I can’t even see the photon enumerating a new USB device on startup. I’ve looked under Keyboards, Mice and ‘Human Interface Devices’ in the device manager, no signs of action anywhere.

Firmware’s 0.6.2 (current stable I assume), I’m running Win 7 Pro.

Any suggestions?

Further Information - I hooked up a button, and am calling Mouse.begin() and Keyboard.begin() on rising edge (button release) and Mouse.end() and Keyboard.end() on falling edge (button press). I’m toggling the D7 LED, so I know the press is being detected, but nothing else happens. From the docs I believe I should expect a USB disconnect/reconnect cycle on each of those edges, but I’m seeing nothing.

@DKW_Engineering,

Try this:

// Keyboard.begin() within startup allows the HID device attach for the first time after boot 
// with *both* Serial and Keyboard
STARTUP(Keyboard.begin());

Let us know how it goes!

No Dice.

Start of code now looks like:

// Use STARTUP() macro to avoid USB disconnect/reconnect (see begin() documentation)
STARTUP(Mouse.begin());
STARTUP(Keyboard.begin());
SYSTEM_THREAD(ENABLED);

Still no action. Test with button triggering begin/end also still broken.

@DKW_Engineering

Perhaps try this:

or

Have you tried installing the new drivers? https://github.com/spark/windows-device-drivers/releases/tag/v6.1.0.68

HID doesn’t require any, but if you have pre-0.6.0 drivers installed, they might prevent HID as well as USBSerial1 from working correctly.

Thanks @avtolstoy

Turns out it was indeed a driver issue. Strange thing is this was working on a completely fresh install, I’ve never had the console or drivers installed on this machine before. I used the current links in the docs, including the particle USB drivers, which gave me 6.1.0.51.

The driver install from that link enabled everything to enumerate correctly.

I plugged the photon into a fresh Win7 install, no particle console or drivers, and on that the HID enumerated correctly as-well.

That is the expected behaviour. USB HID is supported by most OSs without the need for any proprietory drivers. Hence on a clean Windows it’ll work as is.
But as Andrey said, if you had the old Particle drivers installed before, they’d be getting in the way of the default system drivers, hence just removing the old drivers from your system completely would have helped just the same for HID to work.
On the other hand you’ll still need Particle drivers for Serial support on Windows versions pre 10, but the new ones will not get in your way with HID support anymore.

1 Like

Cheers @ScruffR, Makes sense now.

I’ll have to chase down where I downloaded the broken driver installer from so they can pull that link. It was somewhere in the ‘getting started’ docs pages, but I’m not sure where. Damn annoying thing to spend a day and a half on :frowning:

1 Like