Qmk_firmware: [Feature Request] RAW HID and Console on V-USB

Created on 5 Mar 2020  路  12Comments  路  Source: qmk/qmk_firmware


Looking at VUSB which is the bases of all the atmega32a and 328p mcus the above 2 features are missing.
Console is especially vital for debugging.
With the help of @fauxpark we have concluded that we need more than the 2 endpoints V-USB shows in all its examples.

This is because 1 endpoint is used to the keyboard HID and the second endpoint for extrakeys and mouse.

A further endpoint would be needed for Console and another for RAW HID.

Any ideas or experiences how to implement this are welcome.

Feature Request Type

  • [x] Core functionality
  • [ ] Add-on hardware support (eg. audio, RGB, OLED screen, etc.)
  • [ ] Alteration (enhancement/optimization) of existing feature(s)
  • [ ] New behavior

Description

enhancement help wanted

Most helpful comment

Ill give it a look later tonight
:) even tho I think a lot of people would want extrakeys as a minimum

All 12 comments

Good timing! I implemented this feature on plaid and keycapsss/plaid_pad.

https://github.com/hsgw/qmk_firmware/tree/VUSB_HIDRAW

I try to choose mouse/extrakeys or hid_raw for now.

I had done to recognize it as a composite device from OS and send data from the device to the host.
I succeed to send data from the host to the device on plaid_pad. but I fail it on plaid and tartan.

~I think that usb polling rate is not enough to keep correct USB connection, because keyboard_task() and matrix_scan() takes time.~

I looked up a bit more this issue, I found strange behavior.

On plaid, interrupt transfer from host uses EP3 and fail, but, on plaid_pad, control transfer (setup-data stage) uses EP1 and success.
I think both keyboards use same config and host code 馃

(edited)

Finally, I got it working correctly on plaid. I tested with this.
https://hsgw.github.io/webhid_qmk/
When use webhid on chrome, please set chrome flag to enable.
https://bugs.chromium.org/p/chromium/issues/detail?id=890096#c38

But I can't do on plaid_pad. Can anyone test with my code?
https://github.com/hsgw/qmk_firmware/tree/VUSB_HIDRAW~~

See latest comment

Ill give it a look later tonight
:) even tho I think a lot of people would want extrakeys as a minimum

extrakeys support

I will try same method as KEYBOARD_SHARED_EP.

I have added you on discord, Have a few questions:)

I read VUSB codes on QMK again, and I realized the following issues.

  • "Boot keyboard" and "Boot mouse" is not implemented on VUSB

    • need to handle USBRQ_HID_(SET/GET)_PROTOCOL in vusb.c.

      but I can use plaid in bios

  • "Boot mouse" is not implemented on LUFA

    • on ChibiOS, boot keyboard and mouse is implemented

And

  • Adding ep4 to VUSB is possible.

    • from discussion with @yiancar

Therefore, I will try implemented following method.

  • EP1 is keyboard (mouse/extrakey shared option)
  • EP3 is hid_raw or mouse/extrakey
  • EP4 is reserved for console

First, I will make a PR to add hid_raw feature soon.

If you have any suggestion, please advise me!

Small update as well:
Looks like we have managed to get 32byte reports in and out! I will be testing this with VIA and see how it goes.

From a brief look on adding EP4 (and a very helpful email from the authors of V-USB) it looks like it can be done. However it will mean spinning our own version of the library, something that might harm future code maintenance.

Due to the above, I think that @hsgw proposal is a very reasonable compromise.
As boot keyboard was not there anyway, add an option to share EP1 with mouse/extrakeys. This opens up the route to hid_raw. If there is further time and will we can try opening up EP4.

However it will mean spinning our own version of the library, something that might harm future code maintenance.

That's why I'd like to get #8321 in before any of this work is done; we can then fork the V-USB repo to qmk/v-usb and apply our modifications there while still being able to pull down any updates from upstream.

Any idea when that will be done? We can keep testing in the meantime

It's ready to go, just needs more eyes on it. Will also need https://github.com/qmk/qmk_compiler/pull/62 merged & deployed at the same time so as to not break Configurator.

Tested keyboard

  • plaid
  • keycapsss/plaid_pad
  • tartan

Test

  1. send 32bytes data from device to host.
  2. send 32bytes data from host to device.

Device

I made test keymap for plaid, plaid_pad and tartan.
~https://github.com/hsgw/qmk_firmware/tree/vusb_raw_hid_test~
https://github.com/hsgw/qmk_firmware/tree/vusb_raw_hid_test_rewrite

Device settings

  • Disable mouse and extrakey
  • Set RAW_ENABLE = yes
  • `usbconfig.h' in your keyboard
#define USB_CFG_IMPLEMENT_FN_WRITE      1

Host

My small script with webhid on chrome.
https://hsgw.github.io/webhid_qmk/

And hidpytoy is useful too.
Please set send and receive data length to 32.
https://github.com/todbot/hidpytoy

This has been done and can be closed

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jmagee picture jmagee  路  3Comments

kb3dow picture kb3dow  路  3Comments

michaeldauria picture michaeldauria  路  3Comments

jetpacktuxedo picture jetpacktuxedo  路  3Comments

BenRoe picture BenRoe  路  3Comments