USB HID interface

Troubles with your machine? Just want to speak about the latest improvements? This is the place!

Moderators: Mug UK, Zorro 2, spiny, Greenious, Moderator Team

alanh
Hardware Guru
Hardware Guru
Posts: 1420
Joined: Mon Jul 24, 2006 9:01 pm
Location: North Wales, UK

Re: USB HID interface

Post by alanh »

I've bought this board with the intention of doing something for the IKBD interface.

The nice thing about this board, it has dual USB ports for Keyboard and Mouse.

But also a bunch of I/O for joystick emulation too.

It has a serial port for direct interface onto the IKBD interface.

I think it has a second serial port for potential daisy chaining of the original keyboard too.

https://www.electrodragon.com/product/c ... 5x-series/
Falcon CT60, Falcon CT63 x2, TT x3, MegaST x2, MegaSTE x2, STFM x2, STE x2, STacy, STBook, (Dead) Hades 060, Milan 060, T40.
alanh
Hardware Guru
Hardware Guru
Posts: 1420
Joined: Mon Jul 24, 2006 9:01 pm
Location: North Wales, UK

Re: USB HID interface

Post by alanh »

Oh, and it's super cheap.
Falcon CT60, Falcon CT63 x2, TT x3, MegaST x2, MegaSTE x2, STFM x2, STE x2, STacy, STBook, (Dead) Hades 060, Milan 060, T40.
User avatar
olivierg
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 130
Joined: Wed Jul 27, 2016 2:10 pm
Location: Belgium
Contact:

Re: USB HID interface

Post by olivierg »

fieldofcows wrote: Sun May 09, 2021 9:44 am I'm tidying up the config at the moment. I'll try to make the definitions clearer.
Can you add in the code the choice of KEY MAP, by 3P dip switch by activating the 3 bit pull-ups (on choice for you)?
It is easier for the user if the KEY MAP GB, DE, FR, US are already integrated and easy to choose.

Here is the prototype:
Capture.JPG
On the other hand, I can not find the Micro USB Male / Male link all done.
MICRO-USB-Connector.jpg
thanks
Olivier
You do not have the required permissions to view the files attached to this post.
TT030 4/32 TOS 3.06 SCSI2SD 5.x HD, Mega STE 4Mb TOS 2.06 DD, Mega ST4 DD miniCosmosEX, Mega ST2 DD, 1040 STE DD, 2 x 1040STFM DD, 2 x 1040STF, MegaFile 30, Lynx 1
fieldofcows
Retro freak
Retro freak
Posts: 12
Joined: Thu Apr 08, 2021 10:47 pm

Re: USB HID interface

Post by fieldofcows »

alanh wrote: Sun May 09, 2021 11:11 am I've bought this board with the intention of doing something for the IKBD interface.

The nice thing about this board, it has dual USB ports for Keyboard and Mouse.

But also a bunch of I/O for joystick emulation too.

It has a serial port for direct interface onto the IKBD interface.

I think it has a second serial port for potential daisy chaining of the original keyboard too.

https://www.electrodragon.com/product/c ... 5x-series/
One thing I have discovered is that these microcontroller boards do not do USB host very well. You might find some code that allows you to connect a keyboard or mouse but generally they only support the boot protocol and maybe don't support hubs at all. I don't know the board you refer to at all but a quick search didn't show up any code for implementing USB host.

On the other hand, the RP2040 has lots of I/O, 2 UARTs for serial comms and supposedly fairly comprehensive host mode. In reality though, I've spent countless hours over the last couple of weeks trying to get the host mode working properly. Some single mice or keyboards worked. Others just locked up the sample USB host code. The hub support was buggy at best. I've identified at least one hardware USB host bug on the RP2040 and submitted a PR for a workaround on the SDK. I think there is another hardware bug too where if you plug in a device, remove it then plug it in again, if you allocate the same address then you get a hardware 'bit stuffing error'. I've been slowed down by the fact that I do not currently have a USB analyser and cannot really justify the cost of buying one.

I've got to the point now where I've implemented USB HID report handling so mice don't have to use the boot protocol, so you get full resolution. I've added support for USB joysticks and I've fixed a number of errors in lots of other parts of the USB stack. I'd love to contribute it all back to tinyusb but a lot of the workarounds are RP2040 specific and would require more hours than I have available to prepare for merging back into the upstream repository.

But what I've ended up with is a board that can emulate the IKBD very well over a serial connection and allows reliable connection of any USB keyboard, mouse and multiple joysticks. I'm quite happy with how well it works!
fieldofcows
Retro freak
Retro freak
Posts: 12
Joined: Thu Apr 08, 2021 10:47 pm

Re: USB HID interface

Post by fieldofcows »

olivierg wrote: Sun May 09, 2021 6:15 pm Can you add in the code the choice of KEY MAP, by 3P dip switch by activating the 3 bit pull-ups (on choice for you)?
It is easier for the user if the KEY MAP GB, DE, FR, US are already integrated and easy to choose.
Adding multiple key mappings is something that could easily be added. However, I've actually added a simple UI displayed on an SSD1306 OLED for checking connections and configuring the mouse sensitivity via some physical buttons. I would prefer the key mapping is done via this UI.

The UI is optional. You can always hardcode sensible defaults when flashing the Pico board and dispense with the display and buttons.
alanh
Hardware Guru
Hardware Guru
Posts: 1420
Joined: Mon Jul 24, 2006 9:01 pm
Location: North Wales, UK

