1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-06 12:20:30 +00:00

Improve support for XR projects

This commit is contained in:
Fredia Huya-Kouadio
2024-04-20 10:24:11 -07:00
parent 835808ed8f
commit 9dc0543da7
22 changed files with 572 additions and 99 deletions

View File

@@ -31,6 +31,7 @@
package org.godotengine.godot;
import org.godotengine.godot.input.GodotInputHandler;
import org.godotengine.godot.utils.DeviceUtils;
import android.view.SurfaceView;
@@ -63,7 +64,11 @@ public interface GodotRenderView {
void setPointerIcon(int pointerType);
/**
* @return true if pointer capture is supported.
*/
default boolean canCapturePointer() {
return getInputHandler().canCapturePointer();
// Pointer capture is not supported on Horizon OS
return !DeviceUtils.isHorizonOSDevice() && getInputHandler().canCapturePointer();
}
}

View File

@@ -68,6 +68,7 @@ class GodotVulkanRenderView extends VkSurfaceView implements GodotRenderView {
setPointerIcon(PointerIcon.getSystemIcon(getContext(), PointerIcon.TYPE_DEFAULT));
}
setFocusableInTouchMode(true);
setClickable(false);
}
@Override
@@ -132,17 +133,17 @@ class GodotVulkanRenderView extends VkSurfaceView implements GodotRenderView {
@Override
public boolean onKeyUp(final int keyCode, KeyEvent event) {
return mInputHandler.onKeyUp(keyCode, event);
return mInputHandler.onKeyUp(keyCode, event) || super.onKeyUp(keyCode, event);
}
@Override
public boolean onKeyDown(final int keyCode, KeyEvent event) {
return mInputHandler.onKeyDown(keyCode, event);
return mInputHandler.onKeyDown(keyCode, event) || super.onKeyDown(keyCode, event);
}
@Override
public boolean onGenericMotionEvent(MotionEvent event) {
return mInputHandler.onGenericMotionEvent(event);
return mInputHandler.onGenericMotionEvent(event) || super.onGenericMotionEvent(event);
}
@Override

View File

@@ -0,0 +1,52 @@
/**************************************************************************/
/* DeviceUtils.kt */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
/**
* Contains utility methods for detecting specific devices.
*/
@file:JvmName("DeviceUtils")
package org.godotengine.godot.utils
import android.os.Build
/**
* Returns true if running on Meta's Horizon OS.
*/
fun isHorizonOSDevice(): Boolean {
return "Oculus".equals(Build.BRAND, true)
}
/**
* Returns true if running on a native Android XR device.
*/
fun isNativeXRDevice(): Boolean {
return isHorizonOSDevice()
}