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 & HelpOpenGL and 3D Libraries › Setting cursor boundaries
Page Index Toggle Pages: 1
Setting cursor boundaries (Read 1467 times)
Setting cursor boundaries
Jan 11th, 2010, 11:17am
 
Hello all,
I was wondering if it's possible to have the cursor not leave the processing window? I am using the openGL face tracking to control the mouse and essentially control various things in processing by moving one's face and this application only really works if I can keep the mouse inside the processing window.

Thanks in advance
Re: Setting cursor boundaries
Reply #1 - Jan 11th, 2010, 12:03pm
 
you always get the mouse coordinates using mouseX and mouseY. so if the mouse leave the window you still get the latest coordinates. what else do you want ? but you are using the tracking instead of the mouse anyway so i dont really see where the problem is. you are getting some kind of coordinates using the tracking, how can this leave the screen if the face cant ?
Re: Setting cursor boundaries
Reply #2 - Jan 11th, 2010, 12:46pm
 
maybe I was unclear..I am basically making a drawing tool that is controlled by face tracking, but the mouse jumps out of the processing window and when it re-enters it makes a lot of lines etc.

I also have it controlling a pong game and if the mouse leaves the processing window then the paddle doesn't move anymore until they can get the mouse back into the processing window...face tracking isn't perfect so that takes some maneuvering and it makes the game unplayable.

I just need to limit where the mouse can go to the size of my window, but I don't know how. Thanks
Re: Setting cursor boundaries
Reply #3 - Jan 11th, 2010, 12:51pm
 
i guess i still dont get it.
the coordinates you get are already within the sketch boundaries. if the mouse leaves, they stay what they have been when they left the screen. if you reenter the screen you get  new coordinates.

is the face tracking part of the processing sketch or is it an external software that controls your mouse cursors ?

I am not sure if this is a tracking problem. If you would use the mouse instead. wouldnt you have the same problems when leaving the screen ?
Re: Setting cursor boundaries
Reply #4 - Jan 12th, 2010, 3:22am
 
Cedric wrote on Jan 11th, 2010, 12:51pm:
is the face tracking part of the processing sketch or is it an external software that controls your mouse cursors

I'm using the robot class to control the actual mouse, not a fake mouse, so it still has all the functionality of a real mouse, including clicking and moving around the entire computer screen. I'm using this in combination with the openGL face tracking in my processing sketch, but because the openGL face tracking is so jumpy, I need to make it so the mouse (controlled by robot) doesn't leave the processing window. Sorry for any confusion, I'm very new at this! Smiley
Re: Setting cursor boundaries
Reply #5 - Jan 29th, 2010, 4:57pm
 
Constrain the mouse position with robot.mouseMove(constrain(mouseX, 0, width), constrain(mouseY, 0, height))

Page Index Toggle Pages: 1