Viewing Issue Advanced Details
ID Category [?] Severity [?] Reproducibility Date Submitted Last Update
06491 DIP/Input Minor Always Feb 2, 2017, 22:55 Mar 7, 2023, 18:25
Tester Emu View Status Public Platform MAME (Official Binary)
Assigned To Resolution Open OS Windows Vista/7/8 (64-bit)
Status [?] Acknowledged Driver
Version 0.182 Fixed in Version Build 64-bit
Fixed in Git Commit Github Pull Request #
Summary 06491: all gun games: Using Aimtrak light gun with 4:3 games in 16:9 screens the crosshair is not aligned in sides with the pointer
Description When using a gun game with an aspect ratio different from the screen aspect ratio (for example using a 4:3 games in a 16:9 screen) the position of the crosshair in the game is correct onli in the middle vertical axis of the screen: more the gun is moved to the edge of the screen more the crosshair and the pointer increase their distance. At the edge of the screen the crosshair is at the edge of the game screen.

After other test I've noticed that the position detected in the screen ir reproduced proportionally in the game screen, this is more noticeable if rotating the game screen.

Because the Aimtrak light gun is seen as a mouse device I suppose that the mouse pointer should always be over the crosshair.

In this situation the only way to correctly play games is using crosshair or stretching the screen game.

I've attached som screenshot of this behaviour.
Steps To Reproduce
Additional Information
Github Commit
Flags
Regression Version
Affected Sets / Systems all gun games
Attached Files
zip file icon 0_MAME_Lightgun_Pointer.zip (1,772,613 bytes) Feb 2, 2017, 22:55 Uploaded by Emu
MAME screenshots with pointer wrong position in sides
Relationships
There are no relationship linked to this issue.
Notes
11
User avatar
No.13580
Fujix
Administrator
Feb 3, 2017, 06:03
Please try 06426
User avatar
No.13589
Emu
Tester
Feb 4, 2017, 17:55
I made al lthe tests wrote in the post, tryied changing from lightgun to other then saving, then lightun again, but nothing changed.
I tried changing lightgunprovider but it works only with rawinput.
I tried dleting the ini files and setting option in the gui before starting the game but the behaviour remained the same.

I never had any isse in detecting the guns, only with the crosshair that disalighe with the mouse cursor. The MAME mouse cursor is very precise about where hte gun point in the screen.
User avatar
No.13598
Tafoid
Administrator
Feb 6, 2017, 15:49
The problem here is trying to support umpteen amounts of different guns/controllers/input devices. Devs to not have access to a lot of then nor have setups like everyone else.
Has your issue always been present? Do earlier version of MAME show this problem as well or is it a regression in function?
User avatar
No.13601
Emu
Tester
Feb 6, 2017, 21:31
edited on: Feb 6, 2017, 21:32
Hello Tafoid
Thanks for your answer.
I understaind that problem with specific hardware is harder to solve because need the hardware to be reproduced. About this issue, did anyboy take the opportunity to get the free guns from Ultimarc as reported in the "Additional Information " files of this resolved bug http://mametesters.org/view.php?id=6185 ?
From the exeprience I had with Andy I think it may be possible.
Backing in topic, I own those guns from Christmas, I tried them with both MAME 0.181 and 0.182. If is needed I can try old version. I'll do ASAP, in the meanwhile if you have any suggestion abut specific version to test is welcome
If other tests are needed I can do them to acquire more specific details, let me know what you need I do.

The strange thing is that the light gun is configured as emulate mouse in the Aimtrak configuration, in Windows and in MAME configuration the mouse pointer is moved perfectly, but if I configure the lightgun_device as mouse the crosshair do not move at all (using the gun). It works only if configured as lightgun. As lightgun work perfectly, I own 2 guns and always where correctly detected.

This behaviour to mee it seem determined in the code by a specific function, in fact the full screen area is the gun detection area, the the crosshair is proportionally reported in the game screen. I discovered that this is even more noticeable in the Vs games like Duck Hunt, where there are 2 screen and the crosshair is only in the lower game screen. If the detection area is not stretched to game area everythink should work as expected.
It would be good having an option to disable/enable this stretching to game area but I don't know if it's possible.

I'm also available, if needed, in running special builds with debug code.
User avatar
No.13605
Tafoid
Administrator
Feb 7, 2017, 17:42
I've acknowledged for now.
Until a qualified Dev or another user who has a lightgun can help debug or have ideas on how to address the issues, I guess this can act as a holder for gun related issues
User avatar
No.13615
Emu
Tester
Feb 9, 2017, 19:35
OK, I understaind.
When somebody will start investigating on it I'll be available for testing
User avatar
No.15520
alexkidd
Tester
Oct 11, 2018, 22:57
I also have an AimTrak Light Gun and I noticed this issue as well. I wanted to add that there is a workaround for certain games whose in-game calibration settings requires hitting targets on either side of the screen. In those cases, it's possible to under-compensate during calibration, and play the game normally. This unfortunately does not work for those games whose in-game calibration is based on a lone target in the center of the screen (Area51, for instance). I'm debating attempting to fix this myself in MAME, or build a configurable command line tool that remaps mouse events outside of MAME, and have a per-game script handle the orchestration. The latter option would be more versatile as I've seen this behavior in other emulators besides MAME. However while I possess the aptitude to take this on myself, it's becoming increasingly difficult for me to find the time these days...

