[2.0]-Clear Mouse Button Down Events At App Start?

[2.0]-Clear Mouse Button Down Events At App Start?

Hi,

I have a weird issue with SDL 2.0.3 on Microsoft Windows 8.1 Pro 64Bit.
When the SDL2 game first starts it registers a mouse button down event which I want to fix.
How can I clear all mouse button down events at application start in SDL2?

Thanks!------------------------
JeZ+Lee
JessePalser <AT> Gmail <DOT> com
16BitSoft Inc.
Video Game Design Studio
www.16BitSoft.com

You could just run a loop like:

SDL_Event discard;
while (SDL_PollEvent(&discard)) {}

That will clear the event buffer, and stop once the first few events are
fired. You shouldn’t, however, be getting a mouse down unless you’re
clicking. Can you try starting your app from the command line; the app
might be registering a click from double clicking the executable or
something odd like that. If the command line fixes that, then at least you
know where the click is coming from.

-AlexOn Mon, Mar 2, 2015 at 11:06 AM, JeZ-l-Lee < JessePalserMailingLists at gmail.com> wrote:

[2.0]-Clear Mouse Button Down Events At App Start?

Hi,

I have a weird issue with SDL 2.0.3 on Microsoft Windows 8.1 Pro 64Bit.
When the SDL2 game first starts it registers a mouse button down event
which I want to fix.
How can I clear all mouse button down events at application start in SDL2?

Thanks!


JeZ+Lee
JessePalser Gmail com
16BitSoft Inc.
Video Game Design Studio
www.16BitSoft.com


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

I should mention that loop should be placed before your main application
loop.On Mon, Mar 2, 2015 at 11:23 AM, Alex Barry <@Alex_Barry> wrote:

You could just run a loop like:

SDL_Event discard;
while (SDL_PollEvent(&discard)) {}

That will clear the event buffer, and stop once the first few events are
fired. You shouldn’t, however, be getting a mouse down unless you’re
clicking. Can you try starting your app from the command line; the app
might be registering a click from double clicking the executable or
something odd like that. If the command line fixes that, then at least you
know where the click is coming from.

-Alex

On Mon, Mar 2, 2015 at 11:06 AM, JeZ-l-Lee < JessePalserMailingLists at gmail.com> wrote:

[2.0]-Clear Mouse Button Down Events At App Start?

Hi,

I have a weird issue with SDL 2.0.3 on Microsoft Windows 8.1 Pro 64Bit.
When the SDL2 game first starts it registers a mouse button down event
which I want to fix.
How can I clear all mouse button down events at application start in SDL2?

Thanks!


JeZ+Lee
JessePalser Gmail com
16BitSoft Inc.
Video Game Design Studio
www.16BitSoft.com


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

MrOzBarry wrote:

You could just run a loop like:

SDL_Event discard;
while (SDL_PollEvent(&discard)) {}

That will clear the event buffer, and stop once the first few events are fired.?? You shouldn’t, however, be getting a mouse down unless you’re clicking.?? Can you try starting your app from the command line; the app might be registering a click from double clicking the executable or something odd like that.?? If the command line fixes that, then at least you know where the click is coming from.

-Alex
Hi,

I tried adding what you suggested right before the main loop of the game.
Still getting a mouse button down event right when the game starts?
I know it’s a mouse button down event because my company screen skips immediately to title screen.
Only occurs when double-clicking the EXE and not when run from command prompt or Code::Blocks IDE.

Any other ideas?------------------------
JeZxLee
JessePalser <AT> GMail <DOT> com
16BitSoft Inc.
Video Game Design Studio
www.16BitSoft.com

Hi,

Still have issue with mouse button down at app start.

Here is my code:

Code:
for (int index = 0; index < 3; index++)
{
if ( SDL_GetMouseState(NULL, NULL)&SDL_BUTTON(index+1) )
{
if (MouseButtonWasClicked[index] == false)
{
MouseButtonPressed[index] = true;
MouseButtonWasClicked[index] = true;
}
}
else MouseButtonWasClicked[index] = false;
}

