当前位置: 首页>>代码示例>>C++>>正文


C++ AMotionEvent_getY函数代码示例

本文整理汇总了C++中AMotionEvent_getY函数的典型用法代码示例。如果您正苦于以下问题:C++ AMotionEvent_getY函数的具体用法?C++ AMotionEvent_getY怎么用?C++ AMotionEvent_getY使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了AMotionEvent_getY函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: engine_handle_input

/**
  * Process the next input event.
  */
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) 
  {
    int x = AMotionEvent_getX(event, 0);
    int y = AMotionEvent_getY(event, 0);
    if ((AMOTION_EVENT_ACTION_MASK & AMotionEvent_getAction( event )) == AMOTION_EVENT_ACTION_DOWN)
    {
      nuiAndroidBridge::androidMouse(0, 0, x, y);
    }
    else if ((AMOTION_EVENT_ACTION_MASK & AMotionEvent_getAction( event )) == AMOTION_EVENT_ACTION_UP)
    {
      nuiAndroidBridge::androidMouse(0, 1, x, y);      
    }
    else if ((AMOTION_EVENT_ACTION_MASK & AMotionEvent_getAction( event )) == AMOTION_EVENT_ACTION_MOVE)
    {
      nuiAndroidBridge::androidMotion(x, y);
    }

    
    engine->animating = 1;
    engine->state.x = AMotionEvent_getX(event, 0);
    engine->state.y = AMotionEvent_getY(event, 0);
    return 1;
  }
  return 0;
}
开发者ID:JamesLinus,项目名称:nui3,代码行数:31,代码来源:my_native_code.cpp

示例2: AMotionEvent_getAction

//--------------------------------------------------------------------------------
// TapDetector
//--------------------------------------------------------------------------------
GESTURE_STATE TapDetector::Detect(const AInputEvent* motion_event) {
  if (AMotionEvent_getPointerCount(motion_event) > 1) {
    // Only support single touch
    return false;
  }

  int32_t action = AMotionEvent_getAction(motion_event);
  unsigned int flags = action & AMOTION_EVENT_ACTION_MASK;
  switch (flags) {
    case AMOTION_EVENT_ACTION_DOWN:
      down_pointer_id_ = AMotionEvent_getPointerId(motion_event, 0);
      down_x_ = AMotionEvent_getX(motion_event, 0);
      down_y_ = AMotionEvent_getY(motion_event, 0);
      break;
    case AMOTION_EVENT_ACTION_UP: {
      int64_t eventTime = AMotionEvent_getEventTime(motion_event);
      int64_t downTime = AMotionEvent_getDownTime(motion_event);
      if (eventTime - downTime <= TAP_TIMEOUT) {
        if (down_pointer_id_ == AMotionEvent_getPointerId(motion_event, 0)) {
          float x = AMotionEvent_getX(motion_event, 0) - down_x_;
          float y = AMotionEvent_getY(motion_event, 0) - down_y_;
          if (x * x + y * y < TOUCH_SLOP * TOUCH_SLOP * dp_factor_) {
            LOGI("TapDetector: Tap detected");
            return GESTURE_STATE_ACTION;
          }
        }
      }
      break;
    }
  }
  return GESTURE_STATE_NONE;
}
开发者ID:AcmeNinjaCorp,项目名称:android-ndk,代码行数:35,代码来源:gestureDetector.cpp

示例3: AInputEvent_getType

int32_t GLESApplication::handleInput(android_app *app, AInputEvent *event)
{
    int32_t eventType = AInputEvent_getType(event);

    if (eventType == AINPUT_EVENT_TYPE_MOTION) {   
        int32_t action = AMotionEvent_getAction(event);    
        switch(action) {
        case AMOTION_EVENT_ACTION_DOWN:
            onTouchDown(AMotionEvent_getX(event, 0), AMotionEvent_getY(event, 0));
            break;
        case AMOTION_EVENT_ACTION_MOVE:
            onTouchMove(AMotionEvent_getX(event, 0), AMotionEvent_getY(event, 0));
            break;
            
        case AMOTION_EVENT_ACTION_UP:
            onTouchUp(AMotionEvent_getX(event, 0), AMotionEvent_getY(event, 0));
            break;
            
        default:
            break;
        }
    }
    
    return 0;
}
开发者ID:cxb0dly0zz,项目名称:cegui-android-test,代码行数:25,代码来源:GLESApplication.cpp

