Author Topic: Converting Amstrad CPC-464 into USB Keyboard  (Read 2160 times)

0 Members and 1 Guest are viewing this topic.

Offline nomnomnmm

  • Thread Starter
  • Posts: 3
Converting Amstrad CPC-464 into USB Keyboard
« on: Mon, 01 June 2020, 01:08:14 »
Hi all,
I'm working on a project that includes repurposing an old Amstrad CPC-464 keyboard into a USB keyboard.
It uses a membrane with a 10 row, 9 column matrix and I have gotten as far as wiring up the existing ribbon connectors to an Arduino Leonardo and built a very simple program to using Keypad/Keyboard libraries.
A sample of the arduino code is below (only bothered to map the alpha chars at this stage):

Code: [Select]
const byte ROWS = 10; //four rows
const byte COLS = 9; //four columns

//define the cymbols on the buttons of the keypads
char keys[ROWS][COLS] = {
{ '+','+','+', '+', '+', '+', '+', '+', '+'}, //1
{ '+','1','2', '+', 'q', '+', 'a', '+', 'z'}, //11 0x04 => KEY_CAPS_LOCK = Map change
{ '+','4','3', 'e', 'w', 's', 'd', 'c', 'x'}, //12
{ '+','6','5', 'r', 't', 'g', 'f', 'b', 'v'}, //13
{ '+','8','7', 'u', 'y', 'h', 'j', 'n', '+'}, //14
{ '+','0','9', 'o', 'i', 'l', 'k', 'm', ','}, //15
{ '+','+','=', '@', 'p', ';', ':', '/', '.'}, //16
{ '+','+','[', '+', ']', '4', '=', '\\', '+'},//17 0x7e (ª), 0x01 = KEY_LEFT_CTRL, 0x02 = KEY_LEFT_SHIFT
{ '+','+','+', '7', '8', '5', '1', '2', '0'}, //18 0x81 = COPY = Ctrl +c
{ '+','+','+', '+', '9', '6', '3', '+', '.'} //19
};

byte rowPins[ROWS] = {9, 10, 11, 12, A0, A1, A2, A3, A4, A5}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {0, 1, 2, 3, 4, 5, 6, 7, 8}; //connect to the column pinouts of the keypad

What I didn't realise is how complicated the programing behind a keyboard actually is..... I can happily get single keystrokes working and even got some press and hold working but it's nowhere near a fully functional qwerty keyboard.
After a few days playing around I got onto searching for custom firmware solutions and came across QMK/TMK.
I've looked at a few videos/tutorials but can't figure out where to start or if QMK is even the right solution for what I want to do. My specific questions:

- Is QMK or TMK suitable for my project?
- If so, where do I start? I've looked in the QMK repo and I can't see any layouts for CPC-464 (not surprising!) - can I make my own?

Just looking for some general advice, happy to do the hard work but I'm stumped at the moment.
P.S. I love the look of this keyboard, will be very happy if I can get it working. A couple of photos below for reference :D

https://imgur.com/PgvSadG
https://imgur.com/xRf0Dcw
https://imgur.com/6n8lTWC

Offline Maledicted

  • Posts: 2164
  • Location: Wisconsin, United States
Re: Converting Amstrad CPC-464 into USB Keyboard
« Reply #1 on: Mon, 01 June 2020, 11:51:19 »
That's a really cool keyboard. Have you thought about asking hasu directly? He maintains TMK.

Offline nomnomnmm

  • Thread Starter
  • Posts: 3
Re: Converting Amstrad CPC-464 into USB Keyboard
« Reply #2 on: Mon, 01 June 2020, 16:40:54 »
Thanks, will give it a shot!

Offline hasu

  • Posts: 3474
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: Converting Amstrad CPC-464 into USB Keyboard
« Reply #3 on: Wed, 03 June 2020, 01:15:56 »
Hi,
No tutorial for this, but you can consult with under tmk_core/doc/ and wiki pages first.
https://github.com/tmk/tmk_keyboard/tree/master/tmk_core/doc
https://github.com/tmk/tmk_keyboard/wiki

In the end you have to read source codes.
You can start with check codes under keyboard/ to get rough idea on how to define your keyboard, alps64 and gh60 are probably preferable.  You will have to implement matrix_init() and matrix_scan() at least.

And you will have to read codes under tmk_core/common(and tmk_core/protocol/lufa) to know how it works under the hood. You want to start with common/keyboard.c first, especially keyboard_task() in which the matrix_scan() is called.

Also you can ask question in this thread.
https://geekhack.org/index.php?topic=41989.msg841759#msg841759

Good luck with your project!

Offline nomnomnmm

  • Thread Starter
  • Posts: 3
Re: Converting Amstrad CPC-464 into USB Keyboard
« Reply #4 on: Wed, 03 June 2020, 01:39:26 »
Thanks Hasu!! I'll get reading, much appreciated