Main Restorations Software Audio/Jukebox/MP3 Everything Else Buy/Sell/Trade
Project Announcements Monitor/Video GroovyMAME Merit/JVL Touchscreen Meet Up Retail Vendors
Driving & Racing Woodworking Software Support Forums Consoles Project Arcade Reviews
Automated Projects Artwork Frontend Support Forums Pinball Forum Discussion Old Boards
Raspberry Pi & Dev Board controls.dat Linux Miscellaneous Arcade Wiki Discussion Old Archives
Lightguns Arcade1Up Try the site in https mode Site News

Unread posts | New Replies | Recent posts | Rules | Chatroom | Wiki | File Repository | RSS | Submit news

  

Author Topic: IR-GUN4ALL - Enhanced Arduino-powered DIY 4-Point IR Lightgun System  (Read 4200 times)

0 Members and 1 Guest are viewing this topic.

ThatOneSeong

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 57
  • Last login:Yesterday at 06:49:41 pm
  • Just your average Seong.
    • Twitter
And the reward for the longest mouthful of a topic title goes to...
The IR-GUN4ALL Project
The Open-source lightgun system with All the features
I've already mentioned this a few times in the SAMCO thread, as this is a fork of the already-enhanced fork by Prow7. But I felt it was special and distanced enough from the original to deserve its own thread.
So, let's cut to the gist of this then, shall we?
  • Full force-feedback support! From solenoids with single-shot/3-shot burst/rapid fire modes and TMP36 temperature monitoring support, to rumble motors with variable strength for off-screen feedback (with optional alternative rumble-based force feedback soon).
  • Full customization at runtime, from the board's USB identifier, to settings like rumble/solenoid intensity, to even the board's mapping of what pins are attached to what buttons/devices, is all saved to the board's flash and loaded at boot--just flash once per-update, and enjoy unlimited possibilities!
  • Optimizations for low-button gun cases! Features like pressing buttons offscreen to perform different functions, and an optional scrolling simple pause menu, makes even two or one-aux-button guns versatile! Virtua Gun and vanilla GunCon 1 owners, rejoice!
  • Supports for both hardware toggles with physical switches (if any), and additional software toggles for each added feature in the gun's integrated Pause Mode (Button C + Select by default).
  • Uses a four-point, top & bottom, double-IR lightbar arrangement (the very same added by Samco then tweaked by Prow7) for very accurate line-of-sight aiming from most angles and extremely quick tracking (theoretically <4-8ms click-to-click, ~5ms camera updates).
  • Fully cross-platform solution, no reliance on a proprietary Windows-only GUI or any dev environment for initial setup; just use the GUN4ALL-GUI for your platform of choice!
  • On-board three-click calibration, up to four selectable profiles, and configurations saved dynamically to the board; literally save once per-display and never have to recalibrate, even after reflashing!
  • Streamlined setup by removing dependence on dev IDEs! Drop the UF2 file onto your microcontroller, and you're using GUN4ALL! The GUI app takes care of all your custom mapping, naming, setting, and testing needs from there!
  • Fixed a number of legacy quirks and bugs. EEPROM saving on RP2040? Fixed. Keyboard buttons sticking? Doneso.
  • Primarily aimed at and optimized for the RP2040 (a.k.a. the Raspberry Pi Pico), with an optional dual core processing mode for (theoretically) faster input handling, while still maintaining compatibility with Cortex M0's and M4-based microcontrollers. (Only requirements are Arduino compatibility and TinyUSB support!)
  • MAMEHOOKER support! Serial communications can signal the gun to hand off control of its peripherals seamlessly for event-aware feedback (if available).
You can see an early version of the system demonstrated here, though keep in mind that it's somewhat old and doesn't represent all of the various features of the system as it is now.
I'll be updating the demonstration soon!

It is fully compatible with pre-existing SAMCO builds, assuming you make use of the custom pins feature in v4.0 onwards!
I may or may not have spent an unreasonable amount of time working on this as my first big coding project for the past few weeks, but I do genuinely hope that it brings some people enjoyment.
If nothing else, it's at least the most fully featured open-source lightgun system available

« Last Edit: March 02, 2024, 11:38:03 pm by ThatOneSeong »

ZTylerDurden717

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 188
  • Last login:January 07, 2024, 12:52:28 pm
  • I want to build my own arcade controls!
Re: IR-GUN4ALL - Enhanced Arduino-powered DIY 4-Point IR Lightgun System
« Reply #1 on: November 13, 2023, 10:32:42 am »
Which forms of payment do you accept for a $35 license to use GUN4ALL?

ThatOneSeong

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 57
  • Last login:Yesterday at 06:49:41 pm
  • Just your average Seong.
    • Twitter
Re: IR-GUN4ALL - Enhanced Arduino-powered DIY 4-Point IR Lightgun System
« Reply #2 on: November 13, 2023, 02:49:15 pm »
Which forms of payment do you accept for a $35 license to use GUN4ALL?
Uh. . .

>.>
<.<
None?

Honestly, Prow7 probably deserves more credit for making the basis of this hackfest to begin with - and by extension Samco's work, so I'd rather they get appreciation too! I just decided to work on top of their stuff and integrate the things I personally wanted.

Though if you'd still like to donate, which is also linked in the repo readme, I have a Ko-fi. I'm more of a YouTube video creator and editor by trade, which is what it's mainly for, but I don't mind if people somehow think my hobbyist crap is worth something!

ThatOneSeong

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 57
  • Last login:Yesterday at 06:49:41 pm
  • Just your average Seong.
    • Twitter
Re: IR-GUN4ALL - Enhanced Arduino-powered DIY 4-Point IR Lightgun System
« Reply #3 on: November 15, 2023, 05:04:18 pm »
Hey-hey-hey! Sort of an update here regarding some things coming soon!


Firstly, I've slammed my head against a wall slowly, carefully chipped away at the MAMEHOOKER support to at least mitigate the board crashing in serial handoff mode--if not (hopefully) fix it entirely. And I think I've finally figured what may have been causing crashes.
Now, I can't just play Haunted Museum fifty times over to check this and make sure (trust me, I'm way more familiar with that game now than I'd ever cared to be before this), as I've other obligations to deal with and this project is simply a hobby. I just know that I've been able to play half of Virtua Cop and a whole playthrough of HM1 without the board hanging in one sitting.
But if there is anyone still on the fence, or just want to help, I would be incredibly grateful if people check out the latest code from the GitHub repo directly and test it out to make sure that it does, in fact, work!
Of course, since MAMEHOOKER is still technically experimental, you'll have to uncomment (remove //)
Code: [Select]
  // Uncomment this to enable (currently experimental) MAMEHOOKER support, or leave commented out to disable references to serial reading and only use it for debugging.
  // WARNING: Has a chance to CRASH on prolonged play sessions (at least on RP2040) - only enable for now if debugging!
