toggle edit mode

This commit is contained in:
Crispy 2023-04-22 19:21:31 +02:00
parent 533bf45087
commit 1134e37b10
5 changed files with 700 additions and 50 deletions

View file

@ -7,17 +7,22 @@
], ],
"actions": [ "actions": [
{ {
"name": "/actions/main/in/ToggleAll", "name": "/actions/main/in/toggle_visibility",
"requirement": "mandatory", "requirement": "mandatory",
"type": "boolean" "type": "boolean"
}, },
{ {
"name": "/actions/main/in/Grab", "name": "/actions/main/in/edit_mode",
"requirement": "mandatory", "requirement": "mandatory",
"type": "boolean" "type": "boolean"
}, },
{ {
"name": "/actions/main/in/Distance", "name": "/actions/main/in/grab",
"requirement": "mandatory",
"type": "boolean"
},
{
"name": "/actions/main/in/distance",
"requirement": "suggested", "requirement": "suggested",
"type": "vector2" "type": "vector2"
} }
@ -32,9 +37,10 @@
{ {
"language_tag": "en_us", "language_tag": "en_us",
"/actions/main": "Overlay actions", "/actions/main": "Overlay actions",
"/actions/main/in/ToggleAll": "Toggle all", "/actions/main/in/toggle_visibility": "Toggle visibility",
"/actions/main/in/Grab": "Grab panel", "/actions/main/in/edit_mode": "Toggle edit mode",
"/actions/main/in/Distance": "Move away" "/actions/main/in/grab": "grab panel",
"/actions/main/in/distance": "Move away"
} }
] ]
} }

View file

