Apologies for the absence! I'm aware there's that feature request for Analog support but life's kept me pulled away from the project for a bit. Still, lovely to hear all the kind words being sent!
Very interesting project!
How did you managed the communication between the HID emulating Pico and Mamehooker? Thrugh serial? All my tentatives gave negative results...
It's (on the surface) pretty simple; opening up a serial line (which in Arduinoland, it's
Serial.begin(baudrate); ), which all the Arduino USB stacks allow and the project that this was based on already had open for debug messages.
Every iteration of the main gunmode loop basically checks if we have anything in the serial buffer - and when it does, it chews through what's received from the computer character-by-character until that buffer's empty, and returns to the main loop. It's basically a big decision tree based on the code type and the number. The only real complication was parsing what those codes tells the gun to do, and we put that into a separate queue of commands for the peripherals that tells each piece if they should be on, off, or pulsing (which pulsing is technically computed autonomously by the gun, whereas the simple on/off/led static set bits we just take at face value).
You can read more about
how Mamehook works here, and you can see how we handle the codes sent in
this code snippet, under the "SerialProcessing" and "SerialHandling" methods. (Get it? Processing and handling? I've watched too many tv ads as a kid (^^;)
The only thing to watch for, unfortunately (especially where the Pico is concerned) is that our TinyUSB stack has a bit of a bug where it will deadlock when the serial line is active while sending HID commands (like abs mouse move/button press). The instruction manual bundled with the project links to a patched core I'm hosting that's made to work around this problem as best as it can--and in fairness I haven't had issues with it myself since doing so, but there is that stability concern until I hear back from upstream.
Question, does it matter which Pico I get? I'm seeing models online with bigger flash sizes. Is 2MB all I'd need for solenoid support and all that jazz?
Oh, literally any RP2040 board works - even the base Pico is more than plenty code space and memory to fit. The only boards that this project outsizes are the Atmega32u4-based boards, as even the largest can only fit 32kb - but beyond that, the last time I counted the final binary with all the niceties and features enabled is only around 84kb?
On that note, how are you powering the solenoid? I think Gun4IR still needs a separate power supply.
Separate PSU is the reference, indeed! But like @RandyT mentioned, that's the unfortunate reality of dealing with solenoids which can vary in all sorts of power requirements - all of which are much larger than the meager 5V/250mA that USB affords us. The Sinden tried to work around this with basically a super capacitor that, as far as I can tell, gets idly juiced up from the USB port to power the armature; but once you go past a couple quick actuations, that power reserve gets quickly dried up. A separate power line, though probably ugly looking, is the simplest way to power these guys without issues.
But the rumble motor can work straight off the USB power, so long as you connect to the 5V power from the USB port (which afaik basically every board has this unregulated/hipower line available in some form? Even the Pico does). Also these obviously assume both these ff peripherals are being run through the G4IR relays to properly distribute these pulses.
Hands up for this amazing project.
Open source is always better, and acknowledging other people's works is a well-mannered move.
Thank you for your work and your time.
Thank you! I was really adamant on having an open solution with as many of these features as I could fit, given how passionate I already was for Samco - while ensuring Linux remains compatible without any need for an OS-specific flasher. To be honest, I'd expected someone else to have done this beforehand!
If nothing else, I'd like this to at least set some kind of an example for how other people can incorporate these features into their own open gun projects. The cynical part of me wonders if that's a good thing. (^^;
On a related note, speaking of Linux support, I've been looking into how to get outputs working for native Linux versions of the common emulators like MAME, Flycast, or RetroArch. I did come across another project
whose creator seemed at least interested in providing an outputs mode for Serial-enabled guns (like this one, GUN4IR, and/or potential Sinden, if/when that becomes a thing). In the meantime, if anyone has suggestions on this, I'd be stoked to hear!