randyrossi / bmc64

A bare metal Commodore 64 emulator for the Raspberry Pi with true 50hz/60hz smooth scrolling, low input latency and better audio/video sync.
GNU General Public License v3.0
473 stars 56 forks source link

[SOLVED] Arduino Pro Micro as USB adapter instead of Keyrah #182

Closed omiq closed 3 years ago

omiq commented 3 years ago

JULY 2021 ### I created brand new firmware that solves this issue after tips from @mcgurk below

Check out my article here

------- Original Post --------

I made a pro micro usb HID device, so I can use the real C64 keyboard AND do "user port" projects. Unfortunately while it is recognized fine by my Mac, the BMC64 Pi does not recognize it.

I found on the inter webs someone says use "usbhid.quirks=0x2341:0x8037:0x040" in cmdline.txt but that seems to be for Raspbian - anything I can do on BMC64 or is it basically impossible?

mcgurk commented 3 years ago

You don't have to do that yourself. There is readymade very versatile keyboard controller firmware for ProMicro called Soarers keyboard controller: https://github.com/mcgurk/Arduino-USB-HID-RetroJoystickAdapter/tree/master/C64_keyboard

If you wan do everything yourself, you cannot use Arduino IDE with default libraries. Arduino IDE creates ProMicro as multiple USB-devices same time and it is primarily USB-serial-device. It makes it incompatible with many devices. Using Atmel studio you can make it to be only USB-keyboard.

Notice: after ProMicro is just keyboard (like with Soarers keyboard controller), it cannot be programmed normally anymore, because there is no serial device to program with. You must put ProMicro to program mode by hand every time you flash new firmware (connecting RST to GND and starting flashing in right timewindow).

omiq commented 3 years ago

The Arduino and C64 parts are working - I have the Arduino working with the keyboard and it is great when plugged in to my Mac using Vice - but the Pi doesn't recognize it for use with BMC64.

So from what I can tell you are saying the problem with getting it to work with BMC64 us I used the Arduino IDE? (the example you linked also uses Arduino IDE)

mcgurk commented 3 years ago

Right, you cannot use Arduino IDE to make it USB-keyboard. I know that it seems to work with Mac ja Windows and many other devices, but it doesn't work with many simple devices which doesn't understand combination of many USB-devices. When simple device asks "what kind of USB-device you are", ProMicro made with Arduino IDE answers "I'm USB-serial device".

omiq commented 3 years ago

Ah ok that makes sense, thank you!

mcgurk commented 3 years ago

Soarers firmware in my link is not made with Arduino IDE.

Other ways to create code for ProMicro is Atmel tools like Atmel Studio IDE.

Here is my scrappy example for Atmel Studio IDE to create pure USB-joystick device: https://github.com/mcgurk/Arduino-USB-HID-RetroJoystickAdapter/tree/master/C64_joystick_atmelstudio

omiq commented 3 years ago

Yeah I saw just now he uses avrdude, so I am grabbing that from Homebrew but I will also check out using Atmel studio too so I can make custom solution - thank you! :)

omiq commented 3 years ago

Works perfectly, thank you @mcgurk !!