Author Topic: TMK ADB to USB keyboard converter  (Read 572178 times)

0 Members and 1 Guest are viewing this topic.

Offline nevin

  • Posts: 1627
  • Location: US
Re: TMK ADB to USB keyboard converter
« Reply #1200 on: Tue, 26 April 2022, 17:05:23 »
Quote
I'm using an M1-based Mac, could this be causing the issue?

i don't know. i don't have any M1 stuff to test with. do some searching in the brew or tools to see if there's an incompatibility.
do you have any other computers? build the file on your mac & flash on a different computer/laptop?

i have a friend with an M1, let me ask him if he's been able to flash anything since getting it.
edit... my friend is going to test when he can & chime in.
« Last Edit: Tue, 26 April 2022, 17:11:43 by nevin »
Keeb.io Viterbi, Apple m0110, Apple m0120, Apple m0110a, Apple 658-4081, Apple M1242, Apple AEK II, MK96, GH60/Pure, Cherry g84-4100, Adesso AKP-220B, Magicforce 68

Offline ScarletSwordfish

  • Posts: 33
Re: TMK ADB to USB keyboard converter
« Reply #1201 on: Tue, 26 April 2022, 17:36:04 »
I just tried flashing my Pro Micro with QMK Toolbox on my M1 Mac mini, and I am getting the same results as jzw95. My window looks exactly the same, with "No HID console devices connected" at the bottom, and I get no yellow text when I reset the Pro Micro. It may very well be an M1 issue.

Offline nevin

  • Posts: 1627
  • Location: US
Re: TMK ADB to USB keyboard converter
« Reply #1202 on: Tue, 26 April 2022, 17:47:04 »
... little further digging....

looks like it is a known issue
https://github.com/osx-cross/homebrew-avr/issues/220

but it looks like the issue has been resolved in GCC11 and supposedly patched in all versions...
https://github.com/osx-cross/homebrew-avr/pull/249

might have to pull GCC 11 specifically
https://github.com/osx-cross/homebrew-avr
scroll down to current versions
GCC 11.1.0 - provided as
Code: [Select]
avr-gcc@11
....not positive which you need, but give it a shot. update avr-gcc by itself.
Keeb.io Viterbi, Apple m0110, Apple m0120, Apple m0110a, Apple 658-4081, Apple M1242, Apple AEK II, MK96, GH60/Pure, Cherry g84-4100, Adesso AKP-220B, Magicforce 68

Offline hasu

  • Thread Starter
  • Posts: 3418
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK ADB to USB keyboard converter
« Reply #1203 on: Tue, 26 April 2022, 19:16:43 »
• The first keypad is working great.
• The second keypad is OK too (the one with a trackball), there is just a weird things :

What's the weird things actually?


