SDL_KEYDOWN event on mouse movement

Hi, I am finding that moving the mouse over an sdl screen is causing the
SDL_WaitEvent function to detect an SDL_KEYDOWN event. Has anyone else
seen this?

Jim

No, and I’m quite sure that would have confused some of my code…!

Do you have a minimal code example that demonstrates this?

//David Olofson - Programmer, Composer, Open Source Advocate

.------- http://olofson.net - Games, SDL examples -------.
| http://zeespace.net - 2.5D rendering engine |
| http://audiality.org - Music/audio engine |
| http://eel.olofson.net - Real time scripting |
’-- http://www.reologica.se - Rheology instrumentation --'On Monday 17 December 2007, James Barrett wrote:

Hi, I am finding that moving the mouse over an sdl screen is causing
the SDL_WaitEvent function to detect an SDL_KEYDOWN event. Has
anyone else seen this?

Sorry, my logic was faulty. When a mouse event occurred, my code was
allowing it to fall thru a switch statement. Ugh.

Jim

David Olofson wrote:> On Monday 17 December 2007, James Barrett wrote:

Hi, I am finding that moving the mouse over an sdl screen is causing
the SDL_WaitEvent function to detect an SDL_KEYDOWN event. Has
anyone else seen this?

No, and I’m quite sure that would have confused some of my code…!

Do you have a minimal code example that demonstrates this?

//David Olofson - Programmer, Composer, Open Source Advocate

.------- http://olofson.net - Games, SDL examples -------.
| http://zeespace.net - 2.5D rendering engine |
| http://audiality.org - Music/audio engine |
| http://eel.olofson.net - Real time scripting |
’-- http://www.reologica.se - Rheology instrumentation --’


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

David Olofson wrote:> On Monday 17 December 2007, James Barrett wrote:

Hi, I am finding that moving the mouse over an sdl screen is causing
the SDL_WaitEvent function to detect an SDL_KEYDOWN event. Has
anyone else seen this?

No, and I’m quite sure that would have confused some of my code…!

Do you have a minimal code example that demonstrates this?

It seems to be happening again. When I move the mouse out of the sdl
window it seem like a keyboard event is firing. I am Running debian
linux, and have the debian package for SDL v 1.2.11-8 installed. I am
noticing that even if I never mouse over the sdl window, but rather
cause the sdl window to gain and lose focus via the gnome panel, looks
like the keyboard event is firing anytime the sdl window loses focus.
The output from my cerr statement is whenever the sdl window loses focus is:

****** KEYBOARD EVENT *******
SDLKey is 300

bool InputSubSystem::PollForEvents()
{
bool returnValue = false;
//send to devices for processing
SDL_Event se;

bool EventNotProcessed = true;
while(EventNotProcessed)
{
    if(SDL_WaitEvent(&se))
    {
        if(isValidEvent(se))
        {
            EventNotProcessed = false;
            returnValue = ProcessEvent(se);
            //flush the input
            SDL_Event event;
            while(SDL_PollEvent(&event));
        }
        else
        {
            EventNotProcessed = true;
        }
    }
}

return returnValue;

}

bool InputSubSystem::ProcessEvent(SDL_Event& se)
{
bool returnValue = false;
switch(se.type)
{
case SDL_KEYDOWN:
case SDL_KEYUP:
cerr << “****** KEYBOARD EVENT *" << endl;
returnValue = this->k->HandleEvent(se);
break;
case SDL_JOYBUTTONDOWN:
case SDL_JOYBUTTONUP:
cerr << "
JOYSTICK BUTTON EVENT *" << endl;
this->j[se.jbutton.which]->HandleEvent(se.jbutton);
break;
case SDL_JOYAXISMOTION:
cerr << "
JOYSTICK AXIS EVENT *******” << endl;
this->j[se.jaxis.which]->HandleEvent(se.jaxis);
break;
}
return returnValue;
}

bool InputSubSystem::isValidEvent(const SDL_Event& se)
{
bool returnValue = false;
switch(se.type)
{
case SDL_KEYDOWN:
case SDL_KEYUP:
case SDL_JOYBUTTONDOWN:
case SDL_JOYBUTTONUP:
case SDL_JOYAXISMOTION:
returnValue = true;
break;
}
return returnValue;
}

David Olofson wrote:

Hi, I am finding that moving the mouse over an sdl screen is causing
the SDL_WaitEvent function to detect an SDL_KEYDOWN event. Has
anyone else seen this?

No, and I’m quite sure that would have confused some of my code…!

Do you have a minimal code example that demonstrates this?

It seems to be happening again. When I move the mouse out of the sdl
window it seem like a keyboard event is firing. I am Running debian
linux, and have the debian package for SDL v 1.2.11-8 installed. I am
noticing that even if I never mouse over the sdl window, but rather
cause the sdl window to gain and lose focus via the gnome panel, looks
like the keyboard event is firing anytime the sdl window loses focus.
The output from my cerr statement is whenever the sdl window loses focus is:

****** KEYBOARD EVENT *******
SDLKey is 300

bool InputSubSystem::PollForEvents()
{
bool returnValue = false;
//send to devices for processing
SDL_Event se;

bool EventNotProcessed = true;
while(EventNotProcessed)
{
    if(SDL_WaitEvent(&se))
    {
        if(isValidEvent(se))
        {
            EventNotProcessed = false;
            returnValue = ProcessEvent(se);
            //flush the input
            SDL_Event event;
            while(SDL_PollEvent(&event));
        }
        else
        {
            EventNotProcessed = true;
        }
    }
}

return returnValue;

}

bool InputSubSystem::ProcessEvent(SDL_Event& se)
{
bool returnValue = false;
switch(se.type)
{
case SDL_KEYDOWN:
case SDL_KEYUP:
cerr << “****** KEYBOARD EVENT *" << endl;
returnValue = this->k->HandleEvent(se);
break;
case SDL_JOYBUTTONDOWN:
case SDL_JOYBUTTONUP:
cerr << "
JOYSTICK BUTTON EVENT *" << endl;
this->j[se.jbutton.which]->HandleEvent(se.jbutton);
break;
case SDL_JOYAXISMOTION:
cerr << "
JOYSTICK AXIS EVENT *******” << endl;
this->j[se.jaxis.which]->HandleEvent(se.jaxis);
break;
}
return returnValue;
}

bool InputSubSystem::isValidEvent(const SDL_Event& se)
{
bool returnValue = false;
switch(se.type)
{
case SDL_KEYDOWN:
case SDL_KEYUP:
case SDL_JOYBUTTONDOWN:
case SDL_JOYBUTTONUP:
case SDL_JOYAXISMOTION:
returnValue = true;
break;
}
return returnValue;

}


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

James,

I posted a similar response a couple months ago about the NUM LOCK key
status being sent when the window gained focus (caused by moving the
mouse over an sdl screen as you described). I would check to see which
key is being detected as “pressed,” it is probably one of the status
keys. If you don’t have a case for that particular key, and you don’t
have a “press any key” scenario, it shouldn’t mess up your
application.

I realize this isn’t a fix, but hopefully it sheds some light on the scenario,

JohnOn Dec 17, 2007 4:42 PM, James Barrett wrote:

On Monday 17 December 2007, James Barrett wrote: