Build Your Own Arcade Controls Forum

Main => Raspberry Pi & Dev Board => Topic started by: syntax_x on July 30, 2019, 12:29:03 am

Title: Mounted Guns and Arduino mouse mapping
Post by: syntax_x on July 30, 2019, 12:29:03 am
I recently purchased an arcade cabinet that has those mounted type guns.
They are basically just 2x10k pots and a switch for the trigger.

I wanted to interface them with an Arduino to a mame PC to play a heap of different games.
In mame I would map it to the mouse.

My problem is all the code i have found so far accelerates the cursor depending on xy values. This causes the gun to drift and is not how it should play.

I need to find a way to map out the corners of my screen and calibrate a centre, so xy values = a specific screen position.

Any pointers??
Title: Re: Mounted Guns and Arduino mouse mapping
Post by: PL1 on July 30, 2019, 02:07:33 am
I recently purchased an arcade cabinet that has those mounted type guns.
They are basically just 2x10k pots and a switch for the trigger.
They are commonly referred to as postional guns.

I wanted to interface them with an Arduino to a mame PC to play a heap of different games.
In mame I would map it to the mouse.

My problem is all the code i have found so far accelerates the cursor depending on xy values. This causes the gun to drift and is not how it should play.
A postional gun is an analog joystick, not a mouse.

You need a gamepad+analog joystick (USB/HID Joypad) sketch or firmware.

