Created
May 5, 2022 11:56
-
-
Save cmdr2/51b6377b92f61d41ebbebe3ad4cdb4f8 to your computer and use it in GitHub Desktop.
Diff for exposing user_path and user_path_other in the Blender XrEventData
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
diff --git a/source/blender/makesrna/intern/rna_xr.c b/source/blender/makesrna/intern/rna_xr.c | |
index 6f43afe23fe..52efa1b6653 100644 | |
--- a/source/blender/makesrna/intern/rna_xr.c | |
+++ b/source/blender/makesrna/intern/rna_xr.c | |
@@ -1195,6 +1195,50 @@ static int rna_XrEventData_action_length(PointerRNA *ptr) | |
# endif | |
} | |
+static void rna_XrEventData_user_path_get(PointerRNA *ptr, char *r_value) | |
+{ | |
+# ifdef WITH_XR_OPENXR | |
+ const wmXrActionData *data = ptr->data; | |
+ strcpy(r_value, data->user_path); | |
+# else | |
+ UNUSED_VARS(ptr); | |
+ r_value[0] = '\0'; | |
+# endif | |
+} | |
+ | |
+static int rna_XrEventData_user_path_length(PointerRNA *ptr) | |
+{ | |
+# ifdef WITH_XR_OPENXR | |
+ const wmXrActionData *data = ptr->data; | |
+ return strlen(data->user_path); | |
+# else | |
+ UNUSED_VARS(ptr); | |
+ return 0; | |
+# endif | |
+} | |
+ | |
+static void rna_XrEventData_user_path_other_get(PointerRNA *ptr, char *r_value) | |
+{ | |
+# ifdef WITH_XR_OPENXR | |
+ const wmXrActionData *data = ptr->data; | |
+ strcpy(r_value, data->user_path_other); | |
+# else | |
+ UNUSED_VARS(ptr); | |
+ r_value[0] = '\0'; | |
+# endif | |
+} | |
+ | |
+static int rna_XrEventData_user_path_other_length(PointerRNA *ptr) | |
+{ | |
+# ifdef WITH_XR_OPENXR | |
+ const wmXrActionData *data = ptr->data; | |
+ return strlen(data->user_path_other); | |
+# else | |
+ UNUSED_VARS(ptr); | |
+ return 0; | |
+# endif | |
+} | |
+ | |
static int rna_XrEventData_type_get(PointerRNA *ptr) | |
{ | |
# ifdef WITH_XR_OPENXR | |
@@ -2401,6 +2445,18 @@ static void rna_def_xr_eventdata(BlenderRNA *brna) | |
prop, "rna_XrEventData_action_get", "rna_XrEventData_action_length", NULL); | |
RNA_def_property_ui_text(prop, "Action", "XR action name"); | |
+ prop = RNA_def_property(srna, "user_path", PROP_STRING, PROP_NONE); | |
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE); | |
+ RNA_def_property_string_funcs( | |
+ prop, "rna_XrEventData_user_path_get", "rna_XrEventData_user_path_length", NULL); | |
+ RNA_def_property_ui_text(prop, "Action", "User path of the action. E.g. \"/user/hand/left\""); | |
+ | |
+ prop = RNA_def_property(srna, "user_path_other", PROP_STRING, PROP_NONE); | |
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE); | |
+ RNA_def_property_string_funcs( | |
+ prop, "rna_XrEventData_user_path_other_get", "rna_XrEventData_user_path_other_length", NULL); | |
+ RNA_def_property_ui_text(prop, "Action", "Other user path, for bimanual actions. E.g. \"/user/hand/right\""); | |
+ | |
prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); | |
RNA_def_property_clear_flag(prop, PROP_EDITABLE); | |
RNA_def_property_enum_items(prop, rna_enum_xr_action_types); | |
diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h | |
index a9b8d91ca03..2d9c9546964 100644 | |
--- a/source/blender/windowmanager/WM_types.h | |
+++ b/source/blender/windowmanager/WM_types.h | |
@@ -812,6 +812,10 @@ typedef struct wmXrActionData { | |
char action_set[64]; | |
/** Action name. */ | |
char action[64]; | |
+ /** User path. E.g. "/user/hand/left" */ | |
+ char user_path[64]; | |
+ /** Other user path, for bimanual actions. E.g. "/user/hand/right" */ | |
+ char user_path_other[64]; | |
/** Type. */ | |
eXrActionType type; | |
/** State. Set appropriately based on type. */ | |
diff --git a/source/blender/windowmanager/xr/intern/wm_xr_session.c b/source/blender/windowmanager/xr/intern/wm_xr_session.c | |
index 0a76fd0a25f..925d38338a0 100644 | |
--- a/source/blender/windowmanager/xr/intern/wm_xr_session.c | |
+++ b/source/blender/windowmanager/xr/intern/wm_xr_session.c | |
@@ -1027,6 +1027,11 @@ static wmXrActionData *wm_xr_session_event_create(const char *action_set_name, | |
strcpy(data->action, action->name); | |
data->type = action->type; | |
+ strcpy(data->user_path, action->subaction_paths[subaction_idx]); | |
+ if (bimanual) { | |
+ strcpy(data->user_path_other, action->subaction_paths[subaction_idx_other]); | |
+ } | |
+ | |
switch (action->type) { | |
case XR_BOOLEAN_INPUT: | |
data->state[0] = ((bool *)action->states)[subaction_idx] ? 1.0f : 0.0f; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment