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

[Feature Request] RAW HID and Console on V-USB #8320

Closed
1 of 4 tasks
yiancar opened this issue Mar 5, 2020 · 12 comments
Closed
1 of 4 tasks

[Feature Request] RAW HID and Console on V-USB #8320

yiancar opened this issue Mar 5, 2020 · 12 comments

Comments

@yiancar
Copy link
Contributor

yiancar commented Mar 5, 2020

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

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

Description

@hsgw
Copy link
Contributor

hsgw commented Mar 8, 2020

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.

@hsgw
Copy link
Contributor

hsgw commented Mar 8, 2020

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

@yiancar
Copy link
Contributor Author

yiancar commented Mar 9, 2020

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

@hsgw
Copy link
Contributor

hsgw commented Mar 9, 2020

extrakeys support

I will try same method as KEYBOARD_SHARED_EP.

@yiancar
Copy link
Contributor Author

yiancar commented Mar 9, 2020

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

@hsgw
Copy link
Contributor

hsgw commented Mar 11, 2020

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.

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!

@yiancar
Copy link
Contributor Author

yiancar commented Mar 11, 2020

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.

@fauxpark
Copy link
Member

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.

@yiancar
Copy link
Contributor Author

yiancar commented Mar 11, 2020

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

@fauxpark
Copy link
Member

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

@hsgw
Copy link
Contributor

hsgw commented Mar 11, 2020

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

@hsgw hsgw mentioned this issue Mar 11, 2020
14 tasks
@yiancar
Copy link
Contributor Author

yiancar commented May 4, 2020

This has been done and can be closed

@yiancar yiancar closed this as completed May 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants