Mouse sensitivity.

Started by Ethan D, Thu 20/05/2010 04:24:49

Previous topic - Next topic

Ethan D

I looked around and searched a little so forgive me if I overlooked it, but is there a way to change the sensitivity of the mouse from within a games script. 

I.E. Make it so that the player has to move the mouse further in order for the cursor to move the same distance.

I'm hoping there's a simple way to do it but I'm betting it won't be. 

Thanks in advance for all the great help!  ;)

Dualnames

There's no command to set mouse sensitivity in AGS. Khris once suggested a way of this to be done, and I recall it was a great idea, so let me look it up.
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)

Ethan D


Mr Flibble

As far as I know the mouse sensitivity in AGS is taken from that of Windows. You could simulate different speeds by manually relocating the cursor relative to the user's movements (which I'm guessing is what Khris's suggestion will be) but it's not a trivial piece of coding.

To lower sensitivity, you'd want to adjust the cursor so that it only "moves" when you tell it to, as opposed to relative to the actual speed of the mouse. Infact, you'd probably want to do this with an invisible cursor and a cursor sprite which follows it, appearing to be the cursor. It'd mess up if you clicked while moving so you'd probably want to disable that.
Ah! There is no emoticon for what I'm feeling!

Khris

The thing is, you can only make the cursor go faster this way. Slowing it down is possible, but then the screen borders aren't reachable any longer.
I guess one could somehow work around that, changing the mouse position every few loops etc., but it's gonna get quite messy.

Ethan D

#5
Like this Mr. Flibble?


1. Create an object named Cursor.

Code: ags
Under repetedly execute.
{
  if (puzzle)
  {
  Cursor.Graphic = mouse.GetModeGraphic(mouse.Mode);
  Cursor.x = mouse.x;
  Cursor.y = mouse.y;
  Cursor.Visible = true;
  mouse.Visible = false;
  puzzle = false;
  }

  if (mouse.x >= Cursor.X +2)
  {
  Cursor.X += 1;
  mouse.SetPosition(Cursor.X, mouse.y); 
  }

  if (mouse.y <= Cursor.Y -2)
  {
    Cursor.Y-1;
    mouse.SetPosition(mouse.x, Cursor.Y);
  }

  if (mouse.y >= Cursor.Y +2)
  {
    Cursor.Y+1;
    mouse.SetPosition(mouse.x, Cursor.Y);
  }

  if (mouse.x <= Cursor.X -2)
  {
    Cursor.X -1;
    mouse.SetPosition(Cursor.X, mouse.y);
  }
}

I think this would work.....  Although, it may cause jerky movement.  To adjust the sensitivity you would just have to change a few numbers.

I may have overcomplicated it though.

Any thoughts?

Calin Leafshade

Couldn't you just grab a unit vector from the mouse object?

so you take the difference between the previous mouse coords and the current ones and normalise it.

Then you can multiply that unit vector by whatever mouse speed you like and reset the position of the invisible mouse cursor to the centre of the screen each loop and render the cursor yourself.

Dualnames

Additionally you can grab a Brownian motion, put the long dangly bit of the Plotter in it, and plug the Improbability drive on the small receptacle of the plotter.

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)

Calin Leafshade

you fool! You'll kill us all!

Ethan D

Well, now you've got me confused.  ???

Can you explain how to do what your talking about Calin?


Calin Leafshade

OK, sure.. but bear in mind that this method is likely to cause more headaches than it is worth.

Imagine you don't use AGS's mouse system for rendering or moving the mouse.. you merely use it as an interface with the mouse.

If after every frame you reset *AGS's mouse system* to the centre of the screen you can use the data from it's subsequent movement to find out in which direction and how quickly the user is moving the mouse.

so you reset the mouse to 160, 120.
the user moves the mouse
the mouse is now at 172,130
so the mouse has moved 12 pixels by x and 10 pixels by y.
you then multiply these values by whatever your sensitivity value is, say 0.5 for the sake of argument, which gives up 6 by x and 5 by y
you then add those values to your custom rendered pointers position (clamping at the edges of the screen of course)
then reset AGS's mouse pointer to the centre of the screen ready to receive input from the user the next loop.

this should work pretty well.. you just have to remember to use your custom mouse pointer's position for any clicking but that's simple enough.
you would have to fiddle with the gui button's clicking method since the AGS mouse would never actually be over any gui buttons but you can just use GUIControl.GetAtScreen

the good thing about this method is that mouse acceleration would still apply since we use AGS's mouse system for input.

I hope that helps

Ethan D

That's some pretty cool stuff there.  I really only need it for one puzzle, but I'll probably do it the way you suggested for the experience.

Not to mention that I think it would be somewhat neat to have a sensitivity scroll bar in the options.

Thanks Calin!

SMF spam blocked by CleanTalk