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: How to match Windows cursor with MAME crosshair  (Read 1147 times)

0 Members and 1 Guest are viewing this topic.

caiom

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 4
  • Last login:April 13, 2023, 03:01:07 am
  • I want to build my own arcade controls!
How to match Windows cursor with MAME crosshair
« on: March 28, 2023, 04:06:55 am »
Hello everyone, I'm creating a light gun with a Vive tracker. It works great, really low latency and very precise. I plan to release everything on Gitub.

However I noticed a problem in the first MAME game that I have tried. I can't match the the Windows cursor (what I control in absolute terms) with the MAME crosshair.

I can't adjust the sensitivity perfectly and even if I could the cursor and crosshair desync with time (they run on different frequencies I guess). On top of that the MAME crosshair screen is 4:3 and the Windows cursor screen is 16:9. I could fake a 4:3 Windows cursor screen but I don't see that helping much here.

Do you guys have any idea how projects like Gun4IR or Sinden overcome these?

The only solution that I see is to expose the crosshair position by modifying MAME source code.




greymatr

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 12
  • Last login:Yesterday at 06:26:41 am
  • I want to build my own arcade controls!
Re: How to match Windows cursor with MAME crosshair
« Reply #1 on: March 28, 2023, 06:15:49 am »
Hi caiom,

I'm very interested in your project as I have been trying to do the same with a vive tracker. I tried to do it with Python code however I wasn't able to fully resolve the maths for orientation.

I ended up using someone elses project in the meantime, vive_mouse by Olli Moisio. There are several versions hosted here http://olli.wtf/vive/  but no source code. It may give you some ideas though or a way of testing.

I've found that it uses USER32.DLL to do the controlling of the mouse pointer. This won't work with some programs that need DirectX mouse control or for other reasons.

You may find some other information on the project here - https://github.com/agardony/vive_mouse

I've tried it with two games, Virtual Cop and Time Crisis and I believe time crisis is running on MAME but I'm using a frontend package to launch it.

I can't see the windows cursor when playing them however but they seem to line up with the gun well.

I believe Gun4IR uses an arduino board in the gun and connects via USB and I think this emulates a USB HID device and acts like a mouse to the OS. Sinden may be doing something like that too.

In some of my other lightgun testing I've used a Leonardo Arduino USB to do the same thing. It can be plugged in via the one USB cable and can receive COM Port communication and then send back mouse commands.

Ideally though a OS level driver would be installed to do the mouse emulation, ideally again would be a signed driver but an unsigned driver can be installed with a little mucking about.

If you would like someone to help test your program I would be glad to help.

Cheers,
greymatr

caiom

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 4
  • Last login:April 13, 2023, 03:01:07 am
  • I want to build my own arcade controls!
Re: How to match Windows cursor with MAME crosshair
« Reply #2 on: March 28, 2023, 01:03:28 pm »
Hi grey,

Thanks for the interest in my project.

At least in my MAME you can hit TAB and see the Windows cursor. You will see that the Windows cursor and MAME crosshair won't match.

Let me polish up a little bit my code and I can send you the source. I did in Python using the https://github.com/TriadSemi/triad_openvr.  But ideally, I should move to another library (libsurvive or OpenXR).

To control the mouse I'm using Arduino but I was also able to use unsigned drivers as well. This one: https://github.com/hedgar2017/loki-hidriver with modifications.

Regards,


greymatr

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 12
  • Last login:Yesterday at 06:26:41 am
  • I want to build my own arcade controls!
Re: How to match Windows cursor with MAME crosshair
« Reply #3 on: March 29, 2023, 07:02:16 am »
That would be great. I'll definitely install MAME and give it a go

caiom

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 4
  • Last login:April 13, 2023, 03:01:07 am
  • I want to build my own arcade controls!
Re: How to match Windows cursor with MAME crosshair
« Reply #4 on: April 01, 2023, 02:13:13 am »
Hi grey, here's the repository: https://github.com/caiom/vive_tracker_lightgun

It is still very messy, later I will create a topic explaining the whole project. You would be probably interested in the files "calibrate.py" and "tracker_mouse.py".

To match the MAME cursor I ended up modifying MAME to send the coordinates via UDP: https://github.com/caiom/mame

Regards,