Quote
• The last one is this combo "calculator/keypad" (https://www.journaldulapin.com/2020/01/08/un-pave-numerique-qui-fait-office-de-calculatrice-en-adb/). And it will not work. When i plug the keypad, it turn on (seems OK) and there is timer. And whith the adpeter, after a few second, the timer is freezing. And nothing happen. I suppose the keypad need more energy, but even with battery, i have the same thing.

If hid_listen log doesn't show useful info what 'ADB Parser' shows would be useful.


Quote
The AlphaSmart is working great. I can send text from the word processor to my mac. The only weird thing is the Caps Lock key : the key send only "B9FF" on the log.

With iMate/OS9(OSX) the CapsLock key work well, right?

Can you get log with hot-plugging the AlphaSmart? The log doesn't show useful info much.
Please hot-plug a device basically when you get log if possible. This will show more info.

Offline hasu

  • Thread Starter
  • Posts: 3418
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK ADB to USB keyboard converter
« Reply #1204 on: Tue, 26 April 2022, 20:17:10 »
And with the new firmware, i have a good news.

The infamous trackpad "GlidePoint" is working. There is a weird things on the logs, by the way : the line "M:found: reg3:6C01" is repeating, with incrementation.


To support hot-plugging the converter checks mouse and keyboard per 1sec, but this is not useful for dumb devices. I think the converter can stop this once dumb device is found. I'll fix.



Quote
I have try too with the optical ADB/Mouse, and the mouse is not working... but i have the same things on the logs.
And i have tried on a "real" Mac : the mouse seems to go to adress 10 (and not 3). Is this normal ? (i join a capture)

I didn't know ADB Parser tool, it looks great for debug!

Yes, it is what expected according to OSX source code. I think classic OS9 does same thing probably.

1. OSX checks address 3 if it finds a mouse move the mosue to empty address(F in this case).
2. The mouse is configured there(after moved) if driver is avaialble.
3. OSX check address 3 again.
        If it doesn't find mouse anymore, the last mouse is moved back to address 3.
        if it find another mouse it is moved to next empty address(probably E). and go to 2.

Keyboards are also handled in same way.

https://github.com/apple-oss-distributions/IOADBFamily/blob/IOADBFamily-6/IOADBBus/IOADBController.cpp#L278

One mouse is located at 3 and another at F in the result.
This can happen when you have physically two mouses or  a complex mouse like Kensignton.

Mouse at 3 has hadler ID:32 and this indicates that you had Kensington mouse?.



Quote
And the last one is my new mouse, an Elecom branded mouse, with the same switch than the Elecom trackball. And the same problem : a "fail" in the logs.

The Elecom mouse fails at second moving for some reason.
This is similar to NeXT mouse issue.

I'll have to revisit this issue later.

Offline jzw95

  • Posts: 11
  • Location: Edinburgh, Scotland
Re: TMK ADB to USB keyboard converter
« Reply #1205 on: Wed, 27 April 2022, 07:11:36 »
@nevin, thanks for digging further into this. I'm not sure that it is an issue with avr-gcc since I've not tried to compile any keyboard firmware – simply access the Pro Micro with the programmer, but maybe there is some related library that is causing issues with dfu-programmer. My avr-gcc (GCC9) seems to be an ARM binary:

Code: [Select]
1017 ~ » file /opt/homebrew/Cellar/avr-gcc@9/9.3.0_3/bin/avr-gcc
/opt/homebrew/Cellar/avr-gcc@9/9.3.0_3/bin/avr-gcc: Mach-O 64-bit executable arm64

but it's a good idea to be sure, so when I have some time later I'll install avr-gcc@11 specifically and see if that makes a difference.

@ScarletSwordfish I really appreciate your testing this and confirming you see the same (lack of) behaviour. I'm wondering if this has to do with the tightened security model of the M1 Macs and somehow the dfu-programmer is not being allowed access to the tty devices (or /dev at all??). I've got an old Intel-based MacBook Air and when I have a chance I'll fire it up, install the toolchain, and see if the results are any different.

Offline nevin

  • Posts: 1627
  • Location: US
Re: TMK ADB to USB keyboard converter
« Reply #1206 on: Wed, 27 April 2022, 07:40:52 »
the promicro's use caterina bootloader, avrdude flash utility to flash, not dfu util. that's what i mean, the flashing utility sounds like it was updated in those versions of avr-gcc

not sure which version of avrdude is pulled in TMK dependencies during install, avrdude might not be pulled at all during TMK install.
Keeb.io Viterbi, Apple m0110, Apple m0120, Apple m0110a, Apple 658-4081, Apple M1242, Apple AEK II, MK96, GH60/Pure, Cherry g84-4100, Adesso AKP-220B, Magicforce 68

Offline jzw95

  • Posts: 11
  • Location: Edinburgh, Scotland
Re: TMK ADB to USB keyboard converter
« Reply #1207 on: Wed, 27 April 2022, 10:06:03 »
Oh, does the caterina boot loader not support dfu-programmer? I will try avrdude, which should work since that's what the Arduino IDE is using (and the Arduino IDE was able to flash my Pro Micro). But what does QMK Toolbox use to flash? It's strange that it works for your caterina device but not my Pro Micro. That's why I thought it was maybe the M1 causing an issue.

Thanks for all the info. I'll do some testing with my Intel Mac and avrdude and post my results.

Offline nevin

  • Posts: 1627
  • Location: US
Re: TMK ADB to USB keyboard converter
« Reply #1208 on: Wed, 27 April 2022, 12:46:15 »
promicro's are caterina bootloaders. and promicro, at least the original is a Arduino device. if you have a hex file ready, you can probably use the Arduino flasher.

qmk toolbox can flash a bunch of different devices, processors, bootloaders, etc. just depends on what tools are installed that qmk toolbox can utilize.
Keeb.io Viterbi, Apple m0110, Apple m0120, Apple m0110a, Apple 658-4081, Apple M1242, Apple AEK II, MK96, GH60/Pure, Cherry g84-4100, Adesso AKP-220B, Magicforce 68

Offline jzw95

  • Posts: 11
  • Location: Edinburgh, Scotland
Re: TMK ADB to USB keyboard converter
« Reply #1209 on: Fri, 29 April 2022, 10:14:20 »
I've finally had some time to play around a bit more, and the end result is… success! I've got QMK Toolbox to recognise my Pro Micro on my M1 MacBook Pro.

I first got my 2013 Intel-based MacBook Air fired up and downloaded QMK Toolbox to it. I had to use an older version (v0.1.1) as my MacBook Air is running MacOS 10.14.6 which isn't supported by v0.2.0. But as soon as I put my Pro Micro in DFU mode, the magical yellow text appeared:

285638-0

I then installed dfu-programmer on the MacBook Air and confirmed that it doesn't work.

With the knowledge that my Pro Micro should work with QMK Toolbox, I went back to my M1 MacBook Pro. I tried a few things (removing quarantine xattrs from QMK Toolbox, running it under Rosetta) that didn't work. Then I thought I'd download the latest beta and see if that somehow had a fix, and… it worked! I've had a look through the GitHub issues for QMK Toolbox, and I can't see anything that specifically addresses the problem I was having, but possibly it is this one: [macOS] Add libhidapi #357.

In any case, the lesson for anyone who is having similar problems getting QMK Toolbox to recognise a Caterina bootloader device on an M1 Mac running MacOS 12 Monterey: download the latest beta, and it should work.

Thanks again, @nevin, for your help. Without knowing what the expected behaviour was I was struggling to figure out what to do to debug this.

Next up… I am going to try actually flashing the TMK firmware. 🥳
« Last Edit: Fri, 29 April 2022, 14:29:35 by jzw95 »

Offline nevin

  • Posts: 1627
  • Location: US
Re: TMK ADB to USB keyboard converter
« Reply #1210 on: Fri, 29 April 2022, 11:35:11 »
glad you got it working and have fun with your boards!
Keeb.io Viterbi, Apple m0110, Apple m0120, Apple m0110a, Apple 658-4081, Apple M1242, Apple AEK II, MK96, GH60/Pure, Cherry g84-4100, Adesso AKP-220B, Magicforce 68

Offline Dandu

  • Posts: 43
Re: TMK ADB to USB keyboard converter
« Reply #1211 on: Tue, 03 May 2022, 11:09:48 »
What's the weird things actually?

I was tired, sorry.

The keypad use a "shift" key for a second use of the key. The "shift" key has no scan code, but when i press the "5" key, i have FFFF FFFF scan code : the "5" key is the only key without an alternate function (i have join a photo).

Quote
If hid_listen log doesn't show useful info what 'ADB Parser' shows would be useful.

UI will try that this week with my old Mac.

Quote
With iMate/OS9(OSX) the CapsLock key work well, right?

Can you get log with hot-plugging the AlphaSmart? The log doesn't show useful info much.
Please hot-plug a device basically when you get log if possible. This will show more info.

So, with iMate, my HID app say "Keyboard Caps Lock (0x0039)" up and down, but it will not work : even if i press the key, i have nos CAPS.

I have join two logs. The first one, i have hot plug the AlphaSmart and after that, i have powered the keyboard. In the second, i have powered the keyboard, and after that, i have plugged in. The result is the same, by the way, no information.


Offline Dandu

  • Posts: 43
Re: TMK ADB to USB keyboard converter
« Reply #1212 on: Tue, 03 May 2022, 11:12:27 »
Quote
I didn't know ADB Parser tool, it looks great for debug!

Yes, it is what expected according to OSX source code. I think classic OS9 does same thing probably.

1. OSX checks address 3 if it finds a mouse move the mosue to empty address(F in this case).
2. The mouse is configured there(after moved) if driver is avaialble.
3. OSX check address 3 again.
        If it doesn't find mouse anymore, the last mouse is moved back to address 3.
        if it find another mouse it is moved to next empty address(probably E). and go to 2.

Keyboards are also handled in same way.

https://github.com/apple-oss-distributions/IOADBFamily/blob/IOADBFamily-6/IOADBBus/IOADBController.cpp#L278

One mouse is located at 3 and another at F in the result.
This can happen when you have physically two mouses or  a complex mouse like Kensignton.

Mouse at 3 has hadler ID:32 and this indicates that you had Kensington mouse?.

I will try this week too, but on the capture, i have connected only the optical USB/ADB mouse.

Quote
The Elecom mouse fails at second moving for some reason.
This is similar to NeXT mouse issue.

I'll have to revisit this issue later.

OK, thank you !

Offline hasu

  • Thread Starter
  • Posts: 3418
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK ADB to USB keyboard converter
« Reply #1213 on: Wed, 04 May 2022, 09:24:11 »
What's the weird things actually?

I was tired, sorry.

The keypad use a "shift" key for a second use of the key. The "shift" key has no scan code, but when i press the "5" key, i have FFFF FFFF scan code : the "5" key is the only key without an alternate function (i have join a photo).

Confirmed that my keypad also behaves exactly as you described. My keypads was manufactured by Qtronix too.
'FFFF' is not proper scan code but not harmful.



Quote
Quote
With iMate/OS9(OSX) the CapsLock key work well, right?

Can you get log with hot-plugging the AlphaSmart? The log doesn't show useful info much.
Please hot-plug a device basically when you get log if possible. This will show more info.

So, with iMate, my HID app say "Keyboard Caps Lock (0x0039)" up and down, but it will not work : even if i press the key, i have nos CAPS.

I have join two logs. The first one, i have hot plug the AlphaSmart and after that, i have powered the keyboard. In the second, i have powered the keyboard, and after that, i have plugged in. The result is the same, by the way, no information.



Hmm,  no device info in the logs indicattes that AlphaSmart is dumb device that can't reply ADB commands.


And in the log two capslock release events(B9) happened in a row without press event(39).  This is weird and reason why it fails with iMate too. I guess AlphaSmart firmware does something tricky.

Offline hasu

  • Thread Starter
  • Posts: 3418
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK ADB to USB keyboard converter
« Reply #1214 on: Fri, 06 May 2022, 02:21:39 »
Try attached firmware with :
- Pioneer and Macally keyboard
- Elecom, NeXT,  M2706 black mouse

Changed initialization of keyboard and mouse setup.


* adb_usb_rev1.hex (67.38 kB - downloaded 37 times.)

Offline hasu

  • Thread Starter
  • Posts: 3418
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK ADB to USB keyboard converter
« Reply #1215 on: Sat, 21 May 2022, 00:49:33 »
I wrote ADB protocol decoder for sigrok for debug.


Sigrok ADB decoder
Cheap $10-20 Logic Analyzer that is compatible with sigrok works well for this job.

Get one and try. 1MHz sample rate is actually good enough for ADB protocol.
You can use this deocoder with sigrok PulseView to see ADB commands and data.

https://github.com/tmk/tmk_keyboard/wiki/Signal-Capture-for-debug#sigrok

Offline hasu

  • Thread Starter
  • Posts: 3418
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK ADB to USB keyboard converter
« Reply #1216 on: Mon, 30 May 2022, 09:13:00 »
Updated firmware

- Address Resolution was implemented
- Improved hot-plug support

These offers better support for multiple devices on daisy chain.
You can use ANSI and ISO keyboard at same time, for example.

https://github.com/tmk/tmk_keyboard/commit/4923f09377371723c767ab884454571de0740094

Offline nevin

  • Posts: 1627
  • Location: US
Re: TMK ADB to USB keyboard converter
« Reply #1217 on: Mon, 30 May 2022, 09:54:29 »
NICE!
great work as always hasu!
Keeb.io Viterbi, Apple m0110, Apple m0120, Apple m0110a, Apple 658-4081, Apple M1242, Apple AEK II, MK96, GH60/Pure, Cherry g84-4100, Adesso AKP-220B, Magicforce 68

Offline hasu

  • Thread Starter
  • Posts: 3418
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK ADB to USB keyboard converter
« Reply #1218 on: Wed, 08 June 2022, 23:00:15 »
Dandu,

Can you try attached firmware with devices that 'failed to move'?
    - Pioneer MPC-KB2
    - Kensington Optical mouse


With updated firmware Address Resoution was implemented and command timging is changed, so that the converter behaves as what Mac OSX does as possible now.
This can get better result with devices that fails to move to new address, perhaps.

* adb_usb_rev1.hex (61.71 kB - downloaded 32 times.) @8dee557

Offline Dandu

  • Posts: 43
Re: TMK ADB to USB keyboard converter
« Reply #1219 on: Thu, 09 June 2022, 02:36:30 »
Hi

I'm sorry, i'm late, i had a lot of work.

I will try the keyboard this week

Offline wujack

  • Posts: 5
Re: TMK ADB to USB keyboard converter
« Reply #1220 on: Tue, 19 July 2022, 12:35:43 »
Hi, I've just received my controller I'm wondering if I wanted to convert the controller to type-c can I solder wires from the G, +, -, V through-hole to a c3-unified usb-c daughter board? Thanks!

Offline hasu

  • Thread Starter
  • Posts: 3418
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK ADB to USB keyboard converter
« Reply #1221 on: Tue, 19 July 2022, 19:31:21 »
I think so. Let us know your result.

Hi, I've just received my controller I'm wondering if I wanted to convert the controller to type-c can I solder wires from the G, +, -, V through-hole to a c3-unified usb-c daughter board? Thanks!

EDIT: Assuming what you are referring to is this: https://github.com/ai03-2725/Unified-Daughterboard

Offline wujack

  • Posts: 5
Re: TMK ADB to USB keyboard converter
« Reply #1222 on: Wed, 20 July 2022, 00:06:41 »
I think so. Let us know your result.

Hi, I've just received my controller I'm wondering if I wanted to convert the controller to type-c can I solder wires from the G, +, -, V through-hole to a c3-unified usb-c daughter board? Thanks!

EDIT: Assuming what you are referring to is this: https://github.com/ai03-2725/Unified-Daughterboard

Yup, precisely. I'll let you guys know the results!

Offline fabiobelmondo

  • Posts: 1
Re: TMK ADB to USB keyboard converter
« Reply #1223 on: Fri, 26 August 2022, 08:31:06 »
Hello, just wired up the converter for my M0118 using a pro micro and when i plug in th s-video cable i get this message in QMK Toolbox. Needless to say that the keyboard doesn't work.. Any indeas?
https://imgur.com/a/GX4KoaQ
« Last Edit: Fri, 26 August 2022, 08:33:56 by fabiobelmondo »