SDL_Video - Help with fullscreen, suppressed mouse and mouse click coords

I submitted a bug request a couple of weeks ago regarding SDL_Video,
fullscreen mode, mouse suppression and not registering mouse clicks in
the upper 1/4 of the screen on a Windows XP machine. So far, I haven’t
received any useful replies to assist me in my current dilemma.

Normally I’m very patient with open source project however I am under a
time constraint to get this to work. If I cannot get this, what seems to
be trivially simple, problem resolved I am going to have to dump SDL and
go with direct win32 api for this app. Help me keep SDL in our office!
If there’s a better list to post this to for assistance, then point me
to it and I’m there!

Could anyone PLEASE PLEASEe PLEASE compile and try this code and see if
you can get the upper left of your screen clicks to register other than
0,0? Or, if you see some stupid (or not so stupid error) in my code -
please point this out to me. If it fixes this problem I’ll gladly wear a
dunce hat! I have about a week to get this trivial problem resolved or
I’ll have to scrap SDL and I’d really like to stay with it. It’s not
like I’m trying to do something complicated. I am just recording mouse
click coords. Please assist if you can (even if it is - tried it and it
works in the upper left corner). Lower case ‘q’ ends the program. This
is driving me crazy as this seems like the equivalent on not getting a
"Hello world" program to work.

HELP!!!

  • Desperate in Arizona---------------------------------
    #include <iostream.h>
    #include <stdio.h>
    #include <SDL.h>

int main(int argc, char *argv[])
{
SDL_Surface *screen = NULL;
SDL_Event event;
int quit = 0;
char buffer[100];

cout << "Initializing SDL.\n";


/* Initialize defaults */
if((SDL_Init(SDL_INIT_VIDEO) < 0)) 
{ 
    cout << "Could not initialize SDL:" << SDL_GetError();
    return 1;
}

cout << "SDL initialized.\n";

/* Clean up on exit */
atexit(SDL_Quit);

/*
 * Initialize the display to the desktop resolution (0,0 for
 * first two parms to SDL_SetVideoMode), requesting a software

surface
*/
screen = SDL_SetVideoMode(0, 0, 0,
SDL_SWSURFACE|SDL_ANYFORMAT|SDL_FULLSCREEN);

if (screen == NULL) 
{
  cout << "Couldn't set video mode: " << SDL_GetError();
  return 1;
}

sprintf(buffer, "Screen set to resolution %d, %d\n", screen->w,

screen->h);
cout << buffer;

while (quit == 0)
{
  SDL_ShowCursor(SDL_ENABLE);

// hide the mouse pointer
SDL_ShowCursor(SDL_DISABLE);

//Event Processing
while( SDL_PollEvent(&event))
{
switch(event.type)
{
case SDL_KEYDOWN:
cout << SDL_GetKeyName(event.key.keysym.sym)
<< " key down is pressed\n";
break;
case SDL_KEYUP:
cout << SDL_GetKeyName(event.key.keysym.sym)
<< " key up is pressed\n";
if (strcmp(SDL_GetKeyName(event.key.keysym.sym),
“q”) == 0)
quit = 1;
break;
case SDL_QUIT:
quit = 1;
break;
case SDL_MOUSEBUTTONDOWN:
if( event.button.button == SDL_BUTTON_LEFT)
{
cout << "mouse click at " <<
event.button.x << ", " << event.button.y << “\n”;
}

   			    break;
		       } // switch 
    } // while EVENT Processing loop
  } // while quit = 0
    
return 0;		

}

Hello !

Why are you calling SDL_ShowCursor hiding and showing in
your main loop ?

When i enable the mouse cursor i can click everywhere on
the screen and get the correct coords printed.

Also when hiding the mouse cursor it works on my system correctly.

Please checkout also the latest SDL SVN version.

CU

I submitted a bug request a couple of weeks ago regarding SDL_Video,
fullscreen mode, mouse suppression and not registering mouse clicks in the
upper 1/4 of the screen on a Windows XP machine. So far, I haven’t
received any useful replies to assist me in my current dilemma.

Normally I’m very patient with open source project however I am under a
time constraint to get this to work. If I cannot get this, what seems to be
trivially simple, problem resolved I am going to have to dump SDL and go
with direct win32 api for this app. Help me keep SDL in our office! If
there’s a better list to post this to for assistance, then point me to it
and I’m there!

Could anyone PLEASE PLEASEe PLEASE compile and try this code and see if
you can get the upper left of your screen clicks to register other than
0,0? Or, if you see some stupid (or not so stupid error) in my code -
please point this out to me. If it fixes this problem I’ll gladly wear a
dunce hat! I have about a week to get this trivial problem resolved or
I’ll have to scrap SDL and I’d really like to stay with it. It’s not
like I’m trying to do something complicated. I am just recording mouse
click coords. Please assist if you can (even if it is - tried it and it
works in the upper left corner). Lower case ‘q’ ends the program. This is
driving me crazy as this seems like the equivalent on not getting a “Hello
world” program to work.

HELP!!!

  • Desperate in Arizona

#include <iostream.h>
#include <stdio.h>
#include <SDL.h>

