Skip to main content
GameDev.net gamedev.net
🔒 Locked

[java] Mouse Sensitivity

Started by kratz Dec 29, 2006 at 1:49 AM 6 replies 2.9k views
Original Post
kratz
kratz
Anyone have any idea how I might set the mouse sensitivity programmatically from within my app? I'm working on a FSE mode game and need to slow down mouse movement. Any ideas? Thanks Kratz
---------------------------Noobies have feelings too!!----------------------------
Smit
Smit
Windows, Mac and/or Linux?
kratz
kratz
Well I was hoping for a cross-platform solution since I'm using Java but I'm working on a Windows XP machine.

Thanks
kratz
---------------------------Noobies have feelings too!!----------------------------
Son of Cain
Son of Cain
Update whatever is controlled by mouse sensitivity based on a correction of the delta value, using a constant value that can be adjusted to give a more/less sensitive feedback on the output. The adjusting constant can be on a 0 to |1| scale, like the previous poster suggested.

double new_delta = delta * sensitivity; 
a.k.a javabeats at yahoo.ca
harveypekar
harveypekar
Do you still want to show the cursor on the screen (like an rts), or is it invisible (like in a fps),

If you want it to show, you could use java.awt.Robot to move it. You would still have to change the delta (see poster above) of course.

Cheers
kratz
kratz
Thanks for the suggestions guys but I'm not sure how to get a delta value from the MouseEvent item. How do I know where the mouse started and where it ended?

Thanks,
kratz
---------------------------Noobies have feelings too!!----------------------------
harveypekar
harveypekar
MouseEvent gives you where the mouse started, through the methods getX() and getY(). You should have stored the previous mouse position somewhere, so you can calculate the delta now:

float sensitivity = 0.8f; //make it go slightly slower

float changeX = mouseEvent.getX() - oldX; //we stored this somewhere

int newX = oldX + change*sensitivity;

Same for calulating Y...

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.