Final Few Things

Offhand Controls Mostly Fixed
Switch Sticks Added
Forward Movement Added
Performance Hints
This commit is contained in:
Grant Bagwell 2021-01-06 18:22:29 +01:00
parent 42e3158ab3
commit 121b8b7dd9
7 changed files with 47 additions and 39 deletions

View file

@ -50,7 +50,6 @@ float playerYaw;
float vrFOV = 0.0f;
bool vr_moveuseoffhand;
float vr_snapturn_angle;
bool vr_switchsticks;
bool vr_secondarybuttonmappings;
bool vr_twohandedweapons;
bool shutdown;
@ -1631,7 +1630,7 @@ void * AppThreadFunction(void * parm ) {
}
//All the stuff we want to do each frame
void Doom3Quest_FrameSetup(int controlscheme, int refresh)
void Doom3Quest_FrameSetup(int controlscheme, int switch_sticks, int refresh)
{
ALOGV("Refresh = %i", refresh);
@ -1657,7 +1656,7 @@ void Doom3Quest_FrameSetup(int controlscheme, int refresh)
Doom3Quest_processHaptics();
Doom3Quest_getHMDOrientation();
Doom3Quest_getTrackedRemotesOrientation(controlscheme);
Doom3Quest_getTrackedRemotesOrientation(controlscheme, switch_sticks);
}
/*void Doom3Quest_processHaptics() {//Handle haptics
@ -1767,21 +1766,21 @@ void Doom3Quest_getHMDOrientation() {
updateHMDOrientation();
}
void Doom3Quest_getTrackedRemotesOrientation(int controlscheme) {
void Doom3Quest_getTrackedRemotesOrientation(int controlscheme, int switch_sticks) {
//Get info for tracked remotes
acquireTrackedRemotesData(gAppState.Ovr, gAppState.DisplayTime[gAppState.MainThreadFrameIndex % MAX_TRACKING_SAMPLES]);
//Call additional control schemes here
if (controlscheme == RIGHT_HANDED_DEFAULT) {
HandleInput_Default(controlscheme, &rightTrackedRemoteState_new,
HandleInput_Default(controlscheme, switch_sticks, &rightTrackedRemoteState_new,
&rightTrackedRemoteState_old, &rightRemoteTracking_new,
&leftTrackedRemoteState_new, &leftTrackedRemoteState_old,
&leftRemoteTracking_new,
ovrButton_A, ovrButton_B, ovrButton_X, ovrButton_Y);
} else {
//Left handed
HandleInput_Default(controlscheme, &leftTrackedRemoteState_new, &leftTrackedRemoteState_old,
HandleInput_Default(controlscheme, switch_sticks, &leftTrackedRemoteState_new, &leftTrackedRemoteState_old,
&leftRemoteTracking_new,
&rightTrackedRemoteState_new, &rightTrackedRemoteState_old,
&rightRemoteTracking_new,

View file

@ -76,7 +76,7 @@ void Doom3Quest_Vibrate(int channel, float low, float high);
bool Doom3Quest_processMessageQueue();
void Doom3Quest_FrameSetup(int controlscheme, int refresh);
void Doom3Quest_FrameSetup(int controlscheme, int switch_sticks, int refresh);
void Doom3Quest_setUseScreenLayer(int screen);
@ -84,7 +84,7 @@ void Doom3Quest_processHaptics();
void Doom3Quest_getHMDOrientation();
void Doom3Quest_getTrackedRemotesOrientation(int controlscheme);
void Doom3Quest_getTrackedRemotesOrientation(int controlscheme, int switch_sticks);
void Doom3Quest_prepareEyeBuffer();

View file

@ -33,7 +33,7 @@ void sendButtonActionSimple(const char* action);
void acquireTrackedRemotesData(ovrMobile *Ovr, double displayTime);
void HandleInput_Default( int controlscheme, ovrInputStateTrackedRemote *pDominantTrackedRemoteNew, ovrInputStateTrackedRemote *pDominantTrackedRemoteOld, ovrTracking* pDominantTracking,
void HandleInput_Default( int controlscheme, int switchsticks, ovrInputStateTrackedRemote *pDominantTrackedRemoteNew, ovrInputStateTrackedRemote *pDominantTrackedRemoteOld, ovrTracking* pDominantTracking,
ovrInputStateTrackedRemote *pOffTrackedRemoteNew, ovrInputStateTrackedRemote *pOffTrackedRemoteOld, ovrTracking* pOffTracking,
int domButton1, int domButton2, int offButton1, int offButton2 );

View file

@ -61,15 +61,11 @@ extern bool objectiveSystemActive;
extern bool inCinematic;
void HandleInput_Default( int controlscheme, ovrInputStateTrackedRemote *pDominantTrackedRemoteNew, ovrInputStateTrackedRemote *pDominantTrackedRemoteOld, ovrTracking* pDominantTracking,
void HandleInput_Default( int controlscheme, int switchsticks, ovrInputStateTrackedRemote *pDominantTrackedRemoteNew, ovrInputStateTrackedRemote *pDominantTrackedRemoteOld, ovrTracking* pDominantTracking,
ovrInputStateTrackedRemote *pOffTrackedRemoteNew, ovrInputStateTrackedRemote *pOffTrackedRemoteOld, ovrTracking* pOffTracking,
int domButton1, int domButton2, int offButton1, int offButton2 )
{
//Ensure handedness is set correctly
pVRClientInfo->right_handed = controlscheme < 10 ||
controlscheme == 99; // Always right-handed for weapon calibration
//pVRClientInfo->teleportenabled = vr_teleport != 0;
static bool dominantGripPushed = false;
@ -80,7 +76,6 @@ void HandleInput_Default( int controlscheme, ovrInputStateTrackedRemote *pDomina
ovrTracking * pWeapon = pDominantTracking;
ovrTracking * pOff = pOffTracking;
//All this to allow stick and button switching!
ovrVector2f *pPrimaryJoystick;
ovrVector2f *pSecondaryJoystick;
@ -92,26 +87,29 @@ void HandleInput_Default( int controlscheme, ovrInputStateTrackedRemote *pDomina
int primaryButton2;
int secondaryButton1;
int secondaryButton2;
if (vr_switch_sticks)
if(controlscheme == 1) //Left Handed
{
//
// This will switch the joystick and A/B/X/Y button functions only
// Move, Strafe, Turn, Jump, Crouch, Notepad, HUD mode, Weapon Switch
pSecondaryJoystick = &pDominantTrackedRemoteNew->Joystick;
pPrimaryJoystick = &pOffTrackedRemoteNew->Joystick;
secondaryButtonsNew = pDominantTrackedRemoteNew->Buttons;
secondaryButtonsOld = pDominantTrackedRemoteOld->Buttons;
primaryButtonsNew = pOffTrackedRemoteNew->Buttons;
primaryButtonsOld = pOffTrackedRemoteOld->Buttons;
primaryButton1 = offButton1;
primaryButton2 = offButton2;
secondaryButton1 = domButton1;
secondaryButton2 = domButton2;
}
else
primaryButton1 = offButton1;
primaryButton2 = offButton2;
if (switchsticks == 1) //Switch
{
pPrimaryJoystick = &pDominantTrackedRemoteNew->Joystick;
pSecondaryJoystick = &pOffTrackedRemoteNew->Joystick;
} else {
pSecondaryJoystick = &pDominantTrackedRemoteNew->Joystick;
pPrimaryJoystick = &pOffTrackedRemoteNew->Joystick;
}
} else //Right Handed
{
pPrimaryJoystick = &pDominantTrackedRemoteNew->Joystick;
pSecondaryJoystick = &pOffTrackedRemoteNew->Joystick;
primaryButtonsNew = pDominantTrackedRemoteNew->Buttons;
primaryButtonsOld = pDominantTrackedRemoteOld->Buttons;
secondaryButtonsNew = pOffTrackedRemoteNew->Buttons;
@ -120,10 +118,21 @@ void HandleInput_Default( int controlscheme, ovrInputStateTrackedRemote *pDomina
primaryButton2 = domButton2;
secondaryButton1 = offButton1;
secondaryButton2 = offButton2;
if (switchsticks == 1) //Switch
{
pSecondaryJoystick = &pDominantTrackedRemoteNew->Joystick;
pPrimaryJoystick = &pOffTrackedRemoteNew->Joystick;
} else {
pPrimaryJoystick = &pDominantTrackedRemoteNew->Joystick;
pSecondaryJoystick = &pOffTrackedRemoteNew->Joystick;
}
}
{
//Store original values
const ovrQuatf quatRHand = pWeapon->HeadPose.Pose.Orientation;
@ -131,24 +140,24 @@ void HandleInput_Default( int controlscheme, ovrInputStateTrackedRemote *pDomina
const ovrQuatf quatLHand = pOff->HeadPose.Pose.Orientation;
const ovrVector3f positionLHand = pOff->HeadPose.Pose.Position;
VectorSet(pVRClientInfo->rhandposition, positionRHand.x, positionRHand.y, positionRHand.z);
/*VectorSet(pVRClientInfo->rhandposition, positionRHand.x, positionRHand.y, positionRHand.z);
Vector4Set(pVRClientInfo->rhand_orientation_quat, quatRHand.x, quatRHand.y, quatRHand.z, quatRHand.w);
VectorSet(pVRClientInfo->lhandposition, positionLHand.x, positionLHand.y, positionLHand.z);
Vector4Set(pVRClientInfo->lhand_orientation_quat, quatLHand.x, quatLHand.y, quatLHand.z, quatLHand.w);
Vector4Set(pVRClientInfo->lhand_orientation_quat, quatLHand.x, quatLHand.y, quatLHand.z, quatLHand.w);*/
//Right Hand
//GB - FP Already does this so we end up with backward hands
/*if(pVRClientInfo->right_handed) {
VectorSet(pVRClientInfo->rhandposition, positionRHand.x, positionRHand.y, positionRHand.z);
Vector4Set(pVRClientInfo->rhand_orientation_quat, quatRHand.x, quatRHand.y, quatRHand.z, quatRHand.w);
VectorSet(pVRClientInfo->lhandposition, positionLHand.x, positionLHand.y, positionLHand.z);
Vector4Set(pVRClientInfo->lhand_orientation_quat, quatLHand.x, quatLHand.y, quatLHand.z, quatLHand.w);
} else {
if(controlscheme == 1) {//Left Handed
VectorSet(pVRClientInfo->lhandposition, positionRHand.x, positionRHand.y, positionRHand.z);
Vector4Set(pVRClientInfo->lhand_orientation_quat, quatRHand.x, quatRHand.y, quatRHand.z, quatRHand.w);
VectorSet(pVRClientInfo->rhandposition, positionLHand.x, positionLHand.y, positionLHand.z);
Vector4Set(pVRClientInfo->rhand_orientation_quat, quatLHand.x, quatLHand.y, quatLHand.z, quatLHand.w);
}*/
} else {
VectorSet(pVRClientInfo->rhandposition, positionRHand.x, positionRHand.y, positionRHand.z);
Vector4Set(pVRClientInfo->rhand_orientation_quat, quatRHand.x, quatRHand.y, quatRHand.z, quatRHand.w);
VectorSet(pVRClientInfo->lhandposition, positionLHand.x, positionLHand.y, positionLHand.z);
Vector4Set(pVRClientInfo->lhand_orientation_quat, quatLHand.x, quatLHand.y, quatLHand.z, quatLHand.w);
}
//Set gun angles - We need to calculate all those we might need (including adjustments) for the client to then take its pick
@ -419,8 +428,6 @@ void HandleInput_Default( int controlscheme, ovrInputStateTrackedRemote *pDomina
{
handleTrackedControllerButton_AsButton(pDominantTrackedRemoteNew, pDominantTrackedRemoteOld, false, primaryButton2, UB_UP);
}
//Fire Primary
if ((pDominantTrackedRemoteNew->Buttons & ovrButton_Trigger) !=
(pDominantTrackedRemoteOld->Buttons & ovrButton_Trigger)) {

View file

@ -2268,7 +2268,7 @@ void idCommonLocal::InitSIMD( void ) {
}
extern "C" void Doom3Quest_FrameSetup(int controlscheme, int refresh);
extern "C" void Doom3Quest_FrameSetup(int controlscheme, int switch_sticks, int refresh);
extern "C" void Doom3Quest_Vibrate(int channel, float low, float high );
void idCommonLocal::Vibrate(int channel, float low, float high)
@ -2290,6 +2290,7 @@ void idCommonLocal::Frame( void ) {
Sys_GenerateEvents();
Doom3Quest_FrameSetup(cvarSystem->GetCVarInteger("vr_weaponHand"),
cvarSystem->GetCVarInteger("vr_switchSticks"),
cvarSystem->GetCVarInteger("vr_refresh"));
if (game) {

View file

@ -346,6 +346,7 @@ idCVar net_serverDlTable( "net_serverDlTable", "", CVAR_GAME | CVAR_ARCHIV
//In Menu - needs testing
idCVar vr_weaponHand( "vr_weaponHand", "0", CVAR_INTEGER | CVAR_ARCHIVE | CVAR_GAME, "Which hand holds weapon.\n 0 = Right hand\n 1 = Left Hand\n", 0, 1 );
idCVar vr_switchSticks( "vr_switchSticks", "0", CVAR_INTEGER | CVAR_ARCHIVE | CVAR_GAME, "Switch joysticks.\n 0 = No\n 1 = Yes\n", 0, 1 );
idCVar vr_ipd( "vr_ipd", "0.065", CVAR_GAME | CVAR_FLOAT | CVAR_ARCHIVE, "VR IPD" );
idCVar vr_worldscale( "vr_worldscale", "43.0", CVAR_GAME | CVAR_FLOAT | CVAR_ARCHIVE, "VR World Scale" );
idCVar vr_heightoffset( "vr_heightoffset", "0.0", CVAR_GAME | CVAR_FLOAT | CVAR_ARCHIVE, "VR Height Offset" );

Binary file not shown.