Lots of progress

This commit is contained in:
Simon 2020-03-07 00:31:49 +00:00
parent 092bf5ce29
commit 6a1b0a43aa
16 changed files with 123 additions and 217 deletions

View file

@ -1314,9 +1314,6 @@ void VR_Init()
*/
}
/* Called before SDL_main() to initialize JNI bindings in SDL library */
extern void SDL_Android_Init(JNIEnv* env, jclass cls);
static ovrAppThread * gAppThread = NULL;
static ovrApp gAppState;
static ovrJava java;
@ -1435,11 +1432,6 @@ void * AppThreadFunction(void * parm ) {
jclass cls = (*java.Env)->GetObjectClass(java.Env, java.ActivityObject);
/* This interface could expand with ABI negotiation, callbacks, etc. */
// SDL_Android_Init(java.Env, cls);
// SDL_SetMainReady();
// Note that AttachCurrentThread will reset the thread name.
prctl(PR_SET_NAME, (long) "OVR::Main", 0, 0, 0);
@ -1724,8 +1716,6 @@ Activity lifecycle
================================================================================
*/
//JNIEXPORT jint JNICALL SDL_JNI_OnLoad(JavaVM* vm, void* reserved);
int JNI_OnLoad(JavaVM* vm, void* reserved)
{
JNIEnv *env;

View file

@ -555,8 +555,8 @@ ovrLayerCylinder2 BuildCylinderLayer( ovrRenderer * cylinderRenderer,
const float density = 4500.0f;
const float rotateYaw = 0.0f;
const float radius = 2.0f;
const ovrVector3f translation = { 0.0f, playerHeight, -0.5f };
const float radius = 4.0f;
const ovrVector3f translation = { 0.0f, playerHeight, -2.5f };
ovrMatrix4f cylinderTransform =
CylinderModelMatrix( textureWidth, textureHeight, translation,

View file

@ -19,10 +19,7 @@ void Joy_GenerateButtonEvents(int oldbuttons, int newbuttons, int numbuttons, in
void handleTrackedControllerButton(ovrInputStateTrackedRemote * trackedRemoteState, ovrInputStateTrackedRemote * prevTrackedRemoteState, uint32_t button, int key)
{
if ((trackedRemoteState->Buttons & button) != (prevTrackedRemoteState->Buttons & button))
{
//Joy_GenerateButtonEvents();
}
Joy_GenerateButtonEvents(prevTrackedRemoteState->Buttons & button ? 1 : 0, trackedRemoteState->Buttons & button ? 1 : 0, 1, key);
}

View file

@ -17,6 +17,11 @@ Authors : Simon Brown
#include "doomkeys.h"
int getGameState();
int isMenuActive();
void Joy_GenerateButtonEvents(int oldbuttons, int newbuttons, int numbuttons, int base);
void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew, ovrInputStateTrackedRemote *pDominantTrackedRemoteOld, ovrTracking* pDominantTracking,
ovrInputStateTrackedRemote *pOffTrackedRemoteNew, ovrInputStateTrackedRemote *pOffTrackedRemoteOld, ovrTracking* pOffTracking,
int domButton1, int domButton2, int offButton1, int offButton2 )
@ -24,8 +29,6 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
{
static bool dominantGripPushed = false;
static float dominantGripPushTime = 0.0f;
static bool inventoryManagementMode = false;
//Show screen view (if in multiplayer toggle scoreboard)
if (((pOffTrackedRemoteNew->Buttons & offButton2) !=
@ -38,31 +41,29 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
//Menu button
handleTrackedControllerButton(&leftTrackedRemoteState_new, &leftTrackedRemoteState_old, ovrButton_Enter, KEY_ESCAPE);
/* if (cls.key_dest == key_menu)
if (getGameState() != 0 || isMenuActive()) //gamestate != GS_LEVEL
{
int leftJoyState = (pOffTrackedRemoteNew->Joystick.x > 0.7f ? 1 : 0);
if (leftJoyState != (pOffTrackedRemoteOld->Joystick.x > 0.7f ? 1 : 0)) {
Key_Event(K_RIGHTARROW, leftJoyState, global_time);
}
leftJoyState = (pOffTrackedRemoteNew->Joystick.x < -0.7f ? 1 : 0);
if (leftJoyState != (pOffTrackedRemoteOld->Joystick.x < -0.7f ? 1 : 0)) {
Key_Event(K_LEFTARROW, leftJoyState, global_time);
}
leftJoyState = (pOffTrackedRemoteNew->Joystick.y < -0.7f ? 1 : 0);
if (leftJoyState != (pOffTrackedRemoteOld->Joystick.y < -0.7f ? 1 : 0)) {
Key_Event(K_DOWNARROW, leftJoyState, global_time);
}
leftJoyState = (pOffTrackedRemoteNew->Joystick.y > 0.7f ? 1 : 0);
if (leftJoyState != (pOffTrackedRemoteOld->Joystick.y > 0.7f ? 1 : 0)) {
Key_Event(K_UPARROW, leftJoyState, global_time);
Joy_GenerateButtonEvents((pOffTrackedRemoteOld->Joystick.x > 0.7f ? 1 : 0), (pOffTrackedRemoteNew->Joystick.x > 0.7f ? 1 : 0), 1, KEY_PAD_DPAD_RIGHT);
Joy_GenerateButtonEvents((pOffTrackedRemoteOld->Joystick.x < -0.7f ? 1 : 0), (pOffTrackedRemoteNew->Joystick.x < -0.7f ? 1 : 0), 1, KEY_PAD_DPAD_LEFT);
Joy_GenerateButtonEvents((pOffTrackedRemoteOld->Joystick.y < -0.7f ? 1 : 0), (pOffTrackedRemoteNew->Joystick.y < -0.7f ? 1 : 0), 1, KEY_PAD_DPAD_DOWN);
Joy_GenerateButtonEvents((pOffTrackedRemoteOld->Joystick.y > 0.7f ? 1 : 0), (pOffTrackedRemoteNew->Joystick.y > 0.7f ? 1 : 0), 1, KEY_PAD_DPAD_UP);
handleTrackedControllerButton(pDominantTrackedRemoteNew, pDominantTrackedRemoteOld, domButton1, KEY_PAD_A);
handleTrackedControllerButton(pDominantTrackedRemoteNew, pDominantTrackedRemoteOld, ovrButton_Trigger, KEY_PAD_A);
handleTrackedControllerButton(pDominantTrackedRemoteNew, pDominantTrackedRemoteOld, domButton2, KEY_PAD_B);
}
else
{
//Dominant Grip works like a shift key
if ((pDominantTrackedRemoteNew->Buttons & ovrButton_GripTrigger) !=
(pDominantTrackedRemoteOld->Buttons & ovrButton_GripTrigger)) {
dominantGripPushed = true;
}
handleTrackedControllerButton(pDominantTrackedRemoteNew, pDominantTrackedRemoteOld, domButton1, K_ENTER);
handleTrackedControllerButton(pDominantTrackedRemoteNew, pDominantTrackedRemoteOld, ovrButton_Trigger, K_ENTER);
handleTrackedControllerButton(pDominantTrackedRemoteNew, pDominantTrackedRemoteOld, domButton2, K_ESCAPE);
}
else */
{
float distance = sqrtf(powf(pOffTracking->HeadPose.Pose.Position.x - pDominantTracking->HeadPose.Pose.Position.x, 2) +
powf(pOffTracking->HeadPose.Pose.Position.y - pDominantTracking->HeadPose.Pose.Position.y, 2) +
powf(pOffTracking->HeadPose.Pose.Position.z - pDominantTracking->HeadPose.Pose.Position.z, 2));
@ -116,11 +117,6 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
VectorSet(weaponangles, -degrees(atanf(y / zxDist)), (doomYawDegrees - hmdorientation[YAW]) - degrees(atan2f(x, -z)), weaponangles[ROLL]);
}
}
if ((pDominantTrackedRemoteNew->Buttons & ovrButton_GripTrigger) !=
(pDominantTrackedRemoteOld->Buttons & ovrButton_GripTrigger)) {
}
}
float controllerYawHeading = 0.0f;
@ -172,8 +168,8 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
positional_movementForward);
//Jump (B Button)
// handleTrackedControllerButton(pDominantTrackedRemoteNew,
// pDominantTrackedRemoteOld, domButton2, K_SPACE);
handleTrackedControllerButton(pDominantTrackedRemoteNew,
pDominantTrackedRemoteOld, domButton2, KEY_SPACE);
//We need to record if we have started firing primary so that releasing trigger will stop firing, if user has pushed grip
//in meantime, then it wouldn't stop the gun firing and it would get stuck
@ -186,17 +182,6 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
firingPrimary = (pDominantTrackedRemoteNew->Buttons & ovrButton_Trigger);
if (inventoryManagementMode)
{
if (firingPrimary)
{
//Select inventory item
}
}
else
{
//fire primary
}
}
}
@ -219,26 +204,9 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
if (!itemSwitched) {
if (between(0.8f, pDominantTrackedRemoteNew->Joystick.y, 1.0f))
{
if (inventoryManagementMode)
{
//Previous Inventory Item
}
else
{
//Next Inventory Item
}
}
else
{
if (inventoryManagementMode)
{
//Next Inventory Item
}
else
{
//Next Weapon
}
}
itemSwitched = true;
}

View file

@ -54,7 +54,7 @@ struct event_t
int y; // mouse/joystick y move
};
enum gameaction_t : int
{
ga_nothing,

View file

@ -93,6 +93,9 @@ enum gamestate_t : int
extern gamestate_t gamestate;
extern "C" int getGameState();
// wipegamestate can be set to -1
// to force a wipe on the next draw
extern gamestate_t wipegamestate;

View file

@ -120,6 +120,8 @@ extern EMenuState menuactive; // Menu overlayed?
extern int paused; // Game Pause?
extern bool pauseext;
extern "C" int isMenuActive();
extern bool viewactive;

View file

@ -98,6 +98,8 @@
#include "events.h"
#include "d_main.h"
#include <QzDoom/VrInput.h>
static FRandom pr_dmspawn ("DMSpawn");
static FRandom pr_pspawn ("PlayerSpawn");
@ -157,6 +159,11 @@ gameaction_t gameaction;
gamestate_t gamestate = GS_STARTUP;
FName SelectedSlideshow; // what to start when ga_slideshow
int getGameState()
{
return (int)gamestate;
}
int paused;
bool pauseext;
bool sendpause; // send a pause event next tic
@ -563,9 +570,7 @@ static inline int joyint(double val)
}
#ifdef __MOBILE__
extern void Mobile_IN_Move(ticcmd_t* cmd );
#endif
extern "C" void VR_GetMove( float *forward, float *side, float *up, float *yaw, float *pitch, float *roll );
//
// G_BuildTiccmd
@ -655,11 +660,23 @@ void G_BuildTiccmd (ticcmd_t *cmd)
forward -= forwardmove[speed];
}
float vrforward=0;
float vrside=0;
float up=0;
float yaw=0;
float pitch=0;
float roll=0;
VR_GetMove(&vrforward, &vrside, &up, &yaw, &pitch, &roll);
if (Button_MoveRight.bDown)
side += sidemove[speed];
if (Button_MoveLeft.bDown)
side -= sidemove[speed];
side += vrside;
forward += vrforward;
// buttons
if (Button_Attack.bDown) cmd->ucmd.buttons |= BT_ATTACK;
if (Button_AltAttack.bDown) cmd->ucmd.buttons |= BT_ALTATTACK;

View file

@ -808,7 +808,8 @@ void FGLRenderer::Flush()
glScissor(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height);
//Only adjust HUD if we are 3D (otherwise we are rendering to a cylinder compositor layer)
if (!is2D) stereo3dMode.getEyePose(eye_ix)->AdjustHud();
//if (!is2D) stereo3dMode.getEyePose(eye_ix)->AdjustHud();
m2DDrawer->Draw();
FGLDebug::PopGroup();
}

View file

@ -427,45 +427,6 @@ namespace s3d
return int(m);
}
void OculusQuestMode::updateHmdPose(
double hmdYawRadians,
double hmdPitchRadians,
double hmdRollRadians) const
{
hmdYaw = hmdYawRadians;
double hmdpitch = hmdPitchRadians;
double hmdroll = hmdRollRadians;
double hmdYawDelta = 0;
{
// Set HMD angle game state parameters for NEXT frame
static double previousHmdYaw = 0;
static bool havePreviousYaw = false;
if (!havePreviousYaw) {
previousHmdYaw = hmdYaw;
havePreviousYaw = true;
}
hmdYawDelta = hmdYaw - previousHmdYaw;
G_AddViewAngle(mAngleFromRadians(-hmdYawDelta));
previousHmdYaw = hmdYaw;
}
/* */
// Pitch
{
double pixelstretch = level.info ? level.info->pixelstretch : 1.2;
double hmdPitchInDoom = -atan(tan(hmdpitch) / pixelstretch);
double viewPitchInDoom = GLRenderer->mAngles.Pitch.Radians();
double dPitch =
// hmdPitchInDoom
-hmdpitch
- viewPitchInDoom;
G_AddViewPitch(mAngleFromRadians(-dPitch));
}
// Roll can be local, because it doesn't affect gameplay.
GLRenderer->mAngles.Roll = RAD2DEG(-hmdroll);
}
/* void Joy_GenerateUIButtonEvents(int oldbuttons, int newbuttons, int numbuttons, const int *keys)
{
@ -637,7 +598,6 @@ namespace s3d
processHaptics();
//Get controller state here
getHMDOrientation(&tracking);
@ -699,7 +659,54 @@ namespace s3d
lastTime = time;
//G_AddViewAngle(joyint(-1280 * I_OculusQuestGetYaw() * delta * 30 / 1000));
*/ }
*/
updateHmdPose();
}
void OculusQuestMode::updateHmdPose() const
{
double hmdYawDeltaDegrees = 0;
{
static double previousHmdYaw = 0;
static bool havePreviousYaw = false;
if (!havePreviousYaw) {
previousHmdYaw = hmdorientation[YAW];
havePreviousYaw = true;
}
hmdYawDeltaDegrees = hmdorientation[YAW] - previousHmdYaw;
G_AddViewAngle(mAngleFromRadians(DEG2RAD(-hmdYawDeltaDegrees)));
previousHmdYaw = hmdorientation[YAW];
}
/* */
// Pitch
{
double pixelstretch = level.info ? level.info->pixelstretch : 1.2;
double hmdPitchInDoom = -atan(tan(DEG2RAD(hmdorientation[PITCH])) / pixelstretch);
double viewPitchInDoom = GLRenderer->mAngles.Pitch.Radians();
double dPitch =
// hmdPitchInDoom
- DEG2RAD(hmdorientation[PITCH])
- viewPitchInDoom;
G_AddViewPitch(mAngleFromRadians(dPitch));
}
// Roll can be local, because it doesn't affect gameplay.
GLRenderer->mAngles.Roll = hmdorientation[ROLL];
{
GLRenderer->mAngles.Pitch = hmdorientation[PITCH];
double viewYaw = r_viewpoint.Angles.Yaw.Degrees - hmdYawDeltaDegrees;
while (viewYaw <= -180.0)
viewYaw += 360.0;
while (viewYaw > 180.0)
viewYaw -= 360.0;
r_viewpoint.Angles.Yaw = viewYaw;
}
}
/* virtual */
void OculusQuestMode::TearDown() const

