-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OpenXR: Add support for binding modifiers
- Loading branch information
1 parent
9e60984
commit a304355
Showing
53 changed files
with
3,178 additions
and
832 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/**************************************************************************/ | ||
/* openxr_binding_modifier.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_binding_modifier.h" | ||
|
||
void OpenXRBindingModifier::_bind_methods() { | ||
GDVIRTUAL_BIND(_record_on_binding); | ||
GDVIRTUAL_BIND(_get_description); | ||
GDVIRTUAL_BIND(_get_ip_modification); | ||
} | ||
|
||
bool OpenXRBindingModifier::record_on_binding() const { | ||
bool res; | ||
if (GDVIRTUAL_CALL(_record_on_binding, res)) { | ||
return res; | ||
} | ||
return true; | ||
} | ||
|
||
String OpenXRBindingModifier::get_description() const { | ||
String desc; | ||
if (GDVIRTUAL_CALL(_get_description, desc)) { | ||
return desc; | ||
} | ||
return ""; | ||
} | ||
|
||
PackedByteArray OpenXRBindingModifier::get_ip_modification() { | ||
PackedByteArray data; | ||
if (GDVIRTUAL_CALL(_get_ip_modification, data)) { | ||
return data; | ||
} | ||
return PackedByteArray(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/**************************************************************************/ | ||
/* openxr_binding_modifier.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_BINDING_MODIFIER_H | ||
#define OPENXR_BINDING_MODIFIER_H | ||
|
||
#include "../action_map/openxr_action.h" | ||
#include "core/io/resource.h" | ||
|
||
// Part of implementation for: | ||
// https://registry.khronos.org/OpenXR/specs/1.1/html/xrspec.html#XR_KHR_binding_modification | ||
|
||
class OpenXRInteractionProfile; | ||
class OpenXRIPBinding; | ||
|
||
class OpenXRBindingModifier : public Resource { | ||
GDCLASS(OpenXRBindingModifier, Resource); | ||
|
||
private: | ||
protected: | ||
friend class OpenXRInteractionProfile; | ||
friend class OpenXRIPBinding; | ||
|
||
static void _bind_methods(); | ||
|
||
GDVIRTUAL0RC(bool, _record_on_binding) | ||
GDVIRTUAL0RC(String, _get_description) | ||
GDVIRTUAL0R(PackedByteArray, _get_ip_modification) | ||
|
||
OpenXRInteractionProfile *interaction_profile = nullptr; // action belongs to this interaction profile (should only be set if record_on_binding() == false). | ||
OpenXRIPBinding *ip_binding = nullptr; // action belongs to this binding (should only be set if record_on_binding() == true). | ||
|
||
public: | ||
OpenXRInteractionProfile *get_interaction_profile() const { return interaction_profile; } | ||
OpenXRIPBinding *get_ip_binding() const { return ip_binding; } | ||
|
||
virtual bool record_on_binding() const; // If true, this binding modifier is recorded on a specific binding. If false, this binding modifier is recorded on the interaction profile. | ||
|
||
virtual String get_description() const; // Returns the description shown in the editor | ||
virtual PackedByteArray get_ip_modification(); // Return the XrBindingModificationsKHR binding modifier struct data used when calling xrSuggestInteractionProfileBindings | ||
}; | ||
|
||
#endif // OPENXR_BINDING_MODIFIER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/**************************************************************************/ | ||
/* openxr_haptic_feedback.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_haptic_feedback.h" | ||
|
||
//////////////////////////////////////////////////////////////////////////// | ||
// OpenXRHapticBase | ||
|
||
void OpenXRHapticBase::_bind_methods() { | ||
} | ||
|
||
//////////////////////////////////////////////////////////////////////////// | ||
// OpenXRHapticVibration | ||
|
||
void OpenXRHapticVibration::_bind_methods() { | ||
ClassDB::bind_method(D_METHOD("set_duration", "duration"), &OpenXRHapticVibration::set_duration); | ||
ClassDB::bind_method(D_METHOD("get_duration"), &OpenXRHapticVibration::get_duration); | ||
ADD_PROPERTY(PropertyInfo(Variant::INT, "duration"), "set_duration", "get_duration"); | ||
|
||
ClassDB::bind_method(D_METHOD("set_frequency", "frequency"), &OpenXRHapticVibration::set_frequency); | ||
ClassDB::bind_method(D_METHOD("get_frequency"), &OpenXRHapticVibration::get_frequency); | ||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "frequency"), "set_frequency", "get_frequency"); | ||
|
||
ClassDB::bind_method(D_METHOD("set_amplitude", "amplitude"), &OpenXRHapticVibration::set_amplitude); | ||
ClassDB::bind_method(D_METHOD("get_amplitude"), &OpenXRHapticVibration::get_amplitude); | ||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "amplitude", PROPERTY_HINT_RANGE, "0.0,1.0,0.01"), "set_amplitude", "get_amplitude"); | ||
} | ||
|
||
void OpenXRHapticVibration::set_duration(int64_t p_duration) { | ||
haptic_vibration.duration = p_duration; | ||
emit_changed(); | ||
} | ||
|
||
int64_t OpenXRHapticVibration::get_duration() const { | ||
return haptic_vibration.duration; | ||
} | ||
|
||
void OpenXRHapticVibration::set_frequency(float p_frequency) { | ||
haptic_vibration.frequency = p_frequency; | ||
emit_changed(); | ||
} | ||
|
||
float OpenXRHapticVibration::get_frequency() const { | ||
return haptic_vibration.frequency; | ||
} | ||
|
||
void OpenXRHapticVibration::set_amplitude(float p_amplitude) { | ||
haptic_vibration.amplitude = p_amplitude; | ||
emit_changed(); | ||
} | ||
|
||
float OpenXRHapticVibration::get_amplitude() const { | ||
return haptic_vibration.amplitude; | ||
} | ||
|
||
const XrHapticBaseHeader *OpenXRHapticVibration::get_xr_structure() { | ||
return (XrHapticBaseHeader *)&haptic_vibration; | ||
} | ||
|
||
OpenXRHapticVibration::OpenXRHapticVibration() { | ||
haptic_vibration.type = XR_TYPE_HAPTIC_VIBRATION; | ||
haptic_vibration.next = nullptr; | ||
haptic_vibration.duration = -1; | ||
haptic_vibration.frequency = 0.0; | ||
haptic_vibration.amplitude = 1.0; | ||
} |
Oops, something went wrong.