Author Topic: converting USB HID devices (keyboard and mouse) to PS/2  (Read 10774 times)

0 Members and 1 Guest are viewing this topic.

Offline legacyTopic starter

  • Super Contributor
  • ***
  • !
  • Posts: 4415
  • Country: ch
converting USB HID devices (keyboard and mouse) to PS/2
« on: February 01, 2019, 02:32:23 pm »
In the retrocomputing field, a lot of computers are PS/2, some are ADB, and some are even weirder (e.g. DEC terminal have their own standard), and we are receiving a lot of requests about converting USB keyboards to PS/2, including those from lucky guys who are owners of ultimatehacking keyboard, which is a USB device.

USB(kb&mouse)-to-PS/2(host) adapters seem to be rare; we have already found just a couple of commercial products, but they are really expensive (150-180 euro).

I am tempted to get a cheap Linux SBC (router), and using the USB-host to get HID stack handled and decoded so I can attach an MPU to the serial port of the router to provide the PS/2 out streaming.

This costs 10 euro for the Chinese cheap router (DLINK and alike), and 10 euro for the MPU.

But it's not a neat solution, so ... I wonder what do you think about/alternatives  :popcorn:
 

Offline hans

  • Super Contributor
  • ***
  • Posts: 1639
  • Country: nl
Re: converting USB HID devices (keyboard and mouse) to PS/2
« Reply #1 on: February 01, 2019, 02:44:16 pm »
There are many modern microcontrollers that support USB host through hardware.
You'd need to check if they have a HID host driver, which you could use to poll for values from the USB keyboard/mice and send them out via an emulated PS2 port.

I think many Microchip PIC controllers have USB OTG, which supports host/device & switching, but basically anything else with USB host support should work.

Then of course is the question, if you really want to get that involved with controlling USB devices on such a low level to save 10$ of the hardware BOM.
 

Offline legacyTopic starter

  • Super Contributor
  • ***
  • !
  • Posts: 4415
  • Country: ch
Re: converting USB HID devices (keyboard and mouse) to PS/2
« Reply #2 on: February 01, 2019, 03:57:45 pm »
with a teensy MPU?
 

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 6260
  • Country: fi
    • My home page and email address
Re: converting USB HID devices (keyboard and mouse) to PS/2
« Reply #3 on: February 01, 2019, 03:58:38 pm »
You can use an Arduino Pro Mini (I prefer Teensy or a Micro) with a Mini USB Host shield (based on MAX3421E; DuinoFun UHS clones are < $5 at fleabay).  The USB Host Shield 2.0 library works with those (including Teensies). Arduino Playground mentions ps2dev, which implements the device side of the PS/2 protocol.

I haven't done this myself, but looking at the code, there shouldn't be much Arduino tinkering to get this working.  Plus, you have a dozen or so I/O pins left, and plenty of processing power, to implement additional buttons or features.  Maybe an optional I2C OLED display?  I love those things.

As a nice cherry on top, using the same libraries, but adding a BLE module, you can also implement a bluetooth device to PS/2 host keyboard/mouse bridge as well.
 

Offline BloodyCactus

  • Frequent Contributor
  • **
  • Posts: 482
  • Country: us
    • Kråketær
Re: converting USB HID devices (keyboard and mouse) to PS/2
« Reply #4 on: February 01, 2019, 04:28:28 pm »
I know Microchip have a USB HID stack in the MLA. But its more about if you need to attach more than 1 usb device or need to act as a hub or just a simple 1 port client.
-- Aussie living in the USA --
 

Offline legacyTopic starter

  • Super Contributor
  • ***
  • !
  • Posts: 4415
  • Country: ch
Re: converting USB HID devices (keyboard and mouse) to PS/2
« Reply #5 on: February 01, 2019, 04:48:57 pm »
yup, Elisabeth is looking at the Maxim chip used in the USB-shield and she thinks it's a good idea. We have guys looking for an adapter for their usb-keyboards, and we are considering the purchase of happyhacking keyboard for our Sonoko project, which is composed by two PowerPC405GP nodes using a PS/2 through a KVM interface.

For sure we won't change the KVM, but we can add (and integrate) a USB-to-PS/2 adapter.

Anyway, we are also evaluating other keyboards, some are natively PS/2, which is better for us, but other guys want  USB keyboards and mouses so in a way or in another we have to satisfy the need for an adapter.
 

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 6260
  • Country: fi
    • My home page and email address
