implement motion controllers and vr drawing with brush preview
This commit is contained in:
11
src/hmd.h
11
src/hmd.h
@@ -10,6 +10,11 @@ struct Controller
|
||||
Menu = 0x000000002,
|
||||
Grip = 0x000000004,
|
||||
};
|
||||
enum class ButtonAxis : uint8_t
|
||||
{
|
||||
Trigger = 1,
|
||||
Pad = 0,
|
||||
};
|
||||
enum class Action
|
||||
{
|
||||
Press,
|
||||
@@ -18,6 +23,7 @@ struct Controller
|
||||
int index = 0;
|
||||
bool active = false;
|
||||
std::map<uint64_t, bool> buttons;
|
||||
std::map<uint8_t, float> buttons_axis;
|
||||
uint64_t buttons_bits{ 0 };
|
||||
glm::vec2 axis[5];
|
||||
glm::mat4 xform{ 1 };
|
||||
@@ -46,6 +52,7 @@ struct Vive
|
||||
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;
|
||||
@@ -55,18 +62,22 @@ struct Vive
|
||||
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;
|
||||
|
||||
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