[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Grabbing the pointer with OpenGL
On Wed, 11 Apr 2001, Steve Baker wrote:
> Mads Bondo Dydensborg wrote:
>
> > The solution I have devised, uses glutWarpPointer to make the mouse stay
> > in the center of the window, then glutPassiveMotionFunc to get the
> > events. This works, controlwise, but quite often the mouse escapes my
> > window for a brief moment, then returns. Which is annoying.
>
> You can move the mouse all the way from the center of the window (where
> you are presumably warping it to) to the edge of the window in less than
> one iteration of your games' main loop?
> Wow!
>
> You either have a VERY fast hand - or a VERY slow program! ....OH!...
> *OR* you may have your mouse set up to be super-sensitive or have
> mouse 'accelleration' turned on.
Well, I use a Ppro 232 with a dual V2 and a Matrox millinium - which means
that I render into software when I do not run fullscreen. My game runs at
about 4 fps in wireframe mode in software. In a small window.
>
> I guess you could make the mouse less sensitive. You can do that
> with the 'xset mouse ' program - but I have no idea how you do that at
> the level of X-windows calls (but you have the source to 'xset' - so
> you can find out and tell us!)
Maybe this was a good idea. A quick ltrace seems to indicate the
"XChangePointerControl" is the call. The man page seems to confirm this.
Then I only need to figure out how I find my display - which would seem to
be XOpenDisplay. (To get the current values of the pointer,
XGetPointerControl would seem to be the preferred choice).
If I can not get things to work with glutWarpPointer, then I think I will
be looking into this.
(btw: ltrace is wonderfull, if you do not have the source to a program
that you are almost certain uses libs. I know I could download the source,
but this took about 10 seconds to do).
>
> You'd want to be VERY careful to restore it when the game exits
Yes.
> and (my pet hate) be sure to allow a way to 'release' the mouse during
> the game (maybe in Pause mode or something) so that you can park the
> game and do something else.
I totally agree. I have a button for releasing the mouse already, and
actually prints;
"Warping pointer - hit 'a' to disable (default mapping)"
as the first line of output from the program. (Which you can only see if
you are running it from a terminal, but at this stage, I think I have zero
users.
I hate it when some silly program grabs my pointer, but I do not know how
to achieve the effect otherwise.
>
> I'm sceptical about this though...
>
> * Are you *sure* you warp the pointer EVERY frame?
I warp the pointer in the glut callback function. (And sets a flag to
avoid endless loops - is there a smarter way to avoid this?)
> * Are you putting it into the MIDDLE of the window?
Yes.
>
> > So, what do you guys use?
>
> glutWarpPointer...or XGrabPointer if I'm not using GLUT for some reason.
If you use glutWarpPointer, I guess I can too. ;-)
>
> > I have looked at XGrabPointer, but I ran away scared by the man page. And
> > it is not very portable either, I guess.
>
> ...and in any case, that's all glutWarpPointer does.
I thought it called XWarpPointer?
>
> > I would like to stay with OpenGL and glut if at all possible - these are
> > the only libraries my game depends on at the moment.
>
> Good plan!
Well, that depends. For my next project I want to use libraries (I plan to
use plib, btw - people keeps recommending it :-). For this I plan on
trying to do things myself, as part of a learning process. (Which may or
may not be a good thing).
Thanks for your help - as usual it was very helpful.
Mads
--
Mads Bondo Dydensborg. madsdyd@challenge.dk
THE COURT: I'm delighted, Doctor, that this is plain English to someone.
- From DeCSS trial transcript, regarding a plain text describing of DeCSS.
http://www.cs.cmu.edu/~dst/DeCSS/Gallery/touretzky-testimony.txt
---------------------------------------------------------------------
To unsubscribe, e-mail: linuxgames-unsubscribe@sunsite.dk
For additional commands, e-mail: linuxgames-help@sunsite.dk