@ -1,33 +1,658 @@
{ {
"/actions/main": { "action_manifest_version" : 0,
"sources": [ "alias_info" : {
{ "/actions/legacy/in/head_proximity" : {
"path": "/user/hand/right/input/b", "alias_name" : "",
"mode": "button", "hidden" : true
"inputs": { },
"long": { "/actions/legacy/in/left_axis2_press" : {
"output": "/actions/main/in/toggleall" "alias_name" : "",
} "hidden" : true
},
"/actions/legacy/in/left_axis2_touch" : {
"alias_name" : "",
"hidden" : true
},
"/actions/legacy/in/left_axis3_press" : {
"alias_name" : "",
"hidden" : true
},
"/actions/legacy/in/left_axis3_touch" : {
"alias_name" : "",
"hidden" : true
},
"/actions/legacy/in/left_axis3_value_e0" : {
"alias_name" : "",
"hidden" : true
},
"/actions/legacy/in/left_axis3_value_e1" : {
"alias_name" : "",
"hidden" : true
},
"/actions/legacy/in/left_axis4_press" : {
"alias_name" : "",
"hidden" : true
},
"/actions/legacy/in/left_axis4_touch" : {
"alias_name" : "",
"hidden" : true
},
"/actions/legacy/in/left_axis4_value_e0" : {
"alias_name" : "",
"hidden" : true
},
"/actions/legacy/in/left_axis4_value_e1" : {
"alias_name" : "",
"hidden" : true
},
"/actions/legacy/in/left_system_press" : {
"alias_name" : "",
"hidden" : true
},
"/actions/legacy/in/left_system_touch" : {
"alias_name" : "",
"hidden" : true
},
"/actions/legacy/in/right_axis3_press" : {
"alias_name" : "",
"hidden" : true
},
"/actions/legacy/in/right_axis3_touch" : {
"alias_name" : "",
"hidden" : true
},
"/actions/legacy/in/right_axis3_value_e0" : {
"alias_name" : "",
"hidden" : true
},
"/actions/legacy/in/right_axis3_value_e1" : {
"alias_name" : "",
"hidden" : true
},
"/actions/legacy/in/right_axis4_press" : {
"alias_name" : "",
"hidden" : true
},
"/actions/legacy/in/right_axis4_touch" : {
"alias_name" : "",
"hidden" : true
},
"/actions/legacy/in/right_axis4_value_e0" : {
"alias_name" : "",
"hidden" : true
},
"/actions/legacy/in/right_axis4_value_e1" : {
"alias_name" : "",
"hidden" : true
},
"/actions/legacy/in/right_system_press" : {
"alias_name" : "",
"hidden" : true
},
"/actions/legacy/in/right_system_touch" : {
"alias_name" : "",
"hidden" : true
},
"/actions/legacy_mirrored/in/axis2_press" : {
"alias_name" : "",
"hidden" : true
},
"/actions/legacy_mirrored/in/axis2_touch" : {
"alias_name" : "",
"hidden" : true
},
"/actions/legacy_mirrored/in/axis3_press" : {
"alias_name" : "",
"hidden" : true
},
"/actions/legacy_mirrored/in/axis3_touch" : {
"alias_name" : "",
"hidden" : true
},
"/actions/legacy_mirrored/in/axis3_value_e0" : {
"alias_name" : "",
"hidden" : true
},
"/actions/legacy_mirrored/in/axis3_value_e1" : {
"alias_name" : "",
"hidden" : true
},
"/actions/legacy_mirrored/in/axis4_press" : {
"alias_name" : "",
"hidden" : true
},
"/actions/legacy_mirrored/in/axis4_touch" : {
"alias_name" : "",
"hidden" : true
},
"/actions/legacy_mirrored/in/axis4_value_e0" : {
"alias_name" : "",
"hidden" : true
},
"/actions/legacy_mirrored/in/axis4_value_e1" : {
"alias_name" : "",
"hidden" : true
},
"/actions/legacy_mirrored/in/system_press" : {
"alias_name" : "",
"hidden" : true
} }
}, },
"app_key" : "system.generated.overlay",
"bindings" : {
"/actions/legacy" : {
"haptics" : [
{ {
"path": "/user/hand/right/input/thumbstick", "output" : "/actions/legacy/out/left_haptic",
"mode": "joystick", "path" : "/user/hand/left/output/haptic"
"inputs": {
"position": {
"output": "/actions/main/in/distance"
}
}
}, },
{ {
"path": "/user/hand/right/input/trigger", "output" : "/actions/legacy/out/right_haptic",
"mode": "button", "path" : "/user/hand/right/output/haptic"
"inputs": {
"click": {
"output": "/actions/main/in/grab"
} }
],
"poses" : [
{
"output" : "/actions/legacy/in/Left_Pose",
"path" : "/user/hand/left/pose/raw"
},
{
"output" : "/actions/legacy/in/Right_Pose",
"path" : "/user/hand/right/pose/raw"
} }
],
"sources" : [
{
"inputs" : {
"click" : {
"output" : "/actions/legacy/in/left_system_press"
}
},
"mode" : "button",
"path" : "/user/hand/left/input/system"
},
{
"inputs" : {
"pull" : {
"output" : "/actions/legacy/in/left_axis1_value"
},
"touch" : {
"output" : "/actions/legacy/in/left_axis1_touch"
}
},
"mode" : "trigger",
"path" : "/user/hand/left/input/trigger"
},
{
"inputs" : {
"click" : {
"output" : "/actions/legacy/in/right_system_press"
}
},
"mode" : "button",
"path" : "/user/hand/right/input/system"
},
{
"inputs" : {
"click" : {
"output" : "/actions/legacy/in/right_grip_press"
},
"touch" : {
"output" : "/actions/legacy/in/right_grip_touch"
}
},
"mode" : "button",
"path" : "/user/hand/right/input/a"
},
{
"inputs" : {
"click" : {
"output" : "/actions/legacy/in/left_grip_press"
},
"touch" : {
"output" : "/actions/legacy/in/left_grip_touch"
}
},
"mode" : "button",
"path" : "/user/hand/left/input/a"
},
{
"inputs" : {
"click" : {
"output" : "/actions/legacy/in/left_applicationmenu_press"
},
"touch" : {
"output" : "/actions/legacy/in/left_applicationmenu_touch"
}
},
"mode" : "button",
"path" : "/user/hand/left/input/b"
},
{
"inputs" : {
"click" : {
"output" : "/actions/legacy/in/right_applicationmenu_press"
},
"touch" : {
"output" : "/actions/legacy/in/right_applicationmenu_touch"
}
},
"mode" : "button",
"path" : "/user/hand/right/input/b"
},
{
"inputs" : {
"click" : {
"output" : "/actions/legacy/in/left_axis0_press"
},
"position" : {
"output" : "/actions/legacy/in/left_axis0_value"
},
"touch" : {
"output" : "/actions/legacy/in/left_axis0_touch"
}
},
"mode" : "trackpad",
"path" : "/user/hand/left/input/trackpad"
},
{
"inputs" : {
"click" : {
"output" : "/actions/legacy/in/right_axis0_press"
},
"position" : {
"output" : "/actions/legacy/in/right_axis0_value"
},
"touch" : {
"output" : "/actions/legacy/in/right_axis0_touch"
}
},
"mode" : "trackpad",
"path" : "/user/hand/right/input/trackpad"
},
{
"inputs" : {
"pull" : {
"output" : "/actions/legacy/in/right_axis1_value"
},
"touch" : {
"output" : "/actions/legacy/in/right_axis1_touch"
}
},
"mode" : "trigger",
"path" : "/user/hand/right/input/trigger"
},
{
"inputs" : {
"click" : {
"output" : "/actions/legacy/in/left_axis1_press"
},
"touch" : {
"output" : "/actions/legacy/in/left_axis1_touch"
}
},
"mode" : "button",
"parameters" : {
"click_activate_threshold" : "0.55",
"click_deactivate_threshold" : "0.5",
"haptic_amplitude" : "0",
"touch_activate_threshold" : "0.1",
"touch_deactivate_threshold" : "0.05"
},
"path" : "/user/hand/left/input/trigger"
},
{
"inputs" : {
"click" : {
"output" : "/actions/legacy/in/right_axis1_press"
},
"touch" : {
"output" : "/actions/legacy/in/right_axis1_touch"
}
},
"mode" : "button",
"parameters" : {
"click_activate_threshold" : "0.55",
"click_deactivate_threshold" : "0.5",
"haptic_amplitude" : "0",
"touch_activate_threshold" : "0.1",
"touch_deactivate_threshold" : "0.05"
},
"path" : "/user/hand/right/input/trigger"
},
{
"inputs" : {
"click" : {
"output" : "/actions/legacy/in/left_axis0_press"
}
},
"mode" : "button",
"path" : "/user/hand/left/input/trackpad"
},
{
"inputs" : {
"click" : {
"output" : "/actions/legacy/in/right_axis0_press"
}
},
"mode" : "button",
"path" : "/user/hand/right/input/trackpad"
},
{
"inputs" : {
"click" : {
"output" : "/actions/legacy/in/left_axis0_press"
},
"position" : {
"output" : "/actions/legacy/in/left_axis0_value"
},
"touch" : {
"output" : "/actions/legacy/in/left_axis0_touch"
}
},
"mode" : "joystick",
"path" : "/user/hand/left/input/thumbstick"
},
{
"inputs" : {
"click" : {
"output" : "/actions/legacy/in/right_axis0_press"
},
"position" : {
"output" : "/actions/legacy/in/right_axis0_value"
},
"touch" : {
"output" : "/actions/legacy/in/right_axis0_touch"
}
},
"mode" : "joystick",
"path" : "/user/hand/right/input/thumbstick"
},
{
"inputs" : {
"click" : {
"output" : "/actions/legacy/in/left_axis0_press"
}
},
"mode" : "button",
"parameters" : {
"click_activate_threshold" : 0.80000000000000004,
"click_deactivate_threshold" : 0.69999999999999996,
"force_input" : "position",
"haptic_amplitude" : 0
},
"path" : "/user/hand/left/input/thumbstick"
},
{
"inputs" : {
"click" : {
"output" : "/actions/legacy/in/right_axis0_press"
}
},
"mode" : "button",
"parameters" : {
"click_activate_threshold" : 0.80000000000000004,
"click_deactivate_threshold" : 0.69999999999999996,
"force_input" : "position",
"haptic_amplitude" : 0
},
"path" : "/user/hand/right/input/thumbstick"
},
{
"inputs" : {
"click" : {
"output" : "/actions/legacy/in/left_grip_press"
},
"touch" : {
"output" : "/actions/legacy/in/left_grip_touch"
}
},
"mode" : "button",
"parameters" : {
"click_activate_threshold" : "0.8",
"force_input" : "force"
},
"path" : "/user/hand/left/input/grip"
},
{
"inputs" : {
"click" : {
"output" : "/actions/legacy/in/right_grip_press"
},
"touch" : {
"output" : "/actions/legacy/in/right_grip_touch"
}
},
"mode" : "button",
"parameters" : {
"click_activate_threshold" : "0.8",
"force_input" : "force"
},
"path" : "/user/hand/right/input/grip"
}
]
},
"/actions/legacy_mirrored" : {
"haptics" : [
{
"output" : "/actions/legacy_mirrored/out/haptic",
"path" : "/user/hand/left/output/haptic"
},
{
"output" : "/actions/legacy_mirrored/out/haptic",
"path" : "/user/hand/right/output/haptic"
}
],
"poses" : [
{
"output" : "/actions/legacy_mirrored/in/pose",
"path" : "/user/hand/left/pose/raw"
},
{
"output" : "/actions/legacy_mirrored/in/pose",
"path" : "/user/hand/right/pose/raw"
}
],
"sources" : [
{
"inputs" : {
"click" : {
"output" : "/actions/legacy_mirrored/in/axis1_press"
},
"pull" : {
"output" : "/actions/legacy_mirrored/in/axis1_value"
},
"touch" : {
"output" : "/actions/legacy_mirrored/in/axis1_touch"
}
},
"mode" : "trigger",
"path" : "/user/hand/left/input/trigger"
},
{
"inputs" : {
"click" : {
"output" : "/actions/legacy_mirrored/in/axis1_press"
},
"pull" : {
"output" : "/actions/legacy_mirrored/in/axis1_value"
},
"touch" : {
"output" : "/actions/legacy_mirrored/in/axis1_touch"
}
},
"mode" : "trigger",
"path" : "/user/hand/right/input/trigger"
},
{
"inputs" : {
"position" : {
"output" : "/actions/legacy_mirrored/in/axis0_value"
},
"touch" : {
"output" : "/actions/legacy_mirrored/in/axis0_touch"
}
},
"mode" : "trackpad",
"path" : "/user/hand/left/input/trackpad"
},
{
"inputs" : {
"position" : {
"output" : "/actions/legacy_mirrored/in/axis0_value"
},
"touch" : {
"output" : "/actions/legacy_mirrored/in/axis0_touch"
}
},
"mode" : "trackpad",
"path" : "/user/hand/right/input/trackpad"
},
{
"inputs" : {},
"mode" : "joystick",
"path" : "/user/hand/left/input/thumbstick"
},
{
"inputs" : {},
"mode" : "joystick",
"path" : "/user/hand/right/input/thumbstick"
},
{
"inputs" : {
"click" : {
"output" : "/actions/legacy_mirrored/in/grip_press"
},
"touch" : {
"output" : "/actions/legacy_mirrored/in/grip_touch"
}
},
"mode" : "button",
"path" : "/user/hand/left/input/a"
},
{
"inputs" : {
"click" : {
"output" : "/actions/legacy_mirrored/in/grip_press"
},
"touch" : {
"output" : "/actions/legacy_mirrored/in/grip_touch"
}
},
"mode" : "button",
"path" : "/user/hand/right/input/a"
},
{
"inputs" : {
"click" : {
"output" : "/actions/legacy_mirrored/in/applicationmenu_press"
},
"touch" : {
"output" : "/actions/legacy_mirrored/in/applicationmenu_touch"
}
},
"mode" : "button",
"path" : "/user/hand/left/input/b"
},
{
"inputs" : {
"click" : {
"output" : "/actions/legacy_mirrored/in/applicationmenu_press"
},
"touch" : {
"output" : "/actions/legacy_mirrored/in/applicationmenu_touch"
}
},
"mode" : "button",
"path" : "/user/hand/right/input/b"
},
{
"inputs" : {
"click" : {
"output" : "/actions/legacy_mirrored/in/axis0_press"
}
},
"mode" : "button",
"path" : "/user/hand/left/input/trackpad"
},
{
"inputs" : {
"click" : {
"output" : "/actions/legacy_mirrored/in/axis0_press"
}
},
"mode" : "button",
"path" : "/user/hand/right/input/trackpad"
}
]
},
"/actions/main" : {
"sources" : [
{
"inputs" : {
"long" : {
"output" : "/actions/main/in/edit_mode"
}
},
"mode" : "button",
"path" : "/user/hand/right/input/b"
},
{
"inputs" : {
"position" : {
"output" : "/actions/main/in/distance"
}
},
"mode" : "joystick",
"path" : "/user/hand/right/input/thumbstick"
},
{
"inputs" : {
"click" : {
"output" : "/actions/main/in/grab"
}
},
"mode" : "button",
"path" : "/user/hand/right/input/trigger"
},
{
"inputs" : {
"click" : {
"output" : "/actions/main/in/grab"
}
},
"mode" : "button",
"path" : "/user/hand/left/input/trigger"
},
{
"inputs" : {
"long" : {
"output" : "/actions/main/in/toggle_visibility"
}
},
"mode" : "button",
"path" : "/user/hand/left/input/b"
},
{
"inputs" : {
"position" : {
"output" : "/actions/main/in/distance"
}
},
"mode" : "joystick",
"path" : "/user/hand/left/input/thumbstick"
} }
] ]
} }
},
"category" : "steamvr_input",
"controller_type" : "knuckles",
"description" : "Default binding values for legacy apps using the Index Controller",
"interaction_profile" : "",
"name" : "Saved overlay configuration for Index Controller",
"options" : {
"mirror_actions" : true,
"simulated_controller_type" : "none"
},
"simulated_actions" : []
} }

View file

@ -57,11 +57,13 @@ App::App()
printf("actions path: %s\n", _actions_path.c_str()); printf("actions path: %s\n", _actions_path.c_str());
vr_input->SetActionManifestPath(_actions_path.c_str()); vr_input->SetActionManifestPath(_actions_path.c_str());
auto action_err = vr_input->GetActionHandle("/actions/main/in/Grab", &_input_handles.grab); auto action_err = vr_input->GetActionHandle("/actions/main/in/grab", &_input_handles.grab);
assert(action_err == 0); assert(action_err == 0);
action_err = vr_input->GetActionHandle("/actions/main/in/ToggleAll", &_input_handles.toggle); action_err = vr_input->GetActionHandle("/actions/main/in/toggle_visibility", &_input_handles.toggle_hidden);
assert(action_err == 0); assert(action_err == 0);
action_err = vr_input->GetActionHandle("/actions/main/in/Distance", &_input_handles.distance); action_err = vr_input->GetActionHandle("/actions/main/in/edit_mode", &_input_handles.edit_mode);
assert(action_err == 0);
action_err = vr_input->GetActionHandle("/actions/main/in/distance", &_input_handles.distance);
assert(action_err == 0); assert(action_err == 0);
action_err = vr_input->GetActionSetHandle("/actions/main", &_input_handles.set); action_err = vr_input->GetActionSetHandle("/actions/main", &_input_handles.set);
assert(action_err == 0); assert(action_err == 0);
@ -162,19 +164,29 @@ void App::UpdateInput()
vr_sys->GetDeviceToAbsoluteTrackingPose(_tracking_origin, 0, _tracker_poses, MAX_TRACKERS); vr_sys->GetDeviceToAbsoluteTrackingPose(_tracking_origin, 0, _tracker_poses, MAX_TRACKERS);
if (IsInputJustPressed(_input_handles.toggle)) if (IsInputJustPressed(_input_handles.toggle_hidden))
{ {
_hidden = !_hidden; _hidden = !_hidden;
_root_overlay.SetHidden(_hidden);
for (auto &panel : _panels) for (auto &panel : _panels)
{ {
panel.SetHidden(_hidden); panel.SetHidden(_hidden);
} }
_controllers[0]->SetHidden(_hidden); _root_overlay.SetHidden(_hidden || !_edit_mode);
_controllers[1]->SetHidden(_hidden); _controllers[0]->SetHidden(_hidden || !_edit_mode);
_controllers[1]->SetHidden(_hidden || !_edit_mode);
} }
if (!_hidden && IsInputJustPressed(_input_handles.edit_mode))
{
_edit_mode = !_edit_mode;
_root_overlay.SetHidden(_hidden || !_edit_mode);
_controllers[0]->SetHidden(_hidden || !_edit_mode);
_controllers[1]->SetHidden(_hidden || !_edit_mode);
}
if (_edit_mode)
{
_controllers[0]->Update(); _controllers[0]->Update();
_controllers[1]->Update(); _controllers[1]->Update();
}
} }
void App::UpdateFramebuffer() void App::UpdateFramebuffer()

