The keyboard is already working, thanks to the overhaul of the keyboard input code. The joystick ports also used to work. The past tense being employed there, because the overhaul of the keyboard input broke it. I have since fixed that (it was just that I hadn't fed the real joystick pins into the combined joystick input code), and am synthesising the resulting bitstream for testing later today.
For those with an interest in VHDL, here is the logic that is used to update the joystick state:
for n in 0 to 4 loop
joya(n) <= '1' and (joya_physkey(n) or joykey_disable)
and (joya_widget(n) or widget_disable)
and (joya_real(n) or joyreal_disable)
and (joya_ps2(n) or ps2_disable);
joyb(n) <= '1' and (joyb_physkey(n) or joykey_disable)
and (joyb_widget(n) or widget_disable)
and (joyb_real(n) or joyreal_disable)
and (joyb_ps2(n) or ps2_disable);
Basically for each line on both joysticks, we consider all the possible input sources, and merge them together, these are USB/PS2 keyboard using dedicated keys mapped to the joystick, the MEGA65 Widget Board that can be connected to a Nexys4 FPGA development board to allow use of a real keyboard and joysticks on that, and apparently the USB/PS2 keyboard a second time (I just noticed this, and will have to investigate why on earth I have it twice).
However, getting to the point of being able to test joysticks has led me to a long term problem I have had: I don't have any properly working C64 joysticks left. I have a Quick Fire 2, with its lead in very poor condition, with loops of wires on the outside holding it in strange kinks that cause it to sometimes work. I could have fixed that, but the quality of the switches and everything would mean that it would soon die again. Also, it wouldn't solve the above-mentioned problem of both of our children wanting to play games at the same time.
Thus I finally got around to doing what I had intended to do for the last 20 years, and build up a couple of proper arcade joysticks. There is something about the feel of a fully free and well constructed arcade joystick controller, as well as the fact that they are much, much more durable than commodity joysticks, and also much more serviceable. The TAC2 is about the closest C64 joystick I have found, and even those are not as durable, and to me at least, don't quite have the same feel.
Anyway, this adventure in making arcade joysticks was made easier by the fact that Jaycar now stock the joystick assemblies and buttons, as well as cheap plastic boxes in which to put everything. I had previously bodged one up about 20 years ago with parts from a pinball rental company, but Jaycar is much, much cheaper, and the quality of the mechanisms seem to be pretty good.
Wiring up a C64 joystick is really simple: There are dedicated lines for up, down, left, right and fire, and these get connected through the switches to ground. If you want any electronics in there, e.g., an auto-fire function, there is also 5V available. There are also two lines for the analog inputs, but we are not using those.
The arcade joysticks have spade connectors, so I got some nice black 7-core cable and put spade connectors on one end, and the correctly wired DB9 on the other end. I did try to get all clever-pants, and bought the cable as DB9 serial null-modem cables, with the female DB9 on the end, however, they didn't have all nine pins connected, so I had to go for the hand-soldered and screw-box cover. Here is the joystick wired up with spade-connectors and a soldered ground-loop, so that if I have messed up the joystick directions in the wiring, I can easily fix it.
If I were building an arcade game for public use, I would have used spades for the ground-loop as well, so that the micro-switches could be more easily replaced as they wear out. However, for home use, that is unlikely to ever happen, and a bit of remedial soldering doesn't scare me. The spade connectors also mean I can switch one of them to being "left-handed" (button on right), if my daughter's fears about not being able to use a "right-handed" joystick prove to be genuine. I should say that I am also left-handed, but don't have trouble using a right-handed joystick, so we will see how we go.
Anyway, here is one of the finished units. Total cost per unit, about AU$45 (ca. 30€).
They are quite big, which is partly necessitated by the rather large joystick mechanisms, and also because I like a big solid joystick, so that you can whack the stick around as you need, and thump the button with impunity.
The arcade buttons from Jaycar have an LED in them, so you can make the button illuminate, which I decided to do on one of them. The other was already sealed up, so I didn't make the modification to that one, but I might another day. For now, it means that I have an easy way to tell them apart.
I'm pretty happy with the result. They are unlikely to ever appear in an Ikea catalog or anywhere else where styling is important, however, they are solid, should last the next 20 years, and have that nice arcade game feel to them. Now I just need to wait for the FPGA synthesis to finally finish, so I can give it a try...