DIY 4 LED lightgun system on the MiSTer?

https://github.com/MiSTer-devel/Main_MiSTer/wiki

Moderators: Mug UK, Zorro 2, Greenious, spiny, Sorgelig, Moderator Team

Stremon
Atariator
Atariator
Posts: 26
Joined: Fri Mar 22, 2019 3:47 am

DIY 4 LED lightgun system on the MiSTer?

Postby Stremon » Tue Oct 01, 2019 3:55 am

I'm currently finishing the development of two DIY lightgun projects, one simple that works only with 2 led like the wiisensor bar, but needs calibration all the time.
(http://forum.arcadecontrols.com/index.php/topic,161037.0.html)
The second project is with 4 LEDs around the screen to provide the auto callibration and perfect line of sight aiming wherever you sit.
(http://forum.arcadecontrols.com/index.php/topic,161189.0.html)
You can also use pretty much any gun shell as a base for the hardware.

So I wanted to see if I can make them compatible with MiSTer, that would be awesome for people that can't use CRT but still want good lightgun aiming.

For that purpose, can anybody help me for the type of control used by lightguns in MiSTer?
The wiimote for instance is acting a bit like a mouse, but is it absolute coordinate mouse or relative coordinate? It looks like absolute, but not sure.

My guns Arduino sketches so far can simulate a mouse with absolute coordinate or a joystick, but I would gladly add whatever is needed for MiSTer support ;)
Also if needed to make a special drivers or something, I can also help :D

Sorgelig
Ultimate Atarian
Ultimate Atarian
Posts: 5255
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: DIY 4 LED lightgun system on the MiSTer?

Postby Sorgelig » Tue Oct 01, 2019 11:20 pm

WiiMote uses touchscreen mode with absolute coordinates. For lightgun use it has special tweaks in MiSTer.
It's also possible to add similar tweaks for your device. Basically, everything is already in MiSTer for lightgun.
Currently only NES and SNES cores are supporting lightgun.

Stremon
Atariator
Atariator
Posts: 26
Joined: Fri Mar 22, 2019 3:47 am

Re: DIY 4 LED lightgun system on the MiSTer?

Postby Stremon » Wed Oct 02, 2019 2:06 pm

Sorgelig wrote:WiiMote uses touchscreen mode with absolute coordinates. For lightgun use it has special tweaks in MiSTer.
It's also possible to add similar tweaks for your device. Basically, everything is already in MiSTer for lightgun.
Currently only NES and SNES cores are supporting lightgun.

That's awesome! Indeed it shouldn't be hard to make it work, the Arduino is behaving exactly like you say the wiimote is.
Would it be possible to have a "Touchscreen" or "Mouse absolute" mode beside the other one, or should we do a specific change for the device?
My arduino sketch uses standard HID absolute mouse/touchscreen (it's actually detected correctly in mouse mode, but moves way too much due to the mouse being in relative mode), so I guess there would be nothing else needed beside the absolute coordinate mode?
I can edit my code to send the correct data accordingly of course.

Sorgelig
Ultimate Atarian
Ultimate Atarian
Posts: 5255
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: DIY 4 LED lightgun system on the MiSTer?

Postby Sorgelig » Wed Oct 02, 2019 3:30 pm

There is no way to distinguish lightgun from touchpad as all these devices may produce absolute coordinates and generic mouse driver automatically translates it to relative mouse events. So the only way to distinguish is VID/PID which must be unique.
I suggest to advertise your device as joystick, not as mouse/touchpad. Standard analog joystick has absolute X/Y. Joystick won't be converted to mouse events, so it's much easier to adapt it for lightgun events.

Stremon
Atariator
Atariator
Posts: 26
Joined: Fri Mar 22, 2019 3:47 am

Re: DIY 4 LED lightgun system on the MiSTer?

Postby Stremon » Wed Oct 02, 2019 4:53 pm

Sorgelig wrote:There is no way to distinguish lightgun from touchpad as all these devices may produce absolute coordinates and generic mouse driver automatically translates it to relative mouse events. So the only way to distinguish is VID/PID which must be unique.
I suggest to advertise your device as joystick, not as mouse/touchpad. Standard analog joystick has absolute X/Y. Joystick won't be converted to mouse events, so it's much easier to adapt it for lightgun events.

Got it, but in the core you can choose between mouse and joystick 1 and 2, right? Is there any way to add a "Touchpad" mode that will only work with absolute coordinates? I can also provide the VID/PID of the mouse emulated by my Arduino if needed of course :D
I already implemented a joystick mode in my lightgun, I can switch between both modes at any time. But defining the axises and buttons in the joystick menu is a nightmare, it's really hard to try keeping the aim in the center or one axis at a time.

Sorgelig
Ultimate Atarian
Ultimate Atarian
Posts: 5255
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: DIY 4 LED lightgun system on the MiSTer?

Postby Sorgelig » Wed Oct 02, 2019 5:15 pm

Stremon wrote:I already implemented a joystick mode in my lightgun, I can switch between both modes at any time. But defining the axises and buttons in the joystick menu is a nightmare, it's really hard to try keeping the aim in the center or one axis at a time.

if your lightgun will be known lightgun to MiSTer then it won't require settings as it's done for WiiMote.

Stremon
Atariator
Atariator
Posts: 26
Joined: Fri Mar 22, 2019 3:47 am

Re: DIY 4 LED lightgun system on the MiSTer?

Postby Stremon » Wed Oct 02, 2019 5:36 pm

Sorgelig wrote:
Stremon wrote:I already implemented a joystick mode in my lightgun, I can switch between both modes at any time. But defining the axises and buttons in the joystick menu is a nightmare, it's really hard to try keeping the aim in the center or one axis at a time.

if your lightgun will be known lightgun to MiSTer then it won't require settings as it's done for WiiMote.

Ok no problem, so how can I do that? I don't have any experience in FPGA but I know how to code, I would gladly implement myself or help implementing it/maintain it if I can, just show me the way ;)

Sorgelig
Ultimate Atarian
Ultimate Atarian
Posts: 5255
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: DIY 4 LED lightgun system on the MiSTer?

Postby Sorgelig » Wed Oct 02, 2019 7:05 pm

Stremon wrote:
Sorgelig wrote:
Stremon wrote:I already implemented a joystick mode in my lightgun, I can switch between both modes at any time. But defining the axises and buttons in the joystick menu is a nightmare, it's really hard to try keeping the aim in the center or one axis at a time.

if your lightgun will be known lightgun to MiSTer then it won't require settings as it's done for WiiMote.

Ok no problem, so how can I do that? I don't have any experience in FPGA but I know how to code, I would gladly implement myself or help implementing it/maintain it if I can, just show me the way ;)

it's not related to FPGA. It's on ARM side. It's open source. Main_MiSTer repository

Stremon
Atariator
Atariator
Posts: 26
Joined: Fri Mar 22, 2019 3:47 am

Re: DIY 4 LED lightgun system on the MiSTer?

Postby Stremon » Thu Oct 03, 2019 2:40 am

Sorgelig wrote:
Stremon wrote:
Sorgelig wrote:if your lightgun will be known lightgun to MiSTer then it won't require settings as it's done for WiiMote.

Ok no problem, so how can I do that? I don't have any experience in FPGA but I know how to code, I would gladly implement myself or help implementing it/maintain it if I can, just show me the way ;)

it's not related to FPGA. It's on ARM side. It's open source. Main_MiSTer repository

Oh I see! Though it was included on the core side somehow :roll:
Thanks, I think I found it, indeed it seems to be quite easy to add it to input.cpp.

Stremon
Atariator
Atariator
Posts: 26
Joined: Fri Mar 22, 2019 3:47 am

Re: DIY 4 LED lightgun system on the MiSTer?

Postby Stremon » Thu Oct 03, 2019 4:03 pm

I did update the input.cpp to support the Arduino Lightgun, but I have no idea how to compile it using msys and linaro on windows x64, can you give me a hand with this? :oops:

Sorgelig
Ultimate Atarian
Ultimate Atarian
Posts: 5255
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: DIY 4 LED lightgun system on the MiSTer?

Postby Sorgelig » Thu Oct 03, 2019 7:10 pm

You can find discussion here:
viewtopic.php?f=117&t=37365

Stremon
Atariator
Atariator
Posts: 26
Joined: Fri Mar 22, 2019 3:47 am

Re: DIY 4 LED lightgun system on the MiSTer?

Postby Stremon » Fri Oct 04, 2019 1:51 am

Sorgelig wrote:You can find discussion here:
viewtopic.php?f=117&t=37365

Ok thanks, I will try that.

Stremon
Atariator
Atariator
Posts: 26
Joined: Fri Mar 22, 2019 3:47 am

Re: DIY 4 LED lightgun system on the MiSTer?

Postby Stremon » Sat Oct 05, 2019 4:00 am

Stremon wrote:
Sorgelig wrote:You can find discussion here:
viewtopic.php?f=117&t=37365

Ok thanks, I will try that.

Code added and tested, it works nicely!
Is there any place I can commit the change?

warham
Atari maniac
Atari maniac
Posts: 95
Joined: Fri Oct 12, 2018 7:17 am

Re: DIY 4 LED lightgun system on the MiSTer?

Postby warham » Sat Oct 05, 2019 7:34 am

looks cool. Are you going to post all the info here to be able to make one?

Sorgelig
Ultimate Atarian
Ultimate Atarian
Posts: 5255
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: DIY 4 LED lightgun system on the MiSTer?

Postby Sorgelig » Sat Oct 05, 2019 11:03 am

Stremon wrote:
Stremon wrote:
Sorgelig wrote:You can find discussion here:
viewtopic.php?f=117&t=37365

Ok thanks, I will try that.

Code added and tested, it works nicely!
Is there any place I can commit the change?

You can make a pull request to original repo.

Stremon
Atariator
Atariator
Posts: 26
Joined: Fri Mar 22, 2019 3:47 am

Re: DIY 4 LED lightgun system on the MiSTer?

Postby Stremon » Sat Oct 05, 2019 1:48 pm

warham wrote:looks cool. Are you going to post all the info here to be able to make one?

Yes that's the plan, but I have to prepare all the docs first to make it as foolproof as possible :D
But to sum up, the base thing you would need is a gun shell (any old console gun should work), an atmega32u4 arduino clone, the DFRobot IR positioning camera, a small push switch, and 4 IR leds powerful enough to work well with the cam.
You can even add an optional solenoid recoil if you want, I will give the schematics for that too.

Sorgelig wrote:You can make a pull request to original repo.

Ok, I will do ;)

Stremon
Atariator
Atariator
Posts: 26
Joined: Fri Mar 22, 2019 3:47 am

Re: DIY 4 LED lightgun system on the MiSTer?

Postby Stremon » Sat Oct 05, 2019 2:42 pm

Sorgelig wrote:You can make a pull request to original repo.

Nevermind, it doesn't work, it's still seen as relative motion, my mistake :roll:
I put my lightgun VID/PID in the input.cpp the same way as the ultimarc was, I guess it's not enough?
How is it supposed to behave?
Currently, if I plug it with a reset MiSTer, it kind of move correctly (which made me though it is working), but once I reach the borders of the screen, it just get completely off.
I tried with the joystick mode, and surprisingly the axises are working, but no way to remap the trigger, which seems to be hard coded to the second input button, no way to remap them.

Stremon
Atariator
Atariator
Posts: 26
Joined: Fri Mar 22, 2019 3:47 am

Re: DIY 4 LED lightgun system on the MiSTer?

Postby Stremon » Sun Oct 06, 2019 5:16 am

Ok I got it, it's neither mouse mode nor joystick mode, it's hybrid of the 2.
I have to set my gun positioning to emulate a joystick, but keep the mouse mode for the buttons.
Now it's working.
I will try to add that to the wiki, it might prevent people to lose as much time as I did to figure things out.

Sorgelig
Ultimate Atarian
Ultimate Atarian
Posts: 5255
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: DIY 4 LED lightgun system on the MiSTer?

Postby Sorgelig » Sun Oct 06, 2019 6:59 am

it's up to your implementation but it's not the only mode.
WiiMote works in joystick mode.


Return to “MiSTer”

Who is online

Users browsing this forum: Absnerdity and 8 guests