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

Add support for WebUSB #7778

Closed
wants to merge 6 commits into from
Closed

Add support for WebUSB #7778

wants to merge 6 commits into from

Conversation

drashna
Copy link
Member

@drashna drashna commented Jan 3, 2020

Description

This adds the WebUSB feature to QMK Firmware (for LUFA and ChibiOS, at least).

This requires qmk/lufa#8 to be merged (or to use the web_usb)

Types of Changes

  • Core
  • New feature
  • Documentation

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

@drashna drashna added core breaking_change Changes that need to wait for a version increment labels Jan 3, 2020
@yulei
Copy link
Contributor

yulei commented Jan 4, 2020

great, this made online qmk configurator possible :)

@drashna
Copy link
Member Author

drashna commented Jan 5, 2020

@yulei ZSA (ergodox ez, planck ez) are already using WebUSB for the "live training" feature. In fact, this is basically just backporting that code.

@yulei
Copy link
Contributor

yulei commented Jan 10, 2020

@yulei ZSA (ergodox ez, planck ez) are already using WebUSB for the "live training" feature. In fact, this is basically just backporting that code.

Could this webusb implementation work under mac? I tested an implementation from the LUFA pr before, but they failed work under MAC OS.

@drashna
Copy link
Member Author

drashna commented Jan 11, 2020

Works on MacOS, Windows, and Linux. including the "open link" popup. But it does require Chrome or a chrome based browser.

@drashna drashna force-pushed the web_usb branch 6 times, most recently from bba1ea6 to 4e66e94 Compare March 20, 2020 03:53
@wiserfirst
Copy link

@drashna @noroadsleft Just wondering if we plan to merge this in? Thanks!

@noroadsleft
Copy link
Member

@wiserfirst My understanding is that ZSA (makers of the ErgoDox EZ and Planck EZ) is still working on this, hence this PR being in Draft status.

I would expect this to be merged when the underlying pieces are in place. So basically: "When it's done."

@drashna
Copy link
Member Author

drashna commented May 16, 2020

Just wondering if we plan to merge this in? Thanks!

It's complicated.

This PR requires a change to the LUFA module first. Which hasn't happened. Without that change, this PR will fail (right now, it's pointing at the ZSA LUFA module, which is the ONLY reason it works).

Additionally, we (ZSA) haven't had a chance to really test this out yet. The WebUSB part works, but the rest of it isn't tested, and we'd rather have that finished before this gets merged.

That said, once things are finalized on our side, yes, we plan on finishing up this PR and getting this merged.

Until then, we'd rather it remain as a draft.

@wiserfirst
Copy link

@drashna awesome. Thanks for the detailed explanation!

right now, it's pointing at the ZSA LUFA module, which is the ONLY reason it works

Can I assume that the zsa fork (https://github.com/zsa/qmk_firmware) would support WebUSB? Thanks!

@drashna drashna changed the base branch from master to develop June 5, 2020 09:36
@drashna
Copy link
Member Author

drashna commented Jun 5, 2020

Sorry, I meant to respond sooner!

Can I assume that the zsa fork (zsa/qmk_firmware) would support WebUSB? Thanks!

Yes, it does. And ZSA is using it for the live training mode, actively.

And I just added a PR to QMK so that it doesn't have the compile errors when using a keymap for Oryx.

quantum/oryx.c Outdated
Comment on lines 74 to 81
uint8_t i;
dynamic_keymap_get_buffer(offset, size, &param[3]);
event[0] = WEBUSB_STATUS_OK;
event[1] = ORYX_EVT_LIVE_UPDATE_GET_BUFFER;
for (i = 0; i < size; i++) {
event[i+2] = param[i];
}
event[i+2] = WEBUSB_STOP_BIT;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use:

Suggested change
uint8_t i;
dynamic_keymap_get_buffer(offset, size, &param[3]);
event[0] = WEBUSB_STATUS_OK;
event[1] = ORYX_EVT_LIVE_UPDATE_GET_BUFFER;
for (i = 0; i < size; i++) {
event[i+2] = param[i];
}
event[i+2] = WEBUSB_STOP_BIT;
dynamic_keymap_get_buffer(offset, size, &event[2]);
event[0] = WEBUSB_STATUS_OK;
event[1] = ORYX_EVT_LIVE_UPDATE_GET_BUFFER;
event[size+2] = WEBUSB_STOP_BIT;

? The buffer is already allocated. Also, I think there is a bug in the loop of copying things back.

drashna and others added 5 commits July 3, 2021 16:50
change to merged branch later
fix: MS OS 2.0 Property value

fix: run webusb task on chibios

feat: adds pairing key

chore: change manufacturer name to ZSA

feat: webusb keymap examples

fix: adds webusb include on test keymaps

feat: update examples + pairing process

fix: adds webusb include on test keymaps

feat: add landing page url command

chore: unused var cleanup

chore: refactor webusb lp url command

feat: add fw version webusb cmd

fix: lufa handle disconnections gracefully

chore: renaming of the get version cmds

fix: only change usb vesion spec if webusb is enabled

fix: chibios handle disconnections gracefully

feat: add get layer command

fix: remove conditional macro wrapping WEBUSB_PAIR

move webusb include to quantum.h

Fix merge conflict
Move webusb.h includes to quantum.h (qmk#244)

Co-authored-by: Florian Didron <[email protected]>

Start moving code out of webusb and to Oryx feature

fix type in usb_main for chibiOS

Make Dynamic Keymaps more friendly for non-VIA implementations

 Conflicts:
	quantum/dynamic_keymap.c

 It looks like you may be committing a cherry-pick.
 If this is not correct, please remove the file
	.git/CHERRY_PICK_HEAD
 and try again.

 Please enter the commit message for your changes. Lines starting
 with '#' will be ignored, and an empty message aborts the commit.

Add toggle for live training

Add Oryx keymap, etc

Add Dynamic Keymap and other webUSB commands

Implement core communication

Add EEPROM reset functionality

Limit number of layers due to eeprom size contstraints

Disable live training if other webusb commands are sent

Make Dynamic Keymaps optional for Oryx

Add Oryx Keymap with dynamic keymaps enabled

Move webusb pairing key back into quantum

Add firmware ID check

Cleanup magic number and functions

Cleanup oryx init check

Fix function call

feat: disable webusb popup by default

Fix Live Training bug

Forget to check if the firmware is actually paired

fix: remove oryx live training boolean assignment

Enable Oryx Configurator on Ergodox EZ keymap

Fix Dynamic Keymaps includes to be sane
@drashna
Copy link
Member Author

drashna commented Sep 9, 2021

Honestly, I think that the direction that QMK is going with is webHID, which uses the raw HID endpoint. As such, I'm not sure how much use this has, and maintaining this isn't worth it.

@drashna drashna closed this Sep 9, 2021
@ruro
Copy link

ruro commented Sep 9, 2021

@drashna can you clarify, what this means for the live training support? You have previously implied that you were planning to backport webUSB and live training stuff to qmk. Now that WebUSB is apparently being abandoned, what are your plans regarding this in the future?

@drashna
Copy link
Member Author

drashna commented Sep 9, 2021

Likely, a pivot to webHID. WebHID uses the raw HID endpoint via the web browser. Chrome added support for webHID 2 or so years ago, and it is supported by any chromium based browser.

This would be a better way to go, as it would work with raw HID enabled apps like VIA, but also for online based apps (such as Remapper.

And QMK XAP is planning on using raw HID, and we'd like to support that.

@ruro
Copy link

ruro commented Sep 9, 2021

Ah, okay, thank you for the quick answer. Last question. Just to clarify, will the zsa fork and the configure.zsa.io/train live training app also eventually move to webHID?

@drashna
Copy link
Member Author

drashna commented Sep 14, 2021

Ah, okay, thank you for the quick answer. Last question. Just to clarify, will the zsa fork and the configure.zsa.io/train live training app also eventually move to webHID?

I can't say for sure, but I believe that's the goal long term. Especially when QMK XAP is finalized.

@drashna drashna deleted the web_usb branch December 31, 2022 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking_change Changes that need to wait for a version increment core dependencies keyboard keymap
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants