AGS Mouse Sensitivity and Acceleration

Started by xil, Wed 04/02/2015 23:02:06

Previous topic - Next topic

Crimson Wizard

Yes, there is something wrong with this build, 1.0 is way too fast, 0.4 is like original version, and 0.15 is almost as fast as 0.4, and it only becomes slow when < 0.1. Or maybe it depends on game resolution and scaling. I must investigate all this more.

Crimson Wizard

#41
Bumping this topic, for this issue must be solved at last.

I've spent some time investigating how mouse sensitivity is implemented in some of the open sourced software, but to be honest, I did not find anything particularly different from what I was doing (and I was hoping there is some magic formula :tongue:).

I am still not sure where the "massive acceleration" reported previously is getting from, because code-wise it should not; it should move mouse 1:1. Perhaps it will help if I add a display resolution factor, and select different base values. Another idea is to add actual mouse acceleration parameter along with sensitivity (speed). Combining these values could possibly achieve better results (e.g. setting lower sensitivity but slightly positive acceleration).

In the latter case it will also be possible to set a negative acceleration (faster you move the mouse, less is the physical:virtual relation), it would be interesting to run few experiments with that.

Also, now I am making this on 3.3 branch, if I succeed this will be added to next 3.3.5 update first.


xil

Thanks for giving it another go!

I think the problem you're facing is that the 'massive acceleration' only seems to affect certain mouse drivers. This makes fixing it in code a bit of an odd solution as for a lot of people it's perfectly useable.

I think opening up the values for acceleration and speed would be a great idea and I'd be happy to do some testing once OROW is over.
Calico Reverie - Independent Game Development, Pixel Art & Other Stuff
Games: Mi - Starlit Grave - IAMJASON - Aractaur - blind to siberia - Wrong Channel - Memoriae - Point Of No Return

Dualnames

CW, as far as i know the issue comes from the mouse software that comes with certain mouses that uses a software acceleration.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Crimson Wizard

#44
Quote from: xil on Thu 27/08/2015 21:35:57
I think the problem you're facing is that the 'massive acceleration' only seems to affect certain mouse drivers. This makes fixing it in code a bit of an odd solution as for a lot of people it's perfectly useable.

Well... it kinda seems that I was fixing a wrong thing all this time. Well, maybe not generally wrong, but not the one which was critical.

How do other games cope with this? Do they all have extra acceleration too? Should this really be dealt with inside AGS, maybe it is that software that need to be adjusted instead?

E: Hypothetically, extra acceleration could be compensated with deceleration in AGS, but that is a guess.

Snarky

Yes, reading the updates on this issue, I've also wondered if AGS is taking the wrong approach.

I'm not well versed in the technical details here, but my general intuition is that when you're just using the mouse to move a cursor around, the mouse should under normal circumstances behave just like it would on the desktop, and that it should be up to the OS/shell to translate mouse inputs to cursor coordinates (so AGS shouldn't have to set the sensitivity or define screen borders). So I'm wondering if the mouse APIs used by AGS are too low-level. After all, e.g. FPS games that use the mouse for targeting probably need much more direct access to the mouse, so a library like Allegro might provide API calls that are more suitable for such a scenario.

Some caveats to this argument:
-Is there actually a higher-level API available? I mean, I know that when you write a windowed app you don't have to code in the mouse movement yourself, but is that available to the type of application AGS is?
-This might work well in windowed mode or if AGS could run in "pseudo-fullscreen" (scaled to the desktop resolution in an undecorated window), but how does Windows and other OSes handle mouse sensitivity/acceleration when the screen resolution changes? Is the speed in pixels scaled so that the amount of mouse movement needed to cross the screen remains the same?
-In a multi-screen environment, or if the game resolution is not the same as the screen resolution (because of borders etc), would a higher-level API allow us to elegantly keep the cursor within bounds?
-What if we want to be able to adjust these parameters in-game, or use the mouse in some other way. Would that still be possible?

Crimson Wizard

#46
I cannot use any API lower than OS/shell. And I do not translate mouse inputs to coordinates, that is what OS/drivers do.
What I tried to do is to ask the library about relative cursor movements and apply additional speed factor, that could be set up by player. I thought that this would at least limit the troubles caused by accelerating mouse software, but I guess I was wrong.


The current problem is that AGS uses "high-level API" that does not work well. (Actually, I would prefer word "layer" here). It uses Allegro mouse API, but Allegro does some extra processing to mouse coords when in fullscreen mode, making it accelerate, while providing little to no control over this behavior. Even the acceleration threshold factors are hard-coded. And it does so only on Windows for some wicked reason.


BTW, I have only recently found that the way I was implementing sensitivity by getting relative mouse movement instead of absolute coords, does not override Allegro acceleration! because Allegro applies that acceleration to relative movement first.
Meaning, what I've done so far, was still bearing same problem as before.


E: There is one trick I have just found; possibly that will turn this Allegro acceleration off for good. Will try this out today.

Crimson Wizard

#47
To quickly clarify some things (I intentionally do this in a separate post).

Current problems in AGS are:
1) Extra acceleration applied by Allegro library, only on Windows, and only in fullscreen. For the reasons I do not know, Allegro uses DirectInput when in fullscreen, and core Windows API when in windowed mode. Therefore the cursor behavior will be different.
I searched mouse routines for other OSes in Allegro, and they do not seem to make any difference between windowed and fullscreen mode.

2) Extra acceleration applied by "mouse software". The confusing part here, something that I do not know well enough, is when exactly this software kicks in. If it is not a driver, but a normal Windows application, then it should probably work by tracking mouse movement in Windows and set new cursor position on its own.
Question is, whether AGS should bother. The only way to counter this would be to introduce our own acceleration, or rather deceleration. But this sounds pretty... odd. Therefore, I would like to know how other games deal with this situation, and do they?

