From 9456923b824fa4670cf3e13f6f2a2bf7c3984061 Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 23 Jul 2019 22:19:02 +0100 Subject: [PATCH] Tidying and small fixes --- .../jni/src/Lambda1VR/L1VR_SurfaceView.c | 60 ++++++------------- .../Android/jni/src/Lambda1VR/VrCompositor.c | 4 +- .../src/Xash3D/xash3d/engine/common/system.c | 6 +- .../drbeef/lambda1vr/GLES3JNIActivity.java | 2 +- 4 files changed, 25 insertions(+), 47 deletions(-) diff --git a/Projects/Android/jni/src/Lambda1VR/L1VR_SurfaceView.c b/Projects/Android/jni/src/Lambda1VR/L1VR_SurfaceView.c index c89c8c1..5f60f7c 100644 --- a/Projects/Android/jni/src/Lambda1VR/L1VR_SurfaceView.c +++ b/Projects/Android/jni/src/Lambda1VR/L1VR_SurfaceView.c @@ -159,35 +159,11 @@ extern int Host_Main( int argc, const char **argv, const char *progname, int bCh bool showingScoreboard = false; static bool useScreenLayer() { - return (cls.demoplayback || cls.state == ca_cinematic || cls.key_dest != key_game); -} - -//Timing stuff for joypad control -static long oldtime=0; -long delta=0; - -int curtime; -int Sys_Milliseconds (void) -{ - struct timeval tp; - struct timezone tzp; - static int secbase; - - gettimeofday(&tp, &tzp); - - if (!secbase) - { - secbase = tp.tv_sec; - return tp.tv_usec/1000; - } - - curtime = (tp.tv_sec - secbase)*1000 + tp.tv_usec/1000; - - return curtime; + return (showingScoreboard || cls.demoplayback || cls.state == ca_cinematic || cls.key_dest != key_game); } int runStatus = -1; -void QC_exit(int exitCode) +void L1VR_exit(int exitCode) { runStatus = exitCode; } @@ -1208,21 +1184,33 @@ static void ovrApp_HandleInput( ovrApp * app ) static bool dominantGripPushed = false; static float dominantGripPushTime = 0.0f; + //Show multiplayer scoreboard + if (((leftTrackedRemoteState_new.Buttons & ovrButton_Y) != + (leftTrackedRemoteState_old.Buttons & ovrButton_Y))) { + //Check we are in multiplayer + if (CL_GetMaxClients() > 1) { + showingScoreboard = (leftTrackedRemoteState_new.Buttons & ovrButton_Y); + sendButtonAction("+showscores", showingScoreboard); + } + } + + //Menu control - Uses "touch" if (useScreenLayer()) { const ovrQuatf quatRemote = dominantRemoteTracking->HeadPose.Pose.Orientation; float remoteAngles[3]; QuatToYawPitchRoll(quatRemote, remoteAngles); - if (remoteAngles[YAW] > -40.0f && remoteAngles[YAW] < 40.0f && + float yaw = remoteAngles[YAW] - playerYaw; + if (yaw > -40.0f && yaw < 40.0f && remoteAngles[PITCH] > -22.5f && remoteAngles[PITCH] < 22.5f) { - int newRemoteTrigState = (rightTrackedRemoteState_new.Buttons & ovrButton_Trigger) != 0; - int prevRemoteTrigState = (rightTrackedRemoteState_old.Buttons & ovrButton_Trigger) != 0; + int newRemoteTrigState = (dominantTrackedRemoteState->Buttons & ovrButton_Trigger) != 0; + int prevRemoteTrigState = (dominantTrackedRemoteStateOld->Buttons & ovrButton_Trigger) != 0; touchEventType t = event_motion; - float touchX = (-remoteAngles[YAW] + 40.0f) / 80.0f; + float touchX = (-yaw + 40.0f) / 80.0f; float touchY = (remoteAngles[PITCH] + 22.5f) / 45.0f; if (newRemoteTrigState != prevRemoteTrigState) { @@ -1493,16 +1481,6 @@ static void ovrApp_HandleInput( ovrApp * app ) } - //Show multiplayer scoreboard - if (((leftTrackedRemoteState_new.Buttons & ovrButton_Y) != - (leftTrackedRemoteState_old.Buttons & ovrButton_Y))) { - //Check we are in multiplayer - if (CL_GetMaxClients() > 1) { - showingScoreboard = (leftTrackedRemoteState_new.Buttons & ovrButton_Y); - sendButtonAction("+showscores", showingScoreboard); - } - } - //We need to record if we have started firing primary so that releasing trigger will stop definitely firing, if user has pushed grip //in meantime, then it wouldn't stop the gun firing and it would get stuck static bool firingPrimary = false; @@ -2107,7 +2085,7 @@ void * AppThreadFunction( void * parm ) // Add a simple cylindrical layer appState.Layers[appState.LayerCount++].Cylinder = BuildCylinderLayer( &appState.Scene.CylinderRenderer, - appState.Scene.CylinderWidth, appState.Scene.CylinderHeight, &tracking, playerYaw ); + appState.Scene.CylinderWidth, appState.Scene.CylinderHeight, &tracking, radians(playerYaw) ); //Call the game drawing code to populate the cylinder layer texture RenderFrame(&appState.Scene.CylinderRenderer, diff --git a/Projects/Android/jni/src/Lambda1VR/VrCompositor.c b/Projects/Android/jni/src/Lambda1VR/VrCompositor.c index 5077f59..9e03d4f 100644 --- a/Projects/Android/jni/src/Lambda1VR/VrCompositor.c +++ b/Projects/Android/jni/src/Lambda1VR/VrCompositor.c @@ -585,7 +585,7 @@ static ovrMatrix4f CylinderModelMatrix( const int texWidth, const int texHeight, ovrLayerCylinder2 BuildCylinderLayer( ovrRenderer * cylinderRenderer, const int textureWidth, const int textureHeight, - const ovrTracking2 * tracking, float rotateYaw ) + const ovrTracking2 * tracking, float rotatePitch ) { ovrLayerCylinder2 layer = vrapi_DefaultLayerCylinder2(); @@ -602,7 +602,7 @@ ovrLayerCylinder2 BuildCylinderLayer( ovrRenderer * cylinderRenderer, layer.HeadPose = tracking->HeadPose; const float density = 4500.0f; - const float rotatePitch = 0.0f; + const float rotateYaw = 0.0f; const float radius = 2.0f; const ovrVector3f translation = { 0.0f, 0.0f, -0.5f }; diff --git a/Projects/Android/jni/src/Xash3D/xash3d/engine/common/system.c b/Projects/Android/jni/src/Xash3D/xash3d/engine/common/system.c index e3ff0c6..a8adadc 100644 --- a/Projects/Android/jni/src/Xash3D/xash3d/engine/common/system.c +++ b/Projects/Android/jni/src/Xash3D/xash3d/engine/common/system.c @@ -774,13 +774,13 @@ void my_exit(int ret) Sys_Quit2 ================ */ +void L1VR_exit(int exitCode); + void Sys_Quit( void ) { MsgDev( D_INFO, "Shutting down...\n" ); Host_Shutdown(); - if( host.crashed ) - exit( 127 ); - exit( error_on_exit ); + L1VR_exit(0); } /* diff --git a/java/com/drbeef/lambda1vr/GLES3JNIActivity.java b/java/com/drbeef/lambda1vr/GLES3JNIActivity.java index a73b617..55d20ca 100644 --- a/java/com/drbeef/lambda1vr/GLES3JNIActivity.java +++ b/java/com/drbeef/lambda1vr/GLES3JNIActivity.java @@ -99,7 +99,7 @@ import static android.system.Os.setenv; //Read these from a file and pass through - commandLineParams = new String("-dev 3 -log"); + commandLineParams = new String("xash3d -dev 3 -log"); //See if user is trying to use command line params if(new File("/sdcard/xash/commandline.txt").exists()) // should exist!