diff options
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/mono/csharp_script.cpp | 2 | ||||
| -rw-r--r-- | modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs | 25 | ||||
| -rw-r--r-- | modules/mono/editor/GodotTools/GodotTools/Export/XcodeHelper.cs | 93 | ||||
| -rw-r--r-- | modules/mono/editor/GodotTools/GodotTools/Internals/Internal.cs | 9 | ||||
| -rw-r--r-- | modules/mono/editor/editor_internal_calls.cpp | 9 | ||||
| -rw-r--r-- | modules/openxr/extensions/openxr_mxink_extension.cpp | 83 | ||||
| -rw-r--r-- | modules/openxr/extensions/openxr_mxink_extension.h | 48 | ||||
| -rw-r--r-- | modules/openxr/openxr_interface.cpp | 3 | ||||
| -rw-r--r-- | modules/openxr/register_types.cpp | 2 |
9 files changed, 166 insertions, 108 deletions
diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index 36c8a40ed9..8bd0dd14bb 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -2351,8 +2351,8 @@ CSharpInstance *CSharpScript::_create_instance(const Variant **p_args, int p_arg if (!ok) { // Important to clear this before destroying the script instance here instance->script = Ref<CSharpScript>(); - instance->owner = nullptr; p_owner->set_script_instance(nullptr); + instance->owner = nullptr; return nullptr; } diff --git a/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs b/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs index d3720dcb72..ede0600ac1 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs @@ -355,24 +355,23 @@ namespace GodotTools.Export if (outputPaths.Count > 2) { // lipo the simulator binaries together - // TODO: Move this to the native lipo implementation we have in the macos export plugin. - var lipoArgs = new List<string>(); - lipoArgs.Add("-create"); - lipoArgs.AddRange(outputPaths.Skip(1).Select(x => Path.Combine(x, $"{GodotSharpDirs.ProjectAssemblyName}.dylib"))); - lipoArgs.Add("-output"); - lipoArgs.Add(Path.Combine(outputPaths[1], $"{GodotSharpDirs.ProjectAssemblyName}.dylib")); - int lipoExitCode = OS.ExecuteCommand(XcodeHelper.FindXcodeTool("lipo"), lipoArgs); - if (lipoExitCode != 0) - throw new InvalidOperationException($"Command 'lipo' exited with code: {lipoExitCode}."); + string outputPath = Path.Combine(outputPaths[1], $"{GodotSharpDirs.ProjectAssemblyName}.dylib"); + string[] files = outputPaths + .Skip(1) + .Select(path => Path.Combine(path, $"{GodotSharpDirs.ProjectAssemblyName}.dylib")) + .ToArray(); + + if (!Internal.LipOCreateFile(outputPath, files)) + { + throw new InvalidOperationException($"Failed to 'lipo' simulator binaries."); + } outputPaths.RemoveRange(2, outputPaths.Count - 2); } - var xcFrameworkPath = Path.Combine(GodotSharpDirs.ProjectBaseOutputPath, publishConfig.BuildConfig, - $"{GodotSharpDirs.ProjectAssemblyName}_aot.xcframework"); - if (!BuildManager.GenerateXCFrameworkBlocking(outputPaths, - Path.Combine(GodotSharpDirs.ProjectBaseOutputPath, publishConfig.BuildConfig, xcFrameworkPath))) + string xcFrameworkPath = Path.Combine(GodotSharpDirs.ProjectBaseOutputPath, publishConfig.BuildConfig, $"{GodotSharpDirs.ProjectAssemblyName}_aot.xcframework"); + if (!BuildManager.GenerateXCFrameworkBlocking(outputPaths, xcFrameworkPath)) { throw new InvalidOperationException("Failed to generate xcframework."); } diff --git a/modules/mono/editor/GodotTools/GodotTools/Export/XcodeHelper.cs b/modules/mono/editor/GodotTools/GodotTools/Export/XcodeHelper.cs deleted file mode 100644 index 023f46b685..0000000000 --- a/modules/mono/editor/GodotTools/GodotTools/Export/XcodeHelper.cs +++ /dev/null @@ -1,93 +0,0 @@ -using System; -using System.IO; - -namespace GodotTools.Export -{ - public static class XcodeHelper - { - private static string? _XcodePath = null; - - public static string XcodePath - { - get - { - if (_XcodePath == null) - { - _XcodePath = FindXcode(); - - if (_XcodePath == null) - throw new FileNotFoundException("Could not find Xcode."); - } - - return _XcodePath; - } - } - - private static string? FindSelectedXcode() - { - var outputWrapper = new Godot.Collections.Array(); - - int exitCode = Godot.OS.Execute("xcode-select", new string[] { "--print-path" }, output: outputWrapper); - - if (exitCode == 0) - { - string output = (string)outputWrapper[0]; - return output.Trim(); - } - - Console.Error.WriteLine($"'xcode-select --print-path' exited with code: {exitCode}"); - - return null; - } - - public static string? FindXcode() - { - string? selectedXcode = FindSelectedXcode(); - if (selectedXcode != null) - { - if (Directory.Exists(Path.Combine(selectedXcode, "Contents", "Developer"))) - return selectedXcode; - - // The path already pointed to Contents/Developer - var dirInfo = new DirectoryInfo(selectedXcode); - if (dirInfo is not { Parent.Name: "Contents", Name: "Developer" }) - { - Console.WriteLine(Path.GetDirectoryName(selectedXcode)); - Console.WriteLine(System.IO.Directory.GetParent(selectedXcode)?.Name); - Console.Error.WriteLine("Unrecognized path for selected Xcode"); - } - else - { - return System.IO.Path.GetFullPath($"{selectedXcode}/../.."); - } - } - else - { - Console.Error.WriteLine("Could not find the selected Xcode; trying with a hint path"); - } - - const string XcodeHintPath = "/Applications/Xcode.app"; - - if (Directory.Exists(XcodeHintPath)) - { - if (Directory.Exists(Path.Combine(XcodeHintPath, "Contents", "Developer"))) - return XcodeHintPath; - - Console.Error.WriteLine($"Found Xcode at '{XcodeHintPath}' but it's missing the 'Contents/Developer' sub-directory"); - } - - return null; - } - - public static string FindXcodeTool(string toolName) - { - string XcodeDefaultToolchain = Path.Combine(XcodePath, "Contents", "Developer", "Toolchains", "XcodeDefault.xctoolchain"); - - string path = Path.Combine(XcodeDefaultToolchain, "usr", "bin", toolName); - if (File.Exists(path)) - return path; - - throw new FileNotFoundException($"Cannot find Xcode tool: {toolName}"); - } - } -} diff --git a/modules/mono/editor/GodotTools/GodotTools/Internals/Internal.cs b/modules/mono/editor/GodotTools/GodotTools/Internals/Internal.cs index 175bb78051..225ac4073b 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Internals/Internal.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Internals/Internal.cs @@ -35,6 +35,13 @@ namespace GodotTools.Internals return godot_icall_Internal_IsMacOSAppBundleInstalled(bundleIdIn); } + public static bool LipOCreateFile(string outputPath, string[] files) + { + using godot_string outputPathIn = Marshaling.ConvertStringToNative(outputPath); + using godot_packed_string_array filesIn = Marshaling.ConvertSystemArrayToNativePackedStringArray(files); + return godot_icall_Internal_LipOCreateFile(outputPathIn, filesIn); + } + public static bool GodotIs32Bits() => godot_icall_Internal_GodotIs32Bits(); public static bool GodotIsRealTDouble() => godot_icall_Internal_GodotIsRealTDouble(); @@ -121,6 +128,8 @@ namespace GodotTools.Internals private static partial bool godot_icall_Internal_IsMacOSAppBundleInstalled(in godot_string bundleId); + private static partial bool godot_icall_Internal_LipOCreateFile(in godot_string outputPath, in godot_packed_string_array files); + private static partial bool godot_icall_Internal_GodotIs32Bits(); private static partial bool godot_icall_Internal_GodotIsRealTDouble(); diff --git a/modules/mono/editor/editor_internal_calls.cpp b/modules/mono/editor/editor_internal_calls.cpp index 03d8b4eab6..7322a47630 100644 --- a/modules/mono/editor/editor_internal_calls.cpp +++ b/modules/mono/editor/editor_internal_calls.cpp @@ -44,6 +44,7 @@ #include "editor/editor_node.h" #include "editor/editor_paths.h" #include "editor/editor_settings.h" +#include "editor/export/lipo.h" #include "editor/gui/editor_run_bar.h" #include "editor/plugins/script_editor_plugin.h" #include "editor/themes/editor_scale.h" @@ -117,6 +118,13 @@ bool godot_icall_Internal_IsMacOSAppBundleInstalled(const godot_string *p_bundle #endif } +bool godot_icall_Internal_LipOCreateFile(const godot_string *p_output_path, const godot_packed_array *p_files) { + String output_path = *reinterpret_cast<const String *>(p_output_path); + PackedStringArray files = *reinterpret_cast<const PackedStringArray *>(p_files); + LipO lip; + return lip.create_file(output_path, files); +} + bool godot_icall_Internal_GodotIs32Bits() { return sizeof(void *) == 4; } @@ -258,6 +266,7 @@ static const void *unmanaged_callbacks[]{ (void *)godot_icall_EditorProgress_Step, (void *)godot_icall_Internal_FullExportTemplatesDir, (void *)godot_icall_Internal_IsMacOSAppBundleInstalled, + (void *)godot_icall_Internal_LipOCreateFile, (void *)godot_icall_Internal_GodotIs32Bits, (void *)godot_icall_Internal_GodotIsRealTDouble, (void *)godot_icall_Internal_GodotMainIteration, diff --git a/modules/openxr/extensions/openxr_mxink_extension.cpp b/modules/openxr/extensions/openxr_mxink_extension.cpp new file mode 100644 index 0000000000..fe48583c27 --- /dev/null +++ b/modules/openxr/extensions/openxr_mxink_extension.cpp @@ -0,0 +1,83 @@ +/**************************************************************************/ +/* openxr_mxink_extension.cpp */ +/**************************************************************************/ +/* 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. */ +/**************************************************************************/ + +#include "openxr_mxink_extension.h" + +#include "../action_map/openxr_interaction_profile_metadata.h" + +// Not in base XR libs needs def +#define XR_LOGITECH_MX_INK_STYLUS_INTERACTION_EXTENSION_NAME "XR_LOGITECH_mx_ink_stylus_interaction" + +HashMap<String, bool *> OpenXRMxInkExtension::get_requested_extensions() { + HashMap<String, bool *> request_extensions; + + request_extensions[XR_LOGITECH_MX_INK_STYLUS_INTERACTION_EXTENSION_NAME] = &available; + + return request_extensions; +} + +bool OpenXRMxInkExtension::is_available() { + return available; +} + +void OpenXRMxInkExtension::on_register_metadata() { + OpenXRInteractionProfileMetadata *metadata = OpenXRInteractionProfileMetadata::get_singleton(); + ERR_FAIL_NULL(metadata); + + // Logitech MX Ink Stylus + metadata->register_interaction_profile("Logitech MX Ink Stylus", "/interaction_profiles/logitech/mx_ink_stylus_logitech", XR_LOGITECH_MX_INK_STYLUS_INTERACTION_EXTENSION_NAME); + + metadata->register_io_path("/interaction_profiles/logitech/mx_ink_stylus_logitech", "Tip Force", "/user/hand/left", "/user/hand/left/input/tip_logitech/force", "", OpenXRAction::OPENXR_ACTION_FLOAT); + metadata->register_io_path("/interaction_profiles/logitech/mx_ink_stylus_logitech", "Middle force", "/user/hand/left", "/user/hand/left/input/cluster_middle_logitech/force", "", OpenXRAction::OPENXR_ACTION_FLOAT); + metadata->register_io_path("/interaction_profiles/logitech/mx_ink_stylus_logitech", "Front click", "/user/hand/left", "/user/hand/left/input/cluster_front_logitech/click", "", OpenXRAction::OPENXR_ACTION_BOOL); + metadata->register_io_path("/interaction_profiles/logitech/mx_ink_stylus_logitech", "Front double", "/user/hand/left", "/user/hand/left/input/cluster_front_logitech/double_tap_logitech", "", OpenXRAction::OPENXR_ACTION_BOOL); + metadata->register_io_path("/interaction_profiles/logitech/mx_ink_stylus_logitech", "Back click", "/user/hand/left", "/user/hand/left/input/cluster_back_logitech/click", "", OpenXRAction::OPENXR_ACTION_BOOL); + metadata->register_io_path("/interaction_profiles/logitech/mx_ink_stylus_logitech", "Back double", "/user/hand/left", "/user/hand/left/input/cluster_back_logitech/double_tap_logitech", "", OpenXRAction::OPENXR_ACTION_BOOL); + metadata->register_io_path("/interaction_profiles/logitech/mx_ink_stylus_logitech", "System click", "/user/hand/left", "/user/hand/left/input/system/click", "", OpenXRAction::OPENXR_ACTION_BOOL); + metadata->register_io_path("/interaction_profiles/logitech/mx_ink_stylus_logitech", "Docked", "/user/hand/left", "/user/hand/left/input/dock_logitech/docked_logitech", "", OpenXRAction::OPENXR_ACTION_BOOL); + metadata->register_io_path("/interaction_profiles/logitech/mx_ink_stylus_logitech", "Grip pose", "/user/hand/left", "/user/hand/left/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE); + metadata->register_io_path("/interaction_profiles/logitech/mx_ink_stylus_logitech", "Aim pose", "/user/hand/left", "/user/hand/left/input/aim/pose", "", OpenXRAction::OPENXR_ACTION_POSE); + metadata->register_io_path("/interaction_profiles/logitech/mx_ink_stylus_logitech", "Tip pose", "/user/hand/left", "/user/hand/left/input/tip_logitech/pose", "", OpenXRAction::OPENXR_ACTION_POSE); + + metadata->register_io_path("/interaction_profiles/logitech/mx_ink_stylus_logitech", "Tip Force", "/user/hand/right", "/user/hand/right/input/tip_logitech/force", "", OpenXRAction::OPENXR_ACTION_FLOAT); + metadata->register_io_path("/interaction_profiles/logitech/mx_ink_stylus_logitech", "Middle force", "/user/hand/right", "/user/hand/right/input/cluster_middle_logitech/force", "", OpenXRAction::OPENXR_ACTION_FLOAT); + metadata->register_io_path("/interaction_profiles/logitech/mx_ink_stylus_logitech", "Front click", "/user/hand/right", "/user/hand/right/input/cluster_front_logitech/click", "", OpenXRAction::OPENXR_ACTION_BOOL); + metadata->register_io_path("/interaction_profiles/logitech/mx_ink_stylus_logitech", "Front double", "/user/hand/right", "/user/hand/right/input/cluster_front_logitech/double_tap_logitech", "", OpenXRAction::OPENXR_ACTION_BOOL); + metadata->register_io_path("/interaction_profiles/logitech/mx_ink_stylus_logitech", "Back click", "/user/hand/right", "/user/hand/right/input/cluster_back_logitech/click", "", OpenXRAction::OPENXR_ACTION_BOOL); + metadata->register_io_path("/interaction_profiles/logitech/mx_ink_stylus_logitech", "Back double", "/user/hand/right", "/user/hand/right/input/cluster_back_logitech/double_tap_logitech", "", OpenXRAction::OPENXR_ACTION_BOOL); + metadata->register_io_path("/interaction_profiles/logitech/mx_ink_stylus_logitech", "System click", "/user/hand/right", "/user/hand/right/input/system/click", "", OpenXRAction::OPENXR_ACTION_BOOL); + metadata->register_io_path("/interaction_profiles/logitech/mx_ink_stylus_logitech", "Docked", "/user/hand/right", "/user/hand/right/input/dock_logitech/docked_logitech", "", OpenXRAction::OPENXR_ACTION_BOOL); + metadata->register_io_path("/interaction_profiles/logitech/mx_ink_stylus_logitech", "Grip pose", "/user/hand/right", "/user/hand/right/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE); + metadata->register_io_path("/interaction_profiles/logitech/mx_ink_stylus_logitech", "Aim pose", "/user/hand/right", "/user/hand/right/input/aim/pose", "", OpenXRAction::OPENXR_ACTION_POSE); + metadata->register_io_path("/interaction_profiles/logitech/mx_ink_stylus_logitech", "Tip pose", "/user/hand/right", "/user/hand/right/input/tip_logitech/pose", "", OpenXRAction::OPENXR_ACTION_POSE); + + metadata->register_io_path("/interaction_profiles/logitech/mx_ink_stylus_logitech", "Haptic output", "/user/hand/left", "/user/hand/left/output/haptic", "", OpenXRAction::OPENXR_ACTION_HAPTIC); + metadata->register_io_path("/interaction_profiles/logitech/mx_ink_stylus_logitech", "Haptic output", "/user/hand/right", "/user/hand/right/output/haptic", "", OpenXRAction::OPENXR_ACTION_HAPTIC); +} diff --git a/modules/openxr/extensions/openxr_mxink_extension.h b/modules/openxr/extensions/openxr_mxink_extension.h new file mode 100644 index 0000000000..fe0cf866aa --- /dev/null +++ b/modules/openxr/extensions/openxr_mxink_extension.h @@ -0,0 +1,48 @@ +/**************************************************************************/ +/* openxr_mxink_extension.h */ +/**************************************************************************/ +/* 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. */ +/**************************************************************************/ + +#ifndef OPENXR_MXINK_EXTENSION_H +#define OPENXR_MXINK_EXTENSION_H + +#include "openxr_extension_wrapper.h" + +class OpenXRMxInkExtension : public OpenXRExtensionWrapper { +public: + virtual HashMap<String, bool *> get_requested_extensions() override; + + bool is_available(); + + virtual void on_register_metadata() override; + +private: + bool available = false; +}; + +#endif // OPENXR_MXINK_EXTENSION_H diff --git a/modules/openxr/openxr_interface.cpp b/modules/openxr/openxr_interface.cpp index cce9c09361..73ac529537 100644 --- a/modules/openxr/openxr_interface.cpp +++ b/modules/openxr/openxr_interface.cpp @@ -36,7 +36,8 @@ #include "extensions/openxr_eye_gaze_interaction.h" #include "extensions/openxr_hand_interaction_extension.h" -#include "thirdparty/openxr/include/openxr/openxr.h" + +#include <openxr/openxr.h> void OpenXRInterface::_bind_methods() { // lifecycle signals diff --git a/modules/openxr/register_types.cpp b/modules/openxr/register_types.cpp index 85514737f2..64381ae1c7 100644 --- a/modules/openxr/register_types.cpp +++ b/modules/openxr/register_types.cpp @@ -57,6 +57,7 @@ #include "extensions/openxr_local_floor_extension.h" #include "extensions/openxr_meta_controller_extension.h" #include "extensions/openxr_ml2_controller_extension.h" +#include "extensions/openxr_mxink_extension.h" #include "extensions/openxr_palm_pose_extension.h" #include "extensions/openxr_pico_controller_extension.h" #include "extensions/openxr_wmr_controller_extension.h" @@ -126,6 +127,7 @@ void initialize_openxr_module(ModuleInitializationLevel p_level) { OpenXRAPI::register_extension_wrapper(memnew(OpenXRMetaControllerExtension)); OpenXRAPI::register_extension_wrapper(memnew(OpenXREyeGazeInteractionExtension)); OpenXRAPI::register_extension_wrapper(memnew(OpenXRHandInteractionExtension)); + OpenXRAPI::register_extension_wrapper(memnew(OpenXRMxInkExtension)); // register gated extensions if (GLOBAL_GET("xr/openxr/extensions/hand_tracking")) { |