One thing to note for the regular contributors to MAME: In theory, this could be reproduced by enabling the windows cursor in-game with the crosshair enabled (programmatically if necessary). Then try playing a 4:3 Light Gun game on a 16:9 screen. My expectation is that the crosshair and mouse will diverge as you move along the x axis. The "fix" would be to make it so they always remain together. This should work for other light guns too. I believe they all operate under the same principle.
User avatar
No.21036
Emu
Tester
Jan 24, 2023, 22:20
Hello
After many years this issue is still present in last MAME version, and now I decided to have a deeper look into the issue, directly in the MAME sources even if I don't write C code from many-many years.
Unfortunately it is not possible to use the same solution as the mouse pointer, because it's a relative movement device (The new position is calculated using the movement from previous position), instead the lightgun is an absolute movement device (it always give an absolute position inside the screen), so I investigated more.

I found that this issue is caused by how the normalize_absolute_axis function normalyze the values, so I have:

1) Updated the file src\osd\modules\input\input_rawinput.cpp, in a way so the X position point to a different function:

lightgun.lX = normalize_absolute_axis_testx(rawinput.data.mouse.lLastX, 0, osd::INPUT_ABSOLUTE_MAX);
lightgun.lY = normalize_absolute_axis(rawinput.data.mouse.lLastY, 0, osd::INPUT_ABSOLUTE_MAX);

2) Duplicated the function normalize_absolute_axis in file src\osd\modules\input\input_common.h in the following way (below, both the original and modified functions):

inline int32_t normalize_absolute_axis(double raw, double rawmin, double rawmax)
{
double center = (rawmax + rawmin) / 2.0;

// make sure we have valid data
if (rawmin >= rawmax)
return int32_t(raw);

if (raw >= center)
{
// above center
double result = (raw - center) * osd::INPUT_ABSOLUTE_MAX / (rawmax - center);
return std::min(result, (double)osd::INPUT_ABSOLUTE_MAX);
}
else
{
// below center
double result = -((center - raw) * (double)-osd::INPUT_ABSOLUTE_MIN / (center - rawmin));
return std::max(result, (double)osd::INPUT_ABSOLUTE_MIN);
}
}

inline int32_t normalize_absolute_axis_testx(double raw, double rawmin, double rawmax)
{
double center = (rawmax + rawmin) / 2.0;

double screen_resolution_x = 1920; // X Resolution of the screen
double image_size_x = 1440; // X size of the game window

double black_border_size_x = (screen_resolution_x - image_size_x) / 2; // Size in pixel of each black border
double screen_center_x = screen_resolution_x / 2;

// To be recalculated from screen resolution and image size
//double SCREEN_ABSOLUTE_MAX = 87397;
//double SCREEN_ABSOLUTE_MIN = -87397;
double SCREEN_ABSOLUTE_MAX = (screen_resolution_x-screen_center_x) * osd::INPUT_ABSOLUTE_MAX / (image_size_x+black_border_size_x-screen_center_x);
double SCREEN_ABSOLUTE_MIN = -SCREEN_ABSOLUTE_MAX;

// make sure we have valid data
if (rawmin >= rawmax)
return int32_t(raw);

if (raw >= center)
{
// above center
//double result = (raw - center) * osd::INPUT_ABSOLUTE_MAX / (rawmax - center); // Original code
//double result = (raw - center) * (double)87397 / (rawmax - center); // Test #1
double result = (raw - center) * SCREEN_ABSOLUTE_MAX / (rawmax - center); // Test #2
return std::min(result, (double)osd::INPUT_ABSOLUTE_MAX);
}
else
{
// below center
//double result = -((center - raw) * (double)-osd::INPUT_ABSOLUTE_MIN / (center - rawmin)); // Original code
//double result = -((center - raw) * (double)-87397 / (center - rawmin)); // Test #1 ==> Wrong, while on left side of the screen, the crosshair is on right side of the screen
double result = -((center - raw) * -SCREEN_ABSOLUTE_MIN / (center - rawmin)); // Test #2
return std::max(result, (double)osd::INPUT_ABSOLUTE_MIN);
}
}


Now the mouse pointer moved by the lightgun and the crosshar are pefectly syncronized, but only for 4:3 games with image stretched with keep aspect ratio, and a resolution of 1920x1080, because the resulution and the game area are hardcoded. Those hardcoded variables should be replaced by the correct functions to retrieve the correct values for the current enviroment, and also, my solution work only if the game screen is centere, in case it's on a window and not centered the calues are not correct and the formulas should be changed, then it would be nice to have a confirmation that this does not cause other issue in other situaztions (regression tests).

Does anybody know how to complete my PoC for this solution?

Unfortunately my C skills are not enough. :-(
User avatar
No.21037
Fortuna
Tester
Jan 25, 2023, 07:30
This too happen if you use a mouse for use a lightgun, has the same problem, the most rudimentary solution is play in 4:3 in window mode
User avatar
No.21038
ICEknight
Tester
Jan 25, 2023, 20:20
Might be related to this? https://mametesters.org/view.php?id=8444
User avatar
No.21150
Emu
Tester
Mar 7, 2023, 18:25
Hello ICEknight
I think that is caused by the same cause