[Bf-extensions-cvs] [3724a06c] xr-dev: VR: Add mouse event simulation

Peter Kim noreply at git.blender.org
Mon Dec 12 13:34:37 CET 2022


Commit: 3724a06c6a42599c212db82736c92d88a2cb29e2
Author: Peter Kim
Date:   Mon Dec 12 21:26:19 2022 +0900
Branches: xr-dev
https://developer.blender.org/rBA3724a06c6a42599c212db82736c92d88a2cb29e2

VR: Add mouse event simulation

Updated add-on portion of https://developer.blender.org/D13153.

Users can configure the mouse event simulation via a VR action's
"Simulate Mouse" properties, where a simulated type and value can be
set for VR button press, hold (modal operators only), and release,
depending on the operator execution mode.

In addition, the "projection eye" (left or right) used to project 3D
controller positions to 2D mouse positions during mouse simulation can
be set via the View settings.

===================================================================

M	viewport_vr_preview/action_map_io.py
M	viewport_vr_preview/configs/default.py
M	viewport_vr_preview/defaults.py
M	viewport_vr_preview/gui.py

===================================================================

diff --git a/viewport_vr_preview/action_map_io.py b/viewport_vr_preview/action_map_io.py
index 1aa7f4d4..47e192ca 100644
--- a/viewport_vr_preview/action_map_io.py
+++ b/viewport_vr_preview/action_map_io.py
@@ -52,6 +52,17 @@ def ami_args_as_data(ami):
         s.append(f"\"op\": '{ami.op}'")
         s.append(f"\"op_mode\": '{ami.op_mode}'")
         s.append(f"\"bimanual\": '{ami.bimanual}'")
+        s.append(f"\"simulate_mouse\": '{ami.simulate_mouse}'")
+        if ami.simulate_mouse:
+            if ami.op_mode == 'PRESS' or ami.op_mode == 'MODAL':
+                s.append(f"\"simulate_press_type\": '{ami.simulate.press_type}'")
+                s.append(f"\"simulate_press_value\": '{ami.simulate.press_value}'")
+            if ami.op_mode == 'MODAL':
+                s.append(f"\"simulate_hold_type\": '{ami.simulate.hold_type}'")
+                s.append(f"\"simulate_hold_value\": '{ami.simulate.hold_value}'")
+            if ami.op_mode == 'RELEASE' or ami.op_mode == 'MODAL':
+                s.append(f"\"simulate_release_type\": '{ami.simulate.release_type}'")
+                s.append(f"\"simulate_release_value\": '{ami.simulate.release_value}'")
         s.append(f"\"haptic_name\": '{ami.haptic_name}'")
         s.append(f"\"haptic_match_user_paths\": '{ami.haptic_match_user_paths}'")
         s.append(f"\"haptic_duration\": '{ami.haptic_duration}'")
@@ -76,6 +87,17 @@ def ami_data_from_args(ami, args):
         ami.op = args["op"]
         ami.op_mode = args["op_mode"]
         ami.bimanual = True if (args["bimanual"] == 'True') else False
+        ami.simulate_mouse = True if (args["simulate_mouse"] == 'True') else False
+        if ami.simulate_mouse:
+            if ami.op_mode == 'PRESS' or ami.op_mode == 'MODAL':
+                ami.simulate.press_type = args["simulate_press_type"]
+                ami.simulate.press_value = args["simulate_press_value"]
+            if ami.op_mode == 'MODAL':
+                ami.simulate.hold_type = args["simulate_hold_type"]
+                ami.simulate.hold_value = args["simulate_hold_value"]
+            if ami.op_mode == 'RELEASE' or ami.op_mode == 'MODAL':
+                ami.simulate.release_type = args["simulate_release_type"]
+                ami.simulate.release_value = args["simulate_release_value"]
         ami.haptic_name = args["haptic_name"]
         ami.haptic_match_user_paths = True if (args["haptic_match_user_paths"] == 'True') else False
         ami.haptic_duration = float(args["haptic_duration"])
diff --git a/viewport_vr_preview/configs/default.py b/viewport_vr_preview/configs/default.py
index fbd40c1d..49dc34d2 100644
--- a/viewport_vr_preview/configs/default.py
+++ b/viewport_vr_preview/configs/default.py
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0-or-later
 
-actionconfig_version = (3, 2, 8)
+actionconfig_version = (3, 5, 2)
 actionconfig_data = \
 [("blender_default",
   {"items":
@@ -32,7 +32,7 @@ actionconfig_data = \
        ],
       },
      ),
-    ("teleport", {"type": 'FLOAT', "user_paths": ['/user/hand/left'], "op": 'wm.xr_navigation_teleport', "op_mode": 'MODAL', "bimanual": 'False', "haptic_name": '', "haptic_match_user_paths": 'False', "haptic_duration": '0.0', "haptic_frequency": '0.0', "haptic_amplitude": '0.0', "haptic_mode": 'PRESS'},
+    ("teleport", {"type": 'FLOAT', "user_paths": ['/user/hand/left'], "op": 'wm.xr_navigation_teleport', "op_mode": 'MODAL', "bimanual": 'False', "simulate_mouse": 'False', "haptic_name": '', "haptic_match_user_paths": 'False', "haptic_duration": '0.0', "haptic_frequency": '0.0', "haptic_amplitude": '0.0', "haptic_mode": 'PRESS'},
      {"op_properties":
       [("interpolation", 0.9),
        ("color", (0.0, 1.0, 1.0, 1.0)),
@@ -51,7 +51,7 @@ actionconfig_data = \
        ],
       },
      ),
-    ("nav_grab", {"type": 'FLOAT', "user_paths": ['/user/hand/left', '/user/hand/right'], "op": 'wm.xr_navigation_grab', "op_mode": 'MODAL', "bimanual": 'True', "haptic_name": '', "haptic_match_user_paths": 'False', "haptic_duration": '0.0', "haptic_frequency": '0.0', "haptic_amplitude": '0.0', "haptic_mode": 'PRESS'},
+    ("nav_grab", {"type": 'FLOAT', "user_paths": ['/user/hand/left', '/user/hand/right'], "op": 'wm.xr_navigation_grab', "op_mode": 'MODAL', "bimanual": 'True', "simulate_mouse": 'False', "haptic_name": '', "haptic_match_user_paths": 'False', "haptic_duration": '0.0', "haptic_frequency": '0.0', "haptic_amplitude": '0.0', "haptic_mode": 'PRESS'},
      {"op_properties":
       [("lock_rotation", True),
        ],
@@ -69,7 +69,7 @@ actionconfig_data = \
        ],
       },
      ),
-    ("fly_forward", {"type": 'FLOAT', "user_paths": ['/user/hand/left'], "op": 'wm.xr_navigation_fly', "op_mode": 'MODAL', "bimanual": 'False', "haptic_name": '', "haptic_match_user_paths": 'False', "haptic_duration": '0.0', "haptic_frequency": '0.0', "haptic_amplitude": '0.0', "haptic_mode": 'PRESS'},
+    ("fly_forward", {"type": 'FLOAT', "user_paths": ['/user/hand/left'], "op": 'wm.xr_navigation_fly', "op_mode": 'MODAL', "bimanual": 'False', "simulate_mouse": 'False', "haptic_name": '', "haptic_match_user_paths": 'False', "haptic_duration": '0.0', "haptic_frequency": '0.0', "haptic_amplitude": '0.0', "haptic_mode": 'PRESS'},
      {"op_properties":
       [("mode", 'VIEWER_FORWARD'),
        ("lock_location_z", True),
@@ -87,7 +87,7 @@ actionconfig_data = \
        ],
       },
      ),
-    ("fly_back", {"type": 'FLOAT', "user_paths": ['/user/hand/left'], "op": 'wm.xr_navigation_fly', "op_mode": 'MODAL', "bimanual": 'False', "haptic_name": '', "haptic_match_user_paths": 'False', "haptic_duration": '0.0', "haptic_frequency": '0.0', "haptic_amplitude": '0.0', "haptic_mode": 'PRESS'},
+    ("fly_back", {"type": 'FLOAT', "user_paths": ['/user/hand/left'], "op": 'wm.xr_navigation_fly', "op_mode": 'MODAL', "bimanual": 'False', "simulate_mouse": 'False', "haptic_name": '', "haptic_match_user_paths": 'False', "haptic_duration": '0.0', "haptic_frequency": '0.0', "haptic_amplitude": '0.0', "haptic_mode": 'PRESS'},
      {"op_properties":
       [("mode", 'VIEWER_BACK'),
        ("lock_location_z", True),
@@ -105,7 +105,7 @@ actionconfig_data = \
        ],
       },
      ),
-    ("fly_left", {"type": 'FLOAT', "user_paths": ['/user/hand/left'], "op": 'wm.xr_navigation_fly', "op_mode": 'MODAL', "bimanual": 'False', "haptic_name": '', "haptic_match_user_paths": 'False', "haptic_duration": '0.0', "haptic_frequency": '0.0', "haptic_amplitude": '0.0', "haptic_mode": 'PRESS'},
+    ("fly_left", {"type": 'FLOAT', "user_paths": ['/user/hand/left'], "op": 'wm.xr_navigation_fly', "op_mode": 'MODAL', "bimanual": 'False', "simulate_mouse": 'False', "haptic_name": '', "haptic_match_user_paths": 'False', "haptic_duration": '0.0', "haptic_frequency": '0.0', "haptic_amplitude": '0.0', "haptic_mode": 'PRESS'},
      {"op_properties":
       [("mode", 'VIEWER_LEFT'),
        ("lock_location_z", True),
@@ -123,7 +123,7 @@ actionconfig_data = \
        ],
       },
      ),
-    ("fly_right", {"type": 'FLOAT', "user_paths": ['/user/hand/left'], "op": 'wm.xr_navigation_fly', "op_mode": 'MODAL', "bimanual": 'False', "haptic_name": '', "haptic_match_user_paths": 'False', "haptic_duration": '0.0', "haptic_frequency": '0.0', "haptic_amplitude": '0.0', "haptic_mode": 'PRESS'},
+    ("fly_right", {"type": 'FLOAT', "user_paths": ['/user/hand/left'], "op": 'wm.xr_navigation_fly', "op_mode": 'MODAL', "bimanual": 'False', "simulate_mouse": 'False', "haptic_name": '', "haptic_match_user_paths": 'False', "haptic_duration": '0.0', "haptic_frequency": '0.0', "haptic_amplitude": '0.0', "haptic_mode": 'PRESS'},
      {"op_properties":
       [("mode", 'VIEWER_RIGHT'),
        ("lock_location_z", True),
@@ -141,7 +141,7 @@ actionconfig_data = \
        ],
       },
      ),
-    ("fly_up", {"type": 'FLOAT', "user_paths": ['/user/hand/right'], "op": 'wm.xr_navigation_fly', "op_mode": 'MODAL', "bimanual": 'False', "haptic_name": '', "haptic_match_user_paths": 'False', "haptic_duration": '0.0', "haptic_frequency": '0.0', "haptic_amplitude": '0.0', "haptic_mode": 'PRESS'},
+    ("fly_up", {"type": 'FLOAT', "user_paths": ['/user/hand/right'], "op": 'wm.xr_navigation_fly', "op_mode": 'MODAL', "bimanual": 'False', "simulate_mouse": 'False', "haptic_name": '', "haptic_match_user_paths": 'False', "haptic_duration": '0.0', "haptic_frequency": '0.0', "haptic_amplitude": '0.0', "haptic_mode": 'PRESS'},
      {"op_properties":
       [("mode", 'UP'),
        ("speed_min", 0.014),
@@ -160,7 +160,7 @@ actionconfig_data = \
        ],
       },
      ),
-    ("fly_down", {"type": 'FLOAT', "user_paths": ['/user/hand/right'], "op": 'wm.xr_navigation_fly', "op_mode": 'MODAL', "bimanual": 'False', "haptic_name": '', "haptic_match_user_paths": 'False', "haptic_duration": '0.0', "haptic_frequency": '0.0', "haptic_amplitude": '0.0', "haptic_mode": 'PRESS'},
+    ("fly_down", {"type": 'FLOAT', "user_paths": ['/user/hand/right'], "op": 'wm.xr_navigation_fly', "op_mode": 'MODAL', "bimanual": 'False', "simulate_mouse": 'False', "haptic_name": '', "haptic_match_user_paths": 'False', "haptic_duration": '0.0', "haptic_frequency": '0.0', "haptic_amplitude": '0.0', "haptic_mode": 'PRESS'},
      {"op_properties":
       [("mode", 'DOWN'),
        ("speed_min", 0.014),
@@ -179,7 +179,7 @@ actionconfig_data = \
        ],
       },
      ),
-    ("fly_turnleft", {"type": 'FLOAT', "user_paths": ['/user/hand/right'], "op": 'wm.xr_navigation_fly', "op_mode": 'MODAL', "bimanual": 'False', "haptic_name": '', "haptic_match_user_paths": 'False', "haptic_duration": '0.0', "haptic_frequency": '0.0', "haptic_amplitude": '0.0', "haptic_mode": 'PRESS'},
+    ("fly_turnleft", {"type": 'FLOAT', "user_paths": ['/user/hand/right'], "op": 'wm.xr_navigation_fly', "op_mode": 'MODAL', "bimanual": 'False', "simulate_mouse": 'False', "haptic_name": '', "haptic_match_user_paths": 'False', "haptic_duration": '0.0', "haptic_frequency": '0.0', "haptic_amplitude": '0.0', "haptic_mode": 'PRESS'},
      {"op_properties":
       [("mode", 'TURNLEFT'),
        ("speed_min", 0.01),
@@ -198,7 +198,7 @@ actionconfig_data = \
        ],
       },
      ),
-    ("fly_turnright", {"type": 'FLOAT', "user_paths": ['/user/hand/right'], "op":

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list