donn / nudelta

Open source NuPhy Console alternative
GNU General Public License v3.0
521 stars 24 forks source link

Help to support Halo75 #8

Closed ijverig closed 1 year ago

ijverig commented 1 year ago

Hello, how can I reverse engineer USB comm for the Halo75? I'd like to submit a patch to support it, if possible.

Another question: does nudelta save the remappings on the keyboard itself?

yujinlin0224 commented 1 year ago

Also waiting for Halo75

donn commented 1 year ago

@ijverig First of all, yes, Nudelta's changes are written to the keyboard itself.

P.S. @adokitkat - I think you might be interested in this writeup as well.


At a basic level:

I documented the interaction between the NuPhy Console and the Air75 in this file: https://github.com/donn/nudelta/blob/main/util/usb/docs.md. What it boils down to is an exchange of "USB reports": basically the computer requests something with a specific report ID (part of it is technically an offset but don't worry about that) and the keyboard replies. See https://www.usb.org/hid for technical details if you're into that.

The following parts may be different for Halo75 (but not likely):

For Air75, there are three reports read and three corresponding reports written (same general data), one of which I identified to be the keymap. The other two I assume are RGB and Macros, but I'm unsure. There's a lot of guesswork. I had to guess which one is the keymap by just basically changing the keys around a bit and seeing which one of the three reports changes. You'll find some of the scripts I used to help with that in https://github.com/donn/nudelta/tree/main/util/usb.

-- I found the Mac keymap via total guesswork, by the way, as that's not supported in the Nudelta console. I just kept changing the report ID until I found it.

The keymaps are essentially 1024 byte files containing of 256 4-byte keycodes: See https://github.com/donn/nudelta/tree/main/res for YAML files representing this data. This is the core target of my reverse engineering. You need the following pieces of data:

I have a whole section on keycodes and modifiers in https://github.com/donn/nudelta/blob/main/util/usb/docs.md.

What Nudelta's job is, essentially, to be able to generate the write report for a given keymap and write it to the keyboard using the hidapi library, which simplifies reading and writing to HID devices such as the NuPhy Air75.

And well, to support another keyboard? We'd need that same data: keymap report IDs (for both win and mac modes), default keymaps, indices, keycodes and modifiers.


Sorry for the wall of text- this is what happens when I have a presentation to procrastinate. But yeah. Hope that helps. Me personally, I have no plans to buy a Halo75, so I can't do this myself. :slightly_smiling_face:

nocturne1 commented 1 year ago

It seems that they haven't even released a Windows console yet for Halo75, so we're delayed until well after that happens. While we wait, has anyone had success getting USB passthrough working for they keyboard on a Mac? I've tried both Virtualbox and VMWare Fusion, without any luck. Trying to get at least that part out of the way, to potentially help later.

donn commented 1 year ago

@nocturne1 I used USB passthrough for the Air75 on Linux with Virt-Manager for this particular effort.

One annoying aspect is that the keyboard "reboots" when you're trying to upgrade the firmware (and changes device name), so you'll have to pass it through again. But otherwise it should work fine..?

ijverig commented 1 year ago

Thanks a lot @donn for the detailed writeup and explanations. My keyboard hasn't arrived yet, so will wait for it and for NuConsole's update (they told me it's happening soon).

Hope I can soon help!

donn commented 1 year ago

Alpha Halo75 support should be in the latest release- can you all try it?

ijverig commented 1 year ago

Mine has just arrived. Will test it today and get back here.

Your alpha code is in the main branch, correct?

Seems to me you abstracted the code but the underlying communication is the same for both the Air75 and Halo75, right?

donn commented 1 year ago

@ijverig Pretty much- the only difference between the two is the keymaps.

donn commented 1 year ago

Finalized in 0.6.4. Welcome Halo75