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

C++ AKeyEvent_getKeyCode函数代码示例

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

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



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

示例1: key_ascii

/**
 * Convert an Android key event to ASCII.
 */
static unsigned char key_ascii(struct android_app* app, AInputEvent* event) {
  int32_t code = AKeyEvent_getKeyCode(event);

  /* Handle a few special cases: */
  switch (code) {
  case AKEYCODE_DEL:
    return 8;
  case AKEYCODE_FORWARD_DEL:
    return 127;
  case AKEYCODE_ESCAPE:
    return 27;
  }

  /* Get usable JNI context */
  JNIEnv* env = app->activity->env;
  JavaVM* vm = app->activity->vm;
  (*vm)->AttachCurrentThread(vm, &env, NULL);

  jclass KeyEventClass = (*env)->FindClass(env, "android/view/KeyEvent");
  jmethodID KeyEventConstructor = (*env)->GetMethodID(env, KeyEventClass, "<init>", "(II)V");
  jobject keyEvent = (*env)->NewObject(env, KeyEventClass, KeyEventConstructor,
				       AKeyEvent_getAction(event), AKeyEvent_getKeyCode(event));
  jmethodID KeyEvent_getUnicodeChar = (*env)->GetMethodID(env, KeyEventClass, "getUnicodeChar", "(I)I");
  int ascii = (*env)->CallIntMethod(env, keyEvent, KeyEvent_getUnicodeChar, AKeyEvent_getMetaState(event));

  /* LOGI("getUnicodeChar(%d) = %d ('%c')", AKeyEvent_getKeyCode(event), ascii, ascii); */

  return ascii;
}
开发者ID:fatman2021,项目名称:qb64,代码行数:32,代码来源:fg_main_android.c


示例2: packt_Log_debug

    bool InputService::onKeyboardEvent(AInputEvent* pEvent) {
#ifdef INPUTSERVICE_LOG_EVENTS
         packt_Log_debug("AKeyEvent_getAction=%d", AKeyEvent_getAction(pEvent));
         packt_Log_debug("AKeyEvent_getFlags=%d", AKeyEvent_getFlags(pEvent));
         packt_Log_debug("AKeyEvent_getKeyCode=%d", AKeyEvent_getKeyCode(pEvent));
         packt_Log_debug("AKeyEvent_getScanCode=%d", AKeyEvent_getScanCode(pEvent));
         packt_Log_debug("AKeyEvent_getMetaState=%d", AKeyEvent_getMetaState(pEvent));
         packt_Log_debug("AKeyEvent_getRepeatCount=%d", AKeyEvent_getRepeatCount(pEvent));
         packt_Log_debug("AKeyEvent_getDownTime=%lld", AKeyEvent_getDownTime(pEvent));
         packt_Log_debug("AKeyEvent_getEventTime=%lld", AKeyEvent_getEventTime(pEvent));
#endif
        const float ORTHOGONAL_MOVE = 1.0f;

        if (AKeyEvent_getAction(pEvent) == AKEY_EVENT_ACTION_DOWN) {
            switch (AKeyEvent_getKeyCode(pEvent)) {
            case AKEYCODE_DPAD_LEFT:
                mHorizontal = -ORTHOGONAL_MOVE;
                break;
            case AKEYCODE_DPAD_RIGHT:
                mHorizontal = ORTHOGONAL_MOVE;
                break;
            case AKEYCODE_DPAD_DOWN:
                mVertical = -ORTHOGONAL_MOVE;
                break;
            case AKEYCODE_DPAD_UP:
                mVertical = ORTHOGONAL_MOVE;
                break;
            case AKEYCODE_BACK:
                return false;
            }
        } else {
            switch (AKeyEvent_getKeyCode(pEvent)) {
            case AKEYCODE_DPAD_LEFT:
            case AKEYCODE_DPAD_RIGHT:
                mHorizontal = 0.0f;
                break;
            case AKEYCODE_DPAD_DOWN:
            case AKEYCODE_DPAD_UP:
                mVertical = 0.0f;
                break;
            case AKEYCODE_MENU:
                mMenuKey = true;
                break;
            case AKEYCODE_BACK:
                return false;
            }
        }
        return true;
    }
开发者ID:AlexanderGarmash,项目名称:ndkguide,代码行数:49,代码来源:InputService.cpp


示例3: 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


示例4: _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


示例5: handle_input_events

int32_t handle_input_events(struct android_app* app, AInputEvent* event) {
	int etype = AInputEvent_getType(event);
	switch (etype) {
	case AINPUT_EVENT_TYPE_KEY:
		int32_t eaction, eflags, ekeycode, escancode;
		eaction = AKeyEvent_getAction(event);
		eflags = AKeyEvent_getFlags(event);
		ekeycode = AKeyEvent_getKeyCode(event);
//		LOGI(2, "%s", get_key_event_str(eaction, eflags, ekeycode));
		break;
	case AINPUT_EVENT_TYPE_MOTION:
		int32_t action, posX, pointer_index;
		action = AMotionEvent_getAction(event);
		pointer_index = (action&AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
		posX = AMotionEvent_getX(event, pointer_index);
		//write a command to the activity lifecycle event queue (pipe)
		if (action == AMOTION_EVENT_ACTION_MOVE) {
			int xMove = posX - mPreviousX;
			USERDATA* userData = (USERDATA*)app->userData;
			userData->xMove = xMove;
			app->redrawNeeded = 1;
		}
		mPreviousX = posX;
//		LOGI(2, "action: %d, posX: %d, mPreviousX: %d, posX: %d", action, posX, mPreviousX, posX);
		break;
	default:
		LOGI(2, "other input event");
		break;
	}
}
开发者ID:GitNooby,项目名称:notes,代码行数:30,代码来源:NativeInputs.cpp


示例6: CookEvent

bool CookEvent(AInputEvent *event, CookedEventCallback callback) {
    int type = AInputEvent_getType(event);
    int src = AInputEvent_getSource(event);
    bool isJoy = (type == AINPUT_EVENT_TYPE_MOTION) && (src & AINPUT_SOURCE_CLASS_MASK) ==
            SOURCE_CLASS_JOYSTICK;

    if (!_init_done) {
        _init();
        _init_done = true;
    }

    if (isJoy) {
        return CookEvent_Joy(event, callback);
    } else if (type == AINPUT_EVENT_TYPE_KEY) {
        bool handled = _process_keys(false, event, callback);
        if (AKeyEvent_getKeyCode(event) == AKEYCODE_BACK && 0 == AKeyEvent_getAction(event)) {
            // back key was pressed
            struct CookedEvent ev;
            memset(&ev, 0, sizeof(ev));
            ev.type = COOKED_EVENT_TYPE_BACK;
            return callback(&ev);
        }
        // Note: if you want to handle other keys, add code here. For now we only
        // handle DPAD keys as indicated in _process_keys.
        return handled;
    } else if (type == AINPUT_EVENT_TYPE_MOTION) {
        return CookEvent_Motion(event, callback);
    }

    return false;
}
开发者ID:13simon37,项目名称:android-samples,代码行数:31,代码来源:input_util.cpp


示例7: AKeyEvent_getKeyCode

/**
*  @brief
*    Call this to process the next key input event
*/
void AndroidKeyboardDevice::OnKeyInputEvent(const struct AInputEvent &cAKeyInputEvent)
{
	// Check if input device is valid
	if (m_pDevice) {
		// Get Android key code
		const int32_t nKeyCode = AKeyEvent_getKeyCode(&cAKeyInputEvent);

		// Lookout! The virtual keyboard of Android sends "down" and "up" directly one after another
		// -> This is really a problem and we have to delay further keys...
		if (m_lstProcessedKeys.IsElement(nKeyCode)) {
			// Add key for later processing
			KeyInfo sKeyInfo;
			sKeyInfo.nKeyCode = nKeyCode;
			sKeyInfo.bPressed = (AKeyEvent_getAction(&cAKeyInputEvent) == AKEY_EVENT_ACTION_DOWN);
			m_lstDelayedKeys.Add(sKeyInfo);
		} else {
			// Get keyboard device
			Keyboard *pKeyboard = static_cast<Keyboard*>(m_pDevice);

			// Get button
			Button *pButton = GetKeyboardKey(*pKeyboard, nKeyCode);
			if (pButton) {
				// Get button state
				const bool bPressed = (AKeyEvent_getAction(&cAKeyInputEvent) == AKEY_EVENT_ACTION_DOWN);

				// Propagate changes
				if (pButton->IsPressed() != bPressed)
					pButton->SetPressed(bPressed);
			}

			// Add this key to the processed keys
			m_lstProcessedKeys.Add(nKeyCode);
		}
	}
}
开发者ID:ByeDream,项目名称:pixellight,代码行数:39,代码来源:AndroidKeyboardDevice.cpp


示例8: AKeyEvent_getKeyCode

	event_result message_dispatcher::fire_on_dpad(app& the_app, AInputEvent *ie)
	{
		int kcode = AKeyEvent_getKeyCode(ie);
		int type = AKeyEvent_getAction(ie);
		bool h = false;

		switch (kcode) {
		case AKEYCODE_DPAD_UP:
			h = the_app.on_dpad_up(type == AKEY_EVENT_ACTION_DOWN ? button_event::down : button_event::up);
			break;
		case AKEYCODE_DPAD_DOWN:
			h = the_app.on_dpad_down(type == AKEY_EVENT_ACTION_DOWN ? button_event::down : button_event::up);
			break;
		case AKEYCODE_DPAD_LEFT:
			h = the_app.on_dpad_left(type == AKEY_EVENT_ACTION_DOWN ? button_event::down : button_event::up);
			break;
		case AKEYCODE_DPAD_RIGHT:
			h = the_app.on_dpad_right(type == AKEY_EVENT_ACTION_DOWN ? button_event::down : button_event::up);
			break;
		case AKEYCODE_DPAD_CENTER:
			h = the_app.on_dpad_center(type == AKEY_EVENT_ACTION_DOWN ? button_event::down : button_event::up);
			break;
		default:
			break;
		}

		return h ? event_result::handled : event_result::unhandled;
	}
开发者ID:emmanuel-deloget,项目名称:anapi,代码行数:28,代码来源:anapi_message_dispatcher.cpp


示例9: get_key_event

///// キー入力イベント処理
void get_key_event(struct android_app* app, AInputEvent* event) {
    struct engine* engine = (struct engine*) app->userData;
    int keyaction;
    // キーコードを取得
    int keycode = AKeyEvent_getKeyCode(event); /////-----(1) ここから
    // 音量キー(上)の入力が変化した
    if (keycode == AKEYCODE_VOLUME_UP) { /////-----(1) ここまで
        keyaction = AKeyEvent_getAction(event); /////-----(2) ここから
        if (keyaction == AKEY_EVENT_ACTION_DOWN) { /////-----(2) ここまで
            // キーを押した
            engine->volumeup_keydown = TRUE;
        } else {
            // キーを離した
            engine->volumeup_keydown = FALSE;
        }
    }
    // 音量キー(下)の入力変化した
    if (keycode == AKEYCODE_VOLUME_DOWN) {
        keyaction = AKeyEvent_getAction(event);
        if (keyaction == AKEY_EVENT_ACTION_DOWN) {
            // キーを押した
            engine->volumedown_keydown = TRUE;
        } else {
            // キーを離した
            engine->volumedown_keydown = FALSE;
        }
    }
}
开发者ID:hongwd75,项目名称:NDKBook_2nd,代码行数:29,代码来源:main.c


示例10: handle_key_input

/*
* Handle Key Inputs
*/
static int32_t handle_key_input(AInputEvent *event)
{
    if (AKeyEvent_getAction(event) == AKEY_EVENT_ACTION_UP)
    {
        auto dispatcher = cocos2d::Director::getInstance()->getEventDispatcher();

        switch (AKeyEvent_getKeyCode(event))
        {
        case AKEYCODE_BACK:	
            {
                cocos2d::EventKeyboard event(cocos2d::EventKeyboard::KeyCode::KEY_BACKSPACE, false);
                dispatcher->dispatchEvent(&event);
            }
            return 1;
        case AKEYCODE_MENU:
            {
                cocos2d::EventKeyboard event(cocos2d::EventKeyboard::KeyCode::KEY_MENU, false);
                dispatcher->dispatchEvent(&event);
            }
            return 1;
        default:
            break;
        }
    }
    return 0;
}
开发者ID:6520874,项目名称:pipiGame,代码行数:29,代码来源:nativeactivity.cpp


示例11: handleInput

	static int32_t handleInput(struct android_app* app, AInputEvent* event) 
	{
		if (okit.getInput())
		{
	        if (AInputEvent_getType(event) == AINPUT_EVENT_TYPE_MOTION) 
            {
                int action = (int)(AMOTION_EVENT_ACTION_MASK & AMotionEvent_getAction(event));
                    
				
                if (action == 0)
					okit.injectTouch(2, AMotionEvent_getRawX(event, 0), AMotionEvent_getRawY(event, 0));
                    
                okit.injectTouch(action, AMotionEvent_getRawX(event, 0), AMotionEvent_getRawY(event, 0));
            }
            else 
            {
				int action = AKeyEvent_getAction(event);
				int unicodeChar = 0;
				okit.injectKey(action, unicodeChar, AKeyEvent_getKeyCode(event));
                //mInputInjector->injectKeyEvent(AKeyEvent_getAction(event), AKeyEvent_getKeyCode(event));
            }

            return 1;
        }
        return 0;
	}
开发者ID:Ali-il,项目名称:gamekit,代码行数:26,代码来源:Main.cpp


示例12: process_input

static void process_input(struct android_app* app, struct android_poll_source* source) {
    AInputEvent* event = NULL;
    if (AInputQueue_getEvent(app->inputQueue, &event) >= 0) {
        
        // HACK: Override back buttom to show / hide keyboard.
        int type = AInputEvent_getType(event);
        if(type == AINPUT_EVENT_TYPE_KEY) {
            if(AKeyEvent_getAction(event) == AKEY_EVENT_ACTION_DOWN) {
                static bool keyboard_shown = false;
                if( AKeyEvent_getKeyCode(event) == AKEYCODE_BACK ) {
                    displayKeyboard(app,!keyboard_shown);
                    keyboard_shown = !keyboard_shown;
                    AInputQueue_finishEvent(app->inputQueue, event, 1);
                    return;
                }
            }
        }    
        
        if (AInputQueue_preDispatchEvent(app->inputQueue, event)) {
            return;
        }
        int32_t handled = 0;
        if (app->onInputEvent != NULL) handled = app->onInputEvent(app, event);
        AInputQueue_finishEvent(app->inputQueue, event, handled);
    } else {
        LOGE("Failure reading next input event: %s\n", strerror(errno));
    }
}
开发者ID:GrimDerp,项目名称:Pangolin,代码行数:28,代码来源:display_android.cpp


示例13: input_eventcallback

static int32_t input_eventcallback(struct android_app* app, AInputEvent* event)
{
	int32_t type = AInputEvent_getType(event);
	AndroidApplication* a = (AndroidApplication*)app->userData;
	switch (type)
	{
	case AINPUT_EVENT_TYPE_MOTION:
		switch (AInputEvent_getSource(event))
		{
			case AINPUT_SOURCE_TOUCHSCREEN:
			return a->eventManager()->processTouchEvent(event);
			break;
		}
		break;
	case AINPUT_EVENT_TYPE_KEY:
		Log::debug("EVENT INPUT OK");
		switch(AKeyEvent_getKeyCode(event))
		{
		case AKEYCODE_BACK:

			return 1;
			break;
		}
		return 0;


		break;
	}
}
开发者ID:pollastri-pierre,项目名称:BeanEngine,代码行数:29,代码来源:AndroidApplication.cpp


示例14: AMotionEvent_getAction

int32_t AndroidAppHelper::handleInput (struct android_app* app, AInputEvent* event)
{
    if (mInputInjector)
    {
        if (AInputEvent_getType (event) == AINPUT_EVENT_TYPE_MOTION)
        {
            int action = (int) (AMOTION_EVENT_ACTION_MASK & AMotionEvent_getAction (event));

            if (action == 0)
            {
                mInputInjector->injectTouchEvent (2, AMotionEvent_getRawX (event, 0),
                                                  AMotionEvent_getRawY (event, 0));
            }
            mInputInjector->injectTouchEvent (action, AMotionEvent_getRawX (event, 0),
                                              AMotionEvent_getRawY (event, 0));
        }
        else
        {
            mInputInjector->injectKeyEvent (AKeyEvent_getAction (event), AKeyEvent_getKeyCode (event));
        }

        return 1;
    }
    return 0;
}
开发者ID:OpenTechEngine-Libraries,项目名称:CEGUI,代码行数:25,代码来源:AndroidAppHelper.cpp


示例15: IN_Android_KeyEvent2UCS

/*
* IN_Android_KeyEvent2UCS
*/
static wchar_t IN_Android_KeyEvent2UCS( const AInputEvent *event )
{
	JNIEnv *env = Sys_Android_GetJNIEnv();
	static jclass mapClass;
	static jmethodID load, get;
	jobject map;
	unsigned int ucs;

	if( !mapClass )
	{
		jclass mapClassRef;

		mapClassRef = (*env)->FindClass( env, "android/view/KeyCharacterMap" );
		mapClass = (*env)->NewGlobalRef( env, mapClassRef );
		load = (*env)->GetStaticMethodID( env, mapClass, "load", "(I)Landroid/view/KeyCharacterMap;" );
		get = (*env)->GetMethodID( env, mapClass, "get", "(II)I" );
		(*env)->DeleteLocalRef( env, mapClassRef );
	}

	map = (*env)->CallStaticObjectMethod( env, mapClass, load, AInputEvent_getDeviceId( event ) );
	ucs = (*env)->CallIntMethod( env, map, get, AKeyEvent_getKeyCode( event ), AKeyEvent_getMetaState( event ) );
	(*env)->DeleteLocalRef( env, map );

	return ucs;
}
开发者ID:DenMSC,项目名称:qfusion,代码行数:28,代码来源:android_input.c


示例16: 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


示例17: engine_handle_key_evt

void engine_handle_key_evt (struct android_app* app, AInputEvent* event) {
	int32_t key_code;
	
	if (AKeyEvent_getAction(event) != AKEY_EVENT_ACTION_UP) {
		return;
	}
	
	key_code = AKeyEvent_getKeyCode(event);
}
开发者ID:Fyorl,项目名称:COMP4521-Android-Project,代码行数:9,代码来源:engine.c


示例18: getKeyRune

int32_t getKeyRune(JNIEnv* env, AInputEvent* e) {
	return (int32_t)(*env)->CallIntMethod(
		env,
		current_ctx,
		key_rune_method,
		AInputEvent_getDeviceId(e),
		AKeyEvent_getKeyCode(e),
		AKeyEvent_getMetaState(e)
	);
}
开发者ID:rockxcn,项目名称:mobile,代码行数:10,代码来源:android.c


示例19: _fireInputEvent

void ApplicationContextAndroid::_fireInputEventAndroid(AInputEvent* event, int wheel) {
    Event evt = {0};

    static TouchFingerEvent lastTouch = {0};

    if(wheel) {
        evt.type = MOUSEWHEEL;
        evt.wheel.y = wheel;
        _fireInputEvent(evt, 0);
        lastTouch.fingerId = -1; // prevent move-jump after pinch is over
        return;
    }

    if (AInputEvent_getType(event) == AINPUT_EVENT_TYPE_MOTION) {
        int32_t action = AMOTION_EVENT_ACTION_MASK & AMotionEvent_getAction(event);

        switch (action) {
        case AMOTION_EVENT_ACTION_DOWN:
            evt.type = FINGERDOWN;
            break;
        case AMOTION_EVENT_ACTION_UP:
            evt.type = FINGERUP;
            break;
        case AMOTION_EVENT_ACTION_MOVE:
            evt.type = FINGERMOTION;
            break;
        default:
            return;
        }

        Ogre::RenderWindow* win = getRenderWindow();

        evt.tfinger.fingerId = AMotionEvent_getPointerId(event, 0);
        evt.tfinger.x = AMotionEvent_getRawX(event, 0) / win->getWidth();
        evt.tfinger.y = AMotionEvent_getRawY(event, 0) / win->getHeight();

        if(evt.type == FINGERMOTION) {
            if(evt.tfinger.fingerId != lastTouch.fingerId)
                return; // wrong finger

            evt.tfinger.dx = evt.tfinger.x - lastTouch.x;
            evt.tfinger.dy = evt.tfinger.y - lastTouch.y;
        }

        lastTouch = evt.tfinger;
    } else {
        if(AKeyEvent_getKeyCode(event) != AKEYCODE_BACK)
            return;

        evt.type = AKeyEvent_getAction(event) == AKEY_EVENT_ACTION_DOWN ? KEYDOWN : KEYUP;
        evt.key.keysym.sym = SDLK_ESCAPE;
    }

    _fireInputEvent(evt, 0);
}
开发者ID:yiliu1203,项目名称:OGRE,代码行数:55,代码来源:OgreApplicationContextAndroid.cpp


示例20: android_handle_input

int32_t android_handle_input(struct android_app* app, AInputEvent* event)
{
    switch (AInputEvent_getType(event))
    {
        case AINPUT_EVENT_TYPE_KEY:
            return AKeyEvent_getKeyCode(event) == AKEYCODE_BACK;
        case AINPUT_EVENT_TYPE_MOTION:
            return android_handle_motion(app, event);
        default:
            return 0;
    }
}
开发者ID:wyrover,项目名称:rainbow,代码行数:12,代码来源:main.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ ALCcontext_DecRef函数代码示例发布时间:2022-05-30
下一篇:
C++ AKLOGE函数代码示例发布时间: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