tracking mouse when its outside the applet window without using jinput

Is this even possible? Cause in my game you control your shield and sword with the mouse and the mouse only activating when its in the applet window is a complete disaster.
Why didnt they implement “x moved difference” instead of “x absolute coordinate” cause thats what I need!

you can use AWT’s MouseInfo for this

http://java.sun.com/j2se/1.5.0/docs/api/java/awt/MouseInfo.html

Interesting, I never knew that class existed 8)

I wonder if getPointerInfo() throws a security exception by default… i’ll test it when I’m home

Cool thanks, that works.

I cleared up a bug with that too!

Only problem is I cant get the mouse “vectors” all this means is when the mouse scrolls to the side of the screen id like it to still keep on reading mouse movement, cause if I dont when the mouse reaches the end of the screen the shield will stop moving around the character even if you meant for the character to keep shifting the shield across, its just that you’ve hit the side of the screen and its stopped moving, even though your still moving the mouse!

Like at the moment, to get mouse vectors I am comparing the old mouse position to the new one, but when it hits the side of the screen it stops working…

Is there a way around this?

I dont really mind the security warning, cause jinput needs it to so theres no way around it.

It better throw one otherwise something is broken :slight_smile:

personally I think your approaching this problem wrong, you shouldn’t really need to jump all these hoops to get decent game controls, plenty of other games do it fine without all this extra stuff. Instead I recommend that you grab the mouse and release it when its not absolutely needed.

For the style of game im making I need this, its how the whole idea works.

If I was just happy with keyboard controls, and I was making a simple hack at the enemy combat game then I probably wouldnt need to go to the trouble, but im writing a combat “sim” and I need mouse controls for the arms of the character.
I dont want to have to change my idea just because im using java.

I spose jinput probably could do it so ill just learn that.

Hang on, Ive got another idea… What if I continually set the mouse position to the centre of the screen? Can I do that??

Mouse drags keep coming even when the cursor is outside of the frame (and probably applet). Maybe use mouse drags?

I suppose, but I can’t think of a program that uses a graphical interface with number button on the screen to enter a PIN code :stuck_out_tongue:

java.awt.Robot can do that, and LWJGL has some methods to do that too. Both require full security priveleges

Thanks Commander Keith.

+1 to grab the mouse.