Jump to content
  • Advertisement
Sign in to follow this  
polyfrag

Android engine_handle_input

This topic is 2029 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

Have I got this code right for pointer up and down events? How do I know if it was a movement rather than up or down?

 

// http://stackoverflow.com/questions/12500825/android-ndk-multitouch
static int32_t engine_handle_input(struct android_app* app, AInputEvent* event) 
{
    struct engine* engine = (struct engine*)app->userData;
    if (AInputEvent_getType(event) == AINPUT_EVENT_TYPE_MOTION) 
	{
        //engine->animating = 1;
        //engine->state.x = AMotionEvent_getX(event, 0);
        //engine->state.y = AMotionEvent_getY(event, 0);

		int action = AKeyEvent_getAction(event);

		switch(action)
		{
		case AMOTION_EVENT_ACTION_POINTER_DOWN:
			return 1;
		case AMOTION_EVENT_ACTION_POINTER_UP:
			return 1;
		default:
			break;
		}

        return 1;
    }


    return 0;
}

 

 

Share this post


Link to post
Share on other sites
Advertisement

Keep in mind that these are mutlitouch devices.  

 

There can be many touches simultaneously.

 

They need to provide an index so you know which of the touches it is telling you about.

 

The index is stored in the high bits so you will need to shift by AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT to convert the bits into the correct index.

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!