Carsten Haubold wrote: > I'm using FLTK to manage the window specific stuff for my 3D-Engine. > The Fl_Gl_Window was able to do anything I liked, but now I wanted to add > mouse-look, and I'd need to fix the mouse cursor or set it to a certain > position every frame... > Is there any way of doing this? Like a setMousePos(x,y) or so?
A while ago I found some posts here about this issue, but i can't seem to find them anymore, but among them was the following function to solve this problem: int jump_cursor (int new_x, int new_y) { #if defined WIN32 BOOL result = SetCursorPos(new_x, new_y); if (result) return 0; // OK #elif defined __APPLE__ CGPoint new_pos; CGEventErr err; new_pos.x = new_x; new_pos.y = new_y; err = CGWarpMouseCursorPosition(new_pos); if (!err) return 0; // OK #else // Assume this is Xlib Window rootwindow = DefaultRootWindow(fl_display); XWarpPointer(fl_display, rootwindow, rootwindow, 0, 0, 0, 0, new_x, new_y); return 0; // Assume OK #endif return -1; // Fail } // jump_cursor I have used it successfully on linux and on windows. It sets mouse pointer to a screen position (new_x,new_y). So If you have a top level window, w, and you want to warp the pointer to a position (x,y) in it, to a position in a window 'w', you need to write: jump_cursor(w.x()+my_x,w.y()+my_y); If w is a subwindow then you write: jump_cursor(w.parent().x()+w.x()+x,w.parent().y()+w.y()+y); _______________________________________________ fltk-opengl mailing list fltk-opengl@easysw.com http://lists.easysw.com/mailman/listinfo/fltk-opengl