Skip to content
This repository has been archived by the owner on Sep 4, 2019. It is now read-only.

mouse motion event under simulator #26

Open
hamlatzis opened this issue Jul 19, 2012 · 3 comments
Open

mouse motion event under simulator #26

hamlatzis opened this issue Jul 19, 2012 · 3 comments

Comments

@hamlatzis
Copy link

I don't know if I'm doing something wrong or if there is an issue with SDL_MOUSEMOTION event under the simulator. Although I don't think the problem is in my code. I receive SDL_MOUSEBUTTONDOWN & SDL_MOUSEBUTTONUP events but never the SDL_MOUSEMOTION event

Below is a snippet code for my event loop function and I never get the SDL_MOUSEMOTION event:

eventloop()
{
// we'll be using this for event polling
SDL_Event ev;

bool gotEvent = false;

if ( SDL_IsPaused )
{
    SDL_WaitEvent(&ev);
    gotEvent = true;
}
else
    gotEvent = (SDL_PollEvent(&ev) != 0);

while (gotEvent)
{
    fprintf( stderr,"ev.type = %d\n", ev.type );

    switch (ev.type) 
    {
        case SDL_MOUSEBUTTONDOWN:
            {
                fprintf( stderr,"SDL_MOUSEBUTTONDOWN\n" );

                // do something
            }
            break;
        case SDL_MOUSEBUTTONUP:
            {
                fprintf( stderr,"SDL_MOUSEBUTTONUP\n" );

                // do something

                }
            }
            break;
        case SDL_MOUSEMOTION:
            {
                fprintf( stderr,"SDL_MOUSEMOTION\n" );

                // do something

            }
            break;

        // List of keys that have been pressed
        case SDL_KEYDOWN:
        {
            fprintf( stderr,"SDL_KEYDOWN\n" );

            switch (ev.key.keysym.sym)
            {
                // Escape forces us to quit the app
                // this is also sent when the user makes a back gesture
                case SDLK_ESCAPE:
                    ev.type = SDL_QUIT;
                    break;

                default:
                    break;
            }
            break;
        }
        break;

        case SDL_ACTIVEEVENT:
        {
            fprintf( stderr,"SDL_ACTIVEEVENT\n" );

            if (ev.active.state == SDL_APPACTIVE)
            {
                SDL_IsPaused = !ev.active.gain;
            }
        }
        break;

        case SDL_QUIT:
        {
            fprintf( stderr,"SDL_QUIT\n" );

            mbGameRunning = false;
        }
        break; 
    }

    gotEvent = (SDL_PollEvent(&ev) != 0);
}

}

@jnicholl
Copy link
Collaborator

I really haven't tested much at all on the simulator, I'm afraid. I'm assuming you're dragging the mouse (holding left button) and not getting any events?
Are you using touchcontroloverlay?

----- Original Message -----
From: iosif hamlatzis [mailto:[email protected]]
Sent: Thursday, July 19, 2012 02:11 PM
To: Jeremy Nicholl
Subject: [SDL] mouse motion event under simulator (#26)

I don't know if I'm doing something wrong or if there is an issue with SDL_MOUSEMOTION event under the simulator. Although I don't think the problem is in my code. I receive SDL_MOUSEBUTTONDOWN & SDL_MOUSEBUTTONUP events but never the SDL_MOUSEMOTION event

Below is a snippet code for my event loop function and I never get the SDL_MOUSEMOTION event:

eventloop()
{
// we'll be using this for event polling
SDL_Event ev;

bool gotEvent = false;

if ( SDL_IsPaused )
{
    SDL_WaitEvent(&ev);
    gotEvent = true;
}
else
    gotEvent = (SDL_PollEvent(&ev) != 0);

while (gotEvent)
{
    fprintf( stderr,"ev.type = %d\n", ev.type );

    switch (ev.type) 
    {
        case SDL_MOUSEBUTTONDOWN:
            {
                fprintf( stderr,"SDL_MOUSEBUTTONDOWN\n" );

                // do something
            }
            break;
        case SDL_MOUSEBUTTONUP:
            {
                fprintf( stderr,"SDL_MOUSEBUTTONUP\n" );

                // do something

                }
            }
            break;
        case SDL_MOUSEMOTION:
            {
                fprintf( stderr,"SDL_MOUSEMOTION\n" );

                // do something

            }
            break;

        // List of keys that have been pressed
        case SDL_KEYDOWN:
        {
            fprintf( stderr,"SDL_KEYDOWN\n" );

            switch (ev.key.keysym.sym)
            {
                // Escape forces us to quit the app
                // this is also sent when the user makes a back gesture
                case SDLK_ESCAPE:
                    ev.type = SDL_QUIT;
                    break;

                default:
                    break;
            }
            break;
        }
        break;

        case SDL_ACTIVEEVENT:
        {
            fprintf( stderr,"SDL_ACTIVEEVENT\n" );

            if (ev.active.state == SDL_APPACTIVE)
            {
                SDL_IsPaused = !ev.active.gain;
            }
        }
        break;

        case SDL_QUIT:
        {
            fprintf( stderr,"SDL_QUIT\n" );

            mbGameRunning = false;
        }
        break; 
    }

    gotEvent = (SDL_PollEvent(&ev) != 0);
}

}


Reply to this email directly or view it on GitHub:
#26


This transmission (including any attachments) may contain confidential information, privileged material (including material protected by the solicitor-client or other applicable privileges), or constitute non-public information. Any use of this information by anyone other than the intended recipient is prohibited. If you have received this transmission in error, please immediately reply to the sender and delete this information from your system. Use, dissemination, distribution, or reproduction of this transmission by unintended recipients is not authorized and may be unlawful.

@hamlatzis
Copy link
Author

Yes that's correct I keep pressed the left, the right, the wheel and nothing while dragging the mouse. Even without any buttons pressed, just moving the mouse.

Also correct that I'm using the touchcontroloverlay with and without sdl-controls.xml

I've placed the sdl-controls.xml in the assets folder as one large control (full screen):

@hamlatzis
Copy link
Author

I've just built my game for the device (both debug and release versions) and the code runs ok, I do receive mouse move events. So it seams the problem is only in the simulator.

One more thing I've noticed running on the actual hardware, even though I get the mouse motion events for different fingers, the code runs sluggish. So you can't say it can be used for multi touch.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants