bitcores wrote: Sun Jun 09, 2024 2:25 amUntil the USB host is ready or sends the first packets, what default state should the Pico send to the NES if the NES strobes for a read? Should it just send the 110 device identification? Should it say that there is a keyboard and mouse present and that it is in relative or absolute mode, even though it hasn't received that information from the USB host yet?
What should be the default initial state and what behavior should software written for this spec expect?
1. Absolute vs. relative as a default:
The communication is only one way, so the absolute vs. relative bit just allows the hardware to be one or the other, or it could have its own mode switch I guess. If the hardware you build can do both, choosing a default is probably situational.
My intent with the inclusion of an absolute mode was to make it easy to integrate mouse support that works seamlessly to move between the emulator and surrounding tools. So, in an emulated window, absolute is likely the best default, but in other situations relative is probably better.
I would expect the NES software to just check the bit after polling, and deal with both cases. If software requires one or the other, it could say so. In general, software should be able to deal with that bit changing on a per-frame basis.
In a hardware implementation, I guess if you have an absolute option, it might start up by default at 128,120 to begin in the middle of the screen? For the software, there's no guaranteed startup position for absolute anyway, since in the emulator case it would just be wherever your mouse already is.
2. Use of mouse/keyboard present bits:
The other issue, I guess you're saying it might not know if a keyboard or mouse are present right after powering on? I think it should
always give the device ID whenever polled, if that's possible. Ideally software should know this host device is connected without having to delay after booting. Normally it's not a very good idea to hotswap controllers on an NES anyway, and I think this is still true for this host device, regardless of whether its USB keyboard/mouse are hot pluggable.
Otherwise, it seems fine if the mouse/keyboard present bits can change at runtime to indicate connect/disconnects. Software should generally be able to respond to this, The bit is just indicates whether either is worth polling/responding to, and that's easily something that can be decided on a per-frame basis. It could also be used to relay the device connection information to the user.
Alternatively, if it's easier to implement, there's not really anything wrong with the host always sending 1s for mouse/keyboard present regardless.
So, I think best practice for software is just that if it sees the 110 device signature at boot, it should expect that host device will be connected for the lifetime of the program, and be ready to poll and respond to either a mouse and keyboard, on any frame they report as present.
If desired, the software could do stuff like hide the mouse cursor if indicated as not present, or have an on-screen indicator for the keyboard, but that'd be up to the program.
If you think the device should be permanently attached, with most games just using the controller as pass-through, it might be nice to have an on/off switch that could disable the device signature.