AGS Mouse Sensitivity and Acceleration

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

Previous topic - Next topic

xil

I've been doing a few tests on various devices as I've recently made a super low res game (160x90 in the new alpha 3.4.0.3) and have had issues with the mouse movement in fullscreen. No matter what settings I play with and what hardware I use, there still seems to be something off with the mouse movement (I'm not sure if anything was ever even addressed as the other topics just seemed to fizzle out months/years ago).

All tests have been windows 7 based using the following equipment:

  • a laptop (running at 1366x768) using the track pad
  • a laptop (running at 1366x768) using a default cheap mouse with no drivers
  • a desktop PC (running at 1080p) using a high end razer gaming mouse (razer synapse drivers - similar to logitech and set point I imagine)
  • a desktop PC (running at 720p) using a default cheap mouse with no drivers
I've used pretty much all of the combinations of settings to scale the game when in fullscreen and all act the same.

The best fullscreen mouse movement seems to be split between the laptop using the track pad and the desktop PC 720p with default mouse no drivers. The worse movement is on my desktop PC with the razer mouse tweaked for optimal FPS settings (high DPI, polling rate etc).

However, in every single case, no matter what tech or drivers, there is definitely mouse acceleration present (I play a lot of FPS games so I know when my mouse doesn't feel right). It ranges from barely noticeable to horribly evident and unusable. My problem is that whatever settings I set my razer mouse/windows settings to (0 acceleration everywhere possible) it is still present when running fullscreen in the AGS engine.

I can live with no settings to change sensitivity in game as it's trivial to set my mouse speed to whatever works with the game (sensitivity options for the user would be perfect, but not needed).

But why does AGS apply acceleration seemingly hard wired in?
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

Crimson Wizard

#1
After some research I found that the mouse acceleration parameter for fullscreen mode is set up inside Allegro library using some curious formulae, where screen metrics are input parameters.
Code: cpp

/* mouse_directx_set_range: [primary thread]
 */
static void mouse_directx_set_range(int x1, int y1, int x2, int y2)
{
   <...>

   /* scale up the acceleration multiplier to the range */
   mouse_accel_mult = mouse_accel_fact * MAX(x2-x1+1, y2-y1+1)/320;
}


By tweaking that code I could find a value that worked well for me... (it was "mouse_accel_mult = 2;" or "3", while formulae gave result of "5")

I also could find that "mouse_accel_fact" parameter can be read from config file, but only using built-in Allegro config system (which AGS does not use, it seems); nevertheless, using this parameter alone does not allow me to set the fine speed: value "1" is faster, and value "0" is too slow.

(these params should be real numbers instead of integers :()

This should be researched some more... but I guess I should either modify the formulae, or just allow AGS get deep into Allegro internals and set this value from its own config.

Dualnames

As this have been trackered by me, a month ago or so, from what I gathered is that AGS grabs the x and y directly from the input given from the mouse device. Thus acceleration done by software will always mess things up. For some weird reason, when on fullscreen, the mouse behaves a bit weird, barely noticeable, but still there.

http://www.adventuregamestudio.co.uk/forums/index.php?topic=51548.msg636504981#msg636504981

I even tried some sort of software acceleration hoping that the allowance of mouse speed alteration via software would fix the issue, but to no avail.

Digging deeper into this, I did find out that Allegro allows the setting of the mouse-speed, but i believe even with the mouse sensitivity option existing, the issue remains elsewhere. As far as I could tell, AGS is using Allegro to get the X,Y of the mouse and then assigns a sprite to the cursor, and then sets the X,Y pos somewhere else, for some reason, I couldn't tell myself, the issue is terribly annoying on full screen.

I'm prolly talking non-sense.
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)

xil

Hi, sorry Dualnames, I was searching for mouse acceleration so missed your post.

I've tried the code you posted but didn't have much luck I'm afraid (the code that monkey_05_06 modified unfortunately didn't help either, if anything it was worse).

Crimson Wizard, the screen metrics being input parameters seems interesting as my tests do indicate that the problem is less evident the higher the resolution of the game but I have even tested a full 1920x1080 game running and the mouse acceleration makes the game (for me anyway) unplayable. If I needed to do any sort of precision movement within say 100 pixels then it's OK but if I need to just move around the screen it accelerates beyond control.

When you talk about the value 0 for mouse_accel_fact being too slow, what do you mean exactly? Does it feel like acceleration is off, but the mouse speed is stupidly slow? I'm afraid my knowledge of allegro and windows programming in general is very limited.

Does it not differ between accelerating the mouse and the speed of the mouse? E.g. I would expect as a user that if the acceleration was turned off and my mouse speed was very low, I'd just hop into the settings and increase the mouse speed to suit.
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

Crimson Wizard

Quote from: xil on Thu 05/02/2015 07:21:23
When you talk about the value 0 for mouse_accel_fact being too slow, what do you mean exactly? Does it feel like acceleration is off, but the mouse speed is stupidly slow?
Well, it is stupidly slow. Like 10 times more slow than the windows cursor (speaking of feelings here, I did not actually make any measures).


I cannot answer other questions yet. My previous post was just a quick note.
I am searching through Allegro forums now to see what they say about this problem.

xil

Yea it could be stupidly slow because the engine was set up by default to have a medium amount of acceleration. If that was always on by default then in theory I understand  why the mouse speed would be hardwired so low.

Thanks for having a look anyway, hopefully the stupidly slow mouse speed was due to eliminating acceleration and now it's just a case of upping the speed in another way.
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

xil

Quick update, I found a forum post from a user stating that allegro 4 has issues with fullscreen mouse acceleration and that allegro 5.0.5 'fixed' the issue. I say 'fixed' as he states: "i had to port my infinite perlin noise terrain generator to allegro 5.0.5 to get the mouse to work in fullscreen without annoying excessive acceleration." - so it might just be useable rather than removed.
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

Crimson Wizard

Well, Allegro 5 code is in numerous ways not compatible with Allegro 4. I will check the lib sources to see how they solved it though.

Regardless, I would not like to change anything in libraries, unless there's just no other way.
I am currently interested in testing out another solution I found, using get_mouse_mickeys function. If I use it instead of just getting x,y coords Allegro provided me with, I could override its acceleration mechanics. If that actually works, this solution would have such benefit as 1) portability, 2) easier implementing user setup.

