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: Mounted Guns and Arduino mouse mapping  (Read 7254 times)

0 Members and 1 Guest are viewing this topic.

syntax_x

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 42
  • Last login:October 27, 2019, 09:32:44 pm
Mounted Guns and Arduino mouse mapping
« 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??

PL1

  • Global Moderator
  • Trade Count: (+1)
  • Full Member
  • *****
  • Offline Offline
  • Posts: 9404
  • Last login:Today at 01:03:25 am
  • Designated spam hunter
Re: Mounted Guns and Arduino mouse mapping
« Reply #1 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 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.



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

syntax_x

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 42
  • Last login:October 27, 2019, 09:32:44 pm
Re: Mounted Guns and Arduino mouse mapping
« Reply #2 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 :)

PL1

  • Global Moderator
  • Trade Count: (+1)
  • Full Member
  • *****
  • Offline Offline
  • Posts: 9404
  • Last login:Today at 01:03:25 am
  • Designated spam hunter
Re: Mounted Guns and Arduino mouse mapping
« Reply #3 on: July 30, 2019, 04:07:20 am »
Always glad to assist.   :cheers:


Scott

syntax_x

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 42
  • Last login:October 27, 2019, 09:32:44 pm
Re: Mounted Guns and Arduino mouse mapping
« Reply #4 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

PL1

  • Global Moderator
  • Trade Count: (+1)
  • Full Member
  • *****
  • Offline Offline
  • Posts: 9404
  • Last login:Today at 01:03:25 am
  • Designated spam hunter
Re: Mounted Guns and Arduino mouse mapping
« Reply #5 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 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.




Scott

syntax_x

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 42
  • Last login:October 27, 2019, 09:32:44 pm
Re: Mounted Guns and Arduino mouse mapping
« Reply #6 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?

PL1

  • Global Moderator
  • Trade Count: (+1)
  • Full Member
  • *****
  • Offline Offline
  • Posts: 9404
  • Last login:Today at 01:03:25 am
  • Designated spam hunter
Re: Mounted Guns and Arduino mouse mapping
« Reply #7 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

syntax_x

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 42
  • Last login:October 27, 2019, 09:32:44 pm
Re: Mounted Guns and Arduino mouse mapping
« Reply #8 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.

PL1

  • Global Moderator
  • Trade Count: (+1)
  • Full Member
  • *****
  • Offline Offline
  • Posts: 9404
  • Last login:Today at 01:03:25 am
  • Designated spam hunter
Re: Mounted Guns and Arduino mouse mapping
« Reply #9 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

Hydreigon

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 25
  • Last login:October 11, 2023, 09:57:11 pm
  • I want to build my own arcade controls!
Re: Mounted Guns and Arduino mouse mapping
« Reply #10 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?

baritonomarchetto

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 805
  • Last login:Yesterday at 09:51:46 am
Re: Mounted Guns and Arduino mouse mapping
« Reply #11 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.
« Last Edit: August 01, 2019, 12:34:26 am by baritonomarchetto »

Zebra

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 619
  • Last login:August 19, 2021, 01:12:24 pm
  • I want to build my own arcade controls!
Re: Mounted Guns and Arduino mouse mapping
« Reply #12 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.