3) Do we actually need a cursor speed control in AGS? If yes, Allegro one is not precise; its speed config is integer, and lowest possible value is 1:1. If we want to open cursor speed setting to end-user, then I'd rather use our own cursor routine.

Snarky

Is it possible to not use Allegro for mouse input?

Crimson Wizard

Quote from: Snarky on Fri 28/08/2015 17:30:08
Is it possible to not use Allegro for mouse input?
Of course, but I would need to use another cross-platform library, or write all the mouse code myself from scratch, at least for Windows and Linux.

Crimson Wizard

#50
Alright! Silly me... I actually found a way to completely disable Allegro acceleration.
It appeared it reads the base acceleration factor from config file, being 1 by default, and setting it to 0 would disable acceleration completely.
Thing is that AGS never registered any config file for Allegro.

I could let Allegro read from our own config file, but I am slightly concerned of option name conflicts. Therefore I went other way and generated config text for the library at runtime (it does not create any temp files in folder, but writes text in memory).

Here's the build:
http://www.mediafire.com/download/ki1nm72bfpfa2df/acwin_3.3.5-mouse-sens.zip

This build is based on 3.3.5 version (next update to 3.3, do not confuse it with 3.4.0 !).
As with previous experimental builds, following config options works:
Code: text

[mouse]
control = never | fullscreen | always // when to control mouse movement, fullscreen is default
sensitivity = 1.0 // mouse speed, uniform one, or optionally separate for X and Y axis
sensitivity_x = 1.0
sensitivity_y = 1.0

al_win_mouse_accel_factor = 0 // to adjust Allegro's acceleration (integer values only)

I am letting to set Allegro acceleration for easier test of difference between having and not having it.
Original value is 1. Setting higher values will make acceleration extreme.

Mind, that this acceleration really works only in Windows...



A note on sensitivity. It appears my "default" mouse speed is faster from Allegro's fullscreen by factor of 2. This is because Allegro uses additional mouse input / pixel conversion, dividing mouse motion by 2. I am not sure why it is doing that.
Anyway, with sensitivity config you can return old speeds back (set sensitivity = 0.5). But I think this is too slow.
For my personal preference sensitivity = 1.5 works pretty well.

To achieve original AGS control feel:
Code: text

[mouse]
sensitivity = 0.5
al_win_mouse_accel_factor = 1



Since I've been spoiled by Microsoft's Pointer Precision, I might try adding configurable mouse acceleration later.

Problem

This is excellent news! So to get it straight, if I set al_win_mouse_accel_factor to 0, I do get the mouse driver acceleration like the Windows dekstop, but I don't get any additional acceleration from Allegro?

Crimson Wizard

#52
Quote from: Problem on Fri 28/08/2015 22:26:15
This is excellent news! So to get it straight, if I set al_win_mouse_accel_factor to 0, I do get the mouse driver acceleration like the Windows dekstop, but I don't get any additional acceleration from Allegro?
You know,... I was about to tell that you do not get any acceleration from Windows desktop, but then I tested this out, and in fact you do.
Pixel Precision setting affects fullscreen AGS too!

I am still not sure whether mouse speed fully matches the desktop one. For better tests I would need to use the 3.4 branch and test mouse speeds in game running in my desktop resolution.

Crimson Wizard

#53
Made test build for 3.4.0 too.

To list available ones:
* 3.3.5 with mouse sensitivity
* 3.4.0.7 with mouse sensitivity


In regards to tests: it appears that a) cursor movement is now linked to your desktop settings; b) it does not take resolution into account, which means that running with smaller display resolution makes cursor movement faster. Latter is true for both Allegro's and my code.
(Well, this is true for Windows, so...)
Allegro code has an attempt to rely on resolution, but the factor is applied only to acceleration, which we hate so much. I am going to try applying similar factor to mouse speed instead. My idea is that sensitivity "1" should feel about same way in any resolution.

Snarky

Great work, CW! I've never had mouse problems myself, or I'd help test it.

Crimson Wizard

Well, it will be good to test that it remains usable for you too. :)

Problem

I can confirm that the mouse movement is a lot better now, and that lower (display) resolutions make the mouse pointer faster.

Michael Davis

#57
So to try out this latest 3.4 test build we just overwrite the acwin.exe inside our existing AGS folder? Are there any settings we need to change along with it?

Crimson Wizard

Quote from: Michael Davis on Mon 31/08/2015 01:53:45
So to try out this latest 3.4 test build we just overwrite the acwin.exe inside our existing AGS folder? Are there any settings we need to change along with it?

You are not required to change any settings in your game project, but you may try adjusting the mouse behavior by manually modifying acsetup.cfg, as explained here: http://www.adventuregamestudio.co.uk/forums/index.php?topic=51695.msg636519799#msg636519799

In the final release there will be more convenient means to do so.

Michael Davis

#59
Ha! Total coincidence, yesterday a YouTuber left a comment on my game's GameJolt page saying he had made a series of Let's Plays of it, so I started watching it today and you can see in his first episode, at around 07:15, the player "discover" the mouse acceleration bug:

https://www.youtube.com/watch?v=n_LVDkTOsAQ

He's using the mouse to scroll along some words he's reading, and the mouse cursor suddenly takes off when he hits the mouse movement speed threshold that triggers the acceleration.

So if you didn't have concrete evidence of the behaviour yet there it is. I can certainly vouch that my Logitech mouse behaves lousy in the current 3.4.0.6 alpha, in this specific way, I mean, so I'm really excited to test your latest patch! Thanks for everything you do, CW <3

edit----
Also, it just occurred to me, that he would have been playing my game that was compiled with AGS 3.3.3, so this must not be a new issue?

SMF spam blocked by CleanTalk