SDL Cursor!

Hi all!

does anyone knows about any bug with the SDL_ShowCursor(false) in fullscreen?

Running in windowed mode I have no problem… when I hide the cursor
SDL_ShowCursor(false)… (since the cursor is not visible its hard to tell) for
some reason my mouse look does not work in fullscreen… maybe its me but… it
is a pretty strange behavior!

THX

Hi all!

does anyone knows about any bug with the SDL_ShowCursor(false) in
fullscreen?

Running in windowed mode I have no problem… when I hide the cursor
SDL_ShowCursor(false)… (since the cursor is not visible its hard to
tell) for
some reason my mouse look does not work in fullscreen… maybe its me
but… it
is a pretty strange behavior!

What is your “mouse look?” It sounds like a game feature, specifically,
an FPS aiming control. Speak in SDL terms, not terms specific to your
own game. It eliminates ambiguity, and forces you to be more specific
about your program in useful, descriptive ways.

What OS are you running? What version? How are you building? What
version of SDL are you using? Does this happen with any of the SDL test
programs included in the SDL source code? Does this happen with any
other popular SDL applications?On Sep 13, 2004, at 10:14 PM, Golgoth wrote:

THX


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Donny Viszneki <smirk thebuicksix.com> writes:

What is your “mouse look?” It sounds like a game feature, specifically,
an FPS aiming control.

Yes

What OS are you running?

windows

What version?

XP

How are you building?

C++

What version of SDL are you using?

latest

Does this happen with any of the SDL test programs included in the SDL source
code? Does this happen with any other popular SDL applications?

no clues on this…

The one thing I m sure is…

one of those funtions does not deliver when SDL_ShowCursor(SDL_DISABLE) is set
in full screen;

SDL_WarpMouse(…)
SDL_GetMouseState(…)

in windowed mode it works beautyfully so far… so… I m pretty sure you can
considered it as a bug report! but I hope I m wrong…

Thx again!>

THX


SDL mailing list
SDL libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Donny Viszneki <smirk thebuicksix.com> writes:

What is your “mouse look?” It sounds like a game feature,
specifically,
an FPS aiming control.

Yes

What OS are you running?

SNIPSNIPSNIP

You really couldn’t have answered my questions in a more annoying
format than the one you chose.

Not surprisingly, your answers sucked.

C++ is not how you’re building your application, that’s the programming
language you’re using. Think compilers or IDEs.

Latest version of SDL? Is that the latest release or the latest CVS?

Does this happen with any of the SDL test programs included in the SDL
source
code? Does this happen with any other popular SDL applications?

no clues on this…

Yeah that’s kind of important. Unless it’s a known problem (and it
sounds like a big f’n problem and wouldn’t go unnoticed or undealt with
for long) then you’re going to have to provide details so that we can
tell you WHAT YOU’RE DOING WRONG. Thank you however for filling us in a
little more in your last post.

The one thing I m sure is…

one of those funtions does not deliver when
SDL_ShowCursor(SDL_DISABLE) is set
in full screen;

SDL_WarpMouse(…)
SDL_GetMouseState(…)

in windowed mode it works beautyfully so far… so… I m pretty sure
you can
considered it as a bug report! but I hope I m wrong…

Thx again!

Well the police currently enjoy my Windows XP system - does anyone else
have any thoughts on this part?On Sep 13, 2004, at 11:26 PM, Golgoth wrote:

Hello,

one of those funtions does not deliver when SDL_ShowCursor(SDL_DISABLE) is set
in full screen;

SDL_WarpMouse(…)
SDL_GetMouseState(…)

 My engine works in fullscreen-hardware-doublebuffered mode with

called SDL_ShowCursor(SDL_DISABLE), but both of those functions
work just fine… IMO, something wrong only with your code. I think
that SDL isn’t guilty here.–
Best regards,
Flashback

I think I start one the wrong foot here… my apologies! I didn’t want to be
rude and/or annoying by any means…

so if I may… I’ll start over!

We’re currently working with the SDL-1.2.7 release on Window XP platforms using
Visual Studio .NET Enterprise Architect as the compiler.

We also decide to wrap all SDL features… so SDL is not a part of the
engine… it makes things a bit more complicated but SDL stays out of the game
lib. and that’s the plan!

Here’s the mouse routine in the main loop:

… SNIP SNIP

// var we need for the exemple…

int l_x, l_y;
Mouse *l_mouse = Game->GetMouse();
S_AppStatus l_appStatus;

… SNIP SNIP

while (l_event.type != SDL_QUIT)
{
	while(SDL_PollEvent(&l_event))
	{
		switch (l_event.type)
		{

… SNIP SNIP

		if(l_appStatus.InputFocus)
		{
			if (l_mouse) // Yes we have a mouse.
			{
				// Needs to set the cursor position?
				if (l_mouse->IsSetCursorPos())
				{
					// If there's no need to set 

the mouse position we wont be here.
l_mouse->SetCursorPos(false);
// In this case… the Camera
mouse look function set the cursor in the middle of the screen!
SDL_WarpMouse(l_mouse->GetX(),
l_mouse->GetY());
}

				// Where's the cursor now?
				SDL_GetMouseState(&l_x, &l_y);
				
				// Notify the game (mouse*) where's the 

cursor!
l_mouse->SetX(l_x);
l_mouse->SetY(l_y);

				if (l_mouse->IsCursor()) // Do we hide 

the cursor? In this case… yes!
SDL_ShowCursor(SDL_ENABLE);
else
SDL_ShowCursor(SDL_DISABLE);
}
}

… SNIP SNIP

Now… the status on this works fine with SDL_SetVideoMode(640, 480, 32,
SDL_OPENGL|SDL_RESIZABLE);
but doesn’t with SDL_SetVideoMode(640, 480, 32, SDL_OPENGL|SDL_FULLSCREEN);

the interesting thing here is… it will work with SDL_SetVideoMode(640, 480,
32, SDL_OPENGL|SDL_FULLSCREEN);

only without this part:

				if (l_mouse->IsCursor()) // Do we hide 

the cursor? In this case… yes!
SDL_ShowCursor(SDL_ENABLE);
else
SDL_ShowCursor(SDL_DISABLE);

… means the cursor’s always visible.

So my guess is… for some reasons when video mode is SDL_FULLSCREEN and
SDL_ShowCursor(SDL_DISABLE) are set… it conflics with SDL_WarpMouse(…);

I hope its me… but it seams really straight forward here… is there any
other features beside a mouse look that required to set the cursor position
when is hidden???

Hope this exemple will help you help me better!

Thx again!

Golgoth (if that is your real name,) I skimmed over your code, and it
seems kind of confusing. Let me offer a strategy for implementing mouse
look, and you tell me if that’s what you’re doing.

Each frame you collect the movement vector for the mouse, then send
that data to your mouse-look routine. Then you set the mouse position
to the center of the screen.

If this is not how you’re implementing mouse-look, please tell me how
you’re doing it so I can better understand your last post. If this is
how you’re doing it, maybe you could explain your code a little more,
but I doubt that’s what you’re doing, but perhaps I’m just being thrown
off by your in-between-game-engine-and-sdl layer.

I think I start one the wrong foot here… my apologies! I didn’t want
to be
rude and/or annoying by any means…

so if I may… I’ll start over!

We’re currently working with the SDL-1.2.7 release on Window XP
platforms using
Visual Studio .NET Enterprise Architect as the compiler.

We also decide to wrap all SDL features… so SDL is not a part of the
engine… it makes things a bit more complicated but SDL stays out of
the game
lib. and that’s the plan!

Here’s the mouse routine in the main loop:

… SNIP SNIP

// var we need for the exemple…

int l_x, l_y;
Mouse *l_mouse = Game->GetMouse();
S_AppStatus l_appStatus;

… SNIP SNIP

while (l_event.type != SDL_QUIT)
{
while(SDL_PollEvent(&l_event))
{
switch (l_event.type)
{

… SNIP SNIP

  	if(l_appStatus.InputFocus)
  	{
  		if (l_mouse) // Yes we have a mouse.
  		{
  			// Needs to set the cursor position?
  			if (l_mouse->IsSetCursorPos())
  			{
  				// If there's no need to set

the mouse position we wont be here.
l_mouse->SetCursorPos(false);
// In this case… the Camera
mouse look function set the cursor in the middle of the screen!
SDL_WarpMouse(l_mouse->GetX(),
l_mouse->GetY());

What is the purpose of this line? It LOOKS like it would warp the mouse
to the position it’s already at…On Sep 14, 2004, at 11:10 AM, Golgoth wrote:

  			}

  			// Where's the cursor now?
  			SDL_GetMouseState(&l_x, &l_y);
  			
  			// Notify the game (mouse*) where's the

cursor!
l_mouse->SetX(l_x);
l_mouse->SetY(l_y);

  			if (l_mouse->IsCursor()) // Do we hide

the cursor? In this case… yes!
SDL_ShowCursor(SDL_ENABLE);
else
SDL_ShowCursor(SDL_DISABLE);
}
}

… SNIP SNIP

Now… the status on this works fine with SDL_SetVideoMode(640, 480,
32,
SDL_OPENGL|SDL_RESIZABLE);
but doesn’t with SDL_SetVideoMode(640, 480, 32,
SDL_OPENGL|SDL_FULLSCREEN);

the interesting thing here is… it will work with
SDL_SetVideoMode(640, 480,
32, SDL_OPENGL|SDL_FULLSCREEN);

only without this part:

  			if (l_mouse->IsCursor()) // Do we hide

the cursor? In this case… yes!
SDL_ShowCursor(SDL_ENABLE);
else
SDL_ShowCursor(SDL_DISABLE);

… means the cursor’s always visible.

So my guess is… for some reasons when video mode is SDL_FULLSCREEN
and
SDL_ShowCursor(SDL_DISABLE) are set… it conflics with
SDL_WarpMouse(…);

I hope its me… but it seams really straight forward here… is there
any
other features beside a mouse look that required to set the cursor
position
when is hidden???

Hope this exemple will help you help me better!

Thx again!


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Hi!

Ok there we go…

I’ve made the simpliest exemple to show you what’s happening!

here’s the code that fits in .cpp file… it’s all you need in a news window
application project under windows XP and SDL SDL-1.2.7 release and VS .NET as a
compiler! Include the sdl lib to your project and add the sdl.dll in the root
folder of the new project. (you already known that!) :wink:

////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////

#include <sdl.h>
#pragma comment(lib, “SDLmain.lib”)
#pragma comment(lib, “SDL.lib”)

int main(int in_argc, char **in_argv)
{
SDL_Init(SDL_INIT_VIDEO);
SDL_WM_SetCaption(“SDL Test”, NULL);
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 32);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);

SDL_Surface *l_screen;
l_screen = SDL_SetVideoMode(640, 480, 32, SDL_OPENGL | SDL_FULLSCREEN);

SDL_Event l_event;
l_event.type = SDL_NOEVENT;

int l_x, l_y;
static char l_position[16];

FILE *l_file = fopen("mousepos.txt", "w+");

//SDL_ShowCursor(SDL_DISABLE);

while (l_event.type != SDL_QUIT)
{
	while(SDL_PollEvent(&l_event))
	{
	switch (l_event.type)
	{
	case SDL_KEYDOWN:
	{
		switch (l_event.key.keysym.sym)
		{
			case SDLK_ESCAPE:
				{
					fclose(l_file);
					SDL_Quit();
					return 0;
				}
				break;
		}
	}
	break;
	}
	}
	SDL_WarpMouse(320, 240);
	SDL_GetMouseState(&l_x, &l_y);
	
	sprintf(l_position, "X: %d, Y: %d\n ", l_x, l_y);
	SDL_WM_SetCaption(l_position, NULL);
	fwrite(l_position, 1, sizeof(l_position), l_file);
}
fclose(l_file);
SDL_Quit();
return 0;

}

////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////

Now… run this and move the mouse… esc after 5 sec or so, cauze it will
filled up the .txt file pretty badly…

look at the mousepos.txt. You ll see that the mouse position change… it will
give you something like this:


X: 320, Y: 240
X: 320, Y: 240
X: 320, Y: 240
X: 320, Y: 240
X: 320, Y: 240
X: 320, Y: 240
X: 238, Y: 316 ----- Here s the important one!!!
X: 320, Y: 240
X: 320, Y: 240
X: 320, Y: 240
X: 320, Y: 240
X: 320, Y: 240
X: 320, Y: 240
X: 320, Y: 240

Next… uncomment SDL_ShowCursor(SDL_DISABLE); and run it again… open the
mousepos.txt and see the difference…

X: 320, Y: 240
X: 320, Y: 240
X: 320, Y: 240
X: 320, Y: 240
X: 320, Y: 240
X: 320, Y: 240
X: 320, Y: 240
X: 320, Y: 240
X: 320, Y: 240
X: 320, Y: 240
X: 320, Y: 240
X: 320, Y: 240
X: 320, Y: 240
X: 320, Y: 240

The mouse never moved…

Hope you guys can figure this out! I’ve been as far as I could on this!

THX

  SDL_WarpMouse(320, 240);
  SDL_GetMouseState(&l_x, &l_y);

This should not work at all really. If you’re setting the mouse to the
center of the screen, and then checking its position, it should ALWAYS
report that position even when the player has moved the mouse.On Sep 14, 2004, at 7:25 PM, Golgoth wrote:

Donny Viszneki <smirk thebuicksix.com> writes:

  SDL_WarpMouse(320, 240);
  SDL_GetMouseState(&l_x, &l_y);

This should not work at all really. If you’re setting the mouse to the
center of the screen, and then checking its position, it should ALWAYS
report that position even when the player has moved the mouse.

Yes I agree… but it doesn’t… thats why I made the sample… its a pretty
simple and fast routine here… but when the routine get bigger… this little
unwanted behaviour could make things worst… and the SDL_ShowCursor
(SDL_DISABLE) running fullscreen as definitly something to do with it… with
the result we have (if anyone else tried it)… I think It worth
investigating…!

best regards!

Golgoth> On Sep 14, 2004, at 7:25 PM, Golgoth wrote:

Look, I don’t mean to offend you, but your english isn’t very good, and
I don’t understand what you’ve just said.

What confusion is there? The example you gave should NEVER WORK. Do you
understand?On Sep 14, 2004, at 9:52 PM, Golgoth wrote:

Donny Viszneki <smirk thebuicksix.com> writes:

On Sep 14, 2004, at 7:25 PM, Golgoth wrote:

  SDL_WarpMouse(320, 240);
  SDL_GetMouseState(&l_x, &l_y);

This should not work at all really. If you’re setting the mouse to the
center of the screen, and then checking its position, it should ALWAYS
report that position even when the player has moved the mouse.

Yes I agree… but it doesn’t… thats why I made the sample… its a
pretty
simple and fast routine here… but when the routine get bigger…
this little
unwanted behaviour could make things worst… and the SDL_ShowCursor
(SDL_DISABLE) running fullscreen as definitly something to do with
it… with
the result we have (if anyone else tried it)… I think It worth
investigating…!

best regards!

Golgoth


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Donny Viszneki <smirk thebuicksix.com>:

Look, I don’t mean to offend you, but your english isn’t very good, and
I don’t understand what you’ve just said.

And I don’t mean to offend YOU, but if you didn’t understand, maybe
you need to go back and reread his emails a little more carefully.

You said:

This should not work at all really. If you’re setting the mouse to
the center of the screen, and then checking its position, it
should ALWAYS report that position even when the player has moved
the mouse.

To which Golgoth replied:

Yes I agree… but it doesn’t…

So what’s the source of your confusion?

I had to edit his sample program to work on my machine (replace
<sdl.h> with “SDL.h”, remove the #pragmas and all references to
OpenGL), but once I got it running, it pretty much behaved as he
described.

When the line SDL_ShowCursor(SDL_DISABLE) is in place, then the
program behaves as you would expect: SDL_GetMouseState() always
returns 320,240 – consistent with the SDL_WarpMouse() line directly
preceding. But when the call to SDL_ShowCursor() is removed, then you
get all kinds of values from SDL_GetMouseState(). (Assuming, of
course, that you manually move the mouse while the program is
running).

For example, in a one-second run of his sample program, I got a
mousepos.txt file of approximately 5000 lines, of which a little over
100 lines reported a mouse position other than 320,240. When the
SDL_ShowCursor() line is removed, then I get 320,240 every single
time.

Note that the above tests were done on Linux X. (Golgotha’s tests were
almost certainly done under Windows, given the #pragmas.) I was NOT
able to reproduce the problem using SVGAlib.

Important Disclaimer: I’m still running SDL 1.2.5 on the machine I
tested this on, so this problem may have already been addressed.

b

but once I got it running, it pretty much behaved as he described.

but once I got it running, it pretty much behaved as he described.

Thx Briand for trying the sample… I appreciated!

This line run every frame should always stick the cursor at one point right?..
in this case, in the middle of the screen.

SDL_WarpMouse(320, 240);

In fact, when we move the mouse and the cursor is visible… we can see the
cursor appeared like a glitch else where*** …and it shouldn’t happen
regarding Donny and I definitely agree with him… but in practice… it does…

So my guess is… there’s something else other then SDL who still has control
over the cursor position and cause conflicts… maybe windows does a faster
update on the mouse inputs and/or not in synch with SDL. More precisely… when
the cursor is still visible and SDL does not set the cursor position…
something else does! compared with windowed mode, running full screen must also
makes a difference on the cursor behavior… but that’s way beyond my interests.

rings a bell anyone?

*** This could put in perspective the concept of the mouse look feature that
brings back the cursor every frame at one point to determine the camera
orientation vector and it’s velocity based on the mouse movements… what’s the
point of keeping the cursor at one point every frame if you want a see in which
direction and how far it gets from its origin… how’s that logically
possible??? not surprisingly… slower your cpu is… better it will works.

Am I taking crazy pills or what?

Golgoth

  SDL_WarpMouse(320, 240);
  SDL_GetMouseState(&l_x, &l_y);

Does it make any difference if you don’t use SDL_GetMouseState to track
the mouse movement, but insted saves the values that the SDL_MOUSEMOTION
events tell you?

// MartinOn Tue, 14 Sep 2004, Golgoth wrote:

Hi Golgoth,

I remember a line checking the focus of your window. Have you tried to
remove that in full screen and see what happens? I’m just curious.

-yzt

Hi Golgoth,On Wednesday 15 September 2004 03:52, Golgoth wrote:

Donny Viszneki <smirk thebuicksix.com> writes:

On Sep 14, 2004, at 7:25 PM, Golgoth wrote:

SDL_WarpMouse(320, 240);
SDL_GetMouseState(&l_x, &l_y);

This should not work at all really. If you’re setting the mouse to the
center of the screen, and then checking its position, it should ALWAYS
report that position even when the player has moved the mouse.

Yes I agree… but it doesn’t… thats why I made the sample… its a
pretty simple and fast routine here… but when the routine get bigger…
this little unwanted behaviour could make things worst… and the
SDL_ShowCursor (SDL_DISABLE) running fullscreen as definitly something to
do with it… with the result we have (if anyone else tried it)… I think
It worth
investigating…!

The reason is SDL_WarpMouse.
If the mouse is visible, SDL uses system calls to move the mouse pointer.
The private mouse coordinates are updated when the system mouse motion event
is pushed to the SDL event queue.

If the mouse is invisible, SDL uses its SDL_PrivateMouseMotion to update the
mouse coordinates.

Please try:

SDL_WarpMouse(320, 240);
SDL_PumpEvents();
SDL_GetMouseState(&l_x, &l_y);

Regards,
Johannes
<libufo.sourceforge.net>

The reason is SDL_WarpMouse.
If the mouse is visible, SDL uses system calls to move the mouse pointer.
The private mouse coordinates are updated when the system mouse motion event
is pushed to the SDL event queue.

If the mouse is invisible, SDL uses its SDL_PrivateMouseMotion to update the
mouse coordinates.

Hi Johannes!

that is interesting…

Please try:

SDL_WarpMouse(320, 240);
SDL_PumpEvents();
SDL_GetMouseState(&l_x, &l_y);

SDL_PumpEvents(); does make a difference when the cursor is hidden and running
full screen… without it the position will always be 320, 240… now it
changed… not often but it does. this little test here is a condensed example
use to create a moose look feature… the more will have values other then 320,
240… smoother the mouse look will be… with SDL_PumpEvents(); running full
screen and the cursor hidden… its does move now… but staccato!

my point here was to determine if there were any difference with the cursor
behavior visible or hidden; the answer is yes, but our problem is not solved
yet…

so my question is:

can we still use system calls to move the mouse pointer when the cursor is
hidden and running full screen?

it makes our mouse look motion much more smother that way…

THX

After reading everything in this thread, might I suggest using
SDL_CreateCursor and SDL_SetCursor? You could create an invisible
cursor this way, and perhaps avoid this problem even if SDL never
changes this behavior.

Donny Viszneki <smirk thebuicksix.com> writes:

After reading everything in this thread, might I suggest using
SDL_CreateCursor and SDL_SetCursor? You could create an invisible
cursor this way, and perhaps avoid this problem even if SDL never
changes this behavior.

Good idea indeed!

But i got good news… we finaly managed to make our mouse look works with a
simple changed in our sequence code… and it works beautyfully in all
scenerios so far… thanks to you all!

Golgoth