cleanup
This commit is contained in:
81
src/hmd.h
81
src/hmd.h
@@ -1,84 +1,23 @@
|
||||
#pragma once
|
||||
#include "rtt.h"
|
||||
|
||||
struct Controller
|
||||
{
|
||||
enum class Button : uint64_t
|
||||
{
|
||||
Trigger = 0x200000000,
|
||||
Pad = 0x100000000,
|
||||
Menu = 0x000000002,
|
||||
Grip = 0x000000004,
|
||||
};
|
||||
enum class ButtonAxis : uint8_t
|
||||
{
|
||||
Trigger = 1,
|
||||
Pad = 0,
|
||||
};
|
||||
enum class Action
|
||||
{
|
||||
Press,
|
||||
Release,
|
||||
};
|
||||
int index = 0;
|
||||
bool active = false;
|
||||
std::map<uint64_t, bool> buttons;
|
||||
std::map<uint8_t, bool> buttons_axis;
|
||||
uint64_t buttons_bits{ 0 };
|
||||
glm::vec2 axis[5];
|
||||
glm::mat4 xform{ 1 };
|
||||
glm::vec3 pos{ 0 };
|
||||
glm::vec3 rot{ 0 };
|
||||
vr::VRControllerState_t state;
|
||||
bool valid = false;
|
||||
int role = 0;
|
||||
|
||||
void update(const glm::mat4& m)
|
||||
{
|
||||
xform = m;
|
||||
pos = glm::vec3(m[3]);
|
||||
//float sx = glm::length(glm::vec3(m[0]));
|
||||
//float sy = glm::length(glm::vec3(m[1]));
|
||||
//float sz = glm::length(glm::vec3(m[2]));
|
||||
glm::extractEulerAngleXYZ(m, rot.x, rot.y, rot.z);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
struct Vive
|
||||
{
|
||||
int comp_attempts = 0;
|
||||
uint32_t eyeWidth = 0, eyeHeight = 0;
|
||||
RTT eyes[2];
|
||||
vr::IVRSystem* hmd = nullptr;
|
||||
vr::IVRCompositor* comp = nullptr;
|
||||
vr::IVRSettings* settings = nullptr;
|
||||
glm::vec3 euler{ 0 };
|
||||
glm::vec4 background{ .5, .2, .2, 1 };
|
||||
float yaw_offset = 0;
|
||||
glm::mat4 view[2];
|
||||
glm::mat4 proj[2];
|
||||
glm::mat4 pose;
|
||||
Controller controllers[32];
|
||||
Controller trackers[32];
|
||||
bool swap_controllers = false;
|
||||
bool active = false;
|
||||
std::string dev_serial{ "0000001" };
|
||||
std::string dev_model{ "Vive" };
|
||||
std::string dev_tracksys{ "lighthouse" };
|
||||
std::string dev_manufacturer{ "HTC" };
|
||||
std::function<void(const glm::mat4& proj, const glm::mat4& view, const glm::mat4& pose)> on_draw = nullptr;
|
||||
std::function<void(const Controller&, Controller::Button, Controller::Action)> on_button = nullptr;
|
||||
std::function<void(const Controller&, Controller::ButtonAxis, Controller::Action)> on_button_axis = nullptr;
|
||||
uint32_t m_eye_width = 0, m_eye_height = 0;
|
||||
RTT m_eyes[2];
|
||||
vr::IVRSystem* m_hmd = nullptr;
|
||||
vr::IVRCompositor* m_comp = nullptr;
|
||||
vr::IVRSettings* m_settings = nullptr;
|
||||
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;
|
||||
|
||||
Vive();
|
||||
bool Initialize();
|
||||
void Terminate();
|
||||
void ResetYaw();
|
||||
void Update();
|
||||
void Draw();
|
||||
std::string ReadPropString(vr::TrackedDeviceIndex_t nDevice, vr::ETrackedDeviceProperty p);
|
||||
bool Valid();
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user