Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compatibility to Portal Reloaded #136

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions L4D2VR/SteamVRActionManifest/action_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
"name": "/actions/main/in/SecondaryAttack",
"type": "boolean"
},
{
"name": "/actions/main/in/ThirdAttack",
"type": "boolean"
},
{
"name": "/actions/main/in/Jump",
"type": "boolean"
Expand Down Expand Up @@ -154,6 +158,7 @@
"/actions/main" : "Main",
"/actions/main/in/PrimaryAttack" : "Primary Attack",
"/actions/main/in/SecondaryAttack" : "Secondary Attack",
"/actions/main/in/ThirdAttack" : "Third Attack",
"/actions/main/in/Jump" : "Jump",
"/actions/main/in/Walk" : "Walk",
"/actions/main/in/Turn" : "Turn",
Expand Down
9 changes: 9 additions & 0 deletions L4D2VR/SteamVRActionManifest/bindings_knuckles.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@
},
"path" : "/user/hand/left/input/grip"
},
{
"inputs" : {
"click" : {
"output" : "/actions/main/in/ThirdAttack"
}
},
"mode" : "button",
"path" : "/user/hand/left/input/trigger"
},
{
"inputs" : {
"click" : {
Expand Down
9 changes: 9 additions & 0 deletions L4D2VR/SteamVRActionManifest/bindings_oculus_touch.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@
"mode" : "button",
"path" : "/user/hand/left/input/trigger"
},
{
"inputs" : {
"click" : {
"output" : "/actions/main/in/ThirdAttack"
}
},
"mode" : "button",
"path" : "/user/hand/left/input/trigger"
},
{
"inputs" : {
"click" : {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@
"mode" : "button",
"path" : "/user/hand/left/input/trigger"
},
{
"inputs" : {
"click" : {
"output" : "/actions/main/in/ThirdAttack"
}
},
"mode" : "button",
"path" : "/user/hand/left/input/trigger"
},
{
"inputs" : {
"click" : {
Expand Down
6 changes: 3 additions & 3 deletions L4D2VR/l4d2vr.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
<ModuleDefinitionFile>$(SolutionDir)dxvk\src\d3d9\d3d9.def</ModuleDefinitionFile>
</Link>
<PostBuildEvent>
<Command>copy /Y "$(OutDir)$(TargetName)$(TargetExt)" "H:\SteamLibrary\steamapps\common\Portal 2\bin\$(TargetName)$(TargetExt)"</Command>
<Command>copy /Y "$(OutDir)$(TargetName)$(TargetExt)" "C:\Program Files (x86)\Steam\steamapps\common\Portal 2\bin\$(TargetName)$(TargetExt)"</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
Expand Down Expand Up @@ -143,7 +143,7 @@
<AdditionalDependencies>openvr_api.lib;libMinHook.x86.lib;$(SolutionDir)dxvk\lib32\vulkan-1.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command>copy /Y "$(OutDir)$(TargetName)$(TargetExt)" "H:\SteamLibrary\steamapps\common\Portal 2\bin\$(TargetName)$(TargetExt)"</Command>
<Command>copy /Y "$(OutDir)$(TargetName)$(TargetExt)" "C:\Program Files (x86)\Steam\steamapps\common\Portal 2\bin\$(TargetName)$(TargetExt)"</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
Expand Down Expand Up @@ -608,4 +608,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
85 changes: 34 additions & 51 deletions L4D2VR/vr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ int VR::SetActionManifest(const char *fileName)
m_Input->GetActionHandle("/actions/main/in/Scoreboard", &m_Scoreboard);
m_Input->GetActionHandle("/actions/main/in/ShowHUD", &m_ShowHUD);
m_Input->GetActionHandle("/actions/main/in/Pause", &m_Pause);
m_Input->GetActionHandle("/actions/main/in/ThirdAttack", &m_ThirdAttack);

m_Input->GetActionSetHandle("/actions/main", &m_ActionSet);
m_ActiveActionSet = {};
Expand Down Expand Up @@ -442,19 +443,18 @@ void VR::GetViewParameters()
m_EyeToHeadTransformPosRight.z = eyeToHeadRight.m[2][3];
}

bool VR::PressedDigitalAction(vr::VRActionHandle_t &actionHandle, bool checkIfActionChanged)
bool VR::CheckDigitalActionChanged(vr::VRActionHandle_t &actionHandle, bool &state)
{
vr::InputDigitalActionData_t digitalActionData;
vr::EVRInputError result = m_Input->GetDigitalActionData(actionHandle, &digitalActionData, sizeof(digitalActionData), vr::k_ulInvalidInputValueHandle);

if (result == vr::VRInputError_None)
{
if (checkIfActionChanged)
return digitalActionData.bState && digitalActionData.bChanged;
else
return digitalActionData.bState;
state = digitalActionData.bState;
return digitalActionData.bChanged;
}

state = false;
return false;
}

Expand Down Expand Up @@ -545,7 +545,8 @@ void VR::ProcessMenuInput()
{
vr::VROverlay()->SetOverlayFlag(currentOverlay, vr::VROverlayFlags_MakeOverlaysInteractiveIfVisible, false);

if (PressedDigitalAction(m_MenuSelect, true))
bool state;
if (CheckDigitalActionChanged(m_MenuSelect, state) && state)
{
INPUT input {};
input.type = INPUT_KEYBOARD;
Expand All @@ -554,7 +555,7 @@ void VR::ProcessMenuInput()
input.ki.dwFlags = KEYEVENTF_KEYUP;
SendInput(1, &input, sizeof(INPUT));
}
if (PressedDigitalAction(m_MenuBack, true) || PressedDigitalAction(m_Pause, true))
if ((CheckDigitalActionChanged(m_MenuBack, state) && state) || (CheckDigitalActionChanged(m_Pause, state) && state))
{
INPUT input {};
input.type = INPUT_KEYBOARD;
Expand All @@ -563,7 +564,7 @@ void VR::ProcessMenuInput()
input.ki.dwFlags = KEYEVENTF_KEYUP;
SendInput(1, &input, sizeof(INPUT));
}
if (PressedDigitalAction(m_MenuUp, true))
if (CheckDigitalActionChanged(m_MenuUp, state) && state)
{
INPUT input {};
input.type = INPUT_KEYBOARD;
Expand All @@ -572,7 +573,7 @@ void VR::ProcessMenuInput()
input.ki.dwFlags = KEYEVENTF_KEYUP;
SendInput(1, &input, sizeof(INPUT));
}
if (PressedDigitalAction(m_MenuDown, true))
if (CheckDigitalActionChanged(m_MenuDown, state) && state)
{
INPUT input {};
input.type = INPUT_KEYBOARD;
Expand All @@ -581,7 +582,7 @@ void VR::ProcessMenuInput()
input.ki.dwFlags = KEYEVENTF_KEYUP;
SendInput(1, &input, sizeof(INPUT));
}
if (PressedDigitalAction(m_MenuLeft, true))
if (CheckDigitalActionChanged(m_MenuLeft, state) && state)
{
INPUT input {};
input.type = INPUT_KEYBOARD;
Expand All @@ -590,7 +591,7 @@ void VR::ProcessMenuInput()
input.ki.dwFlags = KEYEVENTF_KEYUP;
SendInput(1, &input, sizeof(INPUT));
}
if (PressedDigitalAction(m_MenuRight, true))
if (CheckDigitalActionChanged(m_MenuRight, state) && state)
{
INPUT input {};
input.type = INPUT_KEYBOARD;
Expand Down Expand Up @@ -654,80 +655,62 @@ void VR::ProcessInput()
m_RotationOffset.y -= 360 * std::floor(m_RotationOffset.y / 360);
}

if (PressedDigitalAction(m_ActionPrimaryAttack))
bool state;
if (CheckDigitalActionChanged(m_ActionPrimaryAttack, state))
{
m_Game->ClientCmd_Unrestricted("+attack");
}
else
{
m_Game->ClientCmd_Unrestricted("-attack");
m_Game->ClientCmd_Unrestricted(state ? "+attack" : "-attack");
}

if (PressedDigitalAction(m_ActionSecondaryAttack))
if (CheckDigitalActionChanged(m_ActionSecondaryAttack, state))
{
m_Game->ClientCmd_Unrestricted("+attack2");
}
else
{
m_Game->ClientCmd_Unrestricted("-attack2");
m_Game->ClientCmd_Unrestricted(state ? "+attack2" : "-attack2");
}

if (PressedDigitalAction(m_ActionJump))
{
m_Game->ClientCmd_Unrestricted("+jump");
}
else
if (CheckDigitalActionChanged(m_ThirdAttack, state) && state)
{
m_Game->ClientCmd_Unrestricted("-jump");
m_Game->ClientCmd_Unrestricted("ent_fire @att3 trigger");
}

if (PressedDigitalAction(m_ActionCrouch))
if (CheckDigitalActionChanged(m_ActionJump, state))
{
m_Game->ClientCmd_Unrestricted("+duck");
}
else
{
m_Game->ClientCmd_Unrestricted("-duck");
m_Game->ClientCmd_Unrestricted(state ? "+jump" : "-jump");
}

if (PressedDigitalAction(m_ActionUse))
if (CheckDigitalActionChanged(m_ActionCrouch, state))
{
m_Game->ClientCmd_Unrestricted("+use");
}
else
{
m_Game->ClientCmd_Unrestricted("-use");
m_Game->ClientCmd_Unrestricted(state ? "+duck" : "-duck");
}

if (PressedDigitalAction(m_ActionReload))
if (CheckDigitalActionChanged(m_ActionUse, state))
{
m_Game->ClientCmd_Unrestricted("+reload");
m_Game->ClientCmd_Unrestricted(state ? "+use" : "-use");
}
else

if (CheckDigitalActionChanged(m_ActionReload, state))
{
m_Game->ClientCmd_Unrestricted("-reload");
m_Game->ClientCmd_Unrestricted(state ? "+reload" : "-reload");
}

if (PressedDigitalAction(m_ActionPrevItem, true))
if (CheckDigitalActionChanged(m_ActionPrevItem, state) && state)
{
m_Game->ClientCmd_Unrestricted("invprev");
}
else if (PressedDigitalAction(m_ActionNextItem, true))
else if (CheckDigitalActionChanged(m_ActionNextItem, state) && state)
{
m_Game->ClientCmd_Unrestricted("invnext");
}

if (PressedDigitalAction(m_ActionResetPosition, true))
if (CheckDigitalActionChanged(m_ActionResetPosition, state) && state)
{
ResetPosition();
}

if (PressedDigitalAction(m_ActionFlashlight, true))
if (CheckDigitalActionChanged(m_ActionFlashlight, state) && state)
{
m_Game->ClientCmd_Unrestricted("impulse 100");
}

if (PressedDigitalAction(m_Spray, true))
if (CheckDigitalActionChanged(m_Spray, state) && state)
{
m_Game->ClientCmd_Unrestricted("impulse 201");
}
Expand All @@ -753,7 +736,7 @@ void VR::ProcessInput()

m_RenderedHud = false;

if (PressedDigitalAction(m_Pause, true))
if (CheckDigitalActionChanged(m_Pause, state) && state)
{
m_Game->ClientCmd_Unrestricted("gameui_activate");
RepositionOverlays();
Expand Down
3 changes: 2 additions & 1 deletion L4D2VR/vr.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ class VR
vr::VRActionHandle_t m_Scoreboard;
vr::VRActionHandle_t m_ShowHUD;
vr::VRActionHandle_t m_Pause;
vr::VRActionHandle_t m_ThirdAttack;

TrackedDevicePoseData m_HmdPose;
TrackedDevicePoseData m_LeftControllerPose;
Expand Down Expand Up @@ -223,7 +224,7 @@ class VR
Vector GetViewOrigin(Vector setupOrigin);
Vector GetViewOriginLeft(Vector setupOrigin);
Vector GetViewOriginRight(Vector setupOrigin);
bool PressedDigitalAction(vr::VRActionHandle_t &actionHandle, bool checkIfActionChanged = false);
bool CheckDigitalActionChanged(vr::VRActionHandle_t& actionHandle, bool& state);
bool GetAnalogActionData(vr::VRActionHandle_t &actionHandle, vr::InputAnalogActionData_t &analogDataOut);
void ResetPosition();
void GetPoseData(vr::TrackedDevicePose_t &poseRaw, TrackedDevicePoseData &poseOut);
Expand Down
Binary file modified thirdparty/minhook/lib/Debug/libMinHook.x86.lib
Binary file not shown.
Binary file modified thirdparty/minhook/lib/Release/libMinHook.x86.lib
Binary file not shown.