Monado OpenXR Runtime
Loading...
Searching...
No Matches
openvr_input.hpp
Go to the documentation of this file.
1// Copyright 2026, Beyley Cardellio
2// SPDX-License-Identifier: BSL-1.0
3/*!
4 * @file
5 * @brief Implementation of OpenVR input.
6 *
7 * @author Beyley Cardellio <ep1cm1n10n123@gmail.com>
8 * @ingroup openvr
9 */
10
11#pragma once
12
13#include "os/os_threading.h"
14
15#include "openvr_devices.hpp"
16
17#include <unordered_map>
18
19
20namespace xrt::state_trackers::openvr {
21
22namespace os = xrt::auxiliary::os;
23
24struct Input
25{
26private: // Fields
27 // Handle 0 is reserved (k_ulInvalidActionSetHandle / k_ulInvalidActionHandle /
28 // k_ulInvalidInputValueHandle are all 0), so allocation starts at 1. Shared for simplicity.
29 xrt_atomic_s64_t next_handle{1};
30
31 mutable os::Mutex lock;
32
33 std::unordered_map<std::string, vr::VRActionSetHandle_t> action_set_handles;
34 std::unordered_map<std::string, vr::VRActionHandle_t> action_handles;
35 std::unordered_map<std::string, vr::VRInputValueHandle_t> input_source_handles;
36
37 vr::ETrackedControllerRole dominant_hand{vr::ETrackedControllerRole::TrackedControllerRole_RightHand};
38
39public: // Methods
40 Input();
41
42 // State
43 vr::EVRInputError
44 setDominantHand(vr::ETrackedControllerRole dominant_hand);
45
46 vr::EVRInputError
47 getDominantHand(vr::ETrackedControllerRole &dominant_hand);
48
49 // Handles
50 vr::EVRInputError
51 getActionSetHandle(const std::string &name, vr::VRActionSetHandle_t &handle);
52
53 vr::EVRInputError
54 getActionHandle(const std::string &name, vr::VRActionHandle_t &handle);
55
56 vr::EVRInputError
57 getInputSourceHandle(const std::string &name, vr::VRInputValueHandle_t &handle);
58};
59
60}; // namespace xrt::state_trackers::openvr
Implementation of a dynamic OpenVR devices array using the xrt_system_devices interface.
Wrapper around OS threading native functions.
Definition openvr_input.hpp:25