English Amiga Board


Go Back   English Amiga Board > Support > support.Hardware > Hardware mods

 
 
Thread Tools
Old 21 April 2021, 19:47   #1
BennehBoy
Registered User
 
Join Date: Apr 2021
Location: England
Posts: 58
HID USB Mouse to Amiga

So I don't have a mouse for the A500 that I just acquired - I ordered one of those PS2 Compatible USB mouse adapters but they sent an ST version, oops!

While I wait for the correct one to come I thought I'd just make my own using an STM32 microcontroller I have sitting about.

Anyhow, total parts cost is ~ 7 quid.

MCU is a WeAct stm32f401CCU6 from Aliexpress like this -> https://www.aliexpress.com/item/4000...archweb201603_ (Not the F411CEU6, the code would need modifying to work with that).

There're 2x 5v to 3.3V bidirectional level shiters to cope with the 7 GPIO lines the Amiga uses for left, mid, right buttons, and the X&Y signals (4 lines for those in quadrature encoded format). One of the level shifters also steps the 5v power from the amiga down to 3.3v to power the MCU.

A 9 pin Female D-sub

Some wires, solder, and a breadboard/prototyping board (or a custom PCB if you have time).

A USB A female to USB C adapter.

Code is here on github -> https://github.com/BennehBoy/F401_AMIGA_HID

I need to do some documentation yet.

Crappy photo of the prototype below



Looks a bit more complicated than it is in reality because the programmer and serial converter I was using for debugging are still connected.

I am NOT going to be building these for people, just sharing a days effort for anyone else capable.

PS This can be made to run on other hardware by anyone familiar with STM32 Cube IDE. For example an STM32F105RBT6

I may add HID Controller support if I get bored, it's not hard to bake in.
BennehBoy is offline  
Old 21 April 2021, 19:50   #2
Jope
-
 
Jope's Avatar
 
Join Date: Jul 2003
Location: Helsinki / Finland
Age: 43
Posts: 9,916
Wow, that's a lot of work. You can change the Atari ST mouse adapter into an Amiga one by swapping pins 1 and 4 at the D connector.
Jope is offline  
Old 21 April 2021, 19:52   #3
BennehBoy
Registered User
 
Join Date: Apr 2021
Location: England
Posts: 58
Quote:
Originally Posted by Jope View Post
Wow, that's a lot of work. You can change the Atari ST mouse adapter into an Amiga one by swapping pins 1 and 4 at the D connector.
Yup, but this way I can use _any_ HID mouse, and not just this cheapo MS PS2 compatible one.

And in terms of work, I've probably spent 3 hours on it - most of which was getting to grips with Cube IDE after coming from Arduino (No USB Host support in the STM32 Arduino core).

PS Oh, and the adapter is being RMA'd so I didn't want to chop it.
BennehBoy is offline  
Old 21 April 2021, 20:07   #4
BennehBoy
Registered User
 
Join Date: Apr 2021
Location: England
Posts: 58
At the moment the mouse needs to be replugged each time the amiga is powered on - I'll be including some USB re-enumeration to fix that soon.
BennehBoy is offline  
Old 21 April 2021, 22:51   #5
jasonsbeer
Registered User
 
jasonsbeer's Avatar
 
Join Date: May 2020
Location: Iowa, USA
Posts: 154
Nice work. I'm on a "modernization" kick right now and HID is high on my list of concerns. Glad someone is sharing their efforts. Kudos!
jasonsbeer is offline  
Old 21 April 2021, 23:04   #6
robinsonb5
Registered User
 
Join Date: Mar 2012
Location: Norfolk, UK
Posts: 1,157
Nice work - thanks for sharing! I want to explore HID -> PS/2 at some point since nice PS/2 keyboards are now more difficult to obtain these days.
robinsonb5 is offline  
Old 21 April 2021, 23:08   #7
Nightshft
Registered User
 
Nightshft's Avatar
 
Join Date: Mar 2018
Location: Austria
Posts: 617
That's the real hacker! Send me the correct item or I will build it on my own while waiting for the replacement.
Nice work!
Nightshft is offline  
Old 22 April 2021, 08:22   #8
sampedenawa
Registered User
 
Join Date: Sep 2017
Location: IT
Posts: 178
Similar projects:


https://github.com/EmberHeavyIndustries/HID2AMI


https://github.com/simoninns/SmallyMouse2


https://gitlab.com/SukkoPera/unijoysticle2 (should have mouse support soon)
sampedenawa is online now  
Old 22 April 2021, 09:17   #9
Jope
-
 
Jope's Avatar
 
Join Date: Jul 2003
Location: Helsinki / Finland
Age: 43
Posts: 9,916
Quote:
Originally Posted by BennehBoy View Post
Yup, but this way I can use _any_ HID mouse, and not just this cheapo MS PS2 compatible one.

And in terms of work, I've probably spent 3 hours on it - most of which was getting to grips with Cube IDE after coming from Arduino (No USB Host support in the STM32 Arduino core).

PS Oh, and the adapter is being RMA'd so I didn't want to chop it.
Nice work in such a short amount of time, didn't mean to detract from that.

One niche you could serve with your adapter is: KVM support. A single adapter that supports those multi device HID implementations where both mouse and keyboard come in via the same USB cable. No-one has designed or sells an Amiga USB adapter like this to my knowledge.
Jope is offline  
Old 22 April 2021, 09:18   #10
BennehBoy
Registered User
 
Join Date: Apr 2021
Location: England
Posts: 58
Quote:
Originally Posted by sampedenawa View Post
Choice is good
BennehBoy is offline  
Old 22 April 2021, 09:30   #11
BennehBoy
Registered User
 
Join Date: Apr 2021
Location: England
Posts: 58
Quote:
Originally Posted by Jope View Post
One niche you could serve with your adapter is: KVM support. A single adapter that supports those multi device HID implementations where both mouse and keyboard come in via the same USB cable. No-one has designed or sells an Amiga USB adapter like this to my knowledge.
Not sure what devices you mean - do you mean as in a real KVM where multiple amigas could hang off one device which has a single KB & Mouse attached? If so that's not really an avenue I want to explore.

I'm not familiar with any other combined KB/Mouse devices that someone may wish to interface with an Amiga, got any links?

How would the KB signals be interfaced with the Amiga? There's no single option here right, I think the big boxes, 500, a600/1200 all use different connectors (granted the underlying circuitry is the same just embedded in the motherboard or the keyboard sub board), but it's getting access to those in order to connect something that's a pain. And I only have an a500 here.

It's more likely that I'll just expand the software for this to cover game controllers, and have a menu to switch the GPIOs to accommodate Atari + others - but anyone with wiring knowledge can do this in the hardware side (and this sharing is really aimed at those who can build things).

I won't be providing the level of software support that HID2AMI does, as this is just meant to be a quick hack - anyone wanting extended support should go support that project. But anyone wanting a quick mouse hack bodge and has the skills might find this useful.

PS Scope creep - the death of all projects
BennehBoy is offline  
Old 22 April 2021, 09:41   #12
torsti76
Registered User
 
Join Date: May 2018
Location: Germany, Baden-Wuerttemberg
Posts: 387
Quote:
Originally Posted by Jope View Post
Nice work in such a short amount of time, didn't mean to detract from that.



One niche you could serve with your adapter is: KVM support. A single adapter that supports those multi device HID implementations where both mouse and keyboard come in via the same USB cable. No-one has designed or sells an Amiga USB adapter like this to my knowledge.
Interesting idea. So, the plan would be to build a Y cable on the Amiga side that splices the keyboard DIN connector off the DB9 mouse port?
torsti76 is offline  
Old 22 April 2021, 09:44   #13
Jope
-
 
Jope's Avatar
 
Join Date: Jul 2003
Location: Helsinki / Finland
Age: 43
Posts: 9,916
KVMs are commonly like this, but you can find them closer to home.

These ps2 -> usb adapters show up as a keyboard and mouse simultaneously.


Also the very commonly found Logitech Unifying Receiver does keyboard + mouse simultaneously.


As for the keyboard, in my opinion a short male ps2 pigtail would be fine, then people can use what ever extension cords and adapters to connect it to their computer.

The main difference between wedge/big box: how ctrl-amiga-amiga reset is handled. Wedge amigas have a separate keyboard reset signal, big box machines pulse the clock line low for a while. Even this could be left as an exercise to the end user. Have the ps2 connector -> wedge amiga adapter include this.

On the other hand, this could be a problem that is worth solving in the USB domain instead of making it Amiga specific.

Last edited by Jope; 22 April 2021 at 10:49.
Jope is offline  
Old 22 April 2021, 09:51   #14
BennehBoy
Registered User
 
Join Date: Apr 2021
Location: England
Posts: 58
OK I'm with you now, so these are mainly combination receivers for wireless mouse/kb devices.

It ought to be simple enough to handle, those will just be USB Composite devices. STM's USB stack should just seemlessly add each unless they use some proprietary drivers.

