Twin DB9-2-USB
- Gary Metheringham
- Feb 22, 2020
- 3 min read
This is my TWIN Db9 Joystick adapter for the, TheC64 Mini/Maxi and windows/ (linux/Raspberry Pi Untested)
Background
I started off this project with a single DB9 adapter based on an arduino Pro-Micro. then I Got my TheC64 and decided I would try to get both of the Commodore64's (TheC64) Joystick ports to work off one Arduino. (Please note i am no coder i can copy & paste code and try to work out what bit of code does what but thats my limits)
first thing i did was work out how many available pins i have to play with on the Pro-micro
(16), How many buttons do we need (Joystick=5 each, Menu controls 4) so 14 leaving 2 spare pins so i set them as the Left & Right Triangle buttons found on theC64's joystick.
Building the Board
So i set about designing a schematic for my design

The second Arduino in the pic is just because there are 2 different sized pro-micros, when i went on to make the PCB I just placed them on top of each other to get 2 lots of pin holes side by side.
Not to create a pcb

This is what i came up with
Order all parts from China and wait 3-4 weeks for everything to arrive
then get building
Now all built up time to get some codeing done. there is not much info on the pro-micro and usb HID devices out there and what is is well above my pay-grade so lets start looking at arduino examples. and single pro-micro usb adapter code out there. I managed to find enough info to cut copy merge and splice bits of code together to come up with my very messy code.
playing about i got 2 joysticks to show up in windows but they would not work on TheC64
a few more weeks of digging around and i found out that Linux (the base of TheC64) dosen't recognize very many Twin Controllers. but I managed to find the Vender ID and Product ID of one that is supported.
Editing Files
First temporarily disable arduino's alternate locations for file by finding the 'hardware' folders and renaming them (I just add a 1 to the end hardware1)
they are in
C:\Users\USERNAME\Documents\Arduino
and
C:\Users\USERNAME\AppData\Local\Arduino15\packages\arduino
Now we must load up Arduino boards.txt file and edit 3 lines of code in there
located here
\PATH TO\arduino-beta1.9\hardware\arduino\avr
scroll down to Leonardo section (mine starts on line 280
edit the 3 blue line to match below (Make a note of the original values as you will need to replace them when finished
##############################################################
leonardo.name=Arduino Leonardo
leonardo.vid.0=0x2341
leonardo.pid.0=0x0036
leonardo.vid.1=0x2341
leonardo.pid.1=0x8036
leonardo.vid.2=0x2A03
leonardo.pid.2=0x0036
leonardo.vid.3=0x2A03
leonardo.pid.3=0x8036
leonardo.upload.tool=avrdude
leonardo.upload.protocol=avr109
leonardo.upload.maximum_size=28672
leonardo.upload.maximum_data_size=2560
leonardo.upload.speed=57600
leonardo.upload.disable_flushing=true
leonardo.upload.use_1200bps_touch=true
leonardo.upload.wait_for_upload_port=true
leonardo.bootloader.tool=avrdude
leonardo.bootloader.low_fuses=0xff
leonardo.bootloader.high_fuses=0xd8
leonardo.bootloader.extended_fuses=0xcb
leonardo.bootloader.file=caterina/Caterina-Leonardo.hex
leonardo.bootloader.unlock_bits=0x3F
leonardo.bootloader.lock_bits=0x2F
leonardo.build.mcu=atmega32u4
leonardo.build.f_cpu=16000000L
leonardo.build.vid=0x8282
leonardo.build.pid=0x3201
leonardo.build.usb_product="DB9-2-USB"
leonardo.build.board=AVR_LEONARDO
leonardo.build.core=arduino
leonardo.build.variant=leonardo
leonardo.build.extra_flags={build.usb_flags}
##############################################################
download the arduino project from https://github.com/garymeg/Twin-DB9-2-USB
open up your arduino ide and load up the project det the board to leonardo and upload your code.
now all you need to do is add 1 line to the end of the file in the TheC64's gamecontrollerdb.txt file
easiest way is to use the x-windows hack to copy gamecontrollerdb.txt to a usb drive edit then copy back to TheC64.
this is where the gamecontrollerdb.txt file is stored on the64
\usr\share\the64\ui\data
the line to add is this
03000000828200000132000001010000,DB9-2-USB,a:b4,b:b5,back:b6,lefttrigger:b0,leftx:a0,lefty:a1,righttrigger:b1,start:b7,x:b3,y:b2,platform:Linux,
The line is all 1 line no CR's or spaces
Now with gamecontrollerdb.txt copied back reboot your c64 and plug in the joystick adapter
Note... I think you will have to hold the joystick plugged into port1 on the adapter in the up position with fire pressed to set this up as the c64's port 2 joystick if you want to use both as c64's port 1,2 stick or else port 2 on the adapter defaults to c64 port2 and port 1 not work.
Final thing go back to top of page and work your way through undoing all the file edits/renames in the early steps above just not the gamecontrollerdb.txt obviously.
PS
There is an error on the pcb with the ISP connector. please make an adapter lead up to correct the pins
Comments