|
|
|
@@ -507,7 +507,7 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPara
|
|
|
|
|
break;
|
|
|
|
|
// keyboard
|
|
|
|
|
case WM_CHAR :
|
|
|
|
|
case WM_SYSCHAR :
|
|
|
|
|
case WM_SYSCHAR :
|
|
|
|
|
#ifdef _NAPI_SOCKET
|
|
|
|
|
if (wParam == VK_RETURN) {
|
|
|
|
|
parseCommand(command);
|
|
|
|
@@ -533,7 +533,7 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPara
|
|
|
|
|
if (style & WS_OVERLAPPEDWINDOW) {
|
|
|
|
|
MONITORINFO mInfo = { sizeof(mInfo) };
|
|
|
|
|
if (GetWindowPlacement(hWnd, &pLast) && GetMonitorInfo(MonitorFromWindow(hWnd, MONITOR_DEFAULTTOPRIMARY), &mInfo)) {
|
|
|
|
|
RECT &r = mInfo.rcMonitor;
|
|
|
|
|
RECT &r = mInfo.rcMonitor;
|
|
|
|
|
SetWindowLong(hWnd, GWL_STYLE, style & ~WS_OVERLAPPEDWINDOW);
|
|
|
|
|
MoveWindow(hWnd, r.left, r.top, r.right - r.left, r.bottom - r.top, FALSE);
|
|
|
|
|
}
|
|
|
|
@@ -601,23 +601,23 @@ vr::TrackedDevicePose_t tPose[vr::k_unMaxTrackedDeviceCount];
|
|
|
|
|
//eye textures(eventually)
|
|
|
|
|
|
|
|
|
|
//action handles
|
|
|
|
|
vr::VRActionHandle_t VRcLeft = vr::k_ulInvalidActionHandle;
|
|
|
|
|
vr::VRActionHandle_t VRcRight = vr::k_ulInvalidActionHandle;
|
|
|
|
|
vr::VRActionHandle_t VRcUp = vr::k_ulInvalidActionHandle;
|
|
|
|
|
vr::VRActionHandle_t VRcDown = vr::k_ulInvalidActionHandle;
|
|
|
|
|
vr::VRActionHandle_t VRcLeft = vr::k_ulInvalidActionHandle;
|
|
|
|
|
vr::VRActionHandle_t VRcRight = vr::k_ulInvalidActionHandle;
|
|
|
|
|
vr::VRActionHandle_t VRcUp = vr::k_ulInvalidActionHandle;
|
|
|
|
|
vr::VRActionHandle_t VRcDown = vr::k_ulInvalidActionHandle;
|
|
|
|
|
|
|
|
|
|
vr::VRActionHandle_t VRcJump = vr::k_ulInvalidActionHandle;
|
|
|
|
|
vr::VRActionHandle_t VRcWalk = vr::k_ulInvalidActionHandle;
|
|
|
|
|
vr::VRActionHandle_t VRcAction = vr::k_ulInvalidActionHandle;
|
|
|
|
|
vr::VRActionHandle_t VRcWeapon = vr::k_ulInvalidActionHandle;
|
|
|
|
|
vr::VRActionHandle_t VRcRoll = vr::k_ulInvalidActionHandle;
|
|
|
|
|
vr::VRActionHandle_t VRcLook = vr::k_ulInvalidActionHandle;
|
|
|
|
|
vr::VRActionHandle_t VRcJump = vr::k_ulInvalidActionHandle;
|
|
|
|
|
vr::VRActionHandle_t VRcWalk = vr::k_ulInvalidActionHandle;
|
|
|
|
|
vr::VRActionHandle_t VRcAction = vr::k_ulInvalidActionHandle;
|
|
|
|
|
vr::VRActionHandle_t VRcWeapon = vr::k_ulInvalidActionHandle;
|
|
|
|
|
vr::VRActionHandle_t VRcRoll = vr::k_ulInvalidActionHandle;
|
|
|
|
|
vr::VRActionHandle_t VRcLook = vr::k_ulInvalidActionHandle;
|
|
|
|
|
vr::VRActionHandle_t VRcInventory = vr::k_ulInvalidActionHandle;
|
|
|
|
|
vr::VRActionHandle_t VRcStart = vr::k_ulInvalidActionHandle;
|
|
|
|
|
vr::VRActionHandle_t VRcStart = vr::k_ulInvalidActionHandle;
|
|
|
|
|
|
|
|
|
|
vr::VRActionSetHandle_t m_actionsetDemo = vr::k_ulInvalidActionSetHandle;
|
|
|
|
|
|
|
|
|
|
vr::VRInputValueHandle_t m_leftHand = vr::k_ulInvalidInputValueHandle;
|
|
|
|
|
vr::VRInputValueHandle_t m_leftHand = vr::k_ulInvalidInputValueHandle;
|
|
|
|
|
vr::VRInputValueHandle_t m_rightHand = vr::k_ulInvalidInputValueHandle;
|
|
|
|
|
|
|
|
|
|
//only in select TR games
|
|
|
|
@@ -644,33 +644,33 @@ void vrInit() {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//set manifest
|
|
|
|
|
vr::VRInput()->SetActionManifestPath("C:/Users/Austin/Desktop/OpenLaraGitTest2/OpenLara/bin/TombRaidervr_actions.json"); // needs absolutepath
|
|
|
|
|
//set manifest
|
|
|
|
|
vr::VRInput()->SetActionManifestPath("C:/Users/Austin/Desktop/OpenLaraGitTest2/OpenLara/bin/TombRaidervr_actions.json"); // needs absolutepath
|
|
|
|
|
// get action handles
|
|
|
|
|
vr::VRInput()->GetActionHandle("/actions/demo/in/Left", &VRcLeft);
|
|
|
|
|
vr::VRInput()->GetActionHandle("/actions/demo/in/Right", &VRcRight);
|
|
|
|
|
vr::VRInput()->GetActionHandle("/actions/demo/in/Up", &VRcUp);
|
|
|
|
|
vr::VRInput()->GetActionHandle("/actions/demo/in/Down", &VRcDown);
|
|
|
|
|
vr::VRInput()->GetActionHandle("/actions/demo/in/Jump", &VRcJump);
|
|
|
|
|
vr::VRInput()->GetActionHandle("/actions/demo/in/Walk", &VRcWalk);
|
|
|
|
|
vr::VRInput()->GetActionHandle("/actions/demo/in/Action", &VRcAction);
|
|
|
|
|
vr::VRInput()->GetActionHandle("/actions/demo/in/Weapon", &VRcWeapon);
|
|
|
|
|
vr::VRInput()->GetActionHandle("/actions/demo/in/Roll", &VRcRoll);
|
|
|
|
|
vr::VRInput()->GetActionHandle("/actions/demo/in/Inventory", &VRcInventory);
|
|
|
|
|
vr::VRInput()->GetActionHandle("/actions/demo/in/Start", &VRcStart);
|
|
|
|
|
//get actionsethandle
|
|
|
|
|
vr::VRInput()->GetActionSetHandle("/actions/demo", &m_actionsetDemo);
|
|
|
|
|
//get input source handles
|
|
|
|
|
vr::VRInput()->GetInputSourceHandle("/user/hand/left", &m_leftHand);
|
|
|
|
|
vr::VRInput()->GetInputSourceHandle("/user/hand/right", &m_rightHand);
|
|
|
|
|
// aren't using right now
|
|
|
|
|
//vr::VRInput()->GetActionHandle("/actions/demo/in/TriggerHaptic", &m_actionTriggerHaptic);
|
|
|
|
|
//vr::VRInput()->GetActionHandle("/actions/demo/in/AnalogInput", &m_actionAnalongInput);
|
|
|
|
|
vr::VRInput()->GetActionHandle("/actions/demo/in/Left", &VRcLeft);
|
|
|
|
|
vr::VRInput()->GetActionHandle("/actions/demo/in/Right", &VRcRight);
|
|
|
|
|
vr::VRInput()->GetActionHandle("/actions/demo/in/Up", &VRcUp);
|
|
|
|
|
vr::VRInput()->GetActionHandle("/actions/demo/in/Down", &VRcDown);
|
|
|
|
|
vr::VRInput()->GetActionHandle("/actions/demo/in/Jump", &VRcJump);
|
|
|
|
|
vr::VRInput()->GetActionHandle("/actions/demo/in/Walk", &VRcWalk);
|
|
|
|
|
vr::VRInput()->GetActionHandle("/actions/demo/in/Action", &VRcAction);
|
|
|
|
|
vr::VRInput()->GetActionHandle("/actions/demo/in/Weapon", &VRcWeapon);
|
|
|
|
|
vr::VRInput()->GetActionHandle("/actions/demo/in/Roll", &VRcRoll);
|
|
|
|
|
vr::VRInput()->GetActionHandle("/actions/demo/in/Inventory", &VRcInventory);
|
|
|
|
|
vr::VRInput()->GetActionHandle("/actions/demo/in/Start", &VRcStart);
|
|
|
|
|
//get actionsethandle
|
|
|
|
|
vr::VRInput()->GetActionSetHandle("/actions/demo", &m_actionsetDemo);
|
|
|
|
|
//get input source handles
|
|
|
|
|
vr::VRInput()->GetInputSourceHandle("/user/hand/left", &m_leftHand);
|
|
|
|
|
vr::VRInput()->GetInputSourceHandle("/user/hand/right", &m_rightHand);
|
|
|
|
|
// aren't using right now
|
|
|
|
|
//vr::VRInput()->GetActionHandle("/actions/demo/in/TriggerHaptic", &m_actionTriggerHaptic);
|
|
|
|
|
//vr::VRInput()->GetActionHandle("/actions/demo/in/AnalogInput", &m_actionAnalongInput);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void vrInitTargets() {
|
|
|
|
|
uint32_t width, height;
|
|
|
|
|
hmd->GetRecommendedRenderTargetSize( &width, &height);
|
|
|
|
|
hmd->GetRecommendedRenderTargetSize(&width, &height);
|
|
|
|
|
Core::eyeTex[0] = new Texture(width, height, TexFormat::FMT_RGBA);
|
|
|
|
|
Core::eyeTex[1] = new Texture(width, height, TexFormat::FMT_RGBA);
|
|
|
|
|
}
|
|
|
|
@@ -682,13 +682,13 @@ void vrFree() {
|
|
|
|
|
|
|
|
|
|
mat4 convToMat4(const vr::HmdMatrix44_t &m) {
|
|
|
|
|
return mat4(m.m[0][0], m.m[1][0], m.m[2][0], m.m[3][0],
|
|
|
|
|
m.m[0][1], m.m[1][1], m.m[2][1], m.m[3][1],
|
|
|
|
|
m.m[0][2], m.m[1][2], m.m[2][2], m.m[3][2],
|
|
|
|
|
m.m[0][1], m.m[1][1], m.m[2][1], m.m[3][1],
|
|
|
|
|
m.m[0][2], m.m[1][2], m.m[2][2], m.m[3][2],
|
|
|
|
|
m.m[0][3], m.m[1][3], m.m[2][3], m.m[3][3]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mat4 convToMat4(const vr::HmdMatrix34_t &m) {
|
|
|
|
|
return mat4(m.m[0][0], m.m[1][0], m.m[2][0], 0.0f,
|
|
|
|
|
return mat4(m.m[0][0], m.m[1][0], m.m[2][0], 0.0f,
|
|
|
|
|
m.m[0][1], m.m[1][1], m.m[2][1], 0.0f,
|
|
|
|
|
m.m[0][2], m.m[1][2], m.m[2][2], 0.0f,
|
|
|
|
|
m.m[0][3], m.m[1][3], m.m[2][3], 1.0f);
|
|
|
|
@@ -696,71 +696,65 @@ mat4 convToMat4(const vr::HmdMatrix34_t &m) {
|
|
|
|
|
//utility function for reading digital state
|
|
|
|
|
bool GetDigitalActionState(vr::VRActionHandle_t action, vr::VRInputValueHandle_t *pDevicePath = nullptr)
|
|
|
|
|
{
|
|
|
|
|
vr::InputDigitalActionData_t actionData;
|
|
|
|
|
vr::VRInput()->GetDigitalActionData(action, &actionData, sizeof(actionData), vr::k_ulInvalidInputValueHandle);
|
|
|
|
|
if (pDevicePath)
|
|
|
|
|
{
|
|
|
|
|
*pDevicePath = vr::k_ulInvalidInputValueHandle;
|
|
|
|
|
if (actionData.bActive)
|
|
|
|
|
{
|
|
|
|
|
vr::InputOriginInfo_t originInfo;
|
|
|
|
|
if (vr::VRInputError_None == vr::VRInput()->GetOriginTrackedDeviceInfo(actionData.activeOrigin, &originInfo, sizeof(originInfo)))
|
|
|
|
|
{
|
|
|
|
|
*pDevicePath = originInfo.devicePath;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return actionData.bActive && actionData.bState;
|
|
|
|
|
vr::InputDigitalActionData_t actionData;
|
|
|
|
|
vr::VRInput()->GetDigitalActionData(action, &actionData, sizeof(actionData), vr::k_ulInvalidInputValueHandle);
|
|
|
|
|
if (pDevicePath) {
|
|
|
|
|
*pDevicePath = vr::k_ulInvalidInputValueHandle;
|
|
|
|
|
if (actionData.bActive) {
|
|
|
|
|
vr::InputOriginInfo_t originInfo;
|
|
|
|
|
if (vr::VRInputError_None == vr::VRInput()->GetOriginTrackedDeviceInfo(actionData.activeOrigin, &originInfo, sizeof(originInfo))) {
|
|
|
|
|
*pDevicePath = originInfo.devicePath;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return actionData.bActive && actionData.bState;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ProcessVREvent(const vr::VREvent_t &event) {
|
|
|
|
|
char buffer[1024] = "test";
|
|
|
|
|
switch (event.eventType) {
|
|
|
|
|
case vr::VREvent_TrackedDeviceActivated:
|
|
|
|
|
//SetupRenderModelForTrackedDevice( event.trackedDeviceIndex );
|
|
|
|
|
vr::RenderModel_t ** controllerRender;
|
|
|
|
|
hmd->GetStringTrackedDeviceProperty(event.trackedDeviceIndex, vr::ETrackedDeviceProperty::Prop_RenderModelName_String, buffer, 1024); // can be filled with an error,but I can't find the right type
|
|
|
|
|
//rm->LoadRenderModel_Async(buffer, controllerRender);
|
|
|
|
|
// need to process render model?
|
|
|
|
|
LOG("Device %u attached. Setting up render model\n", event.trackedDeviceIndex);
|
|
|
|
|
break;
|
|
|
|
|
case vr::VREvent_TrackedDeviceDeactivated:
|
|
|
|
|
LOG("Device %u detached.\n", event.trackedDeviceIndex);
|
|
|
|
|
break;
|
|
|
|
|
case vr::VREvent_TrackedDeviceUpdated: //not sure what to do here
|
|
|
|
|
LOG("Device %u updated.\n", event.trackedDeviceIndex);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
char buffer[1024] = "test";
|
|
|
|
|
switch (event.eventType) {
|
|
|
|
|
case vr::VREvent_TrackedDeviceActivated:
|
|
|
|
|
//SetupRenderModelForTrackedDevice( event.trackedDeviceIndex );
|
|
|
|
|
vr::RenderModel_t ** controllerRender;
|
|
|
|
|
hmd->GetStringTrackedDeviceProperty(event.trackedDeviceIndex, vr::ETrackedDeviceProperty::Prop_RenderModelName_String, buffer, 1024); // can be filled with an error,but I can't find the right type
|
|
|
|
|
//rm->LoadRenderModel_Async(buffer, controllerRender);
|
|
|
|
|
// need to process render model?
|
|
|
|
|
LOG("Device %u attached. Setting up render model\n", event.trackedDeviceIndex);
|
|
|
|
|
break;
|
|
|
|
|
case vr::VREvent_TrackedDeviceDeactivated:
|
|
|
|
|
LOG("Device %u detached.\n", event.trackedDeviceIndex);
|
|
|
|
|
Input::reset();
|
|
|
|
|
break;
|
|
|
|
|
case vr::VREvent_TrackedDeviceUpdated: //not sure what to do here
|
|
|
|
|
LOG("Device %u updated.\n", event.trackedDeviceIndex);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//taken from openvrsimpleexamples
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void vrUpdateInput() { // going to use action manifest and ivr:input(Steam Vr Input) // broken
|
|
|
|
|
void vrUpdateInput() {
|
|
|
|
|
if (!hmd) return;
|
|
|
|
|
vr::VREvent_t event;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (hmd->PollNextEvent(&event, sizeof(event))) {
|
|
|
|
|
ProcessVREvent( event ); // eventually going to be the function for this while loop
|
|
|
|
|
ProcessVREvent(event);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//process actions( set hmd down)
|
|
|
|
|
vr::VRActiveActionSet_t actionSet = { 0 };
|
|
|
|
|
actionSet.ulActionSet = m_actionsetDemo;
|
|
|
|
|
vr::VRInput()->UpdateActionState(&actionSet, sizeof(actionSet), 1);
|
|
|
|
|
vr::VRActiveActionSet_t actionSet = { 0 };
|
|
|
|
|
actionSet.ulActionSet = m_actionsetDemo;
|
|
|
|
|
vr::VRInput()->UpdateActionState(&actionSet, sizeof(actionSet), 1);
|
|
|
|
|
|
|
|
|
|
Input::hmd.down[cUp] = GetDigitalActionState(VRcUp);
|
|
|
|
|
Input::hmd.down[cDown] = GetDigitalActionState(VRcDown);
|
|
|
|
|
Input::hmd.down[cRight] = GetDigitalActionState(VRcRight);
|
|
|
|
|
Input::hmd.down[cLeft] = GetDigitalActionState(VRcLeft);
|
|
|
|
|
Input::hmd.down[cJump] = GetDigitalActionState(VRcJump);
|
|
|
|
|
Input::hmd.down[cWalk] = GetDigitalActionState(VRcWalk);
|
|
|
|
|
Input::hmd.down[cAction] = GetDigitalActionState(VRcAction);
|
|
|
|
|
Input::hmd.down[cWeapon] = GetDigitalActionState(VRcWeapon);
|
|
|
|
|
Input::hmd.down[cRoll] = GetDigitalActionState(VRcRoll);
|
|
|
|
|
Input::hmd.down[cStart] = GetDigitalActionState(VRcStart);
|
|
|
|
|
Input::hmd.down[cInventory] = GetDigitalActionState(VRcInventory);
|
|
|
|
|
Input::hmd.state[cUp] = GetDigitalActionState(VRcUp);
|
|
|
|
|
Input::hmd.state[cDown] = GetDigitalActionState(VRcDown);
|
|
|
|
|
Input::hmd.state[cRight] = GetDigitalActionState(VRcRight);
|
|
|
|
|
Input::hmd.state[cLeft] = GetDigitalActionState(VRcLeft);
|
|
|
|
|
Input::hmd.state[cJump] = GetDigitalActionState(VRcJump);
|
|
|
|
|
Input::hmd.state[cWalk] = GetDigitalActionState(VRcWalk);
|
|
|
|
|
Input::hmd.state[cAction] = GetDigitalActionState(VRcAction);
|
|
|
|
|
Input::hmd.state[cWeapon] = GetDigitalActionState(VRcWeapon);
|
|
|
|
|
Input::hmd.state[cRoll] = GetDigitalActionState(VRcRoll);
|
|
|
|
|
Input::hmd.state[cStart] = GetDigitalActionState(VRcStart);
|
|
|
|
|
Input::hmd.state[cInventory] = GetDigitalActionState(VRcInventory);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void vrUpdateView() {
|
|
|
|
@@ -777,14 +771,14 @@ void vrUpdateView() {
|
|
|
|
|
if (Input::hmd.zero.x == INF)
|
|
|
|
|
Input::hmd.zero = head.getPos();
|
|
|
|
|
head.setPos(head.getPos() - Input::hmd.zero);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mat4 vL = head * convToMat4(hmd->GetEyeToHeadTransform(vr::Eye_Left));
|
|
|
|
|
mat4 vR = head * convToMat4(hmd->GetEyeToHeadTransform(vr::Eye_Right));
|
|
|
|
|
|
|
|
|
|
vL.setPos(vL.getPos() * ONE_METER);
|
|
|
|
|
vR.setPos(vR.getPos() * ONE_METER);
|
|
|
|
|
Input::hmd.setView(pL, pR, vL, vR);
|
|
|
|
|
// pass this to Lara's rotation value
|
|
|
|
|
|
|
|
|
|
Input::hmd.head = head;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|