示例4: HandleInput

		static int HandleInput(struct android_app* app, AInputEvent* event)
		{
			Android_App* myapp = (Android_App*) app->userData;

			if(myapp)
			{
				switch(AInputEvent_getType(event))
				{
                    case AINPUT_EVENT_TYPE_KEY:
                    {
                        switch(AKeyEvent_getKeyCode(event))
                        {
                            case 4:
                                // Back
                                if(AKeyEvent_getAction(event) == AKEY_EVENT_ACTION_UP)
                                    myapp->OnKeyPress(enumKEY_Back);
                                break;
                            case 24:
                                // Volume up
                                break;
                            case 25:
                                // Volume down
                                break;
                        }
                        break;
                    }
					case AINPUT_EVENT_TYPE_MOTION: // Handle touch events
					{
						switch(AMotionEvent_getAction(event))
						{
							case AMOTION_EVENT_ACTION_DOWN:
							{
								Touch t = { AMotionEvent_getX(event, 0), AMotionEvent_getY(event, 0) };
								myapp->OnTouchDown(&t, 1);

								break;
							}
							case AMOTION_EVENT_ACTION_MOVE:
							{
								Touch t = { AMotionEvent_getX(event, 0), AMotionEvent_getY(event, 0) };
								myapp->OnTouchMoved(&t, 1);

								break;
							}
							case AMOTION_EVENT_ACTION_UP:
							{
								Touch t = { AMotionEvent_getX(event, 0), AMotionEvent_getY(event, 0) };
								myapp->OnTouchUp(&t, 1);

								break;
							}
						}
						return 1;
					}
				}
			}

			return 1;
		}
开发者ID:arron-h,项目名称:gravity-wars-redux,代码行数:59,代码来源:AppImpl.cpp

示例5: AMotionEvent_getAction