View file

@ -91,14 +91,13 @@ public:
protected:
OculusQuestMode();
// void updateDoomViewDirection() const;
void updateHmdPose(double hmdYawRadians, double hmdPitchRadians, double hmdRollRadians) const;
void updateHmdPose() const;
OculusQuestEyePose leftEyeView;
OculusQuestEyePose rightEyeView;
mutable int cachedScreenBlocks;
mutable double hmdYaw; // cached latest value in radians
mutable int cachedViewwidth, cachedViewheight, cachedViewwindowx, cachedViewwindowy;
mutable F2DDrawer * cached2DDrawer;
mutable F2DDrawer * crossHairDrawer;
@ -106,7 +105,6 @@ protected:
private:
typedef Stereo3DMode super;
bool hmdWasFound;
uint32_t sceneWidth, sceneHeight;
};

View file

@ -222,7 +222,7 @@ extern int camtexcount;
void OpenGLFrameBuffer::Swap()
{
bool swapbefore = gl_finishbeforeswap && camtexcount == 0;
/* bool swapbefore = gl_finishbeforeswap && camtexcount == 0;
Finish.Reset();
Finish.Clock();
#ifndef __MOBILE__
@ -246,6 +246,7 @@ void OpenGLFrameBuffer::Swap()
camtexcount = 0;
FHardwareTexture::UnbindAll();
mDebug->Update();
*/
}
//==========================================================================