//#define MAMEHOOKER
(and actually have a Solenoid or rumble motor installed in your gun build, with the pins defined adjusted as needed).
Adjacent to the topic of serial stuff, I also finished the RGB LED code - though this only affects a board's builtin LED atm (as is on the Adafruit boards I use as reference), when serial handoff mode is activated, the LED will now react to fixed values (set by .1.y, y = value) and pulse values (set by .2.y, y = amount of pulses requested). I'm not sure if LED pulses are supposed to be additive--I.E. do we pulse the singular RGB bulb with all the values combined?--or individual colors only, so pulses will use the latter for now (it was just easier to do it that way, but if that's technically not correct, I can change it to additive at a later point). So we pretty much functionally support all the needed and commonly used commands that mamehook configs should as GUN4IR.


Aside from work on that, I've also made it much easier to redefine the USB ID for each gun, and to change the keyboard button maps for individual players - the first being a set of defines that should be plainly obvious if you look at the beginning of the sketch's configuration area:
Code: [Select]
  // Here we define the Manufacturer Name/Device Name/PID:VID of the gun as will be displayed by the operating system.
  // For multiplayer, different guns need different IDs!
  // If confused or if only using one gun, just leave these at their defaults!
#define MANUFACTURER_NAME "3DP"
#define DEVICE_NAME "GUN4ALL-Con"
#define DEVICE_VID 0x0920
#define DEVICE_PID 0x1998

and the latter is set with:
Code: [Select]
  // Set what player this board is mapped to (1-4). This will change keyboard mappings appropriate for the respective player.
  // If unsure, just leave this at 1.
#define PLAYER_NUMBER 1
I realize I neglected to mention in the OP, but multiplayer does in fact work with this system - just change the above bits accordingly now!
These are not in a currently tagged release yet, but as soon as I can confirm that Mamehook is stable enough to remove the experimental tag on, you can bet there will be a more formal release soon!

I've also been asked in private about changing the LED layout (to use GUN4IR's). While that would be really neat to have and certainly make it easier to be used in place of/alongside it (though still not be a drop-in replacement necessarily, noting the different board requirement), the camera bits are by no means my field of expertise, so don't expect the rectangular arrangement to change anytime soon. But, because open source, anyone could theoretically send a pull request if they figure that out and I'd happily accept that (assuming it works and doesn't make tracking any worse, anyways, lol)!

ThatOneSeong

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 57
  • Last login:Yesterday at 06:49:41 pm
  • Just your average Seong.
    • Twitter
Re: IR-GUN4ALL - Enhanced Arduino-powered DIY 4-Point IR Lightgun System
« Reply #4 on: November 23, 2023, 12:12:44 pm »
Merry Thanksmas!
assuming you celebrate this American holiday, anyways.

In the spirit of the season (or the one coming soon thereafter), I've stamped another update (v2.1) for your perusal!
This version, among other things like more easily set player slots through a single value and the finishing of LED pulsing in serial handoff mode, has found the root cause of the MAMEHOOKER crashes to be a bug in the TinyUSB stack we use! As far as I can tell, this is a bug unique to the RP2040 with TinyUSB specifically. So in the meantime, I'm providing a patched version of the Raspberry Pi Pico/RP2040 core until this has been resolved upstream*. Details are in the release notes and the enclosed instruction book, as always.

*it's possible that it still might lock up, but in my testing at least it's been significantly reduced, as far as I can tell anyways. But please report back if you do still run into issues!

judokan

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 7
  • Last login:January 06, 2024, 01:50:06 pm
  • I want to build my own arcade controls!
Re: IR-GUN4ALL - Enhanced Arduino-powered DIY 4-Point IR Lightgun System
« Reply #5 on: November 27, 2023, 02:42:45 pm »
Do you know the project https://gp2040-ce.info/#/ the configuration is done through the website by inserting it into the computer with a button pressed
« Last Edit: November 27, 2023, 03:26:17 pm by judokan »

ThatOneSeong

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 57
  • Last login:Yesterday at 06:49:41 pm
  • Just your average Seong.
    • Twitter
Re: IR-GUN4ALL - Enhanced Arduino-powered DIY 4-Point IR Lightgun System
« Reply #6 on: November 27, 2023, 07:20:01 pm »
Do you know the project https://gp2040-ce.info/#/ the configuration is done through the website by inserting it into the computer with a button pressed
I have heard of GP2040, and that would be a very cool feature to have! Presumably, it would necessitate shifting the preprocessor defines into values resident in memory and expanding a bit on what the profiles save, but I think it could be done - therefore reducing the need to use the Arduino IDE for configuration at all.

Unfortunately, that would have to wait until the kinks with the current featureset is smoothed over (I'm still getting the odd crash report which takes priority, and I'm still waiting on responses from the Adafruit issues). Beyond that, networking isn't really something I've ever messed with, so I'm looking for examples - and the only ones that continues to come up in searches are either using actual Ethernet/Wifi (which the reference boards don't have) or are relying on a Chromium-exclusive API like Serial or WebUSB, which... as a Firefox user, I really don't like the idea of having to use a Chrome-based browser just to configure my board.

kim_sama_999

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 15
  • Last login:Today at 05:04:15 am
  • SHOTA NATION
    • YouTube
Re: IR-GUN4ALL - Enhanced Arduino-powered DIY 4-Point IR Lightgun System
« Reply #7 on: November 29, 2023, 12:35:15 am »
Interesting. Do you use Pro Micro?
YouTube: @KimSamaVideos

judokan

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 7
  • Last login:January 06, 2024, 01:50:06 pm
  • I want to build my own arcade controls!