bool NativeEngine::HandleInput(AInputEvent *event) {

    if (AInputEvent_getType(event) == AINPUT_EVENT_TYPE_MOTION)
    {
        int32_t action = AMotionEvent_getAction(event);
        size_t pointerIndex;
        size_t pointerId;
        size_t pointerCount;
        int x;
        int y;

        switch (action & AMOTION_EVENT_ACTION_MASK)
        {
            case AMOTION_EVENT_ACTION_DOWN:
                pointerId = AMotionEvent_getPointerId(event, 0);
                x = AMotionEvent_getX(event, 0);
                y = AMotionEvent_getY(event, 0);

                touchBegan(pointerId, Origami::maths::vec2(x, y));

                break;
            case AMOTION_EVENT_ACTION_UP:
                pointerId = AMotionEvent_getPointerId(event, 0);
                x = AMotionEvent_getX(event, 0);
                y = AMotionEvent_getY(event, 0);

                touchended(pointerId, Origami::maths::vec2(x, y));
                break;
            case AMOTION_EVENT_ACTION_POINTER_DOWN:
                pointerIndex = (action & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
                pointerId = AMotionEvent_getPointerId(event, pointerIndex);
                x = AMotionEvent_getX(event, pointerIndex);
                y = AMotionEvent_getY(event, pointerIndex);

                touchBegan(pointerId, Origami::maths::vec2(x, y));
                break;
            case AMOTION_EVENT_ACTION_POINTER_UP:
                pointerIndex = (action & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
                pointerId = AMotionEvent_getPointerId(event, pointerIndex);
                x = AMotionEvent_getX(event, pointerIndex);
                y = AMotionEvent_getY(event, pointerIndex);

                touchended(pointerId, Origami::maths::vec2(x, y));
                break;
            case AMOTION_EVENT_ACTION_MOVE:
                pointerCount = AMotionEvent_getPointerCount(event);
                for (size_t i = 0; i < pointerCount; ++i) {
                    pointerId = AMotionEvent_getPointerId(event, i);
                    x = AMotionEvent_getX(event, i);
                    y = AMotionEvent_getY(event, i);

                    touchMoved(pointerId, Origami::maths::vec2(x, y));
                }
                break;
        }
    }
开发者ID:Uliori,项目名称:Origami,代码行数:56,代码来源:native_engine.cpp

示例6: CookEvent_Motion

static bool CookEvent_Motion(AInputEvent *event, CookedEventCallback callback) {
    int src = AInputEvent_getSource(event);
    int action = AMotionEvent_getAction(event);
    int actionMasked = action & AMOTION_EVENT_ACTION_MASK;
    int ptrIndex = (action & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) >>
            AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;

    struct CookedEvent ev;
    memset(&ev, 0, sizeof(ev));

    if (actionMasked == AMOTION_EVENT_ACTION_DOWN || actionMasked ==
            AMOTION_EVENT_ACTION_POINTER_DOWN) {
        ev.type = COOKED_EVENT_TYPE_POINTER_DOWN;
    } else if (actionMasked == AMOTION_EVENT_ACTION_UP || actionMasked ==
            AMOTION_EVENT_ACTION_POINTER_UP) {
        ev.type = COOKED_EVENT_TYPE_POINTER_UP;
    } else {
        ev.type = COOKED_EVENT_TYPE_POINTER_MOVE;
    }

    ev.motionPointerId = AMotionEvent_getPointerId(event, ptrIndex);
    ev.motionIsOnScreen = (src == AINPUT_SOURCE_TOUCHSCREEN);
    ev.motionX = AMotionEvent_getX(event, ptrIndex);
    ev.motionY = AMotionEvent_getY(event, ptrIndex);

    if (ev.motionIsOnScreen) {
        // use screen size as the motion range
        ev.motionMinX = 0.0f;
        ev.motionMaxX = SceneManager::GetInstance()->GetScreenWidth();
        ev.motionMinY = 0.0f;
        ev.motionMaxY = SceneManager::GetInstance()->GetScreenHeight();
    } else {
        // look up motion range for this device
        _look_up_motion_range((int) AInputEvent_getDeviceId(event),
            (int)AInputEvent_getSource(event), &ev.motionMinX, &ev.motionMaxX,
            &ev.motionMinY, &ev.motionMaxY);
    }

    // deliver event
    callback(&ev);

    // deliver motion info about other pointers (for multi-touch)
    int ptrCount = AMotionEvent_getPointerCount(event);
    for (int i = 0; i < ptrCount; i++) {
        ev.type = COOKED_EVENT_TYPE_POINTER_MOVE;
        ev.motionX = AMotionEvent_getX(event, i);
        ev.motionY = AMotionEvent_getY(event, i);
        ev.motionPointerId = AMotionEvent_getPointerId(event, i);
        callback(&ev);        
    }

    // If this is a touch-nav event, return false to indicate that we haven't handled it.
    // This will trigger translation of swipes to DPAD keys, which is what we want.
    // Otherwise, we say that we've handled it.
    return (src != SOURCE_TOUCH_NAVIGATION);
}
开发者ID:13simon37,项目名称:android-samples,代码行数:56,代码来源:input_util.cpp

示例7: AMotionEvent_getPointerCount

bool CAndroidTouch::onTouchEvent(AInputEvent* event)
{
  CXBMCApp::android_printf("%s", __PRETTY_FUNCTION__);
  if (event == NULL)
    return false;

  size_t numPointers = AMotionEvent_getPointerCount(event);
  if (numPointers <= 0)
  {
    CXBMCApp::android_printf(" => aborting touch event because there are no active pointers");
    return false;
  }

  if (numPointers > TOUCH_MAX_POINTERS)
    numPointers = TOUCH_MAX_POINTERS;

  int32_t eventAction = AMotionEvent_getAction(event);
  int8_t touchAction = eventAction & AMOTION_EVENT_ACTION_MASK;
  size_t touchPointer = eventAction >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
  
  CTouchInput::TouchEvent touchEvent = CTouchInput::TouchEventAbort;
  switch (touchAction)
  {
    case AMOTION_EVENT_ACTION_DOWN:
    case AMOTION_EVENT_ACTION_POINTER_DOWN:
      touchEvent = CTouchInput::TouchEventDown;
      break;

    case AMOTION_EVENT_ACTION_UP:
    case AMOTION_EVENT_ACTION_POINTER_UP:
      touchEvent = CTouchInput::TouchEventUp;
      break;

    case AMOTION_EVENT_ACTION_MOVE:
      touchEvent = CTouchInput::TouchEventMove;
      break;

    case AMOTION_EVENT_ACTION_OUTSIDE:
    case AMOTION_EVENT_ACTION_CANCEL:
    default:
      break;
  }

  float x = AMotionEvent_getX(event, touchPointer);
  float y = AMotionEvent_getY(event, touchPointer);
  float size = m_dpi / 16.0f;
  int64_t time = AMotionEvent_getEventTime(event);

  // first update all touch pointers
  for (unsigned int pointer = 0; pointer < numPointers; pointer++)
    CTouchInput::Get().Update(pointer, AMotionEvent_getX(event, pointer), AMotionEvent_getY(event, pointer),
    AMotionEvent_getEventTime(event), m_dpi / 16.0f);

  // now send the event
  return CTouchInput::Get().Handle(touchEvent, x, y, time, touchPointer, size);
}
开发者ID:A600,项目名称:xbmc,代码行数:56,代码来源:AndroidTouch.cpp

示例8: err

void WindowImplAndroid::processScrollEvent(AInputEvent* _event, ActivityStates* states)
{
    // Prepare the java virtual machine
    jint lResult;
    jint lFlags = 0;

    JavaVM* lJavaVM = states->activity->vm;
    JNIEnv* lJNIEnv = states->activity->env;

    JavaVMAttachArgs lJavaVMAttachArgs;
    lJavaVMAttachArgs.version = JNI_VERSION_1_6;
    lJavaVMAttachArgs.name = "NativeThread";
    lJavaVMAttachArgs.group = NULL;

    lResult=lJavaVM->AttachCurrentThread(&lJNIEnv, &lJavaVMAttachArgs);

    if (lResult == JNI_ERR)
        err() << "Failed to initialize JNI, couldn't get the unicode value" << std::endl;

    // Retrieve everything we need to create this MotionEvent in java
    jlong downTime = AMotionEvent_getDownTime(_event);
    jlong eventTime = AMotionEvent_getEventTime(_event);
    jint action = AMotionEvent_getAction(_event);
    jfloat x = AMotionEvent_getX(_event, 0);
    jfloat y = AMotionEvent_getY(_event, 0);
    jfloat pressure = AMotionEvent_getPressure(_event, 0);
    jfloat size = AMotionEvent_getSize(_event, 0);
    jint metaState = AMotionEvent_getMetaState(_event);
    jfloat xPrecision = AMotionEvent_getXPrecision(_event);
    jfloat yPrecision = AMotionEvent_getYPrecision(_event);
    jint deviceId = AInputEvent_getDeviceId(_event);
    jint edgeFlags = AMotionEvent_getEdgeFlags(_event);

    // Create the MotionEvent object in java trough its static constructor obtain()
    jclass ClassMotionEvent = lJNIEnv->FindClass("android/view/MotionEvent");
    jmethodID StaticMethodObtain = lJNIEnv->GetStaticMethodID(ClassMotionEvent, "obtain", "(JJIFFFFIFFII)Landroid/view/MotionEvent;");
    jobject ObjectMotionEvent = lJNIEnv->CallStaticObjectMethod(ClassMotionEvent, StaticMethodObtain, downTime, eventTime, action, x, y, pressure, size, metaState, xPrecision, yPrecision, deviceId, edgeFlags);

    // Call its getAxisValue() method to get the delta value of our wheel move event
    jmethodID MethodGetAxisValue = lJNIEnv->GetMethodID(ClassMotionEvent, "getAxisValue", "(I)F");
    jfloat delta = lJNIEnv->CallFloatMethod(ObjectMotionEvent, MethodGetAxisValue, 0x00000001);

    // Create and send our mouse wheel event
    Event event;
    event.type = Event::MouseWheelMoved;
    event.mouseWheel.delta = static_cast<double>(delta);
    event.mouseWheel.x = AMotionEvent_getX(_event, 0);
    event.mouseWheel.y = AMotionEvent_getY(_event, 0);

    forwardEvent(event);

    // Dettach this thread from the JVM
    lJavaVM->DetachCurrentThread();
}
开发者ID:Erstaf,项目名称:SFML,代码行数:54,代码来源:WindowImplAndroid.cpp

示例9: AMotionEvent_getAction

int32_t cxAndroid::HandleMotionInput(AInputEvent* event)
{
    cxInt action = AMotionEvent_getAction(event);
    cxInt atype =  action & AMOTION_EVENT_ACTION_MASK;
    switch (atype) {
        case AMOTION_EVENT_ACTION_POINTER_DOWN:{
            cxInt idx = action >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
            cxTouchId id = AMotionEvent_getPointerId(event, idx);
            cxFloat x = AMotionEvent_getX(event, idx);
            cxFloat y = AMotionEvent_getY(event, idx);
            cxEngine::Instance()->Dispatch(id, cxTouchPoint::Began, x, y);
            break;
        }
        case AMOTION_EVENT_ACTION_POINTER_UP:{
            cxInt idx = action >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
            cxTouchId id = AMotionEvent_getPointerId(event, idx);
            cxFloat x = AMotionEvent_getX(event, idx);
            cxFloat y = AMotionEvent_getY(event, idx);
            cxEngine::Instance()->Dispatch(id, cxTouchPoint::Ended, x, y);
            break;
        }
        case AMOTION_EVENT_ACTION_MOVE:{
            cxInt count = (cxInt)AMotionEvent_getPointerCount(event);
            for(cxInt i=0; i < count; i++){
                cxTouchId id = AMotionEvent_getPointerId(event, i);
                cxFloat x = AMotionEvent_getX(event, i);
                cxFloat y =AMotionEvent_getY(event, i);
                cxEngine::Instance()->Dispatch(id, cxTouchPoint::Moved, x, y);
            }
            break;
        }
        case AMOTION_EVENT_ACTION_DOWN:{
            cxInt count = (cxInt)AMotionEvent_getPointerCount(event);
            for(cxInt i=0; i < count; i++){
                cxTouchId id = AMotionEvent_getPointerId(event, i);
                cxFloat x = AMotionEvent_getX(event, i);
                cxFloat y =AMotionEvent_getY(event, i);
                cxEngine::Instance()->Dispatch(id, cxTouchPoint::Began, x, y);
            }
            break;
        }
        case AMOTION_EVENT_ACTION_UP:{
            cxInt count = (cxInt)AMotionEvent_getPointerCount(event);
            for(cxInt i=0; i < count; i++){
                cxTouchId id = AMotionEvent_getPointerId(event, i);
                cxFloat x = AMotionEvent_getX(event, i);
                cxFloat y =AMotionEvent_getY(event, i);
                cxEngine::Instance()->Dispatch(id, cxTouchPoint::Ended, x, y);
            }
            break;
        }
    }
    return 0;
}
开发者ID:cxuhua,项目名称:cxengine,代码行数:54,代码来源:cxAndroid.cpp

示例10: switch

	int32_t Window::handle_input( AInputEvent* event )
	{
		switch( AInputEvent_getType( event ) )
		{
		case AINPUT_EVENT_TYPE_MOTION:
		{
			int action = AMotionEvent_getAction( event );
			int index = action >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
			action &= AMOTION_EVENT_ACTION_MASK;
			switch( action )
			{
			case AMOTION_EVENT_ACTION_DOWN:
			case AMOTION_EVENT_ACTION_POINTER_DOWN:
				pointevent(
					"pointdown",
					index + 1,
					AMotionEvent_getX( event, 0 ),
					AMotionEvent_getY( event, 0 ) );
				break;
			case AMOTION_EVENT_ACTION_UP:
			case AMOTION_EVENT_ACTION_CANCEL:
				pointevent(
					"pointup",
					AMotionEvent_getPointerId( event, 0 ) + 1,
					-1,
					-1 );
				break;
			case AMOTION_EVENT_ACTION_POINTER_UP:
				pointevent(
					"pointup",
					index + 1,
					-1,
					-1 );
				break;
			case AMOTION_EVENT_ACTION_MOVE:
				for(
					int i = 0;
					i < int( AMotionEvent_getPointerCount( event ) );
					++i )
				{
				pointevent(
					"pointmove",
					AMotionEvent_getPointerId( event, i ) + 1,
					AMotionEvent_getX( event, i ),
					AMotionEvent_getY( event, i ) );
				}
				break;
			}
			return 0;
		} break;
		}
		return 0;
	}
开发者ID:delfigamer,项目名称:mist,代码行数:53,代码来源:window.cpp

示例11: process_input

	int32_t process_input(struct android_app* app, AInputEvent* event)
	{
		if (AInputEvent_getType(event) == AINPUT_EVENT_TYPE_MOTION)
		{
			const int32_t action = AMotionEvent_getAction(event);
			const int32_t pointerIndex = (action & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
			const int32_t pointerCount = AMotionEvent_getPointerCount(event);

			const int32_t pointerId = AMotionEvent_getPointerId(event, pointerIndex);
			const float x = AMotionEvent_getX(event, pointerIndex);
			const float y = AMotionEvent_getY(event, pointerIndex);

			const int32_t actionMasked = (action & AMOTION_EVENT_ACTION_MASK);

			switch (actionMasked)
			{
				case AMOTION_EVENT_ACTION_DOWN:
				case AMOTION_EVENT_ACTION_POINTER_DOWN:
				{
					_queue.push_touch_event((int16_t)x, (int16_t)y, (uint8_t)pointerId, true);
					break;
				}
				case AMOTION_EVENT_ACTION_UP:
				case AMOTION_EVENT_ACTION_POINTER_UP:
				{
					_queue.push_touch_event((int16_t)x, (int16_t)y, (uint8_t)pointerId, false);
					break;
				}
				case AMOTION_EVENT_ACTION_OUTSIDE:
				case AMOTION_EVENT_ACTION_CANCEL:
				{
					_queue.push_touch_event((int16_t)x, (int16_t)y, (uint8_t)pointerId, false);
					break;
				}
				case AMOTION_EVENT_ACTION_MOVE:
				{
					for (int index = 0; index < pointerCount; index++)
					{
						const float xx = AMotionEvent_getX(event, index);
						const float yy = AMotionEvent_getY(event, index);
						const int32_t id = AMotionEvent_getPointerId(event, index);
						_queue.push_touch_event((int16_t)xx, (int16_t)yy, (uint8_t)id);
					}
					break;
				}
			}

			return 1;
		}
		else if (AInputEvent_getType(event) == AINPUT_EVENT_TYPE_KEY)
开发者ID:RobertoMalatesta,项目名称:crown,代码行数:50,代码来源:main_android.cpp

示例12: packt_Log_debug

    bool InputService::onTouchEvent(AInputEvent* pEvent) {
#ifdef INPUTSERVICE_LOG_EVENTS
         packt_Log_debug("AMotionEvent_getAction=%d", AMotionEvent_getAction(pEvent));
         packt_Log_debug("AMotionEvent_getFlags=%d", AMotionEvent_getFlags(pEvent));
         packt_Log_debug("AMotionEvent_getMetaState=%d", AMotionEvent_getMetaState(pEvent));
         packt_Log_debug("AMotionEvent_getEdgeFlags=%d", AMotionEvent_getEdgeFlags(pEvent));
         packt_Log_debug("AMotionEvent_getDownTime=%lld", AMotionEvent_getDownTime(pEvent));
         packt_Log_debug("AMotionEvent_getEventTime=%lld", AMotionEvent_getEventTime(pEvent));
         packt_Log_debug("AMotionEvent_getXOffset=%f", AMotionEvent_getXOffset(pEvent));
         packt_Log_debug("AMotionEvent_getYOffset=%f", AMotionEvent_getYOffset(pEvent));
         packt_Log_debug("AMotionEvent_getXPrecision=%f", AMotionEvent_getXPrecision(pEvent));
         packt_Log_debug("AMotionEvent_getYPrecision=%f", AMotionEvent_getYPrecision(pEvent));
         packt_Log_debug("AMotionEvent_getPointerCount=%d", AMotionEvent_getPointerCount(pEvent));
         packt_Log_debug("AMotionEvent_getRawX=%f", AMotionEvent_getRawX(pEvent, 0));
         packt_Log_debug("AMotionEvent_getRawY=%f", AMotionEvent_getRawY(pEvent, 0));
         packt_Log_debug("AMotionEvent_getX=%f", AMotionEvent_getX(pEvent, 0));
         packt_Log_debug("AMotionEvent_getY=%f", AMotionEvent_getY(pEvent, 0));
         packt_Log_debug("AMotionEvent_getPressure=%f", AMotionEvent_getPressure(pEvent, 0));
         packt_Log_debug("AMotionEvent_getSize=%f", AMotionEvent_getSize(pEvent, 0));
         packt_Log_debug("AMotionEvent_getOrientation=%f", AMotionEvent_getOrientation(pEvent, 0));
         packt_Log_debug("AMotionEvent_getTouchMajor=%f", AMotionEvent_getTouchMajor(pEvent, 0));
         packt_Log_debug("AMotionEvent_getTouchMinor=%f", AMotionEvent_getTouchMinor(pEvent, 0));
#endif
        const float TOUCH_MAX_RANGE = 65.0f; // In pixels.

        if (mRefPoint != NULL) {
            if (AMotionEvent_getAction(pEvent)
                            == AMOTION_EVENT_ACTION_MOVE) {
                // Needs a conversion to proper coordinates
                // (origin at bottom/left). Only lMoveY needs it.
                float lMoveX = AMotionEvent_getX(pEvent, 0)
                             - mRefPoint->mPosX;
                float lMoveY = mHeight - AMotionEvent_getY(pEvent, 0)
                             - mRefPoint->mPosY;
                float lMoveRange = sqrt((lMoveX * lMoveX)
                                      + (lMoveY * lMoveY));

                if (lMoveRange > TOUCH_MAX_RANGE) {
                    float lCropFactor = TOUCH_MAX_RANGE / lMoveRange;
                    lMoveX *= lCropFactor; lMoveY *= lCropFactor;
                }

                mHorizontal = lMoveX / TOUCH_MAX_RANGE;
                mVertical   = lMoveY / TOUCH_MAX_RANGE;
            } else {
                mHorizontal = 0.0f; mVertical = 0.0f;
            }
        }
        return true;
    }
开发者ID:AlexanderGarmash,项目名称:ndkguide,代码行数:50,代码来源:InputService.cpp

示例13: recordCameraState

void recordCameraState(struct engine* engine, AInputEvent* event)
{
	engine->m_lastMouseX = AMotionEvent_getX(event, 0);
	engine->m_lastMouseY = AMotionEvent_getY(event, 0);
	engine->m_lastPanAngle = engine->m_cameraController->getPanAngle();
	engine->m_lastTiltAngle = engine->m_cameraController->getTiltAngle();
}
开发者ID:daiwei1999,项目名称:AwayCPP,代码行数:7,代码来源:main.cpp

示例14: input

static int32_t input(struct android_app * app, AInputEvent * e) {
    int handled = 1;
    int kc;
    cvkey cvkc;
    int action;
    switch (AInputEvent_getType(e)) {
    case AINPUT_EVENT_TYPE_KEY:
        kc = AKeyEvent_getKeyCode(e);
        action = AKeyEvent_getAction(e);
        cvkc = mapkey(kc);
        handled = kc != CVK_NONE;
        if (handled) {
            if (action == AKEY_EVENT_ACTION_DOWN)
                cvInject(CVE_DOWN, cvkc, 0);
            if (action == AKEY_EVENT_ACTION_UP)
                cvInject(CVE_UP, cvkc, 0);
        }
        break;
    case AINPUT_EVENT_TYPE_MOTION:
        cvInject(CVE_MOTION,
                 AMotionEvent_getX(e, 0), AMotionEvent_getY(e, 0));
        break;
    default:
        handled = 0;
    }
    return handled;
}
开发者ID:jacereda,项目名称:glcv,代码行数:27,代码来源:android.c

示例15: EngineHandleInput

/**
 * Process the next input event.
 */
static int32_t EngineHandleInput(struct android_app* app, AInputEvent* event)
{
    struct Engine* engine = (struct Engine*)app->userData;

    if (AInputEvent_getType(event) == AINPUT_EVENT_TYPE_MOTION)
    {
        int32_t x = AMotionEvent_getX(event, 0);
        int32_t y = AMotionEvent_getY(event, 0);

        if(abs((engine->state.x -x) + (engine->state.y - y)) > 4)
        {
            engine->state.x = x;
            engine->state.y = y;
            if(engine->state.x < engine->state.width/2 )
            {
                scr_touch = 1;
            }
            else
            {
                scr_touch = 2;
            }
        }

        return 1;
    }

    return 0;
}
开发者ID:hyyh619,项目名称:GLESAPIAnalyzer,代码行数:31,代码来源:TcgMacOSXClient.cpp


注:本文中的AMotionEvent_getY函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。