Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example for passthrough of a composite device? #3

Open
Deckoz2302 opened this issue Oct 4, 2020 · 1 comment
Open

Example for passthrough of a composite device? #3

Deckoz2302 opened this issue Oct 4, 2020 · 1 comment

Comments

@Deckoz2302
Copy link

Have a composite device here, Mouse report ID 0, Keyboard 1(with several other reports) Below an example of the HID report descriptor

HID Descriptor Page 1
HID Descriptor Page 2

How would you initialize a composite device? Like this?

HIDBoot < USB_HID_PROTOCOL_KEYBOARD | USB_HID_PROTOCOL_MOUSE > HidComposite(&Usb);
HIDBoot<USB_HID_PROTOCOL_KEYBOARD>    HidKeyboard(&Usb);  // Is this needed with composite init above??
HIDBoot<USB_HID_PROTOCOL_MOUSE>    HidMouse(&Usb); // Is this needed with composite init above?

KbdRptParser KbdPrs;
MouseRptParser MousePrs;

void setup()
{
  Serial.begin( 115200 );
  uint8_t attempts = 30;
  while (!Serial && attempts--) {
    delay(100); // Wait for serial port to connect for up to 3 seconds
  }
  Serial.println("Start");

  if (Usb.Init() == -1) {
    Serial.println("USB host shield did not start.");
  }
  delay( 200 );

  HidComposite.SetReportParser(1, &KbdPrs);
  HidComposite.SetReportParser(0, &MousePrs);
  HidKeyboard.SetReportParser(1, &KbdPrs);  // needed if using HidComposite?
  HidMouse.SetReportParser(0, &MousePrs);  // needed if using HidComposite?

  // begin both? or should I used another library for composites?
  Keyboard.begin(); 
  Mouse.begin();
}
@manuel-91
Copy link

As you asked for an initialization routine but didn't describe a problem maybe my approach helps you − or maybe is of interest for other readers:

When I used the USBMsePassThru.ino example it worked for a single mouse but failed with the trackpoint in my USB Keyboard (ThinkPad Lenovo KU-1255). I disabled the HID().SendReport() because it was wrongly wired and clickend randomly for this device. Then I analyzed the bytes coming from the "correct standard mouse" and from the trackpoint. The Trackpoint has one static bye in the beginning, so all following bytes had to be shifted:

    if (len == 6) {
      uint8_t mouseRpt[4];
      mouseRpt[0] = buf[1];
      mouseRpt[1] = buf[2];
      mouseRpt[2] = buf[3];
      mouseRpt[3] = buf[4];

With that the pass through worked correctly. Both the first and last value had no meaning for this device.

When scrolling horizontally a 3 byte block with a leading 16 + scroll value + static 0 was sent which I don't want to forward, this is why I added the hardcoded length check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants