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


Java KeyEvent.getSource方法代码示例

本文整理汇总了Java中android.view.KeyEvent.getSource方法的典型用法代码示例。如果您正苦于以下问题:Java KeyEvent.getSource方法的具体用法?Java KeyEvent.getSource怎么用?Java KeyEvent.getSource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.KeyEvent的用法示例。


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

示例1: onKeyDown

import android.view.KeyEvent; //导入方法依赖的package包/类
@Override
public boolean onKeyDown(int keyCode, final KeyEvent event)
{
	if( keyCode == KeyEvent.KEYCODE_BACK )
	{
		if( (event.getSource() & InputDevice.SOURCE_MOUSE) == InputDevice.SOURCE_MOUSE )
		{
			// Stupid Samsung and stupid Acer remaps right mouse button to BACK key
			nativeMouseButtonsPressed(2, 1);
			return true;
		}
		else if( mClient.isKeyboardWithoutTextInputShown() )
		{
			return true;
		}
	}

	if( nativeKey( keyCode, 1, event.getUnicodeChar(), DifferentTouchInput.processGamepadDeviceId(event.getDevice()) ) == 0 )
		return super.onKeyDown(keyCode, event);

	return true;
}
 
开发者ID:NeoTerm,项目名称:NeoTerm,代码行数:23,代码来源:Video.java

示例2: onKeyUp

import android.view.KeyEvent; //导入方法依赖的package包/类
@Override
public boolean onKeyUp(int keyCode, final KeyEvent event)
{
	if( keyCode == KeyEvent.KEYCODE_BACK )
	{
		if( (event.getSource() & InputDevice.SOURCE_MOUSE) == InputDevice.SOURCE_MOUSE )
		{
			// Stupid Samsung and stupid Acer remaps right mouse button to BACK key
			nativeMouseButtonsPressed(2, 0);
			return true;
		}
		else if( mClient.isKeyboardWithoutTextInputShown() )
		{
			mClient.showScreenKeyboardWithoutTextInputField(0); // Hide keyboard
			return true;
		}
	}

	if( nativeKey( keyCode, 0, event.getUnicodeChar(), DifferentTouchInput.processGamepadDeviceId(event.getDevice()) ) == 0 )
		return super.onKeyUp(keyCode, event);

	//if( keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU )
	//	DimSystemStatusBar.get().dim(mClient._videoLayout);

	return true;
}
 
开发者ID:NeoTerm,项目名称:NeoTerm,代码行数:27,代码来源:Video.java

示例3: onKey

import android.view.KeyEvent; //导入方法依赖的package包/类
@Override
public boolean onKey(View  v, int keyCode, KeyEvent event) {
    // Dispatch the different events depending on where they come from
    // Some SOURCE_JOYSTICK, SOURCE_DPAD or SOURCE_GAMEPAD are also SOURCE_KEYBOARD
    // So, we try to process them as JOYSTICK/DPAD/GAMEPAD events first, if that fails we try them as KEYBOARD
    //
    // Furthermore, it's possible a game controller has SOURCE_KEYBOARD and
    // SOURCE_JOYSTICK, while its key events arrive from the keyboard source
    // So, retrieve the device itself and check all of its sources
    if (SDLActivity.isDeviceSDLJoystick(event.getDeviceId())) {
        // Note that we process events with specific key codes here
        if (event.getAction() == KeyEvent.ACTION_DOWN) {
            if (SDLActivity.onNativePadDown(event.getDeviceId(), keyCode) == 0) {
                return true;
            }
        } else if (event.getAction() == KeyEvent.ACTION_UP) {
            if (SDLActivity.onNativePadUp(event.getDeviceId(), keyCode) == 0) {
                return true;
            }
        }
    }

    if ((event.getSource() & InputDevice.SOURCE_KEYBOARD) != 0) {
        if (event.getAction() == KeyEvent.ACTION_DOWN) {
            //Log.v("SDL", "key down: " + keyCode);
            SDLActivity.onNativeKeyDown(keyCode);
            return true;
        }
        else if (event.getAction() == KeyEvent.ACTION_UP) {
            //Log.v("SDL", "key up: " + keyCode);
            SDLActivity.onNativeKeyUp(keyCode);
            return true;
        }
    }

    if ((event.getSource() & InputDevice.SOURCE_MOUSE) != 0) {
        // on some devices key events are sent for mouse BUTTON_BACK/FORWARD presses
        // they are ignored here because sending them as mouse input to SDL is messy
        if ((keyCode == KeyEvent.KEYCODE_BACK) || (keyCode == KeyEvent.KEYCODE_FORWARD)) {
            switch (event.getAction()) {
            case KeyEvent.ACTION_DOWN:
            case KeyEvent.ACTION_UP:
                // mark the event as handled or it will be handled by system
                // handling KEYCODE_BACK by system will call onBackPressed()
                return true;
            }
        }
    }

    return false;
}
 
开发者ID:jomof,项目名称:cdep-android-studio-freetype-sample,代码行数:52,代码来源:SDLActivity.java


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