Re: IR-GUN4ALL - Enhanced Arduino-powered DIY 4-Point IR Lightgun System
« Reply #8 on: November 30, 2023, 07:59:01 am »
Hello friend, I don't know why, but I can't get it to work, I use pins 2 SDA and 3 SCL on the Raspberry pi pico and on the Waveshare Zero RP2040, I put 2 Wii bars as explained on a small 22" screen and the The mouse pointer does not move like it does on the gun4ir, the camera has been tested on the gun4ir and works perfectly, could analog controls be added to take advantage of the ones found on Cabela's Top Shot Elite? Cheers.

ThatOneSeong

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 57
  • Last login:Yesterday at 06:49:41 pm
  • Just your average Seong.
    • Twitter
Re: IR-GUN4ALL - Enhanced Arduino-powered DIY 4-Point IR Lightgun System
« Reply #9 on: November 30, 2023, 01:00:41 pm »
Interesting. Do you use Pro Micro?
Technically speaking, Atmega32u4-based boards (like Pro Micro and its clones, Teensy, etc.) are compatible - as in, they will build fine. However, with all the functions added for peripheral support, the final compiled lump exceeds the flash storage space of any Atmega-based board out there.
This is actually part of why the code uses a frankly disgusting amount of precompiler defines, in my attempt to shrink the additional footprint as much as possible.
At one point, I had it built for a Pro Micro with literally every extra feature disabled (which makes the sketch basically amount to Samco/Prow's fork with a button bug fix), and the size was within 50 bytes of the storage limit.

In theory, one could shrink down external library use and stuff to cram it in to fit on those boards; and as much as it would be neat to be a drop-in replacement for other systems, it just wasn't feasible - especially now with mamehook support, there's no way it'd fit now. :D
As a consolation prize, Picos are the current development target - and they can be bought for just as cheap, if not cheaper than Pro Micro clones. Even the SAMD21-based boards (using a Cortex-M0 non-plus) have more than enough space, but the RP2040 just gives so much more room for activity.
Hello friend, I don't know why, but I can't get it to work, I use pins 2 SDA and 3 SCL on the Raspberry pi pico and on the Waveshare Zero RP2040, I put 2 Wii bars as explained on a small 22" screen and the The mouse pointer does not move like it does on the gun4ir, the camera has been tested on the gun4ir and works perfectly, could analog controls be added to take advantage of the ones found on Cabela's Top Shot Elite? Cheers.
Oh no, I'm so sorry to hear that!
I unfortunately don't have a vanilla Pico on me, but I think I know exactly why this is happening - a small goof on my behalf, where the sketch only initializes the I2C lines on the ItsyBitsy board specifically, but not RP2040 boards in general (so nothing gets init'd on the vanilla Pico). Big oof on my behalf, and I'll have it fixed fixed it, should be pushed to the repo now along with a hotfix'd release. If you still can't get the camera booting, toss up an issue on the GitHub repo; I'd be able to track it there and better discuss any further resolutions.
As for the analog stick, it would be possible, but--are you looking to replicate analog functionality, or just read it digitally? I would recommend, again, to make a feature request issue on the repo for easier tracking. I don't have an analog stick I can test myself so I hadn't been able to implement it, but it should be doable.
« Last Edit: November 30, 2023, 01:23:01 pm by ThatOneSeong »

judokan

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 7
  • Last login:January 06, 2024, 01:50:06 pm
  • I want to build my own arcade controls!
Re: IR-GUN4ALL - Enhanced Arduino-powered DIY 4-Point IR Lightgun System
« Reply #10 on: November 30, 2023, 01:42:39 pm »
Now it works perfectly, thank you very much, now I will continue testing things, this is a great project with more memory, more processor and a world of functions that can be added like the analog ones  :lol

ThatOneSeong

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 57
  • Last login:Yesterday at 06:49:41 pm
  • Just your average Seong.
    • Twitter
Re: IR-GUN4ALL - Enhanced Arduino-powered DIY 4-Point IR Lightgun System
« Reply #11 on: November 30, 2023, 03:41:19 pm »
Now it works perfectly, thank you very much, now I will continue testing things, this is a great project with more memory, more processor and a world of functions that can be added like the analog ones  :lol
Nice, glad to hear it!
btw, how's the Top Shot for modding? I had considered getting one for a custom mod myself after wrapping up my CyberGun, but I ended up getting a Big Buck Hunter plug'n'play gun instead. The only problem with it, really, is  how the pump action has its screws hidden beneath plastic caps that, far as I can tell, are part of the top mold and can't be removed - so I have to drill into it just to disassemble. It's a royal PITA.

