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


Java InputDevice.SOURCE_MOUSE属性代码示例

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


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

示例1: onTouchEvent

@Override
public boolean onTouchEvent(MotionEvent event) {
	if (event.getAction() == MotionEvent.ACTION_DOWN) {
		// Selection may be beginning. Sync the TextView with the buffer.
		refreshTextFromBuffer();
	}

	// Mouse input is treated differently:
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH &&
			MotionEventCompat.getSource(event) == InputDevice.SOURCE_MOUSE) {
		if (onMouseEvent(event, terminalView.bridge)) {
			return true;
		}
		terminalView.viewPager.setPagingEnabled(true);
	} else {
		if (terminalView.onTouchEvent(event)) {
			return true;
		}
	}

	return super.onTouchEvent(event);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:TerminalTextViewOverlay.java

示例2: onKeyDown

@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,代码行数:22,代码来源:Video.java

示例3: onKeyUp

@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,代码行数:26,代码来源:Video.java

示例4: shouldBeRightClick

protected boolean shouldBeRightClick (KeyEvent e) {
    boolean result = false;
    int keyCode = e.getKeyCode();
    
    // If the camera button is pressed
    if (keyCode == KeyEvent.KEYCODE_CAMERA) {
        result = true;
    // Or the back button is pressed
    } else if (keyCode == KeyEvent.KEYCODE_BACK) {
        // Determine SDK
        boolean preGingerBread = android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD;
        // Whether the source is a mouse (getSource() is not available pre-Gingerbread)
        boolean mouseSource = (!preGingerBread && e.getSource() == InputDevice.SOURCE_MOUSE);
        // Whether the device has a qwerty keyboard
        boolean noQwertyKbd = (context.getResources().getConfiguration().keyboard != Configuration.KEYBOARD_QWERTY);
        // Whether the device is pre-Gingerbread or the event came from the "hard buttons"
        boolean fromVirtualHardKey = preGingerBread || (e.getFlags() & KeyEvent.FLAG_VIRTUAL_HARD_KEY) != 0;
        if (mouseSource || noQwertyKbd || fromVirtualHardKey) {
            result = true;
        }
    }
    
    return result;
}
 
开发者ID:runsoftdev,项目名称:bVnc,代码行数:24,代码来源:RemotePointer.java

示例5: mouseEventToJavaModifiers

/**
 * Takes an android mouse event and produces a Java InputEvent modifiers int which can be
 * passed to vt320.
 * @param mouseEvent The {@link MotionEvent} which should be a mouse click or release.
 * @return A Java InputEvent modifier int. See
 * http://docs.oracle.com/javase/7/docs/api/java/awt/event/InputEvent.html
 */
@TargetApi(14)
private static int mouseEventToJavaModifiers(MotionEvent mouseEvent) {
	if (MotionEventCompat.getSource(mouseEvent) != InputDevice.SOURCE_MOUSE) return 0;

	int mods = 0;

	// See http://docs.oracle.com/javase/7/docs/api/constant-values.html
	int buttonState = mouseEvent.getButtonState();
	if ((buttonState & MotionEvent.BUTTON_PRIMARY) != 0)
		mods |= 16;
	if ((buttonState & MotionEvent.BUTTON_SECONDARY) != 0)
		mods |= 8;
	if ((buttonState & MotionEvent.BUTTON_TERTIARY) != 0)
		mods |= 4;

	// Note: Meta and Ctrl are intentionally swapped here to keep logic in vt320 simple.
	int meta = mouseEvent.getMetaState();
	if ((meta & KeyEvent.META_META_ON) != 0)
		mods |= 2;
	if ((meta & KeyEvent.META_SHIFT_ON) != 0)
		mods |= 1;
	if ((meta & KeyEvent.META_CTRL_ON) != 0)
		mods |= 4;

	return mods;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:33,代码来源:TerminalTextViewOverlay.java

示例6: onGenericMotion

@Override
public boolean onGenericMotion(View v, MotionEvent event) {
    float x, y;
    int action;

    switch ( event.getSource() ) {
        case InputDevice.SOURCE_JOYSTICK:
        case InputDevice.SOURCE_GAMEPAD:
        case InputDevice.SOURCE_DPAD:
            return SDLActivity.handleJoystickMotionEvent(event);

        case InputDevice.SOURCE_MOUSE:
            action = event.getActionMasked();
            switch (action) {
                case MotionEvent.ACTION_SCROLL:
                    x = event.getAxisValue(MotionEvent.AXIS_HSCROLL, 0);
                    y = event.getAxisValue(MotionEvent.AXIS_VSCROLL, 0);
                    SDLActivity.onNativeMouse(0, action, x, y);
                    return true;

                case MotionEvent.ACTION_HOVER_MOVE:
                    x = event.getX(0);
                    y = event.getY(0);

                    SDLActivity.onNativeMouse(0, action, x, y);
                    return true;

                default:
                    break;
            }
            break;

        default:
            break;
    }

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

示例7: toolTypeToInputSource

public static int toolTypeToInputSource(final int toolType) {
    switch (toolType) {
        case MotionEvent.TOOL_TYPE_MOUSE:
            return InputDevice.SOURCE_MOUSE;
        case MotionEvent.TOOL_TYPE_STYLUS:
            return InputDevice.SOURCE_STYLUS;
        case MotionEvent.TOOL_TYPE_FINGER:
            return InputDevice.SOURCE_TOUCHSCREEN;
    }
    return InputDevice.SOURCE_MOUSE;
}
 
开发者ID:appium,项目名称:appium-uiautomator2-server,代码行数:11,代码来源:ActionsHelpers.java

示例8: onKey

@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,代码行数:51,代码来源:SDLActivity.java

示例9: checkUiChoice

/**
 * Check if the input event make us think that user is on TV.
 * If it is the case and if the Ui mode is not setup, then we propose to try the TV UI.
 * @param event
 */
private void checkUiChoice(InputEvent event) {

    // Make sure we go through this method only once
    if (sUiChoiceCheckDone) {
        return;
    }
    sUiChoiceCheckDone = true;

    // No need to check more if this APK does not integrate the leanback UI (this is decided at build time)
    if (!EntryActivity.isLeanbackUiAvailable()) {
        return;
    }

    boolean probablyTv = false;

    switch (event.getSource()) {
        // All these case mean the user is probably on TV
        case InputDevice.SOURCE_KEYBOARD:
        case InputDevice.SOURCE_TOUCHPAD:
        case InputDevice.SOURCE_DPAD:
        case InputDevice.SOURCE_GAMEPAD:
        case InputDevice.SOURCE_JOYSTICK:
        case InputDevice.SOURCE_HDMI:
            Log.d(TAG, "event source = "+event.getSource()+" -> probably TV");
            probablyTv = true;
            break;
        case InputDevice.SOURCE_STYLUS:
        case InputDevice.SOURCE_TOUCHSCREEN:
        case InputDevice.SOURCE_TRACKBALL:
        case InputDevice.SOURCE_MOUSE:
        default:
            Log.d(TAG, "event source = "+event.getSource()+" -> probably not TV");
            probablyTv = false;
            break;
    }

    if (!probablyTv) {
        return;
    }

    final String uiMode = PreferenceManager.getDefaultSharedPreferences(this)
            .getString(UiChoiceDialog.UI_CHOICE_LEANBACK_KEY, "unset");

    // If the choice has not been done yet, ask user
    if (uiMode.equals("unset") &&
         !getPackageManager().hasSystemFeature(PackageManager.FEATURE_LEANBACK)) { // no UI choice to do on actual AndroidTV devices
        new UiChoiceDialog().show(getFragmentManager(), "UiChoiceDialog");
    }
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:54,代码来源:MainActivity.java

示例10: process

public void process(final MotionEvent event)
{
	int hwMouseEvent =  ((event.getSource() & InputDevice.SOURCE_MOUSE) == InputDevice.SOURCE_MOUSE || Globals.ForceHardwareMouse) ? Mouse.MOUSE_HW_INPUT_MOUSE :
						((event.getSource() & InputDevice.SOURCE_STYLUS) == InputDevice.SOURCE_STYLUS) ? Mouse.MOUSE_HW_INPUT_STYLUS :
						Mouse.MOUSE_HW_INPUT_FINGER;
	if( ExternalMouseDetected != hwMouseEvent )
	{
		ExternalMouseDetected = hwMouseEvent;
		DemoGLSurfaceView.nativeHardwareMouseDetected(hwMouseEvent);
	}
	super.process(event);
	if( !Globals.FingerHover && ExternalMouseDetected == Mouse.MOUSE_HW_INPUT_FINGER )
		return; // Finger hover disabled in settings
	if( (event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_HOVER_MOVE ) // Support bluetooth/USB mouse - available since Android 3.1
	{
		int action;
		// TODO: it is possible that multiple pointers return that event, but we're handling only pointer #0
		if( touchEvents[0].down )
			action = Mouse.SDL_FINGER_UP;
		else
			action = Mouse.SDL_FINGER_HOVER;
		touchEvents[0].down = false;
		touchEvents[0].x = (int)event.getX();
		touchEvents[0].y = (int)event.getY();
		touchEvents[0].pressure = Mouse.MAX_HOVER_DISTANCE;
		touchEvents[0].size = 0;
		//if( event.getAxisValue(MotionEvent.AXIS_DISTANCE) != 0.0f )
		InputDevice device = InputDevice.getDevice(event.getDeviceId());
		if( device != null && device.getMotionRange(MotionEvent.AXIS_DISTANCE) != null &&
			device.getMotionRange(MotionEvent.AXIS_DISTANCE).getRange() > 0.0f )
			touchEvents[0].pressure = (int)((event.getAxisValue(MotionEvent.AXIS_DISTANCE) -
					device.getMotionRange(MotionEvent.AXIS_DISTANCE).getMin()) * Mouse.MAX_PRESSURE / device.getMotionRange(MotionEvent.AXIS_DISTANCE).getRange());
		DemoGLSurfaceView.nativeMotionEvent( touchEvents[0].x, touchEvents[0].y, action, 0, touchEvents[0].pressure, touchEvents[0].size );
	}
	if( (event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_HOVER_EXIT ) // Update screen for finger hover
	{
		touchEvents[0].pressure = Mouse.HOVER_REDRAW_SCREEN;
		touchEvents[0].size = 0;
		DemoGLSurfaceView.nativeMotionEvent( touchEvents[0].x, touchEvents[0].y, Mouse.SDL_FINGER_HOVER, 0, touchEvents[0].pressure, touchEvents[0].size );
	}
}
 
开发者ID:NeoTerm,项目名称:NeoTerm,代码行数:41,代码来源:Video.java


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