Knox

With all of this being potentially "fixed", would it be then possible in the future for the player being able to tweak mouse sensitivity/acceleration to his/her liking in the game settings as well?
--All that is necessary for evil to triumph is for good men to do nothing.

Crimson Wizard

#9
Quote from: Knox on Mon 09/02/2015 17:34:02
With all of this being potentially "fixed", would it be then possible in the future for the player being able to tweak mouse sensitivity/acceleration to his/her liking in the game settings as well?
Yes.

Dualnames

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

#11
Quote from: Crimson Wizard on Mon 09/02/2015 13:19:26
I am currently interested in testing out another solution I found, using get_mouse_mickeys function.

Well, I must point out that this will work in fullscreen mode only.
Allegro does not let me control mouse position outside of the window, therefore I can't know actual cursor coordinates on screen, can't even know when mouse left the game window. Since I keep adjusting cursor position, mouse can't leave the window at all.
For sensivity to work in windowed mode I would need to descend to OS API mouse functions.


Snarky

Quote from: Crimson Wizard on Thu 12/02/2015 13:42:20
Well, I must point out that this will work in fullscreen mode only.
Allegro does not let me control mouse position outside of the window, therefore I can't know actual cursor coordinates on screen, can't even know when mouse left the game window. Since I keep adjusting cursor position, mouse can't leave the window at all.
For sensivity to work in windowed mode I would need to descend to OS API mouse functions.

That sounds fine to me. In Windowed mode I would normally expect the cursor to move uniformly across the screen according to the Windows sensitivity/acceleration settings, whether or not it's on top of the AGS window.

xil

Quote from: Crimson Wizard on Thu 12/02/2015 13:42:20
Quote from: Crimson Wizard on Mon 09/02/2015 13:19:26
I am currently interested in testing out another solution I found, using get_mouse_mickeys function.

