Jump to content
  • Advertisement
Sign in to follow this  
Isolier

[java] Exclusive Mouse Access

This topic is 4845 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, In my current project I generate terrain from a height map and the user may navigate around this virtual world. I am attempting to implement moving with the keyboard (a, d, w and s keys) and viewing with the mouse as in a first person shooter style move\look scheme. The issue I am having is "losing" the mouse as the user moves the mouse around because as soon as the cursor(which I have set to invisible) moves out of the client area it obviously stops sending mouse move messages to my application. Now I know there is a way to "trap" the mouse input because this is exactly what Jake2 does. When you load the game windowed or not the cursor disappears and mouse movement translates to looking around regardless of the operating systems interpretation of the where the cursor is. Anyhow, I have googled the crap out of this and just can't seem to find any information that pertains to my situation. So, any help would be very much appreciated, thank you in advance.

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
You can hack delta mouse movement with java.awt.Robot-class. You can get source-code too for free from brackeen.com. It's not a pretty solution but I guess it works. Though I'd suggest using LWJGL or JInput to get real delta movement.

Share this post


Link to post
Share on other sites
hi!

maybe just set the mouse-position back to the center of your application each time the listener is called...so your cursor is fixed in the center.

hope this helps

Share this post


Link to post
Share on other sites
I already have the cursor hidden, I just need to find a way to keep the cursor centered. I am beginning to think that a library such as JInput which will allow me to track mouse input at a lower level is the way to go.

Share this post


Link to post
Share on other sites
hi !

okay, i assumed you are using the MouseMotion Listener. what are you using to detect your mouse motion ?
i think using the MouseMotion Listener to get the movement and setting the mouse back to the center is pretty straight forward.

hope this helps

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by Isolier
I already have the cursor hidden, I just need to find a way to keep the cursor centered. I am beginning to think that a library such as JInput which will allow me to track mouse input at a lower level is the way to go.


So.. did you check out java.awt.Robot? It has a method mouseMove(x,y).

Share this post


Link to post
Share on other sites
Hello,

I am indeed using a MouseMotionListener however I am unaware of a method that sets the cursor where you want it. There is the translate() method but that simply sends a mouse message to the specified point as if the mouse were there, but does not actually move the cursor so the problem would be the same once the user moved the mouse to the edge of the screen. As far as the Robot class you must use signed jars if your going to use it because it has the potential to be used maliciously so I am trying to stay away from Robot. If it comes down to it I will just have to use JInput I suppose.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!