MiSTeryNano
MiSTeryNano copied to clipboard
Does second hid joystick work?
I've connected two USB gamepads via raspberry pico and I see in logs JOY0 and JOY1 that send command to FPGA, but when I wanted to test two joysticks in a game. Second one never works, so I tried to understand if second joystick port is supported on FPGA, so started reading Verilog (I'm beginner) and I found in misterynano.sv this:
.joystick0(hid_joy),
.joystick1()
Does it means that joystick1 (second joy) is not wired to hid data, which means second joy is not implemented?
If my analysis is correct, do you plan to implement second hid joy support?
Here is diff for verilog to support second joystick for ataris st. It works for me ;-)
There still some issue in Companion rpi fireware, because I cannot boot with 3 usb devices. I need to boot first 2 gamepads and after I need to connectect mouse/keyboard single dongle, but after that it works as expected.
diff --git a/src/misterynano.sv b/src/misterynano.sv
index c1cf8b3..ec521e4 100644
--- a/src/misterynano.sv
+++ b/src/misterynano.sv
@@ -320,7 +320,8 @@ mcu_spi mcu (
// joy0 is usually used for the mouse, joy1 for the joystick. The
// joystick can either be driven from the external MCU or via FPGA IO pins
wire [5:0] hid_mouse; // USB/HID mouse with four directions and two buttons
-wire [7:0] hid_joy; // USB/HID joystick with four directions and four buttons
+wire [7:0] hid_joy0; // USB/HID joystick with four directions and four buttons
+wire [7:0] hid_joy1; // USB/HID joystick with four directions and four buttons
// external DB9 joystick port
wire [5:0] db9_atari = { !io[5], !io[0], !io[2], !io[1], !io[4], !io[3] };
@@ -328,15 +329,15 @@ wire [5:0] db9_amiga = { !io[5], !io[0], !io[3], !io[1], !io[4], !io[2] };
// any db9 mouse replaces usb mouse as mice will keep some signals
// permanently active and can thus not just be wired together
-wire [5:0] joy0 = (system_port_mouse == 2'd0)?hid_mouse:
+wire [5:0] joy0 = hid_joy0 | ((system_port_mouse == 2'd0)?hid_mouse:
(system_port_mouse == 2'd1)?db9_atari:
(system_port_mouse == 2'd2)?db9_amiga:
- 6'b000000;
+ 6'b000000);
// Joystick ports are just wired together and can be used in parallel
// DB9 is used for joystick, whenever the mouse is mapped to USB
wire [5:0] db9_joy = (system_port_mouse==2'd0)?db9_atari: 6'b000000;
-wire [4:0] joy1 = hid_joy[4:0] | db9_joy[4:0];
+wire [4:0] joy1 = hid_joy1[4:0] | db9_joy[4:0];
// The keyboard matrix is maintained inside HID
wire [7:0] keyboard[14:0];
@@ -383,8 +384,8 @@ hid hid (
.mouse(hid_mouse),
.keyboard(keyboard),
- .joystick0(hid_joy),
- .joystick1()
+ .joystick0(hid_joy1),
+ .joystick1(hid_joy0)
);
wire sdc_int;
There still some issue in Companion rpi fireware, because I cannot boot with 3 usb devices. I need to boot first 2 gamepads and after I need to connectect mouse/keyboard single dongle, but after that it works as expected.
I do have the same problems. It could be a USB-Power issue. Not enough juice on power on... Had various success with different USB-Hubs. Sometimes it works, sometimes it doesn't...
Here is diff for verilog to support second joystick for ataris st. It works for me ;-)
Works for me too! Just played IK+ with my nephew! Would like to add also a 2nd DB9 port...
That's most likely a firmware issue and using a different/additional hub chip just changes something slightly solving the problem.
IMHO someone has already started to fix the USB part of the firmware but doesn't bother to publish ...
Please find a PR adding second joy support. For USB issues, there is second PR fixing USB initialization.
Cool. And yeah ... that was planned ... and forgotten ☺
Now that the joysticks got some attention, I'd like to add support for the third and fourth joystick. The games Gauntlet 2 and Frogs support that.
The hardware is actually rather simple, and the additional joysticks are just wired to the (here unused) printer port. However, that will need some further configuration.
Also, PR #100 IMHO needs some tweaking, as this now also switched the DB9 ports. This probably is not what you want.
So what exactly do we want to achieve? IMHO this:
-
If a USB mouse is used, then the (first/main) DB9 port maps to the Atari's joystick port
-
If a DB9 mouse is being used, then the DB9 port maps to the Atari's mouse port
-
If a USB joystick and a DB9 joystick are being used, then we want the USB joystick to be able to replace the Mouse to become the second joystick
The issue is that we cannot tell whether a DB9 port is being used. So when a joystick is used in DB9, we basically want to shift the USB joysticks up. The first USB joystick then shows up at the mouse port using the switcher logic. A second USB joystick currently overlays the DB9 joystick which doesn't hurt but also isn't really useful. Instead, I'd like to map it to the printer port as a third joystick to be usable in Gauntlet 2 or Frogs.
We basically have these cases:
- All devices USB: The USB mouse is mapped to the Atari's mouse port, the first (or only) USB joystick to the Atari's joystick port. A second joystick would overlay and be switchable with the mouse and further joysticks would map to the printer port
- A DB9 mouse: This takes over the role of the USB mouse, which is then ignored. The first USB joystick is then mapped to the Atari's joystick port, the second one overlays the mouse and further ones are mapped to the printer port
- A DB9 mouse and a DB9 joystick: USB mice are ignored, DB9 devices map to Atari ports and the first USB joystick may overlay the mouse. Further USB joysticks map to the printer port
- Two DB9 joysticks: A USB mouse maps to the Atari's mouse port. The first DB9 joystick maps to the Atari's joystick port. The second DB9 joystick overlays the USB mouse and USB joysticks map to the printer port
What do you think? Is this what you need? Did I miss something?
And to make things worse: What about the Atari STE joystick ports?
I'd suggest having two menu items replacing the two current ones:
- "Legacy Mouse type" switchable only between "Atari ST" and "Amiga"
- "Legacy devices", switchable between "None", "Mouse only", "Mouse & Joystick" and "Joysticks only"
Other ideas?
The situation on the ST is a little confusing, with different mouse types and mouse/joystick switching... a bit like a "gordian knot" :- ) What i would like to mention is, that a "Joy Swap" function for the DB9 ports is required, for folks who have only one DB9 port wired to their Tang...
Why would you want to swap the DB9 ports, then? If you only have one DB9 port, then it can be used for mouse or joystick. If you use it for mouse, then it's mapped to the Atari's mouse port, otherwise it's mapped to the Atari's joystick port. When would you want to swap them?
What never happens in Atari ST world is that you only use one joystick in the mouse port. In Atari ST world, a single joystick is always expected to be connected to the joystick port. And only if you connect a second joystick will that replace the mouse in the mouse port.
Edit: The mouse type issue actually never existed in the real world as Atari's were always delivered with Atari mice and an Amiga mouse was barely used with an Atari ST and would have to be rewired. But in the FPGA case, a user may actually want to use an Amiga mouse with the Atari ST core and vice versa.
Why would you want to swap the DB9 ports, then? >
I guess you are right! So then it is a "auto swap" function, which is nice! 👍🏻
You still need to configure that you want to use a DB9 mouse, as that cannot be auto-detected. But then it's obvious which port this is going to use.
My proposal for this. I'm trying to be as simple as possible:
- Mouse: OSD options as exist to select between USB/Atari st/Amiga with auto switch on/off mouse to allow joystick on the same port
- Joystick: I assume based on the comment that we may have 4 joysticks for some games based on previous comment. Then in OSD we are adding Port1, Port2, Port3, Port4 and for every options we have choices: Joy1, Joy2, Usb1, Usb2, Usb3, Usb4 (why not to have 4 USB gamepads ;-)). Then it's user decision how they want to map port to devices. After configuration we can add autosave if storage (SD) card presented. We can also consider in main manu add Save & Exit and Exit to be sure that user explicitlty want to save configuration.
Such approach will allow any possible combinations. User can configure same device for same port, but it's configuration issue and I don't think that a huge problem.
As an improvement we can move device mapping from system OSD to dedicated "Device configuration" menu item.
For me implementation for above it's not so complex, except I don't know how to wire port3 and port4 to KBD controler.
What's your thoughts?
I fully agree that this should be as simple as possible. But I don't see how your approach is simple from a users perspective 😬
My suggestion was actually to have one single menu entry for the joystick setup where you just select how many classic DB9 devices are connected. All the rest would happen automatically. And another entry would allow one to switch between the two classic mouse types.
In that case, mouse type is clear and always connected to same port with our switch on/off. For DB9 joysticks we can always swap cables (two port connected to two joysticks). It's more for USB joys. In that case there should be only one option in OSD for USB joys where you can select where to wire first USB port.
This new options has configuration (numbering of ports start from 0 - as on my Atari ST):
- Port0 selected: in that case we use only USB joys for all ports (my use case for Bubble Bobble ;-) port0 and port1)
- Port1 selected: port0 DB9 joy (or used by mouse) and port2+ used by USB joys
- Port2 selected: 2x DB9 used (2x joys or joy+mouse) + USB joys port2+
- Port3: this option is not need in OSD, because I don't see use case to use only port3
To sum up, there are two OSD options:
- Mouse type (existing one): USB, Atari ST, Amiga
- USB devices first port: Port0, Port1, Port2
Two DB9 are wired always to port0 (old DB9) and port1 (recently added).
How it looks from user perspective?
Not to mention that Atari STE has also two extra Paddle/Analog ports and they are DE-15, or... this https://www.computinghistory.org.uk/det/6748/Gravis%20MouseStick/