|
1 | 1 | // SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
2 | 2 | // SPDX-License-Identifier: Apache-2.0 |
3 | 3 |
|
4 | | -#include "inc/deviceio/controller_tracker.hpp" |
5 | | - |
6 | 4 | #include "inc/deviceio/deviceio_session.hpp" |
| 5 | +#include "inc/deviceio/live_controller_tracker_impl.hpp" |
| 6 | +#include "inc/deviceio/tracker_factory.hpp" |
7 | 7 |
|
8 | 8 | #include <oxr_utils/oxr_funcs.hpp> |
9 | 9 | #include <oxr_utils/oxr_time.hpp> |
@@ -146,60 +146,10 @@ XrAction create_action(const OpenXRCoreFunctions& funcs, |
146 | 146 | } // anonymous namespace |
147 | 147 |
|
148 | 148 | // ============================================================================ |
149 | | -// ControllerTracker::Impl |
| 149 | +// LiveControllerTrackerImpl |
150 | 150 | // ============================================================================ |
151 | 151 |
|
152 | | -class ControllerTracker::Impl : public ITrackerImpl |
153 | | -{ |
154 | | -public: |
155 | | - explicit Impl(const OpenXRSessionHandles& handles); |
156 | | - ~Impl() = default; |
157 | | - |
158 | | - Impl(const Impl&) = delete; |
159 | | - Impl& operator=(const Impl&) = delete; |
160 | | - |
161 | | - bool update(XrTime time) override; |
162 | | - void serialize_all(size_t channel_index, const RecordCallback& callback) const override; |
163 | | - |
164 | | - const ControllerSnapshotTrackedT& get_left_controller() const; |
165 | | - const ControllerSnapshotTrackedT& get_right_controller() const; |
166 | | - |
167 | | -private: |
168 | | - const OpenXRCoreFunctions core_funcs_; |
169 | | - XrTimeConverter time_converter_; |
170 | | - |
171 | | - XrSession session_; |
172 | | - XrSpace base_space_; |
173 | | - |
174 | | - XrPath left_hand_path_; |
175 | | - XrPath right_hand_path_; |
176 | | - |
177 | | - // Action context — declared before action_set_ so it outlives it. |
178 | | - ActionContextFunctions action_ctx_funcs_; |
179 | | - XrInstanceActionContextPtr instance_action_context_; |
180 | | - XrSessionActionContextPtr session_action_context_; |
181 | | - |
182 | | - XrActionSetPtr action_set_; |
183 | | - XrAction grip_pose_action_; |
184 | | - XrAction aim_pose_action_; |
185 | | - XrAction primary_click_action_; |
186 | | - XrAction secondary_click_action_; |
187 | | - XrAction thumbstick_action_; |
188 | | - XrAction thumbstick_click_action_; |
189 | | - XrAction squeeze_value_action_; |
190 | | - XrAction trigger_value_action_; |
191 | | - |
192 | | - XrSpacePtr left_grip_space_; |
193 | | - XrSpacePtr right_grip_space_; |
194 | | - XrSpacePtr left_aim_space_; |
195 | | - XrSpacePtr right_aim_space_; |
196 | | - |
197 | | - ControllerSnapshotTrackedT left_tracked_; |
198 | | - ControllerSnapshotTrackedT right_tracked_; |
199 | | - XrTime last_update_time_ = 0; |
200 | | -}; |
201 | | - |
202 | | -ControllerTracker::Impl::Impl(const OpenXRSessionHandles& handles) |
| 152 | +LiveControllerTrackerImpl::LiveControllerTrackerImpl(const OpenXRSessionHandles& handles) |
203 | 153 | : core_funcs_(OpenXRCoreFunctions::load(handles.instance, handles.xrGetInstanceProcAddr)), |
204 | 154 | time_converter_(handles), |
205 | 155 | session_(handles.session), |
@@ -333,7 +283,7 @@ ControllerTracker::Impl::Impl(const OpenXRSessionHandles& handles) |
333 | 283 | std::cout << "ControllerTracker initialized (left + right) with action context" << std::endl; |
334 | 284 | } |
335 | 285 |
|
336 | | -bool ControllerTracker::Impl::update(XrTime time) |
| 286 | +bool LiveControllerTrackerImpl::update(XrTime time) |
337 | 287 | { |
338 | 288 | last_update_time_ = time; |
339 | 289 |
|
@@ -430,17 +380,17 @@ bool ControllerTracker::Impl::update(XrTime time) |
430 | 380 | return left_tracked_.data || right_tracked_.data; |
431 | 381 | } |
432 | 382 |
|
433 | | -const ControllerSnapshotTrackedT& ControllerTracker::Impl::get_left_controller() const |
| 383 | +const ControllerSnapshotTrackedT& LiveControllerTrackerImpl::get_left_controller() const |
434 | 384 | { |
435 | 385 | return left_tracked_; |
436 | 386 | } |
437 | 387 |
|
438 | | -const ControllerSnapshotTrackedT& ControllerTracker::Impl::get_right_controller() const |
| 388 | +const ControllerSnapshotTrackedT& LiveControllerTrackerImpl::get_right_controller() const |
439 | 389 | { |
440 | 390 | return right_tracked_; |
441 | 391 | } |
442 | 392 |
|
443 | | -void ControllerTracker::Impl::serialize_all(size_t channel_index, const RecordCallback& callback) const |
| 393 | +void LiveControllerTrackerImpl::serialize_all(size_t channel_index, const RecordCallback& callback) const |
444 | 394 | { |
445 | 395 | if (channel_index > 1) |
446 | 396 | { |
@@ -482,17 +432,17 @@ std::string_view ControllerTracker::get_schema_text() const |
482 | 432 |
|
483 | 433 | const ControllerSnapshotTrackedT& ControllerTracker::get_left_controller(const DeviceIOSession& session) const |
484 | 434 | { |
485 | | - return static_cast<const Impl&>(session.get_tracker_impl(*this)).get_left_controller(); |
| 435 | + return static_cast<const ControllerTrackerImpl&>(session.get_tracker_impl(*this)).get_left_controller(); |
486 | 436 | } |
487 | 437 |
|
488 | 438 | const ControllerSnapshotTrackedT& ControllerTracker::get_right_controller(const DeviceIOSession& session) const |
489 | 439 | { |
490 | | - return static_cast<const Impl&>(session.get_tracker_impl(*this)).get_right_controller(); |
| 440 | + return static_cast<const ControllerTrackerImpl&>(session.get_tracker_impl(*this)).get_right_controller(); |
491 | 441 | } |
492 | 442 |
|
493 | | -std::shared_ptr<ITrackerImpl> ControllerTracker::create_tracker(const OpenXRSessionHandles& handles) const |
| 443 | +std::unique_ptr<ITrackerImpl> ControllerTracker::create_tracker_impl(TrackerFactory& factory) const |
494 | 444 | { |
495 | | - return std::make_shared<Impl>(handles); |
| 445 | + return factory.create_controller_tracker_impl(); |
496 | 446 | } |
497 | 447 |
|
498 | 448 | } // namespace core |
0 commit comments