Re: USB HID interface

Post by alanh »

fieldofcows wrote: Sun May 09, 2021 9:41 pm
alanh wrote: Sun May 09, 2021 11:11 am I've bought this board with the intention of doing something for the IKBD interface.

The nice thing about this board, it has dual USB ports for Keyboard and Mouse.

But also a bunch of I/O for joystick emulation too.

It has a serial port for direct interface onto the IKBD interface.

I think it has a second serial port for potential daisy chaining of the original keyboard too.

https://www.electrodragon.com/product/c ... 5x-series/
One thing I have discovered is that these microcontroller boards do not do USB host very well. You might find some code that allows you to connect a keyboard or mouse but generally they only support the boot protocol and maybe don't support hubs at all. I don't know the board you refer to at all but a quick search didn't show up any code for implementing USB host.

On the other hand, the RP2040 has lots of I/O, 2 UARTs for serial comms and supposedly fairly comprehensive host mode. In reality though, I've spent countless hours over the last couple of weeks trying to get the host mode working properly. Some single mice or keyboards worked. Others just locked up the sample USB host code. The hub support was buggy at best. I've identified at least one hardware USB host bug on the RP2040 and submitted a PR for a workaround on the SDK. I think there is another hardware bug too where if you plug in a device, remove it then plug it in again, if you allocate the same address then you get a hardware 'bit stuffing error'. I've been slowed down by the fact that I do not currently have a USB analyser and cannot really justify the cost of buying one.

I've got to the point now where I've implemented USB HID report handling so mice don't have to use the boot protocol, so you get full resolution. I've added support for USB joysticks and I've fixed a number of errors in lots of other parts of the USB stack. I'd love to contribute it all back to tinyusb but a lot of the workarounds are RP2040 specific and would require more hours than I have available to prepare for merging back into the upstream repository.

But what I've ended up with is a board that can emulate the IKBD very well over a serial connection and allows reliable connection of any USB keyboard, mouse and multiple joysticks. I'm quite happy with how well it works!
There is code for USB host and it's well tested. I've even got the mouse/keyboard to work just fine.

https://github.com/atc1441/CH559sdccUSBHost
Falcon CT60, Falcon CT63 x2, TT x3, MegaST x2, MegaSTE x2, STFM x2, STE x2, STacy, STBook, (Dead) Hades 060, Milan 060, T40.
fieldofcows
Retro freak
Retro freak
Posts: 12
Joined: Thu Apr 08, 2021 10:47 pm

Re: USB HID interface

Post by fieldofcows »

Right, it's taken a while to get it all working but I think I'm just about there.
https://github.com/fieldofcows/atari-st-rpikb

It now only supports RP2040, particularly the Raspberry Pi Pico board. You can connect a USB keyboard, mouse and joysticks and also connect Atari 9 pin joysticks.

@Methanoid - I haven't got around to add support for replacing an Atari mouse at the moment. I'll get around to that next.
User avatar
Methanoid
Captain Atari
Captain Atari
Posts: 314
Joined: Mon Jan 26, 2004 2:41 pm
Location: England.. where else?

Re: USB HID interface

Post by Methanoid »

Thanks for this (and for the "I'll get around to that next"). Impressive work and a good use of a Pico. May have to try this, especially as with the RGBtoHDMI solutions plus KB & Mouse being USB, I could plug an ST into my KVM switch :-)
User avatar
olivierg
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 130
Joined: Wed Jul 27, 2016 2:10 pm
Location: Belgium
Contact:

Re: USB HID interface

Post by olivierg »

Hello fieldofcows,

Very nice job, many thanks.

I have create new version of schematic from your schematic.
I have little question, the oled display is connected to 3V3, but normaly the oled as builtin LDO 3V3, and the vcc is 5V ?



Thanks
Olivier
You do not have the required permissions to view the files attached to this post.
TT030 4/32 TOS 3.06 SCSI2SD 5.x HD, Mega STE 4Mb TOS 2.06 DD, Mega ST4 DD miniCosmosEX, Mega ST2 DD, 1040 STE DD, 2 x 1040STFM DD, 2 x 1040STF, MegaFile 30, Lynx 1
fieldofcows
Retro freak
Retro freak
Posts: 12
Joined: Thu Apr 08, 2021 10:47 pm

Re: USB HID interface

Post by fieldofcows »

olivierg wrote: Tue May 25, 2021 9:39 am I have little question, the oled display is connected to 3V3, but normaly the oled as builtin LDO 3V3, and the vcc is 5V ?
The display I'm using allows a range between 3V3 and 5V.
AtariMegaFan
Atarian
Atarian
Posts: 3
Joined: Sat Apr 08, 2017 9:50 pm

Re: USB HID interface

Post by AtariMegaFan »

What's the way to go to install the software on this Raspberry Pico?
The source is c++, right?
I need to install different apps on my local machine (macos) to compile the source?

Pico, the OLED and voltage shifters are arrived today, so i would love to start with a little bit of practice... ;-)
User avatar
DoG
Captain Atari
Captain Atari
Posts: 220
Joined: Sun Apr 01, 2018 11:02 pm

Re: USB HID interface

Post by DoG »

Anyone compiled this and can share a *.UF2 so I can just drag-n-drop on the the Pico?
Post Reply

Return to “Hardware”