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: Arduino as USB Guncon 2  (Read 7245 times)

0 Members and 1 Guest are viewing this topic.

fisch

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 4
  • Last login:September 21, 2022, 11:24:30 am
  • I want to build my own arcade controls!
Arduino as USB Guncon 2
« on: April 11, 2021, 06:08:20 pm »
Hi everyone,

I am working on a new firmware for the SAMCO DIY gun to have the gun look as a USB Guncon 2 when connected to a PS2.
It seems like a novel thing, over the years people have written drivers to use a Guncon 2 on a PC which is like the complementary problem.
On the other hand, I think people have successfully emulated a Guncon with an Arduino for PS1 and PS2.
But I wanted to avoid having another cable come out of the SAMCO (I only have a PS2 and PS2 light gun games to play).

After a couple of painful days, I got it to a state where the gun is recognised by the PS2 and so are the buttons (trigger, dpad, etc.).
I have not tried to activate the X and Y coordinates just yet. Mainly because I am not sure what values I should use.

Does anyone know what are the minimum/maximum X/Y coordinates that the PS2 expects?

I still have the guts of the Guncon 2 I used to create the SAMCO, but unfortunately I do not have a CRT handy that I can use to capture the X and Y coordinates reported.
I unsuccessfully tried to figure this information out from old posts (1)(2) and the drivers linked therein.
It seems like different Guncon 2s can have different minimum and maximum values which is just very confusing.
Especially when the calibration in a game like Time Crisis 2 (for example) only asks you to shoot in the center (so how does the PS2 compensate?).
I can also just try out different values until I feel it works nicely. But that is going to be painful, so I though I would ask first...
Finally, happy to share the code once it is in a usable state.

bandicoot

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 113
  • Last login:Today at 02:33:24 am
Re: Arduino as USB Guncon 2
« Reply #1 on: April 13, 2021, 01:20:32 pm »
got a real guncon 2 , a PS2 with FreeMcboot  and a CRT TV if i could help

sonik

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 75
  • Last login:March 13, 2024, 10:52:59 am
  • I want to build my own arcade controls!
Re: Arduino as USB Guncon 2
« Reply #2 on: April 14, 2021, 08:15:44 am »
Tested right now with my gcon2 driver using a pvm with NTSC signal.
Look for min and max values at attached image.

Also original gcon2 and third party ones works different at least on a pc. Original ones starts in "progressive mode" with the "rolling X" problem.
I have no idea how the game handles it.

Also check this out
http://problemkaputt.de/psx-spx.htm#controllerslightgunsnamcoguncon

You should at least implement the "no light" error code when pointer is out of screen.

fisch

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 4
  • Last login:September 21, 2022, 11:24:30 am
  • I want to build my own arcade controls!
Re: Arduino as USB Guncon 2
« Reply #3 on: April 14, 2021, 03:54:35 pm »
@bandicoot Thanks for the offer!
@sonik Thanks for the test and the link!

In parallel I also did what I defined as the painful test:
I set the dpad to control x/y, first in 10 units increments and then 1 unit increments, and started shooting in Time Crisis 2's menu to track the position of the shot.
The measures I came up with are:
#define GUNCON_X_MIN      150
#define GUNCON_X_MAX      724
#define GUNCON_Y_MIN       32
#define GUNCON_Y_MAX      295

I am playing on a PAL PS2, so it might expect slightly different values.
On top of that, it is producing some non symmetric black bars on all sides of the picture which might influence the coordinates system slightly.
I will do more testing to find a sweet spot and try it out with other games...

I also found out that x=0 and y=0 also seems to be a valid "no light" pair but I will change it to the Guncon specs in the link which are probably consistent with the Guncon 2 specs (I did notice that the dismantled Guncon 2 reports x=1 and y=5 when idle).

I did a quick playing session, it was good but not super accurate.
But that might be because of Samco + IR calibration rather then the value sent form the gun to the PS2.
The only issue was that the Time Crisis 2 calibration screen did not work at all.
I don't know enough yet to understand what might be not working there.

 

sonik

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 75
  • Last login:March 13, 2024, 10:52:59 am
  • I want to build my own arcade controls!
Re: Arduino as USB Guncon 2
« Reply #4 on: April 14, 2021, 05:38:36 pm »
You should also take a look at this emulator plugin as it returns the values that the games expects.
https://github.com/mirror/nuvee/blob/master/nuvee_ps2_usb%20-%20guncon2%2C%20keyboard%2C%20mouse/src/guncon2.cpp

Do you plan on releasing the source code of the firmware?
I might use it on my guncon1 to arduino adapter. Would be cool to use it on a ps2 simulating a guncon2.

bandicoot

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 113
  • Last login:Today at 02:33:24 am
Re: Arduino as USB Guncon 2
« Reply #5 on: April 15, 2021, 02:07:55 am »
if you launch  NTSC game on a PAL PS it will be 60Hz

fisch

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 4
  • Last login:September 21, 2022, 11:24:30 am
  • I want to build my own arcade controls!
Re: Arduino as USB Guncon 2
« Reply #6 on: April 16, 2021, 05:16:51 am »
Damn, having an emulator code is perfect.
I did a brief search and did not find anything.
It will definitely help understand how minimum and maximum values are used.

Yeah, I will try to put something on github maybe this weekend even if it will not be very polished by then.
Disclaimer that it is built on top of TinyUSB and not the standard Arduino USB stack.
I am using an itsybitsy M4, and Adafruit made it easy to replace the standard Arduino USB stack with TinyUSB.

I do not remember how regions worked on PS2, but anyway I am using PAL games with a PAL console.

fisch

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 4
  • Last login:September 21, 2022, 11:24:30 am
  • I want to build my own arcade controls!
Re: Arduino as USB Guncon 2
« Reply #7 on: April 18, 2021, 03:54:51 pm »
I uploaded the code here:
https://github.com/88hcsif/IR-Light-Gun

There is still a lot of work to do...

bandicoot

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 113
  • Last login:Today at 02:33:24 am
Re: Arduino as USB Guncon 2
« Reply #8 on: April 23, 2021, 02:05:51 pm »
thanks for sharing  :applaud:

sonik

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 75
  • Last login:March 13, 2024, 10:52:59 am
  • I want to build my own arcade controls!
Re: Arduino as USB Guncon 2
« Reply #9 on: April 26, 2021, 07:40:36 am »
Thanks for sharing!
I'm done with my gcon1 to usb. Sometime in the future I will try to port your code to arduino and see if I can make it work on the ps2.

ThatOneSeong

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 57
  • Last login:Yesterday at 06:49:41 pm
  • Just your average Seong.
    • Twitter
Re: Arduino as USB Guncon 2
« Reply #10 on: September 14, 2021, 12:14:44 am »
My gosh, how did it take me this long to realize after I just posted asking about this kind of support in SAMCO?I currently have an NTSC-U PS2 hooked up to a flat screen in my living room, which I plan to use as a PC output on a different source. PCSX2's nuvee plugin is a PITA for me personally to use (requires too much intervention just to get a game started), and with latest nightlies bucking plugins entirely, using original hardware would not only be a sweet bonus, but nearly a necessity for my case.

I don't have a SAMCO-modded setup right now, but I plan to mod a GCon2 for this purpose. If there's any further support for this fork (or even better, maybe merge/implement some of Prow7's updates), that would be perfect.
Anything to replace my TopGun 3 I've had lugging around. (^^;