Several significant changes

- Fixed bug where player would randomly move around
- Changed package name to com.drbeef.ioq3quest
- Changed location of files to /sdcard/ioquake3quest
- Added commandline.txt file
- Intermission screen now has headtracking (and in skirmish is a full VR experience)
- Fixed projectile location of railgun
- Made HUD model icons larger
This commit is contained in:
Simon 2022-02-04 20:42:34 +00:00
parent 2524be5017
commit 5066bb9431
15 changed files with 251 additions and 77 deletions

View File

@ -5,7 +5,7 @@ android {
buildToolsVersion "29.0.2"
ndkVersion "21.1.6352462"
defaultConfig {
applicationId = 'com.sparkie.ioq3quest'
applicationId = 'com.drbeef.ioq3quest'
minSdkVersion 25
targetSdkVersion 26
versionCode 1

View File

@ -1,12 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sparkie.ioq3quest"
package="com.drbeef.ioq3quest"
android:installLocation="preferExternal"
android:versionCode="1"
android:versionName="1.0">
<uses-feature android:name="android.hardware.vr.headtracking" android:version="1" android:required="true" />
<uses-feature android:glEsVersion="0x00030001" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:allowBackup="false"
@ -16,7 +21,7 @@
android:hasCode="true">
<meta-data android:name="com.samsung.android.vr.application.mode" android:value="vr_only"/>
<meta-data android:name="com.oculus.supportedDevices" android:value="quest|quest2"/>
<activity android:name="com.sparkie.ioq3quest.MainActivity"
<activity android:name="com.drbeef.ioq3quest.MainActivity"
android:label="@string/app_name"
android:screenOrientation="landscape"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"

View File

@ -31,7 +31,7 @@ static jobject g_ActivityObject = NULL;
extern "C"
{
JNIEXPORT void JNICALL Java_com_sparkie_ioq3quest_MainActivity_nativeCreate(JNIEnv* env, jclass cls, jobject thisObject)
JNIEXPORT void JNICALL Java_com_drbeef_ioq3quest_MainActivity_nativeCreate(JNIEnv* env, jclass cls, jobject thisObject)
{
g_ActivityObject = env->NewGlobalRef(thisObject);
}
@ -73,15 +73,9 @@ int main(int argc, char* argv[]) {
CON_LogcatFn(&ioq3_logfn);
std::string defaultArgs("+set fs_basepath ");
defaultArgs += SDL_AndroidGetExternalStoragePath();
// defaultArgs += " +set fs_game baseq3 +map q3dm6";
defaultArgs += " +set fs_game baseq3";
char *args = (char*)getenv("commandline");
char* args = new char[defaultArgs.length() + 1];
args[defaultArgs.length()] = '\0';
memcpy(args, defaultArgs.c_str(), defaultArgs.length());
Com_Init(args);
Com_Init(args);
VR_InitRenderer(engine);
@ -112,6 +106,5 @@ int main(int argc, char* argv[]) {
Com_Shutdown();
VR_Destroy(engine);
delete [] args;
return 0;
}

View File

@ -0,0 +1,162 @@
package com.drbeef.ioq3quest;
import android.Manifest;
import android.content.pm.PackageManager;
import android.content.res.AssetManager;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import org.libsdl.app.SDLActivity;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import static android.system.Os.setenv;
public class MainActivity extends SDLActivity
{
private int permissionCount = 0;
private static final int READ_EXTERNAL_STORAGE_PERMISSION_ID = 1;
private static final int WRITE_EXTERNAL_STORAGE_PERMISSION_ID = 2;
private static final String TAG = "ioquake3Quest";
String commandLineParams;
@Override
protected void onCreate(Bundle savedInstanceState) {
Log.i(TAG,"onCreate called");
checkPermissionsAndInitialize();
super.onCreate(savedInstanceState);
}
/** Initializes the Activity only if the permission has been granted. */
private void checkPermissionsAndInitialize() {
// Boilerplate for checking runtime permissions in Android.
if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED){
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE},
WRITE_EXTERNAL_STORAGE_PERMISSION_ID);
}
else
{
// Permissions have already been granted.
create();
}
}
/** Handles the user accepting the permission. */
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] results) {
if (requestCode == WRITE_EXTERNAL_STORAGE_PERMISSION_ID) {
finish();
System.exit(0);
}
}
public void create() {
Log.d(TAG, "making dirs");
//Make the directories
new File("/sdcard/ioquake3Quest/").mkdirs();
Log.d(TAG, "copying commandline.txt");
//Copy the command line params file
copy_asset("/sdcard/ioquake3Quest", "commandline.txt", false);
//Read these from a file and pass through
commandLineParams = new String();
Log.d(TAG, "reading commandline.txt");
//See if user is trying to use command line params
if (new File("/sdcard/ioquake3Quest/commandline.txt").exists())
{
BufferedReader br;
try {
br = new BufferedReader(new FileReader("/sdcard/ioquake3Quest/commandline.txt"));
String s;
StringBuilder sb = new StringBuilder(0);
while ((s = br.readLine()) != null)
sb.append(s + " ");
br.close();
commandLineParams = new String(sb.toString());
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Log.d(TAG, "setting env");
try {
setenv("commandline", commandLineParams, true);
}
catch (Exception e)
{
}
Log.d(TAG, "nativeCreate");
nativeCreate(this);
}
public void copy_asset(String path, String name, boolean force) {
File f = new File(path + "/" + name);
if (!f.exists() || force) {
//Ensure we have an appropriate folder
String fullname = path + "/" + name;
String directory = fullname.substring(0, fullname.lastIndexOf("/"));
new File(directory).mkdirs();
_copy_asset(name, path + "/" + name);
}
}
public void _copy_asset(String name_in, String name_out) {
AssetManager assets = this.getAssets();
try {
InputStream in = assets.open(name_in);
OutputStream out = new FileOutputStream(name_out);
copy_stream(in, out);
out.close();
in.close();
} catch (Exception e) {
e.printStackTrace();
}
}
public static void copy_stream(InputStream in, OutputStream out)
throws IOException {
byte[] buf = new byte[1024];
while (true) {
int count = in.read(buf);
if (count <= 0)
break;
out.write(buf, 0, count);
}
}
public static native void nativeCreate(MainActivity thisObject);
static {
System.loadLibrary("main");
}
}

View File

@ -1,19 +0,0 @@
package com.sparkie.ioq3quest;
import android.os.Bundle;
import org.libsdl.app.SDLActivity;
public class MainActivity extends SDLActivity
{
@Override
protected void onCreate(Bundle savedInstanceState) {
nativeCreate(this);
super.onCreate(savedInstanceState);
}
public static native void nativeCreate(MainActivity thisObject);
static {
System.loadLibrary("main");
}
}

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">NativeActivity</string>
<string name="app_name">ioquake3Quest</string>
</resources>

View File

@ -2,13 +2,28 @@
setlocal
set BUILD_TYPE=debug
set KEYSTORE=
set KEYSTORE_PASS=
set VERSION=0.6.0
set ANDROID_SDK_ROOT=%AppData%\..\Local\Android\Sdk
set adb="%ANDROID_SDK_ROOT%\platform-tools\adb.exe"
set make="%ANDROID_SDK_ROOT%\ndk\21.1.6352462\prebuilt\windows-x86_64\bin\make.exe"
set apksigner="%ANDROID_SDK_ROOT%\build-tools\29.0.2\apksigner.bat"
set JAVA_HOME=C:\Program Files\Android\Android Studio\jre\jre
set BUILD_TYPE=release
set GRADLE_BUILD_TYPE=:app:assembleRelease
if "%1"=="clean" (
rm -rf .\build
rm -rf .\android\build
)
if %BUILD_TYPE%==release (
set GRADLE_BUILD_TYPE=:app:assembleRelease
)
if %BUILD_TYPE%==debug (
set GRADLE_BUILD_TYPE=:app:assembleDebug
)
pushd %~dp0\..
%make% -j %NUMBER_OF_PROCESSORS% %BUILD_TYPE%
@ -31,11 +46,19 @@ if %ERRORLEVEL% NEQ 0 (
exit /b 1
)
set PACKAGE_NAME=com.sparkie.ioq3quest
set ANDROID_STORAGE_LOCATION=/sdcard/Android/data/%PACKAGE_NAME%/files/
set APK_LOCATION=.\app\build\outputs\apk\%BUILD_TYPE%\app-%BUILD_TYPE%.apk
set PACKAGE_NAME=com.drbeef.ioq3quest
set ANDROID_STORAGE_LOCATION=/sdcard/ioquake3quest/
set APK_LOCATION=.\app\build\outputs\apk\%BUILD_TYPE%\ioq3quest-%BUILD_TYPE%-%VERSION%.apk
REM %apksigner% sign --ks ../drbeef-release-key.keystore --out %APK_LOCATION% .\app\build\outputs\apk\%BUILD_TYPE%\app-%BUILD_TYPE%-unsigned.apk
if %BUILD_TYPE%==release (
echo "Signing Release APK"
call %apksigner% sign --ks ../%KEYSTORE% --out %APK_LOCATION% --v2-signing-enabled true --ks-pass pass:%KEYSTORE_PASS% .\app\build\outputs\apk\%BUILD_TYPE%\app-%BUILD_TYPE%-unsigned.apk
)
if %BUILD_TYPE%==debug (
echo "Copying Debug APK"
copy .\app\build\outputs\apk\%BUILD_TYPE%\app-%BUILD_TYPE%.apk %APK_LOCATION%
)
%adb% install -r %APK_LOCATION%
if %ERRORLEVEL% NEQ 0 (

View File

@ -47,8 +47,7 @@ Adjusted for resolution and screen aspect ratio
*/
void CG_AdjustFrom640( float *x, float *y, float *w, float *h ) {
if (hudflags & HUD_FLAGS_FULLSCREEN ||
cgVR->virtual_screen)
if (cgVR->virtual_screen)
{
// scale for screen sizes
*x *= cgs.screenXScale;
@ -70,10 +69,10 @@ void CG_AdjustFrom640( float *x, float *y, float *w, float *h ) {
*y *= screenYScale;
if (hudflags & HUD_FLAGS_DRAWMODEL)
{
*w *= cgs.screenXScale;
*x -= (*w / 4);
*h *= cgs.screenYScale;
*y -= (*h / 4);
*w *= (cgs.screenXScale * 2.0f);
*x -= (*w / 3);
*h *= (cgs.screenYScale * 2.0f);
*y -= (*h / 3);
}
else
{

View File

@ -96,8 +96,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#define DEFAULT_REDTEAM_NAME "Stroggs"
#define DEFAULT_BLUETEAM_NAME "Pagans"
//VR HUD
#define HUD_FLAGS_FULLSCREEN 1
#define HUD_FLAGS_DRAWMODEL 2
#define HUD_FLAGS_DRAWMODEL 1
typedef enum {
FOOTSTEP_NORMAL,

View File

@ -341,9 +341,9 @@ static void CG_OffsetFirstPersonView( void ) {
vec3_t predictedVelocity;
int timeDelta;
// if ( cg.snap->ps.pm_type == PM_INTERMISSION ) {
// return;
// }
if ( cg.snap->ps.pm_type == PM_INTERMISSION ) {
return;
}
origin = cg.refdef.vieworg;
angles = cg.refdefViewAngles;
@ -646,15 +646,19 @@ static int CG_CalcViewValues( void ) {
cg.cameraMode = qfalse;
}
}
*/
// intermission view
static float hmdYaw = 0;
if ( ps->pm_type == PM_INTERMISSION ) {
VectorCopy( ps->origin, cg.refdef.vieworg );
VectorCopy( ps->viewangles, cg.refdefViewAngles );
AnglesToAxis( cg.refdefViewAngles, cg.refdef.viewaxis );
VectorCopy(cgVR->hmdorientation, cg.refdefViewAngles);
cg.refdefViewAngles[YAW] += (ps->viewangles[YAW] - hmdYaw);
AnglesToAxis( cg.refdefViewAngles, cg.refdef.viewaxis );
return CG_CalcFov();
}
*/
hmdYaw = cgVR->hmdorientation[YAW];
cg.bobcycle = ( ps->bobCycle & 128 ) >> 7;
cg.bobfracsin = fabs( sin( ( ps->bobCycle & 127 ) / 127.0 * M_PI ) );
cg.xyspeed = sqrt( ps->velocity[0] * ps->velocity[0] +

View File

@ -534,8 +534,8 @@ void CG_RailTrail (clientInfo_t *ci, vec3_t start, vec3_t end) {
if (cg_oldRail.integer)
{
// nudge down a bit so it isn't exactly in center
re->origin[2] -= 8;
re->oldorigin[2] -= 8;
//re->origin[2] -= 8;
//re->oldorigin[2] -= 8;
return;
}

View File

@ -1797,11 +1797,11 @@ void PM_UpdateViewAngles( playerState_t *ps, const usercmd_t *cmd ) {
short temp;
int i;
/*
if ( ps->pm_type == PM_INTERMISSION || ps->pm_type == PM_SPINTERMISSION) {
return; // no view changes at all
}
*/
/* We want to allow user to look around if they are dead
if ( ps->pm_type != PM_SPECTATOR && ps->stats[STAT_HEALTH] <= 0 ) {
return; // no view changes at all

View File

@ -48,7 +48,7 @@ void VR_InitCvars( void )
Cvar_Get ("vr_weapon_adjustment_4", "0.75,-4.0,6.5,-4,0,0,0", CVAR_ARCHIVE);
Cvar_Get ("vr_weapon_adjustment_5", "0.8,-3.8,6,7.5,0,0,0", CVAR_ARCHIVE);
Cvar_Get ("vr_weapon_adjustment_6", "0.8,-3.3,6,7,0,0,0", CVAR_ARCHIVE);
Cvar_Get ("vr_weapon_adjustment_7", "0.8,-3.3,6,0,0,0,0", CVAR_ARCHIVE);
Cvar_Get ("vr_weapon_adjustment_7", "0.8,-3.0,6,0,0,0,0", CVAR_ARCHIVE);
Cvar_Get ("vr_weapon_adjustment_8", "0.8,-3.5,6,1.5,0,0,0", CVAR_ARCHIVE);
Cvar_Get ("vr_weapon_adjustment_9", "0.8,-5.5,6,0,0,0,0", CVAR_ARCHIVE);
@ -72,6 +72,8 @@ void VR_EnterVR( engine_t* engine, ovrJava java ) {
engine->frameIndex = 0;
vrapi_SetTrackingSpace(engine->ovr, VRAPI_TRACKING_SPACE_LOCAL_FLOOR);
vrapi_SetClockLevels(engine->ovr, 4, 4);
}
}
@ -88,9 +90,14 @@ engine_t* VR_GetEngine( void ) {
bool VR_useScreenLayer( void )
{
int keyCatcher = Key_GetCatcher( );
//intermission is never full screen
/* if ( cl.snap.ps.pm_type == PM_INTERMISSION )
{
return qfalse;
}
*/
int keyCatcher = Key_GetCatcher( );
return (bool)( clc.state != CA_ACTIVE ||
//( cl.snap.ps.stats[STAT_HEALTH] <= 0 ) ||
( keyCatcher & (KEYCATCH_UI | KEYCATCH_CONSOLE) ));
}
//#endif

View File

@ -38,6 +38,7 @@ static qboolean controllerInit = qfalse;
static vrController_t leftController;
static vrController_t rightController;
static int in_vrEventTime = 0;
static double lastframetime = 0;
static float pressedThreshold = 0.75f;
static float releasedThreshold = 0.5f;
@ -252,18 +253,6 @@ static void IN_VRJoystick( qboolean isRightController, float joystickX, float jo
{
vrController_t* controller = isRightController == qtrue ? &rightController : &leftController;
//Positional movement speed correction for when we are not hitting target framerate
static double lastframetime = 0;
int refresh = vrapi_GetSystemPropertyInt(&(VR_GetEngine()->java), VRAPI_SYS_PROP_DISPLAY_REFRESH_RATE);
double newframetime = Sys_Milliseconds();
float multiplier = (float)((1000.0 / refresh) / (newframetime - lastframetime));
lastframetime = newframetime;
vec2_t positional;
float factor = (refresh / 72.0F) * 10.0f; // adjust positional factor based on refresh rate
rotateAboutOrigin(-vr.hmdposition_delta[0] * factor * multiplier,
vr.hmdposition_delta[2] * factor * multiplier, - vr.hmdorientation[YAW], positional);
if (vr.virtual_screen)
{
const float x = joystickX * 5.0;
@ -273,6 +262,15 @@ static void IN_VRJoystick( qboolean isRightController, float joystickX, float jo
} else
{
if (isRightController == qfalse) {
//Positional movement speed correction for when we are not hitting target framerate
int refresh = vrapi_GetSystemPropertyInt(&(VR_GetEngine()->java), VRAPI_SYS_PROP_DISPLAY_REFRESH_RATE);
float multiplier = (float)((1000.0 / refresh) / (in_vrEventTime - lastframetime));
vec2_t positional;
float factor = (refresh / 72.0F) * 10.0f; // adjust positional factor based on refresh rate
rotateAboutOrigin(-vr.hmdposition_delta[0] * factor * multiplier,
vr.hmdposition_delta[2] * factor * multiplier, - vr.hmdorientation[YAW], positional);
//sideways
Com_QueueEvent(in_vrEventTime, SE_JOYSTICK_AXIS, 0, joystickX * 127.0f + positional[0] * 127.0f, 0, NULL);
@ -374,7 +372,9 @@ static void IN_VRButtonsChanged( qboolean isRightController, uint32_t buttons )
}
if ((buttons & ovrButton_X) && !(controller->buttons & ovrButton_X)) {
//sendButtonActionSimple("give all");
#ifdef DEBUG
sendButtonActionSimple("fraglimit 1");
#endif
Com_QueueEvent(in_vrEventTime, SE_KEY, K_PAD0_X, qtrue, 0, NULL);
} else if (!(buttons & ovrButton_X) && (controller->buttons & ovrButton_X)) {
Com_QueueEvent(in_vrEventTime, SE_KEY, K_PAD0_X, qfalse, 0, NULL);
@ -494,6 +494,7 @@ void IN_VRInputFrame( void )
IN_VRTriggers(isRight, state.IndexTrigger);
}
lastframetime = in_vrEventTime;
in_vrEventTime = Sys_Milliseconds( );
}

View File

@ -259,11 +259,11 @@ void VR_DrawFrame( engine_t* engine ) {
const framebuffer_t* framebuffers = engine->framebuffers;
//Now using a symmetrical render target, based on the horizontal FOV
float fov = vrapi_GetSystemPropertyInt( engine->ovr, VRAPI_SYS_PROP_SUGGESTED_EYE_FOV_DEGREES_Y);
//float fov = vrapi_GetSystemPropertyInt( engine->ovr, VRAPI_SYS_PROP_SUGGESTED_EYE_FOV_DEGREES_Y);
// Setup the projection matrix.
const ovrMatrix4f projectionMatrix = ovrMatrix4f_CreateProjectionFov(
fov, fov, 0.0f, 0.0f, 1.0f, 0.0f );
90, 90, 0.0f, 0.0f, 1.0f, 0.0f );
re.SetVRHeadsetParms(&projectionMatrix, &projectionMatrix,
framebuffers[0].framebuffers[framebuffers[0].swapchainIndex],