The KADE miniArcade 2.0 (http://forum.arcadecontrols.com/index.php/topic,154126.0.html) firmware can handle 4 analog axes (X-axis and Y-axis for each gun) and 13 gamepad buttons on a single Pro Micro board.
- Step-by-step configuration directions are in the User Guide PDF.

(http://forum.arcadecontrols.com/index.php?action=dlattach;topic=149895.0;attach=360710;image)

Once you get the Aduino programmed and wired:

1. Calibrate the analog axes in Windows Control Panel
- Devices and Printers
- Right-click on the KADE icon, "Game Controller Settings" menu item
- Properties button on the popup window
- Settings tab, "Calibrate..." button

2. Map the analog axes in MAME. (Joy 1 X Axis, etc)
- Set the "Inc" and "Dec" inputs to "none" (press Enter then Esc)

3. Check each game to see if there is a calibration menu for the guns. (press F2 for service menu)
- With some games like Star Wars you need to trace a few laps around the outer perimeter of the screen (use the full range of motion) to calibrate it.


Scott
Title: Re: Mounted Guns and Arduino mouse mapping
Post by: syntax_x on July 30, 2019, 03:16:37 am
Scott I cannot thank you enough for such an in depth response.

Thanks for putting me on the straight and narrow mate :)
Title: Re: Mounted Guns and Arduino mouse mapping
Post by: PL1 on July 30, 2019, 04:07:20 am
Always glad to assist.   :cheers:


Scott
Title: Re: Mounted Guns and Arduino mouse mapping
Post by: syntax_x on July 30, 2019, 04:15:14 am
Im having trouble flashing to a Pro Micro the same as you have pictured.

In the mapper i get

Erasing flash...

dfu-programmer: no device present.

Error. Exit code: 1


And if i try avrdude command line i get

c:\avrdude>avrdude -p atmega32u4 -P COM5 -c avr109 -U flash:w:MINIARCADE2.hex -U eeprom:w:EEPROM.hex -C avrdude.conf

Connecting to programmer: .avrdude: butterfly_recv(): programmer is not responding
Title: Re: Mounted Guns and Arduino mouse mapping
Post by: PL1 on July 30, 2019, 04:31:18 am
1. Are you using the correct bootloader port number?

2. Are you double-click grounding the reset port to put it into bootloader mode just before you run avrdude?

Additional info learned in this thread (http://forum.arcadecontrols.com/index.php/topic,158171.0.html) for anyone using the Arduino AVR procedure on pages 13-14 of the User Guide under "Procedures for non-DFU boards".

Tested the avrdude .bat file on an Arduino Micro and a Pro Micro -- it works perfectly.   ;D

In Control Panel -- Devices and Printers, the bootloader port number is displayed in the device description when the board is put in bootloader mode.

To put a Pro Micro into bootloader mode, double-click ground the RST port as described in the "Reset to Bootloader" procedure here (https://learn.sparkfun.com/tutorials/pro-micro--fio-v3-hookup-guide/troubleshooting-and-faq).

(https://cdn.sparkfun.com/assets/6/d/3/4/a/523c8e23757b7fbe5f8b4584.png)


Scott
Title: Re: Mounted Guns and Arduino mouse mapping
Post by: syntax_x on July 30, 2019, 04:41:48 am
Ok, so i soldered a capacitor leg to the RST via as a dodgy button to ground. Pressed it quickly twice.

Turns out the Pro Micro would change from COM5 in normal mode to COM6 when in bootloader mode.

Had to catch it in the arduino software by making a new sketch to refresh port numbers ect.

Seems to have programmed now.


But shouldnt this type of board work with the mapper flasher instead of having to command line AVRdude?
Title: Re: Mounted Guns and Arduino mouse mapping
Post by: PL1 on July 30, 2019, 05:59:13 am
Ok, so i soldered a capacitor leg to the RST via as a dodgy button to ground. Pressed it quickly twice.

Turns out the Pro Micro would change from COM5 in normal mode to COM6 when in bootloader mode.

Had to catch it in the arduino software by making a new sketch to refresh port numbers ect.

Seems to have programmed now.
Glad you got it sorted.   :cheers:

But shouldnt this type of board work with the mapper flasher instead of having to command line AVRdude?
One of the things we wanted to avoid is getting stuck with only one type of board that will only work with Mapper, like what happened with the Minimus boards and the original KADE Loader program.

Bruno wrote the Mapper program to work automatically with either the MattairTech MT-DB-U4 or the custom KADE 32U4 AVRs. (same pinout, similar bootloaders)

Don't know the details, but IIRC there was some obstacle getting Arduino boards/bootloaders to work automatically with the Mapper program.   :dunno

Bruno added the EEPROM HEX and ELF export features and we documented the command line procedure to ensure that the EEPROM/firmware would work with the greatest variety of 32U4 boards/bootloaders, whether or not the Mapper program is ever updated.   ;D


Scott
Title: Re: Mounted Guns and Arduino mouse mapping
Post by: syntax_x on July 30, 2019, 11:02:30 am
After a short play ive found that I had to drop Mame deadzone to 0.

Also x-axis also controls z-axis. Is there a way around that? When I map mame Y-axis looks fine, x axis is a long line with both z axis.
Title: Re: Mounted Guns and Arduino mouse mapping
Post by: PL1 on July 30, 2019, 09:36:00 pm
KADE miniArcade 2.0's "right analog" stick is on the Z and Zro axes since USB HID Joypads don't use the same axis naming conventions as MAME.
- Mapper calls them X and Y so you know which pot to connect to which port.

Also x-axis also controls z-axis. Is there a way around that? When I map mame Y-axis looks fine, x axis is a long line with both z axis.
That's how Windows displays those four axes by default -- left analog stick on the X and Y box, right analog stick on the Z and Zro bars. (same as my generic USB PS2 controller)

If you'd like to see a test display with cross-hairs in two boxes, use the Pad Test function in Mapper.   ;D


Scott
Title: Re: Mounted Guns and Arduino mouse mapping
Post by: Hydreigon on July 31, 2019, 11:02:14 pm
I recently purchased an arcade cabinet that has those mounted type guns.
They are basically just 2x10k pots and a switch for the trigger.

I wanted to interface them with an Arduino to a mame PC to play a heap of different games.
In mame I would map it to the mouse.

My problem is all the code i have found so far accelerates the cursor depending on xy values. This causes the gun to drift and is not how it should play.

I need to find a way to map out the corners of my screen and calibrate a centre, so xy values = a specific screen position.

Any pointers??
What arcade machine did you buy? Did it ever have any main board or monitor?
Title: Re: Mounted Guns and Arduino mouse mapping
Post by: baritonomarchetto on August 01, 2019, 12:31:05 am
The default Arduino mouse library threat the mouse position as "relative". This means you can move the mouse pointer a definite amount of pixels in each direction od the axis of choice, relative to the previous position. You are in the need for an alternate library with absolute positioning. There are at least two of those libs, if I remember well.
Title: Re: Mounted Guns and Arduino mouse mapping
Post by: Zebra on October 26, 2019, 06:38:11 pm
Why don't you just use an Apac and avoid all those issues?

I use them for my positional guns and they are super easy to set up.

https://www.youtube.com/watch?v=L5Vdo_9FSx8&t=32s