mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-21 05:46:03 +00:00
Glasses: Play SteamVR beside the glasses button instead of starting SteamVR with them, pad hands drawn as Index controllers and off while other VR controllers are connected, glasses sheet tabs sized like Steam's
This commit is contained in:
1 parent
b2beed6290
commit
b8fe2fbd88
27 files changed
+153
-56
No files matched your search
+4
-1
@@ -340,6 +340,8 @@ def execute(args: argparse.Namespace, adb: str, serial: str) -> dict:
|
||||
if not args.url.startswith("steam://"):
|
||||
raise ControlError("Steam URL must start with steam://", "INVALID_STEAM_URL")
|
||||
request["steamUrl"] = args.url
|
||||
if args.steamvr:
|
||||
request["steamVr"] = True
|
||||
if args.reuse:
|
||||
# A scenario's per-run "before": keep a session of this mode that is already up, so only
|
||||
# a run after one that ended (a crash, the low-memory killer) starts a new one.
|
||||
@@ -551,6 +553,7 @@ def build_parser() -> argparse.ArgumentParser:
|
||||
start = commands.add_parser("start", help="start Steam or the desktop")
|
||||
start.add_argument("mode", choices=["steam", "desktop"])
|
||||
start.add_argument("--ui", choices=["bigpicture", "desktop"], default="bigpicture")
|
||||
start.add_argument("--steamvr", action="store_true", help="start SteamVR with the session (VITURE glasses)")
|
||||
start.add_argument("--url", help="steam:// URL to pass to the client")
|
||||
start.add_argument("--wait", action="store_true", help="wait for READY after starting")
|
||||
start.add_argument("--reuse", action="store_true", help="keep a running session of this mode instead of failing")
|
||||
@@ -674,7 +677,7 @@ def build_parser() -> argparse.ArgumentParser:
|
||||
glasses_ops = glasses.add_subparsers(dest="glasses_op")
|
||||
glasses_ops.add_parser("status")
|
||||
glasses_ops.add_parser("allow", help="ask for USB control of the glasses again")
|
||||
glasses_set = glasses_ops.add_parser("set", help="refreshHz, sbsHz, brightness, volume, sunblock, 3d, gameOnGlasses, headTracking, auto3d, picture3d, screenWidthDm, screenDistanceDm, vrFovDeg, autoSteamVr")
|
||||
glasses_set = glasses_ops.add_parser("set", help="refreshHz, sbsHz, brightness, volume, sunblock, 3d, gameOnGlasses, headTracking, auto3d, picture3d, screenWidthDm, screenDistanceDm, vrFovDeg")
|
||||
glasses_set.add_argument("key")
|
||||
glasses_set.add_argument("value")
|
||||
glasses_sim = glasses_ops.add_parser("simulate", help="feed a moving head pose (yaw, pitch and roll sweeps), or hold one")
|
||||
|
||||
@@ -387,7 +387,8 @@ public:
|
||||
VRProperties()->SetStringProperty(c, Prop_ModelNumber_String, "DroidDeck Pad Hand");
|
||||
VRProperties()->SetStringProperty(c, Prop_ManufacturerName_String, "DroidDeck");
|
||||
VRProperties()->SetStringProperty(c, Prop_TrackingSystemName_String, "droiddeck");
|
||||
VRProperties()->SetStringProperty(c, Prop_RenderModelName_String, "generic_controller");
|
||||
VRProperties()->SetStringProperty(c, Prop_RenderModelName_String,
|
||||
right_ ? "{indexcontroller}valve_controller_knu_1_0_right" : "{indexcontroller}valve_controller_knu_1_0_left");
|
||||
VRProperties()->SetStringProperty(c, Prop_ControllerType_String, "vive_controller");
|
||||
VRProperties()->SetStringProperty(c, Prop_InputProfilePath_String, "{htc}/input/vive_controller_profile.json");
|
||||
VRProperties()->SetInt32Property(c, Prop_ControllerRoleHint_Int32,
|
||||
@@ -414,6 +415,20 @@ public:
|
||||
|
||||
DriverPose_t GetPose() override { return pose_; }
|
||||
|
||||
void Disconnect() {
|
||||
if (id_ == k_unTrackedDeviceIndexInvalid) return;
|
||||
DriverPose_t p = {};
|
||||
p.qWorldFromDriverRotation.w = 1;
|
||||
p.qDriverFromHeadRotation.w = 1;
|
||||
p.qRotation.w = 1;
|
||||
p.result = TrackingResult_Uninitialized;
|
||||
pose_ = p;
|
||||
VRServerDriverHost()->TrackedDevicePoseUpdated(id_, p, sizeof(p));
|
||||
auto in = VRDriverInput();
|
||||
for (VRInputComponentHandle_t h : {system_, menu_, grip_, triggerClick_, padClick_, padTouch_}) in->UpdateBooleanComponent(h, false, 0);
|
||||
for (VRInputComponentHandle_t h : {trigger_, padX_, padY_}) in->UpdateScalarComponent(h, 0.0f, 0);
|
||||
}
|
||||
|
||||
// From the driver's pose thread: the head's orientation and the pad.
|
||||
static constexpr float kReachSpeed = 0.6f, kReachMin = -0.2f, kReachMax = 1.0f;
|
||||
|
||||
@@ -685,7 +700,17 @@ private:
|
||||
if (havePad && pad.axes[7] && !CardboardController::Grabbing(pad, false) && !CardboardController::Grabbing(pad, true))
|
||||
reach_ = std::clamp(reach_ - (pad.axes[7] > 0 ? 1.0f : -1.0f) * CardboardController::kReachSpeed * dt,
|
||||
CardboardController::kReachMin, CardboardController::kReachMax);
|
||||
for (CardboardController *hand : hands_) if (hand) hand->Update(head.qRotation, havePad ? &pad : nullptr, sticksMoveHands_, reach_);
|
||||
if (now - lastScan_ > std::chrono::seconds(1)) {
|
||||
lastScan_ = now;
|
||||
const bool other = OtherControllers();
|
||||
if (other != otherControllers_) {
|
||||
otherControllers_ = other;
|
||||
Log("%s", other ? "other VR controllers connected: pad hands off" : "no other VR controllers: pad hands on");
|
||||
if (other) for (CardboardController *hand : hands_) if (hand) hand->Disconnect();
|
||||
}
|
||||
}
|
||||
if (!otherControllers_)
|
||||
for (CardboardController *hand : hands_) if (hand) hand->Update(head.qRotation, havePad ? &pad : nullptr, sticksMoveHands_, reach_);
|
||||
if (havePad) lastPad_ = pad;
|
||||
lastSent = now;
|
||||
}
|
||||
@@ -693,6 +718,18 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
static bool OtherControllers() {
|
||||
TrackedDevicePose_t poses[k_unMaxTrackedDeviceCount];
|
||||
VRServerDriverHost()->GetRawTrackedDevicePoses(0.0f, poses, k_unMaxTrackedDeviceCount);
|
||||
for (uint32_t i = 0; i < k_unMaxTrackedDeviceCount; i++) {
|
||||
if (!poses[i].bDeviceIsConnected) continue;
|
||||
PropertyContainerHandle_t c = VRProperties()->TrackedDeviceToPropertyContainer(i);
|
||||
if (VRProperties()->GetInt32Property(c, Prop_DeviceClass_Int32) != TrackedDeviceClass_Controller) continue;
|
||||
if (VRProperties()->GetStringProperty(c, Prop_TrackingSystemName_String) != "droiddeck") return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t id_ = k_unTrackedDeviceIndexInvalid;
|
||||
int32_t width_ = 1920, height_ = 1080;
|
||||
std::atomic<float> tanHalf_{1.0f}, eyeAspect_{0.889f}, renderScale_{1.4f};
|
||||
@@ -710,6 +747,8 @@ private:
|
||||
bool sticksMoveHands_ = true;
|
||||
float reach_ = 0.0f;
|
||||
std::chrono::steady_clock::time_point lastReach_ = std::chrono::steady_clock::now();
|
||||
std::chrono::steady_clock::time_point lastScan_{};
|
||||
bool otherControllers_ = false;
|
||||
CardboardController *hands_[2] = {nullptr, nullptr};
|
||||
bool virtualDisplay_ = false, directMode_ = false;
|
||||
VirtualDisplay vd_;
|
||||
|
||||
Reference in new issue
Block a user