ebvetle

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 5
  • Last login:December 17, 2023, 06:35:35 am
  • I want to build my own arcade controls!
Re: IR-GUN4ALL - Enhanced Arduino-powered DIY 4-Point IR Lightgun System
« Reply #12 on: December 09, 2023, 08:24:11 am »
Hands up for this amazing project. :cheers:
Open source is always better, and acknowledging other people's works is a well-mannered move.
Thank you for your work and your time.
 :applaud:

z0mgitsjared

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 1
  • Last login:January 31, 2024, 11:22:46 am
  • I want to build my own arcade controls!
Re: IR-GUN4ALL - Enhanced Arduino-powered DIY 4-Point IR Lightgun System
« Reply #13 on: December 12, 2023, 04:39:45 pm »
I'm heading down the rabbit hole of Gun4IR vs Lichtknarre, and now this project appeared!  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?

On that note, how are you powering the solenoid? I think Gun4IR still needs a separate power supply.

RandyT

  • Trade Count: (+14)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 6879
  • Last login:Yesterday at 01:56:55 am
  • Friends don't let friends hack keyboards.
    • GroovyGameGear.com
Re: IR-GUN4ALL - Enhanced Arduino-powered DIY 4-Point IR Lightgun System
« Reply #14 on: December 13, 2023, 01:14:17 pm »
I'm heading down the rabbit hole of Gun4IR vs Lichtknarre, and now this project appeared!

Good problem to have when it comes to lightguns :)

Power requirements for solenoids will be dependent on the size of the solenoid.  There's no way around that part of the equation. If you just want a small click for a little while, a big capacitor and a small solenoid on USB power might get you through.  But if you want to slam a heavy receiver action back and forth until the plastic around it melts from the heat, or anything which might approach an actual recoil, you'll need external power :) 

baritonomarchetto

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 805
  • Last login:Today at 03:15:56 am
Re: IR-GUN4ALL - Enhanced Arduino-powered DIY 4-Point IR Lightgun System
« Reply #15 on: December 14, 2023, 01:15:50 am »
Very interesting project!
How did you managed the communication between the HID emulating Pico and Mamehooker? Thrugh serial? All my tentatives gave negative results...

ThatOneSeong

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 57
  • Last login:Yesterday at 06:49:41 pm
  • Just your average Seong.
    • Twitter
Re: IR-GUN4ALL - Enhanced Arduino-powered DIY 4-Point IR Lightgun System
« Reply #16 on: December 14, 2023, 04:43:27 pm »
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?

Quote
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. :cheers:
Open source is always better, and acknowledging other people's works is a well-mannered move.
Thank you for your work and your time.
 :applaud:
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!
« Last Edit: December 14, 2023, 04:52:41 pm by ThatOneSeong »

baritonomarchetto

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 805
  • Last login:Today at 03:15:56 am
Re: IR-GUN4ALL - Enhanced Arduino-powered DIY 4-Point IR Lightgun System
« Reply #17 on: December 17, 2023, 02:17:50 am »
Quote
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.
Ok, so the IRGun is not emulating a HID controller through USB, which leaves out the built-in FTDI chip for USB through serial communication, right?
I am asking you because I had to use two arduino's in my arcade projects, one for HID emulation (32u4 microprocessor) and another for serial communication with Mamehooker (nano). I was in the hope you found a solution to use a single microcontroller board without the need for a cumbersome additional FTDI circuitry

ThatOneSeong

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 57
  • Last login:Yesterday at 06:49:41 pm
  • Just your average Seong.
    • Twitter
Re: IR-GUN4ALL - Enhanced Arduino-powered DIY 4-Point IR Lightgun System
« Reply #18 on: December 17, 2023, 12:33:12 pm »
Ok, so the IRGun is not emulating a HID controller through USB, which leaves out the built-in FTDI chip for USB through serial communication, right?
No, it is emulating HID--that's how the kb+m outputs work. I'm not exactly sure what your project is doing so I obviously can't speak for that - but here, both pieces are mostly handled through the USB stack and some libraries.
And though GUN4IR is closed source, it's almost certainly doing effectively the same thing to provide Mamehook support parallel to gun control there too - also using/primarily targeting 32u4 boards.

