• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ AMotionEvent_getY函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: AInputEvent_getSource

void WindowImplAndroid::processPointerEvent(bool isDown, AInputEvent* _event, ActivityStates* states)
{
    int32_t device = AInputEvent_getSource(_event);
    int32_t action = AMotionEvent_getAction(_event);

    int index = (action & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
    int id = AMotionEvent_getPointerId(_event, index);

    float x = AMotionEvent_getX(_event, index);
    float y = AMotionEvent_getY(_event, index);

    Event event;

    if (isDown)
    {
        if (device == AINPUT_SOURCE_MOUSE)
        {
            event.type = Event::MouseButtonPressed;
            event.mouseButton.button = static_cast<Mouse::Button>(id);
            event.mouseButton.x = x;
            event.mouseButton.y = y;

            if (id >= 0 && id < Mouse::ButtonCount)
                states->isButtonPressed[id] = true;
        }
        else if (device == AINPUT_SOURCE_TOUCHSCREEN)
        {
            event.type = Event::TouchBegan;
            event.touch.finger = id;
            event.touch.x = x;
            event.touch.y = y;

            states->touchEvents[id] = Vector2i(event.touch.x, event.touch.y);
        }
    }
    else
    {
        if (device == AINPUT_SOURCE_MOUSE)
        {
            event.type = Event::MouseButtonReleased;
            event.mouseButton.button = static_cast<Mouse::Button>(id);
            event.mouseButton.x = x;
            event.mouseButton.y = y;

            if (id >= 0 && id < Mouse::ButtonCount)
                states->isButtonPressed[id] = false;
        }
        else if (device == AINPUT_SOURCE_TOUCHSCREEN)
        {
            event.type = Event::TouchEnded;
            event.touch.finger = id;
            event.touch.x = x;
            event.touch.y = y;

            states->touchEvents.erase(id);
        }
    }

    forwardEvent(event);
}
开发者ID:Erstaf,项目名称:SFML,代码行数:60,代码来源:WindowImplAndroid.cpp


示例17: AMotionEvent_getAction

bool CAndroidMouse::onMouseEvent(AInputEvent* event)
{
  if (event == NULL)
    return false;

  int32_t eventAction = AMotionEvent_getAction(event);
  int8_t mouseAction = eventAction & AMOTION_EVENT_ACTION_MASK;
  size_t mousePointer = eventAction >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;

  CXBMCApp::android_printf("%s pointer:%i", __PRETTY_FUNCTION__, mousePointer);
  float x = AMotionEvent_getX(event, mousePointer);
  float y = AMotionEvent_getY(event, mousePointer);

  switch (mouseAction)
  {
    case AMOTION_EVENT_ACTION_UP:
    case AMOTION_EVENT_ACTION_DOWN:
      MouseButton(x,y,mouseAction);
      return true;
    default:
      MouseMove(x,y);
      return true;
  }
  return false;
}
开发者ID:2BReality,项目名称:xbmc,代码行数:25,代码来源:AndroidMouse.cpp


示例18: AMotionEvent_getAction

bool CAndroidMouse::onMouseEvent(AInputEvent* event)
{
  if (event == NULL)
    return false;

  int32_t eventAction = AMotionEvent_getAction(event);
  int8_t mouseAction = eventAction & AMOTION_EVENT_ACTION_MASK;
  size_t mousePointerIdx = eventAction >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
  int32_t mousePointerId = AMotionEvent_getPointerId(event, mousePointerIdx);

#ifdef DEBUG_VERBOSE
  CXBMCApp::android_printf("%s idx:%i, id:%i", __PRETTY_FUNCTION__, mousePointerIdx, mousePointerId);
#endif
  CPoint in(AMotionEvent_getX(event, mousePointerIdx), AMotionEvent_getY(event, mousePointerIdx));
  CPoint out = in * m_droid2guiRatio;

  switch (mouseAction)
  {
    case AMOTION_EVENT_ACTION_UP:
    case AMOTION_EVENT_ACTION_DOWN:
      MouseButton(out.x, out.y, mouseAction, AMotionEvent_getButtonState(event));
      return true;
    case AMOTION_EVENT_ACTION_SCROLL:
      MouseWheel(out.x, out.y, AMotionEvent_getAxisValue(event, AMOTION_EVENT_AXIS_VSCROLL, mousePointerIdx));
      return true;
    default:
      MouseMove(out.x, out.y);
      return true;
  }
  return false;
}
开发者ID:MrMC,项目名称:mrmc,代码行数:31,代码来源:AndroidMouse.cpp


示例19: _process_keys

static bool _process_keys(bool isJoy, AInputEvent *event, CookedEventCallback callback) {
    if (AInputEvent_getType(event) == AINPUT_EVENT_TYPE_KEY) {
        int action = AKeyEvent_getAction(event);
        int code = _translate_keycode(AKeyEvent_getKeyCode(event));
        bool handled = code >= 0;
        if (code >= 0 && action == AKEY_EVENT_ACTION_DOWN) {
            _report_key_state(code, true, callback);
        } else if (code >= 0 && action == AKEY_EVENT_ACTION_UP) {
            _report_key_state(code, false, callback);
        }
        return handled;
    } else if (isJoy) {
        // use joystick axes to emulate directional key events (we could leave this
        // up to the platform, but joystick-to-dpad conversion doesn't work
        // on NDK on older devices,  so we implement manually for maximum compatibility)
        float x = AMotionEvent_getX(event, 0);
        float y = AMotionEvent_getY(event, 0);
        if (_getAxisValue) {
            // take the hat switches into account too, so that either the
            // regular axes or the hat axes can be used to navigate UIs
            x += _getAxisValue(event, AXIS_HAT_X, 0);
            y += _getAxisValue(event, AXIS_HAT_Y, 0);
            x = Clamp(x, -1.0f, 1.0f);
            y = Clamp(y, -1.0f, 1.0f);
        }
        _report_key_states_from_axes(x, y, callback);
        return true;
    }
}
开发者ID:13simon37,项目名称:android-samples,代码行数:29,代码来源:input_util.cpp


示例20: AMotionEvent_getPointerCount

    int32_t Engine::onMotionEvent(android_app* app, AInputEvent* event) {
        if (!this->loaded) return 0;
        if (!this->focused) return 0;

        size_t pointerCount =  AMotionEvent_getPointerCount(event);

        this->updateUptime();

        for (size_t i = 0; i < pointerCount; i++) {
            size_t pointerId = AMotionEvent_getPointerId(event, i);
            size_t action = AMotionEvent_getAction(event) & AMOTION_EVENT_ACTION_MASK;
            size_t pointerIndex = i;
        
            if (action == AMOTION_EVENT_ACTION_POINTER_DOWN || action == AMOTION_EVENT_ACTION_POINTER_UP) {
                pointerIndex = (AMotionEvent_getAction(event) & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
                pointerId = AMotionEvent_getPointerId(event, pointerIndex);
            }

            this->touchEventParamCache[0] = pointerId;
            this->touchEventParamCache[1] = action;
            this->touchEventParamCache[2] = AMotionEvent_getX(event, pointerIndex);
            this->touchEventParamCache[3] = AMotionEvent_getY(event, pointerIndex);
            this->touchEventParamCache[4] = this->uptime.time;
            this->touchEventParamCache[5] = this->uptime.millitm;
            this->touchEventParamCache[6] = AInputEvent_getDeviceId(event);
            this->touchEventParamCache[7] = AInputEvent_getSource(event);
            
            if (callSqFunction_Bool_Floats(this->sqvm, EMO_NAMESPACE, EMO_FUNC_MOTIONEVENT, this->touchEventParamCache, MOTION_EVENT_PARAMS_SIZE, false)) {
                return 1;
            }
        }
开发者ID:dreadpiratepj,项目名称:emo-framework-experiment,代码行数:31,代码来源:Engine.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ AN函数代码示例发布时间:2022-05-30
下一篇:
C++ AMotionEvent_getAction函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap