We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › How to set the mouse position
Page Index Toggle Pages: 1
How to set the mouse position (Read 812 times)
How to set the mouse position
Mar 27th, 2006, 7:41pm
 
I am making a 3d fps game.  I want to use the mouse to "look around".  the problem is that it hits the edge of the screen.  I want the mouse to be able to move forever in any direction without hitting the edge of the screen.  Is there a way to do that?  Can I reposition the mouse to the center of the screen each timestep??  I tried

mouseX = screen.width/2;
mouseY = screen.height/2;

in the draw method... but it doesn't work.

TIA>
Re: How to set the mouse position
Reply #1 - Mar 27th, 2006, 8:07pm
 
It is possible, using something called the Robot class.

http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Robot.html

However it should be noted that you'll not be able to use this in an online applet, unless you sign it, due to the potential for evil if you can control the mouse.
Re: How to set the mouse position
Reply #2 - Mar 28th, 2006, 5:03pm
 
here's a much longer discussion of the same topic,

http://processing.org/discourse/yabb/YaBB.cgi?board=Contributions_Beyond;action=display;num=1102415302
Re: How to set the mouse position
Reply #3 - Apr 11th, 2006, 8:24pm
 
Digging deeper... this is really a mess!!  I tried to use a Robot to set the mouse position, and aside from the headache of signing the applet, it also doesn't work because the Robot runs in SCREEN COORDINATES and mouseX mouseY are in WINDOW COORDINATES.  When the user moves the window, my 3D world begins to spin madly.  From what I can tell, there is NO WAY to convert between the two.  I think processing should have a topleft.x and topleft.y status in addition to the width and height.
Page Index Toggle Pages: 1