Though I won't lie when I admit that my knowledge on the nitty-gritty details of the microcontroller and how it juggles between them isn't quite there yet. (^^;

baritonomarchetto

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 805
  • Last login:Today at 03:15:56 am
Re: IR-GUN4ALL - Enhanced Arduino-powered DIY 4-Point IR Lightgun System
« Reply #19 on: December 18, 2023, 01:12:48 am »
I made some further testing and, yes, HID emulation and serial communication can actually cohexist in the sketch. Nice find... :)
« Last Edit: December 19, 2023, 07:40:39 am by baritonomarchetto »

ThatOneSeong

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 57
  • Last login:Yesterday at 06:49:41 pm
  • Just your average Seong.
    • Twitter
Re: IR-GUN4ALL - Enhanced Arduino-powered DIY 4-Point IR Lightgun System
« Reply #20 on: December 28, 2023, 12:04:52 pm »
Hey all! Seong here. Happy holidays for those who celebrate, or happy belated Monday to those that didn't.

I'll be getting my hands on another camera and a few more Pico boards soon, so I'll be able to start on implementing some of the features I promised earlier; like the support for analog sticks, but I'll also be working on outputting as a gamepad for the likes of PCSX2 or some Steam games that treat a stick as another absolute pointing device, more serial codes for configuring the gun in lieu of pause mode (for guns with too few buttons or for future use), and adding on the ability for buttons to serve different functions when on/off screen (distinct from the off-screen reload button, which is already there).

That being said, I did open up a discussion post on the repo recently about future plans after these features are added. At some point in 2024, I'd like to try pivoting away from purely in-sketch configuration and the hard-coded defines that are in use currently to dynamically changing the user adjustable aspects like button and pins mapping (and the other options) to make a graphical user interface more feasible. Part of this would necessitate moving as much as is possible to EEPROM/Flash and refactoring the save functionality a bit to accommodate for this, but also for making a simpler flashing/configuration utility--preferably with cross-platform support for Windows & Linux at minimum.
At the very least, I know much of the setup can be automated using the Arduino CLI (and/or the ability to push and communicate with the board through serial), though it could also be nice to be able to distribute raw binaries that can be simply drag'n'dropped onto a board. I'm still not quite sure on what the ideal would be for this going forward, in an effort to reduce friction as much as possible for the end user--and also not being a UI designer nor having ever written a desktop app myself. (^^;

If anyone has input to offer about this, please do share! But in the meantime, expect some updates in the coming weeks.

ThatOneSeong

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 57
  • Last login:Yesterday at 06:49:41 pm
  • Just your average Seong.
    • Twitter
Re: IR-GUN4ALL - Enhanced Arduino-powered DIY 4-Point IR Lightgun System
« Reply #21 on: January 04, 2024, 06:41:17 pm »
Happy New Year, everyone!  :cheers:

Apparently 'coming weeks' came early, as I've spent the better part of a day pushing in support for Gamepad output, extra debugging/control commands, on-the-fly control mapping (so you can now send a signal and the Start/Select buttons will reflect the player slot!) and real off-screen button support for low-button gun shells to the repo (and also fixes for Picos so they should 'just werk' - camera goes to GP4&5/physical pins 6&7, I need to add this to the manual).
As far as I know, this is probably the only open-source gun system with full support for multiplayer on PCSX2 nightly and others? But it's something I was excited to include and I hope everyone can try it out and see how it goes. There is no formal update released yet, but it should be working fine--if anyone wants to test these out and provide feedback, please do!

Anyways, I'll be getting my hands on a Top Shot soon so I can provide analog stick input support of some kind - it'll likely either be duplicated to the keyboard arrows, or the gamepad's POV hat/d-pad. Other than that, I'll be pulling in some form of external RGB support--once these are all done and the baseline features are in a good state, I can start working on the save system to hopefully make things more portable and/or easier in the future!

