vr paint
This commit is contained in:
37
src/hmd.h
37
src/hmd.h
@@ -1,6 +1,39 @@
|
||||
#pragma once
|
||||
#include "rtt.h"
|
||||
|
||||
struct ViveController
|
||||
{
|
||||
enum class kButton : uint8_t
|
||||
{
|
||||
Pad,
|
||||
Trigger,
|
||||
Menu,
|
||||
Grip,
|
||||
COUNT,
|
||||
};
|
||||
enum class kButtonMask : uint64_t
|
||||
{
|
||||
TriggerBit = 0x200000000,
|
||||
PadBit = 0x100000000,
|
||||
MenuBit = 0x000000002,
|
||||
GripBit = 0x000000004,
|
||||
};
|
||||
enum class kAction
|
||||
{
|
||||
Press,
|
||||
Release,
|
||||
};
|
||||
static std::map<kButton, kButtonMask> m_mask;
|
||||
std::array<bool, (int)kButton::COUNT> m_buttons;
|
||||
std::array<bool, (int)kButton::COUNT> m_analog_buttons;
|
||||
glm::mat4 m_mat;
|
||||
vr::VRControllerState_t m_state{ 0 };
|
||||
bool m_valid = false;
|
||||
glm::vec2 axis(kButton button) const {
|
||||
return { m_state.rAxis[(int)button].x, m_state.rAxis[(int)button].y };
|
||||
}
|
||||
};
|
||||
|
||||
struct Vive
|
||||
{
|
||||
int comp_attempts = 0;
|
||||
@@ -9,15 +42,19 @@ struct Vive
|
||||
vr::IVRSystem* m_hmd = nullptr;
|
||||
vr::IVRCompositor* m_comp = nullptr;
|
||||
vr::IVRSettings* m_settings = nullptr;
|
||||
ViveController m_controllers[2];
|
||||
glm::mat4 m_view[2];
|
||||
glm::mat4 m_proj[2];
|
||||
glm::mat4 m_pose;
|
||||
bool m_active = false;
|
||||
std::function<void(const glm::mat4& m_proj, const glm::mat4& m_view, const glm::mat4& m_pose)> on_draw = nullptr;
|
||||
std::function<void(const ViveController&, ViveController::kButton, ViveController::kAction)> on_button = nullptr;
|
||||
std::function<void(const ViveController&, ViveController::kButton, ViveController::kAction)> on_analog_button = nullptr;
|
||||
|
||||
bool Initialize();
|
||||
void Terminate();
|
||||
void Update();
|
||||
void Draw();
|
||||
bool Valid();
|
||||
glm::mat4 Pose2Mat(vr::HmdMatrix34_t const& m);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user