mouse sensitivity

Member
Posts: 61
Joined: 2007.01
Post: #1
Hey,

I'm trying to improve the movement of the cursor/pointer on a board game in GLUT (I know it's old hat at this stage but I've started so I'll finish!).

At the moment I have the cursor moving from board square to board square but it moves _way_ too fast, so I've been trying to slow it down.

Right now, the way I've thought of doing it (and I think it's a bit of a hack way) is I have a "sensitivity" value (which is a number of pixels) and I calculate the delta of the mouse's x coordinate between frames.

If the delta is greater or equal to the threshold the cursor moves to the next square.

so, in pseudo code:

int delta_x = currX - prevX;
int sensitivity = 20;

if (delta_x >= sensitivity)
// move to next square

I was wondering if anyone else has dealt with this problem in the past?

Cheers!
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #2
what about somthing like:

deltaX = (currX - prevX)*sensitivty;
if(deltaX > 1) ...

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Member
Posts: 61
Joined: 2007.01
Post: #3
Thanks unknown, i like that solution!
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #4
You're going to want the sensitivity to be a float for greater precision, and you may want it somewhere closer to 1.
Quote this message in a reply
Member
Posts: 61
Joined: 2007.01
Post: #5
akb825, I have all the values as floats to allow for greater control of their sensitivity but thanks for replying to my post!
Quote this message in a reply
Post Reply