ThatOneSeong

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 57
  • Last login:Yesterday at 06:49:41 pm
  • Just your average Seong.
    • Twitter
Re: IR-GUN4ALL - Enhanced Arduino-powered DIY 4-Point IR Lightgun System
« Reply #22 on: January 13, 2024, 01:41:40 pm »
Happy Saturday!


I've finally implemented the things I'd said I would for a bit now--analog stick and full-fledged RGB support is now in! It required me faffing about with the HID device descriptor, which... never again, it's a royal PITA. But it will now expose both left and right analog sticks and a full lot of 15 buttons to use.
Shortly after, I got a helpful tip to add the ability to switch what stick the gun camera reports as when in analog output mode, so I've just finished that too! Sending `XAL` or `XAR` over serial to the device will set the camera to either be the left or right stick of the gamepad device, and the one leftover is reserved for the gun's physical analog stick.
As for RGB, it supports both types of fourpin units: common Anode (+/5V) and common Cathode (-/GND), and the code will invert RGB commands as appropriate. I've also exposed the option to have an external NeoPixel as an addressable LED--either a single unit or a user-definable strip of them if you happen to have them/daisy chain units together.

You can help test all this out by downloading the source directly, as I need some people to help confirm that the analog stick is in fact working as it should! Once I've confirmed it's all working, it'll go up as a proper release - which I hope to be the very first binary releases, meaning anyone with the Pico or a matching board can just download the UF2, stick it on the microcontroller and get going with predefined pins--no dev tools necessary! I'll still have a backdoor method for advanced users to load and save their own custom pin definitions (and as always, the source remains available for those who want fully custom deployments). :)
« Last Edit: January 13, 2024, 06:48:15 pm by ThatOneSeong »

ThatOneSeong

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 57
  • Last login:Yesterday at 06:49:41 pm
  • Just your average Seong.
    • Twitter
Re: IR-GUN4ALL - Enhanced Arduino-powered DIY 4-Point IR Lightgun System
« Reply #23 on: February 07, 2024, 02:52:54 am »
Sorry for the terseness of this update, as it's hella late for me now, but save support is being expanded on a separate branch.

Once this is done (and when I actually get around to updating documentation and making some Pico-appropriate pinout diagrams), I can confidently lean on the binary releases full time - since this means you won't need the full IDE or any development environment to configure the gun's features after flashing the firmware. It's a much bigger release than I'd anticipated, but since I have the time to work on things now I may as well go the full distance, right?

It does look a bit ugly if you look at it close enough, but it's worked well so far in my testing tonight!

ThatOneSeong

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 57
  • Last login:Yesterday at 06:49:41 pm
  • Just your average Seong.
    • Twitter
Re: IR-GUN4ALL - Enhanced Arduino-powered DIY 4-Point IR Lightgun System
« Reply #24 on: February 09, 2024, 01:39:34 pm »
v3.0 is finally here.
The release notes are far too long to get into, so click the link to see it for yourself. But the cliffnotes are:
  • First binary releases, so you can just plop the firmware on a board and flash it without any dev environment or compilation needed.
  • Full save support, making pins configuration and other settings fully customizable on the board without a reflash (except for the minutia of button mapping, but it should be good for most situations anyways).
  • Offscreen buttons functionality and general improvements for lower button gun setups, i.e. vanilla GunCon 1's or Saturn Stunners.
  • Analog output (gun coords as joystick) and physical analog sticks supported.
  • External RGB LEDs support, both 4-pin devices with common cathode/anode or NeoPixels.
  • Pico is the default for realsies, documentation has been updated to reflect it (ItsyBitsy is still largely the same as before).
  • Plumbing in places and other misc fixes.
Aside from whatever fixes that might be needed as people report them, I'm pretty happy with how things have come out!
Since we provide binaries for simple installation now, I'll be looking into smoothing over the actual configuration process via GUI - though the information is already there in the wiki for those who have access to a serial terminal.

I guess I should probably work on an update demo video soon too, aha.

ThatOneSeong

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 57
  • Last login:Yesterday at 06:49:41 pm
  • Just your average Seong.
    • Twitter
Re: IR-GUN4ALL - Enhanced Arduino-powered DIY 4-Point IR Lightgun System
« Reply #25 on: February 26, 2024, 12:46:38 am »
v4.0 - The GUI update

Kind of speaks for itself, really, as most of the changes were made to facilitate this companion app that I developed in C++ w/ QT for Windows & Linux.
Some other niceties, like custom pins mapping (which you can now do without a master's degree in serial terminal use) taking effect in real-time, and fixes to the first-run UX, should truly make open source lightguns much more accessible than ever before; as one can simply grab the UF2, flash it onto their Pico/RP2040 board, dock it to the GUI app, set it up, and get to shooting in a matter of one minute -- all without needing admin privileges or a dev environment of any kind.

Might be a small thing to some people, but I'm pretty proud of this tbh. It only took a whole month of learning desktop app development and QT to do it. That said, it should work just as well for Windows 7-and-up and Linux, as I've tested this on both platforms.
The only caveat here is that I've received comments about compatibility with Arduino Nano RP2040 Connect boards specifically, which I haven't been able to figure out why that board specifically isn't handling inputs like the Pico or Adafruit board is. If anyone else with the Arduino RP2040 board could comment about their experiences using this firmware with it, I'd love to hear about it! Those things are costly for a broke ---smurfette--- like me, lol.


Oh, and one more thing! I've been working on a smaller side-project, also in QT, as a Lightgun-focused minified alternative to MAMEHOOKER that uses the MAME network output format - this should allow Linux users to enjoy the force feedback integration for native versions of MAME, Flycast, and their RetroArch ports, using the same configuration files. Since that's more of a general Lightguns thing though (as it should work across both this and GUN4IR) and not specific to this project, I'll be making a separate post about it.
But safe to say, I've been cooking for all of February, and I'm beyond stoked to see it come to fruition like this.

ThatOneSeong

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 57
  • Last login:Yesterday at 06:49:41 pm
  • Just your average Seong.
    • Twitter
Re: IR-GUN4ALL - Enhanced Arduino-powered DIY 4-Point IR Lightgun System
« Reply #26 on: March 02, 2024, 11:24:37 pm »
Enjoy the version bump.

v4.0-rev1 on the firmware side, and v1.1 on the GUI side, brings a reimplementation of the SAMCO Processing sketch into the app. Should be very useful for those who need to test their camera unit's alignment (and should mitigate any need for tertiary programs, aside from the GUI itself)!

The only reason the firmware was updated is to throttle the Test Mode output, because the damn thing updated every cycle possible - and with a Pico, that meant too many updates on the GUI's vector window that it had comically delayed updates; this resolves that. (^^;

I also updated the OP to better reflect the current state of the project (since there's no more need for IDEs at all post-v4.0 and GUI release).
« Last Edit: March 02, 2024, 11:39:02 pm by ThatOneSeong »

ThatOneSeong

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 57
  • Last login:Yesterday at 06:49:41 pm
  • Just your average Seong.
    • Twitter
Re: IR-GUN4ALL - Enhanced Arduino-powered DIY 4-Point IR Lightgun System
« Reply #27 on: March 15, 2024, 06:48:19 pm »
Guess who got their Cabela's modded after all this time?

v4.1 is out to resolve long-standing issues with the initial analog stick implementation: it should work great now, at least for Cabela's Top Shot Elites.


UPDATE: Hotfix was just pushed out for a potential issue with hold-to-pause mode and serial handoff, but I also now have added Adafruit KB2040 board support! Because this version of the board is Pro Micro spec, it should be compatible with GUN4IR adapters or builds (assuming you swap the microcontroller out, anyways). Associated GUI update to accommodate this.
« Last Edit: March 16, 2024, 07:50:14 pm by ThatOneSeong »

Daniel B.

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 241
  • Last login:Yesterday at 05:19:20 pm
  • Lightgun and Point Blank enthusiast
I may have missed it, as I've been out of the forum for a few years. Is there a BOM list for this project?

I've already bought a "license" for gun4IR and just want to figure out whats going to the best and easiest for me.

I have CRT arcade cabs but Would still love line of sight accuracy on flat panels and the like.

Appreciate all your hard work as I've skimmed this you guys are absolute Mad lads!
Namco Exceleena II (red) | Sega Astro City (needs ms9 monitor work)