Jump to content
  • Advertisement
Sign in to follow this  
garyfletcher

Cursor control problems with SDL - last question (Anyone??)

This topic is 4834 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Okay I'm almost there. I've now got a cursor on screen and moving and got mouse events being detected...hooray. I have noticed though that when a mouse even is taking place, such as mouse motion, background rendering starts slowing down. Is there anything that I can do to prevent this?
void SiSECursor::mGetCursPos()
{
    SDL_Event event;
    
    button = NONPRESSED;
    
    if (SDL_PollEvent(&event))
    {
        if (event.type == SDL_MOUSEMOTION ) 
        {
            SDL_GetMouseState(&mouseAX,&mouseAY);
        }
        else if  (event.type == SDL_MOUSEBUTTONDOWN )
        {
            if (SDL_GetMouseState(NULL,NULL)&SDL_BUTTON(SDL_BUTTON_LEFT))
            {
                button = LPRESSED;
            }
            else if (SDL_GetMouseState(NULL,NULL)&SDL_BUTTON(SDL_BUTTON_RIGHT))
            {
                button = RPRESSED;
            }
        }
    }
}



Any suggestions? [Edited by - garyfletcher on May 24, 2005 12:23:27 AM]

Share this post


Link to post
Share on other sites
Advertisement
That doesn't sound like it should be happening. I don't think that code is all required, try something like this:


void SiSECursor::mGetCursPos()
{
button = NONPRESSED;
int state = SDL_GetMouseState(&mouseAX,&mouseAY);

if ( state & SDL_BUTTON(SDL_BUTTON_LEFT) )
{
button = LPRESSED;
}
else if ( state & SDL_BUTTON(SDL_BUTTON_RIGHT) )
{
button = RPRESSED;
}
}




When you call that PollEvent like that, you might disrupt the natural event loop for your app. That's the cause of the slowdown I believe. Let me know the results.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!