int main(int argc, char *argv[]) {
SDL_Surface *screen = NULL;
SDL_Event event;
int quit = 0; char buffer[100];

cout << “Initializing SDL.\n”;

/* Initialize defaults */
if((SDL_Init(SDL_INIT_VIDEO) < 0)) {
cout << “Could not initialize SDL:” << SDL_GetError(); return 1; }

cout << “SDL initialized.\n”;

/* Clean up on exit */
atexit(SDL_Quit);

/*

  • Initialize the display to the desktop resolution (0,0 for
  • first two parms to SDL_SetVideoMode), requesting a software
    surface */
    screen = SDL_SetVideoMode(0, 0, 0,
    SDL_SWSURFACE|SDL_ANYFORMAT|SDL_FULLSCREEN);

if (screen == NULL) {
cout << "Couldn’t set video mode: " << SDL_GetError(); return 1; }

sprintf(buffer, “Screen set to resolution %d, %d\n”, screen->w,
screen->h); cout << buffer;

while (quit == 0) {
SDL_ShowCursor(SDL_ENABLE);

// hide the mouse pointer
SDL_ShowCursor(SDL_DISABLE);

//Event Processing
while( SDL_PollEvent(&event)) {
switch(event.type) {
case SDL_KEYDOWN: cout << SDL_GetKeyName(event.key.keysym.sym) << " key
down
is pressed\n"; break; case SDL_KEYUP: cout <<
SDL_GetKeyName(event.key.keysym.sym)
<< " key up is pressed\n";
if (strcmp(SDL_GetKeyName(event.key.keysym.sym), “q”) == 0)
quit = 1; break; case SDL_QUIT: quit = 1; break; case
SDL_MOUSEBUTTONDOWN: if(> event.button.button == SDL_BUTTON_LEFT) {
cout << “mouse click at " << event.button.x << “, " << event.button.y <<
”\n”;
}

break; } // switch
} // while EVENT Processing loop
} // while quit = 0

return 0; }


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

Hello !

This example shows that the cursor
visibly stays in the center.

Is this just visibly so or does a call
to show the MouseCursor moves
it to the center ?

CU

Worked okay for me. I downloaded the latest version of SDL for windows just
now.

Sample output:

Initializing SDL.
SDL initialized.
Screen set to resolution 1280, 1024
mouse click at 0, 0
mouse click at 727, 430
mouse click at 881, 156
mouse click at 340, 511
mouse click at 186, 0
mouse click at 68, 0
mouse click at 37, 0
mouse click at 752, 779
escape key down is pressed
escape key up is pressed
p key down is pressed
p key up is pressed
q key down is pressed
q key up is pressed

Why do you turn on and off the mouse like that? I tried it again putting the
call to SDL_ShowCursor before the main loop, as I imagine your actual code
does, and it still worked.

If I remembered correctly, the problem is not in the mouse click, but the
touchscreen click because I’m having the same problem. I’ve just written
and sent an e-mail about this. Sorry, I didn’t know that Damian
Sobieralski (the originator of “[SDL] Fullscreen with mouse pointer
suppressed” e-mail) has written another e-mail.

AFAIK, the problem is: if the application is using a touchscreen as an
input, if it gets fullscreened and the mouse pointer is hidden, the
touchscreen’s click coordinate is gone haywire. I’ve just thought about a
way to workaround this. I’ planning to create a new mouse pointer with all
transparent color. Dunno if it willl work or not.> Worked okay for me. I downloaded the latest version of SDL for windows

just
now.

Sample output:

Initializing SDL.
SDL initialized.
Screen set to resolution 1280, 1024
mouse click at 0, 0
mouse click at 727, 430
mouse click at 881, 156
mouse click at 340, 511
mouse click at 186, 0
mouse click at 68, 0
mouse click at 37, 0
mouse click at 752, 779
escape key down is pressed
escape key up is pressed
p key down is pressed
p key up is pressed
q key down is pressed
q key up is pressed

Why do you turn on and off the mouse like that? I tried it again putting
the
call to SDL_ShowCursor before the main loop, as I imagine your actual code
does, and it still worked.


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

mouse click coords

If I remembered correctly, the problem is not in the mouse click, but
the
touchscreen click

That’s what I thought too. So I installed my app onto a workstation
that has never had a touchscreen driver installed on it. I alternate
between suppressing and enabling the mouse pointer (it flashes so I can
see where it is at) and the same thing happens. I think the touchscreen
is distracting troubeshooting from the actual culprit - mouse pointer
suppressed in fullscreen whether a touchscreen is hooked up or not.
Seems like as soon as I call DL_ShowCursor(SDL_DISABLE), things go
wacky. It almost seems like the origin of the screen coordinate system
goes from the upper left corner being 0,0 to the center of the screen
being 0,0.

touchscreen’s click coordinate is gone haywire. I’ve just thought
about a
way to workaround this. I’ planning to create a new mouse pointer with
all
transparent color. Dunno if it willl work or not.

Please let me know if it does. I’m going crazy on what seems like such
a simple thing.

Subject: Re: SDL_Video - Help with fullscreen, suppressed mouse and

mouse click coords

Why are you calling SDL_ShowCursor hiding and showing in
your main loop ?

So that I can see where the mouse cursor is at so I know where I am
clicking. Otherwise, in fullscreen mode, how am I going to know where I
am clicking if I dont cycle it like that (if there’s a better way,
please let me know)?

Please checkout also the latest SDL SVN version.

sigh I tried that and followed the instruction at:

http://www.libsdl.org/extras/win32/mingw32/README.txt

I installed MSYS but when I go into the SDL directory and try to issue
./configure I get an error “sh: ./configure no such file or directory”.
There is no configure script in the 1.2 SVN checked out tree that I
have.> From: Torsten Giebl <wizard syntheticsw.com>

Subject: Re: SDL_Video - Help with fullscreen, suppressed mouse and