Well, I must point out that this will work in fullscreen mode only.
Allegro does not let me control mouse position outside of the window, therefore I can't know actual cursor coordinates on screen, can't even know when mouse left the game window. Since I keep adjusting cursor position, mouse can't leave the window at all.
For sensivity to work in windowed mode I would need to descend to OS API mouse functions.

I second that that would be absolutely fine. Id hesitate to say that's exactly how it should work anyway.
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

Crimson Wizard

Hmm, I actually found a way to have it working on windowed mode too. Basically, custom sensivity ony works when the cursor is in the game boundaries.

Here I made a test build:
http://www.mediafire.com/download/gtjbfbo0p2407ki/acwin_3.4.0.3_mouse-sens.zip

Setup parameters to be added to acsetup.cfg:
Code: text

[mouse]
ags_control = 1 // to enable AGS sensivity management
sensivity = 1.0 // overall sensivity (floating point value)
sensivity_x = 1.0 // optional separate sensivity for x
sensivity_y = 1.0 // optional separate sensivity for y

xil

Hi CW,

Thanks for putting together that test build. I've had a little play around but will get you some proper tests on different setups done hopefully in the next couple of days.

Unfortunately the only test I've managed to do (using my gaming mouse with stupidly high DPI and custom drivers e.g. the stuff that seems to mimic the Logitech Setpoint issues) hasn't worked 100%. The actual changes do have an effect and I can now control the sensitivity but there is still a point at which acceleration is applied and I lose control of the mouse.

Good part of the test:

  • the ability to control the mouse by moving it carefully is MASSIVELY improved, literally to the point where it would be playable
  • works great in windowed mode!

Bad part of the test:

  • the mouse can go "out of bounds" and you have to carefully bring it back to gain control of the pointer image again
  • it's possible to almost completely "lose" the mouse as there just seems to be no bounds anymore

On a side note, I might be being stupid but are the setup commands spelled incorrectly?
sensivity = 1.0 // overall sensivity (floating point value)
sensitivity = 1.0 // overall sensitivity (floating point value)
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

Crimson Wizard

#17
Quote from: xil on Wed 18/02/2015 05:14:41
the mouse can go "out of bounds" and you have to carefully bring it back to gain control of the pointer image again
Well, this is essential for the windowed mode. I do not want to bring much technical details here, but in short, when mouse has left the window I loose the ability to know its proper coordinates and cannot control its position beyond the window (at least not with Allegro library); all I can do is getting the deltas of its movement, so I would know when it returns back. If I would alter its position as I do in game bounds, I would lock it inside game, so player would need to Alt+Tab to get to his/her desktop.
OTOH, that may be the way to do this?
E: Hmm, maybe you are speaking about black borders? I might have made a mistake there, letting mouse "loose" too early. I should do this when the mouse has left the window, not the game borders.

Quote from: xil on Wed 18/02/2015 05:14:41
it's possible to almost completely "lose" the mouse as there just seems to be no bounds anymore
Can you elaborate how this happens?

Quote from: xil on Wed 18/02/2015 05:14:41
On a side note, I might be being stupid but are the setup commands spelled incorrectly?
sensivity = 1.0 // overall sensivity (floating point value)
sensitivity = 1.0 // overall sensitivity (floating point value)
Umm... yeah, that is my bad english.

Snarky

I think xil was talking about the mouse going out of bounds in fullscreen mode?

I still think that in windowed mode you should just leave the mouse alone and let windows handle it. As a user, I don't expect the mouse movement to change depending on what window it's over.

Crimson Wizard

I fixed some mistakes, here is a new build for test:
http://www.mediafire.com/download/gtjbfbo0p2407ki/acwin_3.4.0.3_mouse-sens.zip

The options now are:
Code: text

[mouse]
control = always | never | fullscreen // mouse control kind
sensitivity = 1.0 // overall sensitivity (floating point value)
sensitivity_x = 1.0 // optional separate sensitivity for x
sensitivity_y = 1.0 // optional separate sensitivity for y

SMF spam blocked by CleanTalk