Arei's blog

Using Sun Type 5 Mouse in Modern Linux


Back Story

In 2022 Osaka Japan, I found sun type 5 mechanical mouse in secondhand PC shop. I heard that in early 2000s, there were tons of sun’s and other (non IBM PC) computer peripherals available at very low price. It was good days, though I do not know about such era. Now, after 20 years, it is rare to see these kind of old PC parts in the store. The Price? It’s only 500 yen ( about 3 USD) ! I got it!! ….wait, how can I hook this up to my computer?

“Bus and Tag” A long-established secondhand computer store in Osaka, Japan. There are many old computer parts including NEC PC-9801 series that you can hard to see even in Akihabara, Tokyo.

Connector

It is mini-DIN 8pin connector, but only 3 of them exists. Pin 2 is GND, Pin4 is RX, Pin 3 is 5V Vcc.

Protocol

Basicaly, it is normal TTL-UART serial style mouse. Asynchronous, 1200bps, no parity, 1 start bit,8 data bit, 1 stopbit.

But, It is NEGATIVE LOGIC and 5V , unlike normal ttl-uart uses positive logic and 3V signals.

I don’t describe more detail specification because there is no need to you know much about protocol if you are using Linux.(See below)

Driver

Sun Type 5 mouse was used for SPARC station, and it runs Solaris, Solaris is kind of UNIX, and Linux is clone of UNIX, it naturally have mouse driver in its kernel. Therefore I need no micro controllers and no coding for firmware. Easy!

Converter

So, all I had to do is 1. Invert the logic, 2. connect to TTL-USB adapter, 3.Connect to the computer and enable drivers.

You need, 2x 1kΩ Resister and 1 NPN-transistor , mini DIN 8pin socket and TTL-USB adapter

Enabling Serial Mouse Driver

Bash
sudo inputattach --mousesystems --daemon /dev/ttyUSB0  

Seeing inputattach help, there are two possible driver, –sunmouse and –mousesystems. Sunmouse is the sub set of MouseSystem protocol, and type 5 mouse is actually sends MouseSystems Protocols, so I chose one.

Xorg.conf should have responsibility to handle pointer devices, but I can not set up xorg.conf to enable serial mouse in start up. And Udev can run above comand when ttyUSB attached, unfortunately I could not make it work properly ,so I wrote a script and registered to xfce4 startups.

Append

I wrote udev not working propely, but it is my fault. Arch Linux Wiki says, udev dose not spawn long running process such as inputattach daemon, so I fount correct way to auto starting.

First, create systemd service, like /etc/systemd/system/sun-mouse-inputattach@.service

/etc/systemd/system/sun-mouse-inputattach@.service
[Unit]
Description=inputattach for sun serial mouse

[Service]
Type=simple
ExecStart=/usr/bin/inputattach --sunmouse /dev/%I

Second, create udev rules

/etc/udev/rules.d/100-serial-sun-mouse.rules
ACTION=="add|change",  KERNEL=="ttyUSB[0-9]*", TAG+="systemd", ENV{SYSTEMD_WANTS}+="sun-mouse-inputattach@%k.service"

Finally, run

Bash
udevadm control --reload

Then, It works!

However, almost all usb-ttl adapter has same chips, id, name, manufacture, so there are no way to distinguish them. This method will not work properly if you connect more than 2 usb-ttl adapters.

Resources

Sun Keyboard Protocol

PS/2 to Sun mouse Converter

Wacom Serial devices and inputattach in a systemd world

Proper(-ish) way to start long-running systemd service on udev event (device hotplug)


投稿日

カテゴリー:

投稿者:

タグ:

コメント

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です