Am I doing something wrong?------------------------
JeZxLee
JessePalser <AT> GMail <DOT> com
16BitSoft Inc.
Video Game Design Studio
www.16BitSoft.com

JeZ-l-Lee wrote:

Hi,

Still have issue with mouse button down at app start.

Here is my code:

Code:
for (int index = 0; index < 3; index++)
{
if ( SDL_GetMouseState(NULL, NULL)&SDL_BUTTON(index+1) )
{
if (MouseButtonWasClicked[index] == false)
{
MouseButtonPressed[index] = true;
MouseButtonWasClicked[index] = true;
}
}
else MouseButtonWasClicked[index] = false;
}

Am I doing something wrong?

What is before your for loop?
You need a SDL_PumpEvents(); right before it, so the values of SDL_GetMouseState make sense.
BTW, why do you have MouseButtonPressed[index] = true; MouseButtonWasClicked[index] = true;? Seems redundant.

BTW, why do you have MouseButtonPressed[index] = true;
MouseButtonWasClicked[index] = true;? Seems redundant.

It looks like in this case, one means “the button is pressed” the other
means “the button was pressed for the first time during this frame,” I
think.

Jesse, is this only happening Windows (and is this source code somewhere
I can see?). I’d like to verify if this is an SDL bug before 2.0.4 is
finalized.

Thanks,
–ryan.

Ryan C. Gordon wrote:

Jesse, is this only happening Windows (and is this source code somewhere
I can see?). I’d like to verify if this is an SDL bug before 2.0.4 is
finalized.

Thanks,
–ryan.
Hi,

I was not doing “SDL_PumpEvents();” before the mouse button code so the problem might have been that?
The development desktop with Windows 8.1 Pro 64Bit blew a PCI network adapter and I am waiting for a replacement.
On my test desktop with Windows 8.1 Pro 64Bit native this issue is not occurring.
I should note that the problem was only on my broken desktop with Win 8.1 Pro 64Bit running in a VMWare Player 7 virtual machine
under a Linux Mint 17.1 KDE 64Bit host.

When I have the dev desktop back up and running I’ll see if adding "SDL_PumpEvents();"to the source fixes the issue…
Thanks!------------------------
JeZxLee
JessePalser <AT> GMail <DOT> com
16BitSoft Inc.
Video Game Design Studio
www.16BitSoft.com

Hi,

“SDL_PumpEvents();” does not solve the problem.

On Win 8.1 Pro 64Bit VMWare Player guest on Linux Mint 17.1 KDE 64Bit host
SDL2 registers a mouse button down when application is 1st run.
(only occurs when EXE is double-clicked)

Hope this can be fixed in 2.0.4, thanks!------------------------
JeZxLee
JessePalser <AT> GMail <DOT> com
16BitSoft Inc.
Video Game Design Studio
www.16BitSoft.com

Here is the source code to “TetriCrisis 4 110% A.I. Turbo”:
http://16bitsoft.com/TC4T/TetriCrisis4110PercentAITurbo.htm
(this web page is private from my Internet portfolio, please don’t distribute it)

Hope this issue can be fixed, thanks!------------------------
JeZxLee
JessePalser <AT> GMail <DOT> com
16BitSoft Inc.
Video Game Design Studio
www.16BitSoft.com

Same issue with left click starting app with double click

changed

if(event.button.button == SDL_BUTTON_LEFT) GoGame();

to

if(event.button.button == SDL_BUTTON_RIGHT) GoGame();

works correctly so seems like its registering the 2nd click as a click

while (SDL_PollEvent(&discard)) { SDL_Delay(100);} // This worked bit lame tho

macrofeet wrote:

Same issue with left click starting app with double click

while (SDL_PollEvent(&discard)) { SDL_Delay(100);} // This worked bit lame tho
Hi,

I tried what you typed and it does not work for me?------------------------
JeZxLee
JessePalser <AT> GMail <DOT> com
16BitSoft Inc.
Video Game Design Studio
www.16BitSoft.com

SDL_Event event;

while (SDL_PollEvent(&event)) { SDL_Delay(1);}

weird I’m using it on the following game it works fine http://gamejolt.com/games/asteroids-flackroid-hd/52501