#include "../native/launcher_input.h" #include #include #include int main(int argc,char** argv){if(argc!=2)return 2;vr::EVRInitError error;auto* system=vr::VR_Init(&error,vr::VRApplication_Overlay);if(error){std::cerr<<"VR_Init: "<SetActionManifestPath(argv[1]);std::cout<<"manifest="<GetActionSetHandle("/actions/entry",&set)==vr::VRInputError_None&&input->GetActionHandle("/actions/entry/in/primary",&primary)==vr::VRInputError_None&&input->GetActionHandle("/actions/entry/in/upper",&upper)==vr::VRInputError_None&&input->GetActionHandle("/actions/entry/in/aim",&aim)==vr::VRInputError_None; for(int i=0;i<20&&ok;i++){vr::VRActiveActionSet_t active{};active.ulActionSet=set;result=input->UpdateActionState(&active,sizeof(active),1);if(result!=vr::VRInputError_None){std::cerr<<"update="<GetInputSourceHandle(path,&hand);vr::InputDigitalActionData_t a{},b{};vr::InputPoseActionData_t pose{};auto e1=input->GetDigitalActionData(primary,&a,sizeof(a),hand),e2=input->GetDigitalActionData(upper,&b,sizeof(b),hand),e3=input->GetPoseActionDataRelativeToNow(aim,vr::TrackingUniverseStanding,0,&pose,sizeof(pose),hand);std::cout<FindOverlay("framely.dock.button",&button)){ vr::VROverlayIntersectionParams_t ray{};ray.eOrigin=vr::TrackingUniverseStanding;for(int r=0;r<3;r++){ray.vSource.v[r]=pose.pose.mDeviceToAbsoluteTracking.m[r][3];ray.vDirection.v[r]=-pose.pose.mDeviceToAbsoluteTracking.m[r][2];}vr::VROverlayIntersectionResults_t hit{};bool intersects=overlays->ComputeOverlayIntersection(button,&ray,&hit);std::cout<<"dock visible="<IsOverlayVisible(button)<<" hover="<IsHoverTargetOverlay(button)<<" intersection="<GetTrackedDeviceClass(i)!=vr::TrackedDeviceClass_Controller)continue;char type[256]{};system->GetStringTrackedDeviceProperty(i,vr::Prop_ControllerType_String,type,sizeof(type));std::cout<<"controller="<UpdateActionState(&active,sizeof(active),1); if(tick%80==0){vr::TrackedDevicePose_t poses[vr::k_unMaxTrackedDeviceCount]{};system->GetDeviceToAbsoluteTrackingPose(vr::TrackingUniverseStanding,0,poses,vr::k_unMaxTrackedDeviceCount);std::cout<<"tracking";for(unsigned d=0;d<3;d++)std::cout<<" "<GetInputSourceHandle(path,&hand);vr::InputDigitalActionData_t a{},b{};input->GetDigitalActionData(primary,&a,sizeof(a),hand);input->GetDigitalActionData(upper,&b,sizeof(b),hand); auto device=system->GetTrackedDeviceIndexForControllerRole(std::string(path).find("right")!=std::string::npos?vr::TrackedControllerRole_RightHand:vr::TrackedControllerRole_LeftHand);char model[256]{};system->GetStringTrackedDeviceProperty(device,vr::Prop_RenderModelName_String,model,sizeof(model));vr::RenderModel_ControllerMode_State_t mode{};vr::RenderModel_ComponentState_t primaryState{},upperState{};bool c1=vr::VRRenderModels()->GetComponentStateForDevicePath(model,"trigger",hand,&mode,&primaryState),c2=vr::VRRenderModels()->GetComponentStateForDevicePath(model,"bumper",hand,&mode,&upperState);vr::VRControllerState_t restInput{},fullInput{};fullInput.rAxis[1].x=1;vr::RenderModel_ComponentState_t rest{},full{};float pull=-1;bool calibrated=c1&&vr::VRRenderModels()->GetComponentState(model,"trigger",&restInput,&mode,&rest)&&vr::VRRenderModels()->GetComponentState(model,"trigger",&fullInput,&mode,&full)&&entry_trigger_pull(rest,full,primaryState,pull);int side=std::string(path).find("right")!=std::string::npos?1:0;bool changed=std::abs(pull-previousPull[side])>.05f;previousPull[side]=pull; if(tick%80==0||changed)std::cout<GetPoseActionDataRelativeToNow(aim,vr::TrackingUniverseStanding,0,&pose,sizeof(pose),hand);std::cout<ComputeOverlayIntersection(overlay,&ray,&hit);std::cout<<" hover="<IsHoverTargetOverlay(overlay)<<" intersection="<