Author Topic: HID Mouse and Keyboard on the same 18F2550  (Read 5483 times)

towlerg

  • Member
  • ***
  • Posts: 24
HID Mouse and Keyboard on the same 18F2550
« on: December 15, 2018, 07:18:19 am »
I'm trying to get a device to be both keyboard and mouse (personalized wireless remote). I have mouse and keyboard working separatley but at that point my limited understanding of descriptors (and indeed USB generally) fails me.

On the Microchip board this example https://www.microchip.com/forums/FindPost/142315 was suggested. I modified my existing working mouse descriptor and now it seems to enumerates correctly - in device manager I now have an extra USB input device, an extra HID keyboard and an extra HID mouse but the mouse "draw a square" code no longer appearently does anything.

BTW I use Proton Basic to program PIC's, I've tried C but my brain must be just too small.

Hardware appears to be sound, it ran the mouse only code ok, enemerated but did nothing with the modified code, then worked ok again with mouse only code.

I realize that I have only posted part of the project but I am at a loss to know what bits would help.

I include my original and modified descriptors.

Is this method sound?  Any suggestions, advice etc

George

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: HID Mouse and Keyboard on the same 18F2550
« Reply #1 on: December 15, 2018, 10:55:19 am »
Yes, the microchip link explains what you need to do to implement a mouse and keyboard with a single HID interface. Your descriptors look OK though I may have missed something.

Your device will also need code to implement the mouse and keyboard functions. One difference with the mouse + keyboard device is that the mouse data uses report ID 1. So you need to be sure your device is sending mouse data with 01h as the first byte.

Another option is to implement a composite device, where the mouse and keyboard functions each have their own HID interface and endpoints. In this case, you don't need to modify the mouse code, just add keyboard code in a second interface.

towlerg

  • Member
  • ***
  • Posts: 24
Re: HID Mouse and Keyboard on the same 18F2550
« Reply #2 on: December 15, 2018, 02:40:26 pm »
Quote
So you need to be sure your device is sending mouse data with 01h as the first byte.
Just to clarify, if my mouse code works in isolation does that mean it is ok to use as-is with the modified descriptor?

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: HID Mouse and Keyboard on the same 18F2550
« Reply #3 on: December 15, 2018, 09:13:33 pm »
You need to be sure your device is sending mouse data with 01h (report ID) as the first byte.

towlerg

  • Member
  • ***
  • Posts: 24
Re: HID Mouse and Keyboard on the same 18F2550
« Reply #4 on: December 19, 2018, 12:56:19 pm »
Jan, could I impose on you to look at the attached logs. I freely admit they make little sense to me. They seem contradictory, USBTrace has an error STATUS_INVALID_PARAMETER and USBlyser has Babble_detect and Invalid_Pipe_Handle. Any hints gladly accepted.

BTW I took your advice and now write 01 to the first byte although it does not appear to make a difference.

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: HID Mouse and Keyboard on the same 18F2550
« Reply #5 on: December 19, 2018, 03:07:27 pm »
Seq 1-12 appear to show successful enumeration though hard to verify without seeing the requests and reponses.

The host then appears to be attempting interrupt OUT transactions to endpoint EP 81 (OUT 1) (#13), which are failing.

I don't know why the IN transfer attempts (#15) are also using EP 81, should be 1 (IN 1).

I don't have an app that can read the other two files.

towlerg

  • Member
  • ***
  • Posts: 24
Re: HID Mouse and Keyboard on the same 18F2550
« Reply #6 on: December 19, 2018, 03:38:05 pm »
Jan, thanks for looking at my logs, one lasr question, what is babble?

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: HID Mouse and Keyboard on the same 18F2550
« Reply #7 on: December 20, 2018, 10:28:47 am »
From USB 2.0 spec:

Babble Unexpected bus activity that persists beyond a specified point in a
(micro)frame.