View file

@ -19,9 +19,10 @@ struct CursorPos
struct InputHandles struct InputHandles
{ {
vr::VRActionSetHandle_t set; vr::VRActionSetHandle_t set;
vr::VRActionHandle_t toggle; vr::VRActionHandle_t toggle_hidden;
vr::VRActionHandle_t distance; vr::VRActionHandle_t distance;
vr::VRActionHandle_t grab; vr::VRActionHandle_t grab;
vr::VRActionHandle_t edit_mode;
}; };
class App class App
@ -63,6 +64,7 @@ class App
Overlay _root_overlay; Overlay _root_overlay;
std::vector<Panel> _panels; std::vector<Panel> _panels;
bool _hidden = false; bool _hidden = false;
bool _edit_mode = false;
private: private:
void InitX11(); void InitX11();

View file

@ -25,6 +25,7 @@ Controller::Controller(App *app, ControllerSide side)
UpdateStatus(); UpdateStatus();
_laser.SetTextureToColor(255, 200, 255); _laser.SetTextureToColor(255, 200, 255);
_laser.SetAlpha(0.2f); _laser.SetAlpha(0.2f);
_laser.SetHidden(true);
} }
TrackerID Controller::DeviceIndex() TrackerID Controller::DeviceIndex()
@ -50,6 +51,7 @@ bool Controller::IsConnected()
void Controller::SetHidden(bool state) void Controller::SetHidden(bool state)
{ {
_hidden = state; _hidden = state;
_laser.SetHidden(_hidden);
} }
void Controller::ReleaseOverlay() void Controller::ReleaseOverlay()
@ -94,7 +96,7 @@ void Controller::UpdateLaser()
auto controller_pose = _app->GetTrackerPose(_device_index); auto controller_pose = _app->GetTrackerPose(_device_index);
auto controller_pos = GetPos(controller_pose); auto controller_pos = GetPos(controller_pose);
auto forward = -glm::vec3(controller_pose[2]); auto forward = -glm::vec3(controller_pose[2]);
auto ray = _app->IntersectRay(controller_pos, forward, 5.0f); auto ray = _app->IntersectRay(controller_pos, forward, 8.0f);
float len = ray.distance; float len = ray.distance;
_last_pos = controller_pos; _last_pos = controller_pos;
@ -143,5 +145,8 @@ void Controller::UpdateStatus()
_device_index = _app->vr_sys->GetTrackedDeviceIndexForControllerRole(vr::TrackedControllerRole_RightHand); _device_index = _app->vr_sys->GetTrackedDeviceIndexForControllerRole(vr::TrackedControllerRole_RightHand);
} }
_is_connected &= _device_index < MAX_TRACKERS; _is_connected &= _device_index < MAX_TRACKERS;
_laser.SetHidden(!_is_connected || _hidden); if (!_is_connected)
{
_laser.SetHidden(true);
}
} }