View Full Version : Mouse problem using glut

07-05-2000, 02:27 AM
I created a function handler for the mouse motion. It simply takes the x and y parameters and update the coordinates of a 3D object according to them.

It runs well, except when I move the mouse too far in the bottom of the screen. Doing this cause the mouse to stop responding unless I go up enough again.

This bug reminds me of problems when running a windowed program, but mine runs in fullscreen...

07-05-2000, 02:00 PM
Well i am searhing something that you are searhing... :)) i think...

Like q3 when you move the mouse anywhere after a few moves the vision of player doesn't stop but when we code this ourself :)) it is stopping. Are you want to move the mouse with unlimited positioning?
if it is and if you learn it please help me too :) thanks

tip : wm_mousewheel is the starting point i think :) hım?

bye :))

07-05-2000, 02:08 PM
dont know if you want to use glut to do this... but i would do it this way for win32

SetCursorPos(nScreenWidth/2, nScreenHeight/2);


static void GetMouseInput(void)
POINT Point;
long x;
long y;


x = Point.x;
y = Point.y;

dx = ((float) (((float)nScreenWidth/2.0f) - Point.x)); // how far moved x
dy = ((float) (((float)nScreenHeight/2.0f) - Point.y)); // how fa moved y

SetCursorPos(nScreenWidth/2, nScreenHeight/2);

as you can see this sets the mouse pointer to center screen upon init

then in your loop is checks how far the mouse has moved records it in dx and dy
then resets the mouse to center screen again for the next pass.

this way your mouse can always move as it never reaches the end or bottom of screen.

07-06-2000, 07:30 AM
that's nice. and scaling dx and dy give you adjustable mous sensitivity.

07-06-2000, 10:45 AM
thanks for the answers, but i'm using linux, so this doesn't help me. maybe I should try on the linux specific forum...

07-06-2000, 12:23 PM
It shouldnt be a problem to use the same routines on any platform. Just replace the function calls with the platform specific functions. I cant tell you what they are under linux but it shouldnt be hard for you to find out.

07-06-2000, 01:04 PM
This is fine for fullscreen, but I'd be very wary of locking the mouse to the centre if you're ever going to be running in a window!

07-06-2000, 02:15 PM
Speaking of a problem like that...

I have my app scan for keycodes, now this works fine only problem being when the key is hit inside my app i want only my app to accept those key presses. It also works the other way around. If i am running in a window (even if the window is not active) and i hit one of my keys in a text editor my app also picks up the key press and reacts to it. Any ideas on how i can keep my key presses exclusive to my app?

Ill start a new topic on this so dont bother replying here.

07-06-2000, 11:58 PM
Originally posted by MikeC:
This is fine for fullscreen, but I'd be very wary of locking the mouse to the centre if you're ever going to be running in a window!

umm not if you do ShowCursor(FALSE);

btw, first I tried to set the mouse to the center of the screen that didn't work...

then I tried the following:

if ((mx<0.1F*windw) &#0124; &#0124; (my<0.1F*windh) &#0124; &#0124; (mx>(windw-0.1F*windw)) &#0124; &#0124; (my>(windh-0.1F*windh)))

but this didn't work too well, because if you move the mouse fast enough (in window mode)... the mouse would get out of the window!!!

then I added these lines to my CreateWindow code:


and this line to my Killwindow code:


07-07-2000, 12:31 AM
ngill, I'd have thought hiding the mouse only makes matters worse. My point isn't that having a mouse stuck in the middle of your screen is ugly, my point is that when I'm running an app in windowed mode I expect to be able to use the mouse as usual, to drag or close or resize the window, change focus etc etc.

dans, if you're doing async keyboard scans directly then I don't think there's any way to filter keypresses by app. I'm doing my Win32 keyboard stuff a different way, keeping my own table of key states to answer queries and updating the table when I get key msgs in wndProc. Probably not very efficient but makes cohabitation with other apps a lot easier.

[This message has been edited by MikeC (edited 07-07-2000).]

07-08-2000, 05:48 AM
they you have a key or an event that lets go of the mouse http://www.opengl.org/discussion_boards/ubb/smile.gif and then toggle it back again, once you're ready =)