View file

@ -370,6 +370,12 @@ void M_StartControlPanel (bool makeSound)
BackbuttonAlpha = 0;
}
int isMenuActive()
{
return menuactive == MENU_On ? 1 : 0;
}
//=============================================================================
//
//

View file

@ -1 +1 @@
qzdoom --supersampling 1.3 -iwad DOOM.WAD
qzdoom --supersampling 1.2 -iwad wads/DOOM.WAD

Binary file not shown.

View file

@ -163,11 +163,17 @@ import static android.system.Os.setenv;
{
copy_asset("/sdcard/QzDoom", "commandline.txt");
//Create all required folders
new File("/sdcard/QzDoom/res").mkdirs();
new File("/sdcard/QzDoom/mods").mkdirs();
new File("/sdcard/QzDoom/wads").mkdirs();
new File("/sdcard/QzDoom/audiopack/snd_fluidsynth").mkdirs();
copy_asset("/sdcard/QzDoom", "res/lzdoom.pk3");
copy_asset("/sdcard/QzDoom", "res/lz_game_support.pk3");
copy_asset("/sdcard/QzDoom", "res/lights.pk3");
copy_asset("/sdcard/QzDoom", "res/brightmaps.pk3");
copy_asset("/sdcard/QzDoom/audiopack", "snd_fluidsynth/fluidsynth.sf2");
//Read these from a file and pass through
commandLineParams = new String("doom");
@ -324,94 +330,4 @@ import static android.system.Os.setenv;
}
}
// Audio
/**
* This method is called by SDL using JNI.
*/
public static int audioOpen(int sampleRate, boolean is16Bit, boolean isStereo, int desiredFrames) {
int channelConfig = isStereo ? AudioFormat.CHANNEL_CONFIGURATION_STEREO : AudioFormat.CHANNEL_CONFIGURATION_MONO;
int audioFormat = is16Bit ? AudioFormat.ENCODING_PCM_16BIT : AudioFormat.ENCODING_PCM_8BIT;
int frameSize = (isStereo ? 2 : 1) * (is16Bit ? 2 : 1);
Log.v(TAG, "SDL audio: wanted " + (isStereo ? "stereo" : "mono") + " " + (is16Bit ? "16-bit" : "8-bit") + " " + (sampleRate / 1000f) + "kHz, " + desiredFrames + " frames buffer");
// Let the user pick a larger buffer if they really want -- but ye
// gods they probably shouldn't, the minimums are horrifyingly high
// latency already
desiredFrames = Math.max(desiredFrames, (AudioTrack.getMinBufferSize(sampleRate, channelConfig, audioFormat) + frameSize - 1) / frameSize);
if (mAudioTrack == null) {
mAudioTrack = new AudioTrack(AudioManager.STREAM_MUSIC, sampleRate,
channelConfig, audioFormat, desiredFrames * frameSize, AudioTrack.MODE_STREAM);
// Instantiating AudioTrack can "succeed" without an exception and the track may still be invalid
// Ref: https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/media/java/android/media/AudioTrack.java
// Ref: http://developer.android.com/reference/android/media/AudioTrack.html#getState()
if (mAudioTrack.getState() != AudioTrack.STATE_INITIALIZED) {
Log.e(TAG, "Failed during initialization of Audio Track");
mAudioTrack = null;
return -1;
}
mAudioTrack.play();
}
Log.v(TAG, "SDL audio: got " + ((mAudioTrack.getChannelCount() >= 2) ? "stereo" : "mono") + " " + ((mAudioTrack.getAudioFormat() == AudioFormat.ENCODING_PCM_16BIT) ? "16-bit" : "8-bit") + " " + (mAudioTrack.getSampleRate() / 1000f) + "kHz, " + desiredFrames + " frames buffer");
return 0;
}
/**
* This method is called by SDL using JNI.
*/
public static void audioWriteShortBuffer(short[] buffer) {
for (int i = 0; i < buffer.length; ) {
int result = mAudioTrack.write(buffer, i, buffer.length - i);
if (result > 0) {
i += result;
} else if (result == 0) {
try {
Thread.sleep(1);
} catch(InterruptedException e) {
// Nom nom
}
} else {
Log.w(TAG, "SDL audio: error return from write(short)");
return;
}
}
}
/**
* This method is called by SDL using JNI.
*/
public static void audioWriteByteBuffer(byte[] buffer) {
for (int i = 0; i < buffer.length; ) {
int result = mAudioTrack.write(buffer, i, buffer.length - i);
if (result > 0) {
i += result;
} else if (result == 0) {
try {
Thread.sleep(1);
} catch(InterruptedException e) {
// Nom nom
}
} else {
Log.w(TAG, "SDL audio: error return from write(byte)");
return;
}
}
}
/** This method is called by SDL using JNI. */
public static void audioClose() {
if (mAudioTrack != null) {
mAudioTrack.stop();
mAudioTrack.release();
mAudioTrack = null;
}
}
}