[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] Re: Problem with mouse going back to the center of the screen



You can clearly see it if you add this code in the event handler:

293                 elif event.key == K_a:
294                     pygame.mouse.set_visible(False)
295                 elif event.key == K_z:
296                     pygame.mouse.set_visible(True)

At the very beginning i do pygame.event.set_grab(False)
then if you try to press key z to show the mouse, then mouse it, press
a to hide it: you'll see the "virtual input" mode is activated.
I'm pretty sure this is a bogue.
Please tell me if you can reproduce it under Linux, thanks a lot!


Olivier Pons

On 21 juil, 17:39, SurferIX <olivier.p...@xxxxxxxxx> wrote:
> Ok you were right.
> Here is the summary: with Linux:
>
> pygame.event.set_grab()
> pygame.mouse.set_visible() :
>
> grab => False, visible => False => "virtual input" mode
> grab => True, visible => False => "virtual input" mode
>
> grab => False, visible => True => normal mode
> grab => True, visible => True => normal mode
>
> So as long as the mouse is not visible, it's considered "virtual
> input" mode
> I'm pretty sure this is a bug.
> I hope someone will try this my code under Linux and tell me if it's
> the same problem or not.
>
> You cant get the whole sourcecode here:http://olivierpons.com/einstein.tar.bz2
>
> By the way, Enigma (the only fullscreen SDL game I've tested under
> Linux) has exactly the same problem.
>
> On 21 juil, 05:36, Brian Fisher <br...@xxxxxxxxxxxxxxxxxxx> wrote:
>
>
>
> > The only time I know of where that maybe is supposed to happen, is when the
> > mouse is both grabbed by the window, and invisible. SDL takes that to mean
> > you want "virtual input" mode, where the mouse is moved back to the center
> > so you can keep getting relative mouse movement infinitely in all
> > directions, so it can behave like a trackball. This is documented here:http://www.pygame.org/docs/ref/mouse.html
>
> > If this is your case. and relative mouse movement is fine, try using the
> > mouse event's .rel member instead of it's .pos member, or using
> > pygame.mouse.get_rel instead of .get_pos
>
> > if this is your case, but virtual input is not desireable, reconsider
> > whether pygame.event.set_grab(true) and pygame.mouse.set_visible(false) are
> > actually functions you want to call.
>
> > if this is not your case, it's a bug, and a minimal sample to reproduce
> > would be appreciated.
>
> > On Tue, Jul 20, 2010 at 2:32 PM, SurferIX <olivier.p...@xxxxxxxxx> wrote:
> > > Hi!
>
> > > I've got a problem with the mouse: it's going back to the center of
> > > the screen!
> > > I don't know where it could come from because it does this only in
> > > full screen.
> > > It's exactly the same problem with the game Enigma.
>
> > > It seems there's a problem either with SDL or with my computer. But if
> > > it's with my computer why only in full screen?
> > > Did you have any trouble like that?
> > > Thanks a lot!