I'd need to add a KB handler to the code and the appropriate h/w to spit out the PS2 signals.

Might be something to look at from a 'bored got nowt to do' perspective, but my test chain might be a bit precarious because 1) I don't have any of these combined devices so would need to test with just a USB KB connected, and 2) I don't have any device that natively handles PS2 input - I _do_ have a PS2 to USB adapter (sat in a tub since USB first appeared and manufacturers supplied adapters with new PC mobos), so could do a double conversion to test...
BennehBoy is offline  
Old 22 April 2021, 10:51   #15
Jope
-
 
Jope's Avatar
 
Join Date: Jul 2003
Location: Helsinki / Finland
Age: 43
Posts: 9,916
Cool. No obligation to deliver - just a thought if you want to differentiate.

Up to you whether your PS2 connector has PS2 or Amiga signaling, PS2 might have some ready made libraries available, but otoh USB -> Amiga KBD is a thing that may have been solved in an open source manner too. I haven't been following that closely.
Jope is offline  
Old 22 April 2021, 11:08   #16
BennehBoy
Registered User
 
Join Date: Apr 2021
Location: England
Posts: 58
https://github.com/borb/amigahid

Arduino based implementation - will have a look later to see if can be ported to HAL... I can't move my code to Arduino because there's no USB Host support in the stm32 Arduino core.
BennehBoy is offline  
Old 22 April 2021, 11:14   #17
torsti76
Registered User
 
Join Date: May 2018
Location: Germany, Baden-Wuerttemberg
Posts: 387
Quote:
Originally Posted by BennehBoy View Post
https://github.com/borb/amigahid

Arduino based implementation - will have a look later to see if can be ported to HAL... I can't move my code to Arduino because there's no USB Host support in the stm32 Arduino core.
Good find! Didn't know this one.
torsti76 is offline  
Old 22 April 2021, 11:16   #18
sampedenawa
Registered User
 
Join Date: Sep 2017
Location: IT
Posts: 178
In order to deal with multiple HID devices at the same time, you need multiple USB PHY on the chip.

I know that STM32F405 supports two USB OTG, but I suspect that F401 has only one.


Just a couple of "lessons learned":

- STM's USB stack is free, but it's bugged as hell. If you are going to start a "serious" project, I would recommend going to a more stable USB stack (google for lots of them)
- Keyb support is fair easy to implement: there's a good "copy & paste" example in STM's demo application notes

Last edited by sampedenawa; 22 April 2021 at 11:22.
sampedenawa is online now  
Old 22 April 2021, 11:34   #19
BennehBoy
Registered User
 
Join Date: Apr 2021
Location: England
Posts: 58
Quote:
Originally Posted by sampedenawa View Post
In order to deal with multiple HID devices at the same time, you need multiple USB PHY on the chip.

I know that STM32F405 supports two USB OTG, but I suspect that F401 has only one.


Just a couple of "lessons learned":

- STM's USB stack is free, but it's bugged as hell. If you are going to start a "serious" project, I would recommend going to a more stable USB stack (google for lots of them)
- Keyb support is fair easy to implement: there's a good "copy & paste" example in STM's demo application notes
I'll need to go re-read some USB documentation - I hadn't though a composite device would require multiple PHY's since it's essentially one device with multiple interfaces. Always happy to learn.

You're correct regrarding the 401, but I've got a stack of 407's here too, cheap and v capable, just a bit more bulky in dev board form.

As for buggy USB stacks, you're not wrong at all, the partial 'cruft' of the HAL stack into STM's own Arduino core has been a bug bear on this front for a while, so much so that the lead STM dev on it is looking towards tinyusb as an alternative.
BennehBoy is offline  
Old 22 April 2021, 11:36   #20
BennehBoy
Registered User
 
Join Date: Apr 2021
Location: England
Posts: 58
Anyhow... for _this_ project the next step is the USB disconnect/re-enumeration to prevent the mouse having to be replugged at cold start.
BennehBoy is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
HID2AMI - *Any* HID mouse and HID gamepad to Amiga adaptor/converter sampedenawa Hardware mods 238 22 May 2024 21:56
New USB HID Keyboard adapter for the classic Amiga spidi News 49 06 May 2021 08:51
New USB HID mouse / USB Joystick / Gamepad USB adapter for the classic Amiga spidi News 191 21 February 2021 19:18
USB Mouse For Amiga crazyegg support.Hardware 32 24 May 2010 06:07

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 07:55.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.10044 seconds with 13 queries