Re: converting USB HID devices (keyboard and mouse) to PS/2
« Reply #6 on: February 01, 2019, 05:40:20 pm »
(Completely off topic, but if you think the gentoo irc ban is funky, just look at the Debian CTTE discussion on bug #919951, especially posts by Stéphane Glondu and Anil Madhavapeddy. They appropriated a binary without discussion, causing a package conflict, falsely claimed and keep claiming others have agreed to the change; and now complain that someone is suggesting they change the name/path again to fix the clash. "The tone of your message sounds like harassment to me."  Apparently, redoing their earlier change is apparently too much work, because they'd have to run a single find . -type f -exec sed -e 's|/usr/bin/dune|/usr/bin/we-are-idiots|g' -i '{}' ';' stanza on their source archive to fix their changes.)

Give me technical challenges every day, and I'll be happy as a clam.  But these PC manipulations make Nominal Animal a very very unhappy boy.
 

Offline legacyTopic starter

  • Super Contributor
  • ***
  • !
  • Posts: 4415
  • Country: ch
Re: converting USB HID devices (keyboard and mouse) to PS/2
« Reply #7 on: February 01, 2019, 06:09:54 pm »
(Completely off topic, but if you think the gentoo irc ban is funky

Yup. Funny, summarized here.
« Last Edit: February 02, 2019, 12:19:23 pm by legacy »
 

Offline legacyTopic starter

  • Super Contributor
  • ***
  • !
  • Posts: 4415
  • Country: ch
Re: converting USB HID devices (keyboard and mouse) to PS/2
« Reply #8 on: February 01, 2019, 06:21:23 pm »
Plus, you have a dozen or so I/O pins left, and plenty of processing power

The Keyboard Cherry's G81-8308 looks interesting since it implements "programmable keys".
This can be replicated in some way :D

Shown in this video  :D
« Last Edit: February 01, 2019, 08:05:09 pm by legacy »
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14472
  • Country: fr
Re: converting USB HID devices (keyboard and mouse) to PS/2
« Reply #9 on: February 01, 2019, 06:33:42 pm »
I am tempted to get a cheap Linux SBC (router), and using the USB-host to get HID stack handled and decoded so I can attach an MPU to the serial port of the router to provide the PS/2 out streaming.

This costs 10 euro for the Chinese cheap router (DLINK and alike), and 10 euro for the MPU.

Ouch. Even though it may still be "cheap" for your intended target, I don't like this solution much. Not just because it's overkill (you may not care, and that could save a significant development time if I got you right). The main reason would be that as a Linux-based device, it will take a significant amount of time booting up every time it's powered on. That may be quite annoying for the end-user depending on how it's being used. Even if it's just a few seconds (and it could be much more than that, cheap routers sometime take almost 30s...), that's annoying IMO.
 

Offline legacyTopic starter

  • Super Contributor
  • ***
  • !
  • Posts: 4415
  • Country: ch
Re: converting USB HID devices (keyboard and mouse) to PS/2
« Reply #10 on: February 01, 2019, 07:25:21 pm »
The main reason would be that as a Linux-based device, it will take a significant amount of time booting up every time it's powered on.

yup, this is bad. Our Atheros9 chips take 12 sec for booting, plus 4 sec for loading the kernel into the ram.
Anyway, sonoko takes longer for booting.
« Last Edit: February 02, 2019, 10:49:27 am by legacy »
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14472
  • Country: fr
Re: converting USB HID devices (keyboard and mouse) to PS/2
« Reply #11 on: February 01, 2019, 07:45:44 pm »
Additionally, if using Linux, you should also consider using a read-only distribution if you can. Normal distributions tend to write to disk quite often, and that would only wear off the flash memory, and introduce the possibility of data corruption in case of a power supply problem... this fact in itself (finding the right distribution or tweaking it yourself to make it read-only) may take a significant dev. time...

The most cost effective way of implementing this (and most 'simple' from a system pov) would be to use a small MCU with embedded USB host (like USB OTG), then decoding the keyboard input from there, translating it for PS/2 and then send it to PS/2, which is just a serial transmission (looks a bit like I2C IIRC.)

If going for an STM32 MCU, you could start here: https://www.st.com/en/embedded-software/stsw-stm32046.html
 

Offline Buriedcode

  • Super Contributor
  • ***
  • Posts: 1611
  • Country: gb
Re: converting USB HID devices (keyboard and mouse) to PS/2
« Reply #12 on: February 01, 2019, 07:55:29 pm »
Some keyboards still natively support PS/2 - the adapters are purely mechanical, but it is becoming less common.  I'll second a PIC.  Plenty of the PIC24 and PIC32 series have OTG/host capability and 5V operation for <$4.  Seems like overkill to go for an SBC, and a USB host shield, whilst possibly cheap would be rather large. 

Also, Wikipedia mentions the PS/2 spec can supply max 275mA, vs USB's 2.0 500mA.  Fancy keyboards with lots of LED's could draw more than this meaning you'll need an external supply.  Although its probably not much I suspect the total current draw for an Arduino + USB host shield to be non-insignificant, where-as a single PIC MCU would be <10mA.  Not to mention a low part count and size.
 

Offline legacyTopic starter

  • Super Contributor
  • ***
  • !
  • Posts: 4415
  • Country: ch
Re: converting USB HID devices (keyboard and mouse) to PS/2
« Reply #13 on: February 01, 2019, 08:02:23 pm »
yup, for sure we will go with the MPU approach. It's neat.  Already ordered a couple of USB-shields  :D
 

Offline legacyTopic starter

  • Super Contributor
  • ***
  • !
  • Posts: 4415
  • Country: ch
Re: converting USB HID devices (keyboard and mouse) to PS/2
« Reply #14 on: February 01, 2019, 08:08:07 pm »
Also, Wikipedia mentions the PS/2 spec can supply max 275mA, vs USB's 2.0 500mA





like these?  :D
 

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 6260
  • Country: fi
    • My home page and email address
Re: converting USB HID devices (keyboard and mouse) to PS/2
« Reply #15 on: February 01, 2019, 08:23:20 pm »
PCI_Matrox dual VGA
I think I have a PCI G400 and a Rainbow Runner digitizer daughterboard lying around here somewhere..  ;)  The G400 could be an AGP-bus'd G450, if I recall wrong, though.  Have an use for those? I don't.
 

Offline legacyTopic starter

  • Super Contributor
  • ***
  • !
  • Posts: 4415
  • Country: ch
Re: converting USB HID devices (keyboard and mouse) to PS/2
« Reply #16 on: February 01, 2019, 09:42:48 pm »
it's funny because we have here a  Microspeed trackball and it's serial RS232 with a built-in adapter that *magically* makes it a PS/2 device :D

it's a real true good trackball, anyway!
 

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 6260
  • Country: fi
    • My home page and email address
Re: converting USB HID devices (keyboard and mouse) to PS/2
« Reply #17 on: February 01, 2019, 10:45:15 pm »
The main reason would be that as a Linux-based device, it will take a significant amount of time booting up every time it's powered on.
On some dedicated devices with a truly simple userspace (dumb init, eudev, and a custom binary service or application) you can wrap it all as an initrd, and run the thing without any userspace bootup.  Most won't bother, because it is a lot of work and using a proper Linux machine with all the standard services is easier.  But it can be done; I've done it for cluster node benchmarking.  There, it did not really shorten the bootup time at all, because their BIOSes often take a minute or so before even reading any boot sector stuff.  The real point there was to omit anything unnecessary and unrelated to the benchmarking, really.

I backed the La Frite Kickstarter because its developers say they will try hard to get all support into the vanilla kernels. That is rare.  When I get my mittens on it, I will probably look at minimal initrd-only booting on it (because it is pretty easy when the kernel has all the necessary support built-in).  There are many embedded type tasks (like 3D printer control, dumb terminals, displays, media playback devices) that really do not need a full userspace, and cutting the bootup time to a minimum will mean a much better UX.  I have no idea yet how fast I can make it, though.

For retrocomputing, I could imagine using one as a peripheral, faking various interfaces via custom microcontrollers and such.  For example, if I had an older one with composite or S-Video outputs (say, an original Playstation -- wait, I do have one), I could use one of those USB digitizer dongles to digitize that, and use the HDMI output to display it to a modern display, with an easy way to add my own custom graphical overlays (for whatever else I might need, like system configuration and such).

it's serial RS232 with a built-in adapter that *magically* makes it a PS/2 device :D
The PS/2 port protocol is pretty simple, really; reminds me of I2C or SPI.  It is no surprise that you only need a small bus driver chip, probably a 8-bit shift register based one, to implement a RS232-PS/2 bridge.  But, bit-banging PS/2 on an MCU is not at all hard to do.

If you want to do a proper professional board, look into FTDI Vinculum chips. The VDIP2 development kit on Mouser looks to be around $30; it has two USB host ports you could use for HID devices.  I haven't ever even seen FTDI's development tools, so I don't know whether this is a good approach; I'm only saying that if a professional packaged product is what is in your mind, it might be worth it to look into the FTDI offerings, starting with the VDIP2 development kit to see the Vinculum chip capabilities.
 

Offline legacyTopic starter

  • Super Contributor
  • ***
  • !
  • Posts: 4415
  • Country: ch
Re: converting USB HID devices (keyboard and mouse) to PS/2
« Reply #18 on: February 02, 2019, 04:40:44 pm »


it's also funny but in Japan, someone is making keyboards that are designed for being used with emacs. These keyboards are usually USB-device with a custom keybinding, optimized for bash, vi, or emacs  :o :o :o

very expensive keyboards and some of them miss the arrow keys as well as the F{1..12} keys as well as other useful keys.

In short, it seems they assume that one has to have several keyboards and input devices depending on the computing task.


« Last Edit: February 02, 2019, 04:53:21 pm by legacy »
 

Offline legacyTopic starter

  • Super Contributor
  • ***
  • !
  • Posts: 4415
  • Country: ch
Re: converting USB HID devices (keyboard and mouse) to PS/2
« Reply #19 on: February 02, 2019, 04:51:11 pm »
Found this website with information about converting different protocols for old keyboards.
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9890
  • Country: us
Re: converting USB HID devices (keyboard and mouse) to PS/2
« Reply #20 on: February 02, 2019, 11:20:05 pm »
I'm not sure I followed the intent of the first posting...

There have been adapters that take USB peripherals and connect them to PS2 ports - been around a very long time:

https://www.amazon.com/USB-Female-Male-Adapter-Mouse/dp/B00HDGULP8

Whether they work for any particular USB keyboard, I wonder.  Nevertheless, I have used them with KVM switches that only accepted PS2 and I wanted to use a USB mouse/keyboard.  Worked well.

Other than that, I would use RawHID for the Teensy if I actually wanted a USB peripheral.  I could take PS2 into the micro, do some kind of magic and output either USB HID or PS2.  It might work out that I could take a USB peripheral, run it through the adapter to get PS2 and then mangle the PS2 output before sending it along as either PS2 or USB.

A long time ago I connected knobs, switches and dials to Microsoft Flight Simulator using RawHID on one of the early Teensy devices.  It used an Atmel ATmega something or other (I think, it's been a LONG time).
 

Offline NiHaoMike

  • Super Contributor
  • ***
  • Posts: 9016
  • Country: us
  • "Don't turn it on - Take it apart!"
    • Facebook Page
Re: converting USB HID devices (keyboard and mouse) to PS/2
« Reply #21 on: February 03, 2019, 12:02:20 am »
It shouldn't be too difficult to find a microcontroller that has USB host and a USART or two that can be used to output PS/2.
Cryptocurrency has taught me to love math and at the same time be baffled by it.

Cryptocurrency lesson 0: Altcoins and Bitcoin are not the same thing.
 

Offline PCB.Wiz

  • Super Contributor
  • ***
  • Posts: 1542
  • Country: au
Re: converting USB HID devices (keyboard and mouse) to PS/2
« Reply #22 on: February 03, 2019, 08:29:08 am »
If you want to do a proper professional board, look into FTDI Vinculum chips. The VDIP2 development kit on Mouser looks to be around $30; it has two USB host ports you could use for HID devices.  I haven't ever even seen FTDI's development tools, so I don't know whether this is a good approach; I'm only saying that if a professional packaged product is what is in your mind, it might be worth it to look into the FTDI offerings, starting with the VDIP2 development kit to see the Vinculum chip capabilities.

Yes, the FTDI VNC2 series looks useful : https://www.ftdichip.com/Products/ICs/VNC2.htm

Another would be the Chinese CH554/ CH559

I can find source code here, that mentions both USB Host and PS/2, so those might splice together ? 
https://github.com/zhuhuijia0001/ch559-usb-host
and eval boards here
https://www.electrodragon.com/product-category/arduino-2/avr_pic_51/

http://www.wch.cn/products/category/5.html
The CH549/CH548/CH547/CH546  look to be newer, with maybe better ADC, more peripherals, and could be between the 554 & 558/559 in price?
 

Online ebastler

  • Super Contributor
  • ***
  • Posts: 6476
  • Country: de
Re: converting USB HID devices (keyboard and mouse) to PS/2
« Reply #23 on: February 03, 2019, 08:44:32 am »
I'm not sure I followed the intent of the first posting...

There have been adapters that take USB peripherals and connect them to PS2 ports - been around a very long time:
https://www.amazon.com/USB-Female-Male-Adapter-Mouse/dp/B00HDGULP8

^^^ This. It seems that modern USB keyboards still support PS/2, with a simple passive adapter as shown in rstofer's link. At least the brand-name ones; just spot-checked a Cherry datasheet.
 

Offline OwO

  • Super Contributor
  • ***
  • Posts: 1250
  • Country: cn
  • RF Engineer.
Re: converting USB HID devices (keyboard and mouse) to PS/2
« Reply #24 on: February 03, 2019, 11:43:23 am »
I'm glad I'm not the only weeb here   :-+ :-+ :-+
Email: OwOwOwOwO123@outlook.com
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf