Most stuff working..

but looks pretty bad at the moment
This commit is contained in:
Simon 2022-12-10 00:34:51 +00:00
parent f650a3be1c
commit d95f02dca2
7 changed files with 77 additions and 43 deletions

View file

@ -1992,7 +1992,13 @@ void JKVR_FrameSetup()
//get any cvar values required here
vr.immersive_cinematics = (vr_immersive_cinematics->value != 0.0f);
JKVR_processMessageQueue();
//Get controller state here
JKVR_getHMDOrientation();
JKVR_getTrackedRemotesOrientation();
JKVR_processHaptics();
}
int GetRefresh()
@ -2031,7 +2037,7 @@ void JKVR_finishEyeBuffer(int eye )
// Clear the alpha channel, other way OpenXR would not transfer the framebuffer fully
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE);
glClearColor(1.0, 0.0, 0.0, 1.0);
glClearColor(0.0, 0.0, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
@ -2206,6 +2212,7 @@ void JKVR_UpdateControllers( )
gAppState.TrackedController[i].Active = (loc.locationFlags & XR_SPACE_LOCATION_POSITION_VALID_BIT) != 0;
gAppState.TrackedController[i].Pose = loc.pose;
gAppState.TrackedController[i].Velocity = vel;
// apply velocity
// float dt = (in_vrEventTime - lastframetime) * 0.001f;
@ -2217,11 +2224,40 @@ void JKVR_UpdateControllers( )
}
}
//apply controller poses
// if (gAppState.TrackedController[0].Active)
// IN_VRController(qfalse, gAppState.TrackedController[0].Pose);
// if (gAppState.TrackedController[1].Active)
// IN_VRController(qtrue, gAppState.TrackedController[1].Pose);
leftRemoteTracking_new = gAppState.TrackedController[0];
rightRemoteTracking_new = gAppState.TrackedController[1];
memset(&leftTrackedRemoteState_new, 0, sizeof leftTrackedRemoteState_new);
memset(&rightTrackedRemoteState_new, 0, sizeof rightTrackedRemoteState_new);
//button mapping
if (GetActionStateBoolean(menuAction).currentState) leftTrackedRemoteState_new.Buttons |= xrButton_Enter;
if (GetActionStateBoolean(buttonXAction).currentState) leftTrackedRemoteState_new.Buttons |= xrButton_X;
if (GetActionStateBoolean(buttonYAction).currentState) leftTrackedRemoteState_new.Buttons |= xrButton_Y;
leftTrackedRemoteState_new.GripTrigger = GetActionStateFloat(gripLeftAction).currentState;
leftTrackedRemoteState_new.IndexTrigger = GetActionStateFloat(indexLeftAction).currentState;
if (GetActionStateBoolean(thumbstickLeftClickAction).currentState) leftTrackedRemoteState_new.Buttons |= xrButton_LThumb;
if (GetActionStateBoolean(buttonAAction).currentState) rightTrackedRemoteState_new.Buttons |= xrButton_A;
if (GetActionStateBoolean(buttonBAction).currentState) rightTrackedRemoteState_new.Buttons |= xrButton_B;
rightTrackedRemoteState_new.GripTrigger = GetActionStateFloat(gripRightAction).currentState;
rightTrackedRemoteState_new.IndexTrigger = GetActionStateFloat(indexRightAction).currentState;
if (GetActionStateBoolean(thumbstickRightClickAction).currentState) rightTrackedRemoteState_new.Buttons |= xrButton_RThumb;
//index finger click
if (GetActionStateBoolean(indexLeftAction).currentState) leftTrackedRemoteState_new.Buttons |= xrButton_Trigger;
if (GetActionStateBoolean(indexRightAction).currentState) rightTrackedRemoteState_new.Buttons |= xrButton_Trigger;
//thumbstick
XrActionStateVector2f moveJoystickState;
moveJoystickState = GetActionStateVector2(moveOnLeftJoystickAction);
leftTrackedRemoteState_new.Joystick.x = moveJoystickState.currentState.x;
leftTrackedRemoteState_new.Joystick.y = moveJoystickState.currentState.y;
moveJoystickState = GetActionStateVector2(moveOnRightJoystickAction);
rightTrackedRemoteState_new.Joystick.x = moveJoystickState.currentState.x;
rightTrackedRemoteState_new.Joystick.y = moveJoystickState.currentState.y;
}
void JKVR_getHMDOrientation() {//Get orientation

View file

@ -275,6 +275,11 @@ int GetRefresh();
//XrAction stuff
bool ActionPoseIsActive(XrAction action, XrPath subactionPath);
XrActionStateBoolean GetActionStateBoolean(XrAction action);
XrActionStateFloat GetActionStateFloat(XrAction action);
XrActionStateVector2f GetActionStateVector2(XrAction action);
void VR_Recenter();
//Called from engine code

View file

@ -213,6 +213,13 @@ void JKVR_InitActions( void )
handPoseLeftAction = CreateAction(runningActionSet, XR_ACTION_TYPE_POSE_INPUT, "hand_pose_left", NULL, 1, &leftHandPath);
handPoseRightAction = CreateAction(runningActionSet, XR_ACTION_TYPE_POSE_INPUT, "hand_pose_right", NULL, 1, &rightHandPath);
if (leftControllerAimSpace == XR_NULL_HANDLE) {
leftControllerAimSpace = CreateActionSpace(handPoseLeftAction, leftHandPath);
}
if (rightControllerAimSpace == XR_NULL_HANDLE) {
rightControllerAimSpace = CreateActionSpace(handPoseRightAction, rightHandPath);
}
XrPath interactionProfilePath = XR_NULL_PATH;
XrPath interactionProfilePathTouch = XR_NULL_PATH;
XrPath interactionProfilePathKHRSimple = XR_NULL_PATH;
@ -401,14 +408,14 @@ void JKVR_Vibrate( int duration, int chan, float intensity )
int channel = (i + 1) & chan;
if (channel)
{
if (vibration_channel_duration[channel-1] > 0.0f)
if (vibration_channel_duration[channel] > 0.0f)
return;
if (vibration_channel_duration[channel-1] == -1.0f && duration != 0.0f)
if (vibration_channel_duration[channel] == -1.0f && duration != 0.0f)
return;
vibration_channel_duration[channel-1] = duration;
vibration_channel_intensity[channel-1] = intensity * vr_haptic_intensity->value;
vibration_channel_duration[channel] = duration;
vibration_channel_intensity[channel] = intensity * vr_haptic_intensity->value;
}
}
}

View file

@ -832,15 +832,6 @@ void CL_Frame ( int msec,float fractionMsec ) {
SCR_DebugGraph ( cls.realFrametime * 0.25, 0 );
}
JKVR_FrameSetup();
JKVR_processMessageQueue();
//Get controller state here
JKVR_getHMDOrientation();
JKVR_getTrackedRemotesOrientation();
JKVR_processHaptics();
// see if we need to update any userinfo
CL_CheckUserinfo();
@ -1200,7 +1191,6 @@ void CL_InitRef( void ) {
rit.saved_game = &ojk::SavedGame::get_instance();
rit.JKVR_prepareEyeBuffer = JKVR_prepareEyeBuffer;
rit.JKVR_useScreenLayer = JKVR_useScreenLayer;
ret = GetRefAPI( REF_API_VERSION, &rit );

View file

@ -507,31 +507,30 @@ void SCR_UpdateScreen( void ) {
// that case.
if ( cls.uiStarted )
{
//Draw twice for Quest
SCR_DrawScreenField( STEREO_LEFT );
JKVR_FrameSetup();
//This won't perform the submit eye buffers
for (int eye = 0; eye < 2; ++eye)
{
if (com_speeds->integer) {
re.EndFrame(&time_frontend, &time_backend);
} else {
re.EndFrame(NULL, NULL);
JKVR_prepareEyeBuffer(eye);
//Draw twice for Quest
SCR_DrawScreenField(eye == 0 ? STEREO_LEFT : STEREO_RIGHT);
//This won't perform the submit eye buffers
{
if (com_speeds->integer)
{
re.EndFrame(&time_frontend, &time_backend);
}
else
{
re.EndFrame(NULL, NULL);
}
}
JKVR_finishEyeBuffer(eye);
}
JKVR_finishEyeBuffer(0);
SCR_DrawScreenField( STEREO_RIGHT );
//This will perform the submit eye buffers
if ( com_speeds->integer ) {
re.EndFrame( &time_frontend, &time_backend );
} else {
re.EndFrame( NULL, NULL );
}
JKVR_finishEyeBuffer(1);
//And we're done
re.SubmitStereoFrame();

View file

@ -128,7 +128,6 @@ typedef struct {
int (*com_frameTime) ( void );
//JKVR Functions
void (*JKVR_prepareEyeBuffer) (int eye );
bool (*JKVR_useScreenLayer) ( void );
} refimport_t;

View file

@ -1435,8 +1435,6 @@ const void *RB_DrawBuffer( const void *data ) {
qglDrawBuffer( cmd->buffer );
#endif
*/
ri.JKVR_prepareEyeBuffer(cmd->buffer);
// clear screen for debugging
if ( r_clear->integer ) {
qglClearColor( 0, 0, 0, 1 );