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


Java InputDevice.SOURCE_DPAD属性代码示例

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


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

示例1: onKeyUp

@Override public boolean onKeyUp(int keyCode, KeyEvent event) {

		if (keyCode == KeyEvent.KEYCODE_BACK) {
			return true;
		}

		if (keyCode == KeyEvent.KEYCODE_VOLUME_UP || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
			return super.onKeyUp(keyCode, event);
		};

		int source = event.getSource();
		if ((source & InputDevice.SOURCE_JOYSTICK) != 0 || (source & InputDevice.SOURCE_DPAD) != 0 || (source & InputDevice.SOURCE_GAMEPAD) != 0) {

			int button = get_godot_button(keyCode);
			int device = event.getDeviceId();

			GodotLib.joybutton(device, button, false);
			return true;
		} else {

			GodotLib.key(keyCode, event.getUnicodeChar(0), false);
		};
		return super.onKeyUp(keyCode, event);
	}
 
开发者ID:ianholing,项目名称:Crazy-wheel-godot-google-play,代码行数:24,代码来源:GodotView.java

示例2: isDeviceSDLJoystick

public static boolean isDeviceSDLJoystick(int deviceId) {
    InputDevice device = InputDevice.getDevice(deviceId);
    // We cannot use InputDevice.isVirtual before API 16, so let's accept
    // only nonnegative device ids (VIRTUAL_KEYBOARD equals -1)
    if ((device == null) || (deviceId < 0)) {
        return false;
    }
    int sources = device.getSources();
    return (((sources & InputDevice.SOURCE_CLASS_JOYSTICK) == InputDevice.SOURCE_CLASS_JOYSTICK) ||
            ((sources & InputDevice.SOURCE_DPAD) == InputDevice.SOURCE_DPAD) ||
            ((sources & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD)
    );
}
 
开发者ID:jomof,项目名称:cdep-android-studio-freetype-sample,代码行数:13,代码来源:SDLActivity.java

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

示例4: onKeyDown

@Override public boolean onKeyDown(int keyCode, KeyEvent event) {

		if (keyCode == KeyEvent.KEYCODE_BACK) {
			GodotLib.quit();
			// press 'back' button should not terminate program
			//	normal handle 'back' event in game logic
			return true;
		}

		if (keyCode == KeyEvent.KEYCODE_VOLUME_UP || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
			return super.onKeyDown(keyCode, event);
		};

		int source = event.getSource();
		//Log.e(TAG, String.format("Key down! source %d, device %d, joystick %d, %d, %d", event.getDeviceId(), source, (source & InputDevice.SOURCE_JOYSTICK), (source & InputDevice.SOURCE_DPAD), (source & InputDevice.SOURCE_GAMEPAD)));

		if ((source & InputDevice.SOURCE_JOYSTICK) != 0 || (source & InputDevice.SOURCE_DPAD) != 0 || (source & InputDevice.SOURCE_GAMEPAD) != 0) {

			if (event.getRepeatCount() > 0) // ignore key echo
				return true;
			int button = get_godot_button(keyCode);
			int device = event.getDeviceId();
			//Log.e(TAG, String.format("joy button down! button %x, %d, device %d", keyCode, button, device));

			GodotLib.joybutton(device, button, true);
			return true;

		} else {
			GodotLib.key(keyCode, event.getUnicodeChar(0), true);
		};
		return super.onKeyDown(keyCode, event);
	}
 
开发者ID:ianholing,项目名称:Crazy-wheel-godot-google-play,代码行数:32,代码来源:GodotView.java

示例5: isDpadDevice

public static boolean isDpadDevice(InputEvent event) {
    // Check that input comes from a device with directional pads.
    if ((event.getSource() & InputDevice.SOURCE_DPAD)
            != InputDevice.SOURCE_DPAD) {
        return true;
    } else {
        return false;
    }
}
 
开发者ID:huntergdavis,项目名称:cantstoptherock,代码行数:9,代码来源:Dpad.java

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


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