Working stereo

very jittery though
This commit is contained in:
Simon 2020-09-09 23:16:24 +01:00
parent fbb71de2ea
commit 4201c1deca
22 changed files with 368 additions and 930 deletions

View file

@ -34,46 +34,28 @@ Copyright : Copyright 2015 Oculus VR, LLC. All Rights reserved.
#include <SDL2/SDL.h>
#include <SDL2/SDL_main.h>
#include "VrApi.h"
#include "VrApi_Helpers.h"
#include "VrApi_SystemUtils.h"
#include "VrApi_Input.h"
#include "VrApi_Types.h"
#include "VrCompositor.h"
#include "VrInput.h"
#include "../../../../../../VrApi/Include/VrApi_Types.h"
#include "../../../../../../VrApi/Include/VrApi.h"
//Define all variables here that were externs in the VrCommon.h
bool Doom3Quest_initialised;
long long global_time;
float playerYaw;
bool resetDoomYaw;
bool resetPreviousPitch;
float doomYaw;
float previousPitch;
float vrFOV;
vec3_t worldPosition;
vec3_t hmdPosition;
vec3_t hmdorientation;
vec3_t positionDeltaThisFrame;
vec3_t weaponangles;
vec3_t weaponoffset;
bool weaponStabilised;
float vr_weapon_pitchadjust;
bool vr_moveuseoffhand;
float vr_snapturn_angle;
bool vr_switchsticks;
bool vr_secondarybuttonmappings;
bool vr_twohandedweapons;
float vr_use_teleport;
vec3_t offhandangles;
vec3_t offhandoffset;
bool player_moving;
bool shutdown;
bool ready_teleport;
bool trigger_teleport;
#if !defined( EGL_OPENGL_ES3_BIT_KHR )
#define EGL_OPENGL_ES3_BIT_KHR 0x0040
@ -106,7 +88,7 @@ int CPU_LEVEL = 4;
int GPU_LEVEL = 4;
int NUM_MULTI_SAMPLES = 1;
int FFR = 0;
float SS_MULTIPLIER = 1.0f;
float SS_MULTIPLIER = 1.25f;
int DISPLAY_REFRESH = 72;
vr_client_info_t vr;
@ -842,20 +824,24 @@ void QuatToYawPitchRoll(ovrQuatf q, vec3_t rotation, vec3_t out) {
return;
}
void setWorldPosition( float x, float y, float z )
void updateHMDOrientation()
{
positionDeltaThisFrame[0] = (worldPosition[0] - x);
positionDeltaThisFrame[1] = (worldPosition[1] - y);
positionDeltaThisFrame[2] = (worldPosition[2] - z);
//Position
VectorSubtract(vr.hmdposition_last, vr.hmdposition, vr.hmdposition_delta);
worldPosition[0] = x;
worldPosition[1] = y;
worldPosition[2] = z;
//Keep this for our records
VectorCopy(vr.hmdposition, vr.hmdposition_last);
//Orientation
VectorSubtract(vr.hmdorientation_last, vr.hmdorientation, vr.hmdorientation_delta);
//Keep this for our records
VectorCopy(vr.hmdorientation, vr.hmdorientation_last);
}
void setHMDPosition( float x, float y, float z, float yaw )
{
VectorSet(hmdPosition, x, y, z);
VectorSet(vr.hmdposition, x, y, z);
if (!Doom3Quest_useScreenLayer())
{
@ -895,9 +881,9 @@ void VR_GetMove( float *joy_forward, float *joy_side, float *hmd_forward, float
*up = remote_movementUp;
*joy_side = remote_movementSideways;
*hmd_side = positional_movementSideways;
*yaw = hmdorientation[YAW] + snapTurn;
*pitch = hmdorientation[PITCH];
*roll = hmdorientation[ROLL];
*yaw = vr.hmdorientation[YAW] + snapTurn;
*pitch = vr.hmdorientation[PITCH];
*roll = vr.hmdorientation[ROLL];
}
@ -926,8 +912,9 @@ typedef struct
bool Resumed;
ovrMobile * Ovr;
ovrScene Scene;
long long FrameIndex;
double DisplayTime;
long long RenderThreadFrameIndex;
double RenderThreadDisplayTime;
double NextFrameDisplayTime;
int SwapInterval;
int CpuLevel;
int GpuLevel;
@ -944,8 +931,8 @@ static void ovrApp_Clear( ovrApp * app )
app->Java.Env = NULL;
app->Java.ActivityObject = NULL;
app->Ovr = NULL;
app->FrameIndex = 1;
app->DisplayTime = 0;
app->RenderThreadFrameIndex = 1;
app->RenderThreadDisplayTime = 0;
app->SwapInterval = 1;
app->CpuLevel = 4;
app->GpuLevel = 4;
@ -958,30 +945,6 @@ static void ovrApp_Clear( ovrApp * app )
ovrRenderer_Clear( &app->Renderer );
}
static void ovrApp_PushBlackFinal( ovrApp * app )
{
int frameFlags = 0;
frameFlags |= VRAPI_FRAME_FLAG_FLUSH | VRAPI_FRAME_FLAG_FINAL;
ovrLayerProjection2 layer = vrapi_DefaultLayerBlackProjection2();
layer.Header.Flags |= VRAPI_FRAME_LAYER_FLAG_INHIBIT_SRGB_FRAMEBUFFER;
const ovrLayerHeader2 * layers[] =
{
&layer.Header
};
ovrSubmitFrameDescription2 frameDesc = {};
frameDesc.Flags = frameFlags;
frameDesc.SwapInterval = 1;
frameDesc.FrameIndex = app->FrameIndex;
frameDesc.DisplayTime = app->DisplayTime;
frameDesc.LayerCount = 1;
frameDesc.Layers = layers;
vrapi_SubmitFrame2( app->Ovr, &frameDesc );
}
static ovrApp gAppState;
static ovrJava java;
static bool destroyed = false;
@ -1284,8 +1247,6 @@ void VR_Init()
{
//Initialise all our variables
playerYaw = 0.0f;
resetDoomYaw = true;
resetPreviousPitch = true;
remote_movementSideways = 0.0f;
remote_movementForward = 0.0f;
remote_movementUp = 0.0f;
@ -1300,8 +1261,6 @@ void VR_Init()
vr_weapon_pitchadjust = -30.0;
shutdown = false;
ready_teleport = false;
trigger_teleport = false;
}
void Doom3Quest_prepareEyeBuffer(int eye )
@ -1420,13 +1379,13 @@ void shutdownVR() {
vrapi_Shutdown();
}
void incrementFrameIndex()
void incrementRenderThreadFrameIndex()
{
// This is the only place the frame index is incremented, right before
// calling vrapi_GetPredictedDisplayTime().
gAppState.FrameIndex++;
gAppState.DisplayTime = vrapi_GetPredictedDisplayTime(gAppState.Ovr,
gAppState.FrameIndex);
gAppState.RenderThreadFrameIndex++;
gAppState.RenderThreadDisplayTime = vrapi_GetPredictedDisplayTime(gAppState.Ovr,
gAppState.RenderThreadFrameIndex);
ALOGV("gAppState.RenderThreadFrameIndex = %i, gAppState.RenderThreadDisplayTime = %g", gAppState.RenderThreadFrameIndex, gAppState.RenderThreadDisplayTime);
}
void showLoadingIcon();
@ -1520,7 +1479,6 @@ void * AppThreadFunction(void * parm ) {
//Run loading loop until we are ready to start QzDoom
while (!destroyed && !Doom3Quest_initialised) {
Doom3Quest_processMessageQueue();
incrementFrameIndex();
showLoadingIcon();
}
@ -1544,6 +1502,10 @@ void Doom3Quest_FrameSetup()
{
//Use floor based tracking space
vrapi_SetTrackingSpace(gAppState.Ovr, VRAPI_TRACKING_SPACE_LOCAL_FLOOR);
Doom3Quest_processHaptics();
Doom3Quest_getHMDOrientation();
Doom3Quest_getTrackedRemotesOrientation(0);
}
void Doom3Quest_processHaptics() {//Handle haptics
@ -1592,41 +1554,45 @@ void showLoadingIcon()
ovrSubmitFrameDescription2 frameDesc = {};
frameDesc.Flags = frameFlags;
frameDesc.SwapInterval = 1;
frameDesc.FrameIndex = gAppState.FrameIndex;
frameDesc.DisplayTime = gAppState.DisplayTime;
frameDesc.FrameIndex = gAppState.RenderThreadFrameIndex;
frameDesc.DisplayTime = gAppState.RenderThreadDisplayTime;
frameDesc.LayerCount = 2;
frameDesc.Layers = layers;
vrapi_SubmitFrame2( gAppState.Ovr, &frameDesc );
incrementRenderThreadFrameIndex();
}
ovrTracking2 gOvrTracking;
void Doom3Quest_getHMDOrientation() {//Get orientation
void Doom3Quest_getHMDOrientation() {
// Get the HMD pose, predicted for the middle of the time period during which
// the new eye images will be displayed. The number of frames predicted ahead
// depends on the pipeline depth of the engine and the synthesis rate.
// The better the prediction, the less black will be pulled in at the edges.
gOvrTracking = vrapi_GetPredictedTracking2(gAppState.Ovr, gAppState.DisplayTime);
gAppState.NextFrameDisplayTime = vrapi_GetPredictedDisplayTime(gAppState.Ovr,
gAppState.RenderThreadFrameIndex+1);
ovrTracking2 tracking = vrapi_GetPredictedTracking2(gAppState.Ovr, gAppState.NextFrameDisplayTime);
ALOGV("nextFrameDisplayTime = %g", gAppState.NextFrameDisplayTime);
// We extract Yaw, Pitch, Roll instead of directly using the orientation
// to allow "additional" yaw manipulation with mouse/controller.
const ovrQuatf quatHmd = gOvrTracking.HeadPose.Pose.Orientation;
const ovrVector3f positionHmd = gOvrTracking.HeadPose.Pose.Position;
const ovrQuatf quatHmd = tracking.HeadPose.Pose.Orientation;
const ovrVector3f positionHmd = tracking.HeadPose.Pose.Position;
vec3_t rotation = {0};
QuatToYawPitchRoll(quatHmd, rotation, hmdorientation);
setHMDPosition(positionHmd.x, positionHmd.y, positionHmd.z, hmdorientation[YAW]);
QuatToYawPitchRoll(quatHmd, rotation, vr.hmdorientation);
setHMDPosition(positionHmd.x, positionHmd.y, positionHmd.z, vr.hmdorientation[YAW]);
//TODO: fix - set to use HMD position for world position
setWorldPosition(positionHmd.x, positionHmd.y, positionHmd.z);
updateHMDOrientation();
ALOGV(" HMD-Position: %f, %f, %f", positionHmd.x, positionHmd.y, positionHmd.z);
}
void Doom3Quest_getTrackedRemotesOrientation(int vr_control_scheme) {//Get info for tracked remotes
acquireTrackedRemotesData(gAppState.Ovr, gAppState.DisplayTime);
void Doom3Quest_getTrackedRemotesOrientation(int vr_control_scheme) {
//Get info for tracked remotes
acquireTrackedRemotesData(gAppState.Ovr, gAppState.NextFrameDisplayTime);
//Call additional control schemes here
switch ((int)vr_control_scheme)
@ -1647,11 +1613,14 @@ void Doom3Quest_getTrackedRemotesOrientation(int vr_control_scheme) {//Get info
void Doom3Quest_submitFrame()
{
ovrSubmitFrameDescription2 frameDesc = {0};
if (!Doom3Quest_useScreenLayer()) {
//Get the tracking info for the render thread frame id
ovrTracking2 tracking = vrapi_GetPredictedTracking2(gAppState.Ovr, gAppState.RenderThreadDisplayTime);
if (!Doom3Quest_useScreenLayer()) {
ovrLayerProjection2 layer = vrapi_DefaultLayerProjection2();
layer.HeadPose = gOvrTracking.HeadPose;
layer.HeadPose = tracking.HeadPose;
for ( int eye = 0; eye < VRAPI_FRAME_LAYER_EYE_MAX; eye++ )
{
ovrFramebuffer * frameBuffer = &gAppState.Renderer.FrameBuffer[gAppState.Renderer.NumBuffers == 1 ? 0 : eye];
@ -1679,8 +1648,8 @@ void Doom3Quest_submitFrame()
frameDesc.Flags = 0;
frameDesc.SwapInterval = gAppState.SwapInterval;
frameDesc.FrameIndex = gAppState.FrameIndex;
frameDesc.DisplayTime = gAppState.DisplayTime;
frameDesc.FrameIndex = gAppState.RenderThreadFrameIndex;
frameDesc.DisplayTime = gAppState.RenderThreadDisplayTime;
frameDesc.LayerCount = 1;
frameDesc.Layers = layers;
@ -1697,7 +1666,7 @@ void Doom3Quest_submitFrame()
// Add a simple cylindrical layer
gAppState.Layers[gAppState.LayerCount++].Cylinder =
BuildCylinderLayer(&gAppState.Scene.CylinderRenderer,
gAppState.Scene.CylinderWidth, gAppState.Scene.CylinderHeight, &gOvrTracking, radians(playerYaw) );
gAppState.Scene.CylinderWidth, gAppState.Scene.CylinderHeight, &tracking, radians(playerYaw) );
// Compose the layers for this frame.
const ovrLayerHeader2 * layerHeaders[ovrMaxLayerCount] = { 0 };
@ -1709,8 +1678,8 @@ void Doom3Quest_submitFrame()
// Set up the description for this frame.
frameDesc.Flags = 0;
frameDesc.SwapInterval = gAppState.SwapInterval;
frameDesc.FrameIndex = gAppState.FrameIndex;
frameDesc.DisplayTime = gAppState.DisplayTime;
frameDesc.FrameIndex = gAppState.RenderThreadFrameIndex;
frameDesc.DisplayTime = gAppState.RenderThreadDisplayTime;
frameDesc.LayerCount = gAppState.LayerCount;
frameDesc.Layers = layerHeaders;
@ -1718,7 +1687,7 @@ void Doom3Quest_submitFrame()
vrapi_SubmitFrame2(gAppState.Ovr, &frameDesc);
}
incrementFrameIndex();
incrementRenderThreadFrameIndex();
}

View file

@ -8,6 +8,8 @@
extern "C" {
#endif
typedef float vec3_t[3];
typedef struct {
bool screen;
float fov;

View file

@ -17,8 +17,10 @@ Authors : Simon Brown
#include "VrInput.h"
float vr_turn_mode;
float vr_turn_angle;
#include "doomkeys.h"
float vr_turn_mode = 0.0f;
float vr_turn_angle = 45.0f;
float vr_reloadtimeoutms;
float vr_positional_factor;
float vr_walkdirection;
@ -28,7 +30,7 @@ float vr_lasersight;
float vr_control_scheme;
float vr_teleport;
float vr_virtual_stock;
float vr_switch_sticks;
float vr_switch_sticks = 0;
float vr_cinematic_stereo;
float vr_screen_dist;
@ -141,7 +143,6 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
}
//Menu button
int K_ESCAPE = 27;
handleTrackedControllerButton(&leftTrackedRemoteState_new, &leftTrackedRemoteState_old, false, ovrButton_Enter, K_ESCAPE);
static bool resetCursor = true;
@ -149,10 +150,7 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
{
interactWithTouchScreen(resetCursor, pDominantTrackedRemoteNew, pDominantTrackedRemoteOld);
handleTrackedControllerButton(pDominantTrackedRemoteNew, pDominantTrackedRemoteOld, true, ovrButton_Trigger, 1);
// handleTrackedControllerButton(pDominantTrackedRemoteNew, pDominantTrackedRemoteOld, ovrButton_Trigger, K_MOUSE1);
// handleTrackedControllerButton(pDominantTrackedRemoteNew, pDominantTrackedRemoteOld, domButton2, K_ESCAPE);
}
else
{
@ -438,6 +436,7 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
//This section corrects for the fact that the controller actually controls direction of movement, but we want to move relative to the direction the
//player is facing for positional tracking
vec2_t v;
vr_positional_factor = 1000;
rotateAboutOrigin(-pVRClientInfo->hmdposition_delta[0] * vr_positional_factor,
pVRClientInfo->hmdposition_delta[2] * vr_positional_factor, - pVRClientInfo->hmdorientation[YAW], v);
positional_movementSideways = v[0];
@ -452,10 +451,7 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
if ((primaryButtonsNew & primaryButton2) != (primaryButtonsOld & primaryButton2))
{
static bool use = false;
use = !use;
Doom3Quest_setUseScreenLayer(use);
// Sys_QueEvent( 0, SE_KEY, K_SPACE, (primaryButtonsNew & primaryButton2) != 0, 0, NULL );
handleTrackedControllerButton(pDominantTrackedRemoteNew, pDominantTrackedRemoteOld, false, primaryButton2, K_SPACE);
}
}
@ -508,7 +504,8 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
ALOGV("**WEAPON EVENT** Not Grip Pushed %sattack", (pDominantTrackedRemoteNew->Buttons & ovrButton_Trigger) ? "+" : "-");
firing = (pDominantTrackedRemoteNew->Buttons & ovrButton_Trigger);
sendButtonAction("+attack", firing);
handleTrackedControllerButton(pDominantTrackedRemoteNew, pDominantTrackedRemoteOld, false, ovrButton_Trigger, K_CTRL);
}
else if (binocularsactive) // trigger can zoom-in binoculars, remove from face to reset
{
@ -528,7 +525,7 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
(primaryButtonsNew & primaryButton1) !=
(primaryButtonsOld & primaryButton1)) {
sendButtonAction("+movedown", (primaryButtonsNew & primaryButton1));
handleTrackedControllerButton(pDominantTrackedRemoteNew, pDominantTrackedRemoteOld, false, primaryButton1, 'c');
}
//Weapon Chooser
@ -630,7 +627,7 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
if (!pVRClientInfo->teleportenabled)
{
//Run
//handleTrackedControllerButton(pOffTrackedRemoteNew, pOffTrackedRemoteOld, ovrButton_Trigger, K_SHIFT);
handleTrackedControllerButton(pOffTrackedRemoteNew, pOffTrackedRemoteOld, false, ovrButton_Trigger, K_SHIFT);
} else {
if (pOffTrackedRemoteNew->Buttons & ovrButton_Trigger)
{

View file

@ -2,200 +2,161 @@
// Created by simon on 04/03/2020.
//
#ifndef QZDOOM_DOOMKEYS_H
#define QZDOOM_DOOMKEYS_H
#ifndef DOOMKEYS_H
#define DOOMKEYS_H
//
// DOOM keyboard definition. Everything below 0x100 matches
// a mode 1 keyboard scan code.
//
typedef enum {
#define KEY_PAUSE 0xc5 // DIK_PAUSE
#define KEY_RIGHTARROW 0xcd // DIK_RIGHT
#define KEY_LEFTARROW 0xcb // DIK_LEFT
#define KEY_UPARROW 0xc8 // DIK_UP
#define KEY_DOWNARROW 0xd0 // DIK_DOWN
#define KEY_ESCAPE 0x01 // DIK_ESCAPE
#define KEY_ENTER 0x1c // DIK_RETURN
#define KEY_SPACE 0x39 // DIK_SPACE
#define KEY_TAB 0x0f // DIK_TAB
#define KEY_F1 0x3b // DIK_F1
#define KEY_F2 0x3c // DIK_F2
#define KEY_F3 0x3d // DIK_F3
#define KEY_F4 0x3e // DIK_F4
#define KEY_F5 0x3f // DIK_F5
#define KEY_F6 0x40 // DIK_F6
#define KEY_F7 0x41 // DIK_F7
#define KEY_F8 0x42 // DIK_F8
#define KEY_F9 0x43 // DIK_F9
#define KEY_F10 0x44 // DIK_F10
#define KEY_F11 0x57 // DIK_F11
#define KEY_F12 0x58 // DIK_F12
#define KEY_GRAVE 0x29 // DIK_GRAVE
// DG: please don't change any existing constants for keyboard keys below (or recreate the tables in win_input.cpp)!
#define KEY_BACKSPACE 0x0e // DIK_BACK
K_TAB = 9,
K_ENTER = 13,
K_ESCAPE = 27,
K_SPACE = 32,
#define KEY_EQUALS 0x0d // DIK_EQUALS
#define KEY_MINUS 0x0c // DIK_MINUS
K_BACKSPACE = 127,
#define KEY_LSHIFT 0x2A // DIK_LSHIFT
#define KEY_LCTRL 0x1d // DIK_LCONTROL
#define KEY_LALT 0x38 // DIK_LMENU
K_COMMAND = 128,
K_CAPSLOCK,
K_SCROLL,
K_POWER,
K_PAUSE,
#define KEY_RSHIFT KEY_LSHIFT
#define KEY_RCTRL KEY_LCTRL
#define KEY_RALT KEY_LALT
K_UPARROW = 133,
K_DOWNARROW,
K_LEFTARROW,
K_RIGHTARROW,
#define KEY_INS 0xd2 // DIK_INSERT
#define KEY_DEL 0xd3 // DIK_DELETE
#define KEY_END 0xcf // DIK_END
#define KEY_HOME 0xc7 // DIK_HOME
#define KEY_PGUP 0xc9 // DIK_PRIOR
#define KEY_PGDN 0xd1 // DIK_NEXT
// The 3 windows keys
K_LWIN = 137,
K_RWIN,
K_MENU,
#define KEY_MOUSE1 0x100
#define KEY_MOUSE2 0x101
#define KEY_MOUSE3 0x102
#define KEY_MOUSE4 0x103
#define KEY_MOUSE5 0x104
#define KEY_MOUSE6 0x105
#define KEY_MOUSE7 0x106
#define KEY_MOUSE8 0x107
K_ALT = 140,
K_CTRL,
K_SHIFT,
K_INS,
K_DEL,
K_PGDN,
K_PGUP,
K_HOME,
K_END,
#define KEY_FIRSTJOYBUTTON 0x108
#define KEY_FIRSTJOY2BUTTON 0x128
#define KEY_FIRSTJOY3BUTTON 0x148
#define KEY_FIRSTJOY4BUTTON 0x168
#define KEY_JOY1 (KEY_FIRSTJOYBUTTON+0)
#define KEY_JOY2 (KEY_FIRSTJOYBUTTON+1)
#define KEY_JOY3 (KEY_FIRSTJOYBUTTON+2)
#define KEY_JOY4 (KEY_FIRSTJOYBUTTON+3)
#define KEY_JOY5 (KEY_FIRSTJOYBUTTON+4)
#define KEY_JOY6 (KEY_FIRSTJOYBUTTON+5)
#define KEY_JOY7 (KEY_FIRSTJOYBUTTON+6)
#define KEY_JOY8 (KEY_FIRSTJOYBUTTON+7)
#define KEY_LASTJOYBUTTON 0x187
#define KEY_JOYPOV1_UP 0x188
#define KEY_JOYPOV1_RIGHT 0x189
#define KEY_JOYPOV1_DOWN 0x18a
#define KEY_JOYPOV1_LEFT 0x18b
#define KEY_JOYPOV2_UP 0x18c
#define KEY_JOYPOV3_UP 0x190
#define KEY_JOYPOV4_UP 0x194
K_F1 = 149,
K_F2,
K_F3,
K_F4,
K_F5,
K_F6,
K_F7,
K_F8,
K_F9,
K_F10,
K_F11,
K_F12,
K_INVERTED_EXCLAMATION = 161, // upside down !
K_F13,
K_F14,
K_F15,
#define KEY_MWHEELUP 0x198
#define KEY_MWHEELDOWN 0x199
#define KEY_MWHEELRIGHT 0x19A
#define KEY_MWHEELLEFT 0x19B
K_KP_HOME = 165,
K_KP_UPARROW,
K_KP_PGUP,
K_KP_LEFTARROW,
K_KP_5,
K_KP_RIGHTARROW,
K_KP_END,
K_KP_DOWNARROW,
K_KP_PGDN,
K_KP_ENTER,
K_KP_INS,
K_KP_DEL,
K_KP_SLASH,
K_SUPERSCRIPT_TWO = 178, // superscript 2
K_KP_MINUS,
K_ACUTE_ACCENT = 180, // accute accent
K_KP_PLUS,
K_KP_NUMLOCK,
K_KP_STAR,
K_KP_EQUALS,
#define KEY_JOYAXIS1PLUS 0x19C
#define KEY_JOYAXIS1MINUS 0x19D
#define KEY_JOYAXIS2PLUS 0x19E
#define KEY_JOYAXIS2MINUS 0x19F
#define KEY_JOYAXIS3PLUS 0x1A0
#define KEY_JOYAXIS3MINUS 0x1A1
#define KEY_JOYAXIS4PLUS 0x1A2
#define KEY_JOYAXIS4MINUS 0x1A3
#define KEY_JOYAXIS5PLUS 0x1A4
#define KEY_JOYAXIS5MINUS 0x1A5
#define KEY_JOYAXIS6PLUS 0x1A6
#define KEY_JOYAXIS6MINUS 0x1A7
#define KEY_JOYAXIS7PLUS 0x1A8
#define KEY_JOYAXIS7MINUS 0x1A9
#define KEY_JOYAXIS8PLUS 0x1AA
#define KEY_JOYAXIS8MINUS 0x1AB
#define NUM_JOYAXISBUTTONS 8
// DG: please don't change any existing constants above this one (or recreate the tables in win_input.cpp)!
#define KEY_PAD_LTHUMB_RIGHT 0x1AC
#define KEY_PAD_LTHUMB_LEFT 0x1AD
#define KEY_PAD_LTHUMB_DOWN 0x1AE
#define KEY_PAD_LTHUMB_UP 0x1AF
K_MASCULINE_ORDINATOR = 186,
// K_MOUSE enums must be contiguous (no char codes in the middle)
K_MOUSE1 = 187,
K_MOUSE2,
K_MOUSE3,
K_MOUSE4,
K_MOUSE5,
K_MOUSE6,
K_MOUSE7,
K_MOUSE8,
#define KEY_PAD_RTHUMB_RIGHT 0x1B0
#define KEY_PAD_RTHUMB_LEFT 0x1B1
#define KEY_PAD_RTHUMB_DOWN 0x1B2
#define KEY_PAD_RTHUMB_UP 0x1B3
K_MWHEELDOWN = 195,
K_MWHEELUP,
#define KEY_PAD_DPAD_UP 0x1B4
#define KEY_PAD_DPAD_DOWN 0x1B5
#define KEY_PAD_DPAD_LEFT 0x1B6
#define KEY_PAD_DPAD_RIGHT 0x1B7
#define KEY_PAD_START 0x1B8
#define KEY_PAD_BACK 0x1B9
#define KEY_PAD_LTHUMB 0x1BA
#define KEY_PAD_RTHUMB 0x1BB
#define KEY_PAD_LSHOULDER 0x1BC
#define KEY_PAD_RSHOULDER 0x1BD
#define KEY_PAD_LTRIGGER 0x1BE
#define KEY_PAD_RTRIGGER 0x1BF
#define KEY_PAD_A 0x1C0
#define KEY_PAD_B 0x1C1
#define KEY_PAD_X 0x1C2
#define KEY_PAD_Y 0x1C3
K_JOY1 = 197,
K_JOY2,
K_JOY3,
K_JOY4,
K_JOY5,
K_JOY6,
K_JOY7,
K_JOY8,
K_JOY9,
K_JOY10,
K_JOY11,
K_JOY12,
K_JOY13,
K_JOY14,
K_JOY15,
K_JOY16,
K_JOY17,
K_JOY18,
K_JOY19,
K_JOY20,
K_JOY21,
K_JOY22,
K_JOY23,
K_JOY24,
K_JOY25,
K_JOY26,
K_JOY27,
K_GRAVE_A = 224, // lowercase a with grave accent
K_JOY28,
K_JOY29,
K_JOY30,
K_JOY31,
K_JOY32,
#define KEY_JOY2POV1_UP 0x1C4
#define KEY_JOY2POV2_UP 0x1C8
#define KEY_JOY2POV3_UP 0x1CC
#define KEY_JOY2POV4_UP 0x1D0
#define KEY_JOY3POV1_UP 0x1D4
#define KEY_JOY3POV2_UP 0x1D8
#define KEY_JOY3POV3_UP 0x1DC
#define KEY_JOY3POV4_UP 0x1E0
#define KEY_JOY4POV1_UP 0x1E4
#define KEY_JOY4POV2_UP 0x1E8
#define KEY_JOY4POV3_UP 0x1EC
#define KEY_JOY4POV4_UP 0x1F0
K_AUX1 = 230,
K_CEDILLA_C = 231, // lowercase c with Cedilla
K_GRAVE_E = 232, // lowercase e with grave accent
K_AUX2,
K_AUX3,
K_AUX4,
K_GRAVE_I = 236, // lowercase i with grave accent
K_AUX5,
K_AUX6,
K_AUX7,
K_AUX8,
K_TILDE_N = 241, // lowercase n with tilde
K_GRAVE_O = 242, // lowercase o with grave accent
K_AUX9,
K_AUX10,
K_AUX11,
K_AUX12,
K_AUX13,
K_AUX14,
K_GRAVE_U = 249, // lowercase u with grave accent
K_AUX15,
K_AUX16,
#define KEY_JOY2AXIS1PLUS 0x1F4
#define KEY_JOY2AXIS1MINUS 0x1F5
#define KEY_JOY2AXIS2PLUS 0x1F6
#define KEY_JOY2AXIS2MINUS 0x1F7
#define KEY_JOY2AXIS3PLUS 0x1F8
#define KEY_JOY2AXIS3MINUS 0x1F9
#define KEY_JOY2AXIS4PLUS 0x1FA
#define KEY_JOY2AXIS4MINUS 0x1FB
#define KEY_JOY2AXIS5PLUS 0x1FC
#define KEY_JOY2AXIS5MINUS 0x1FD
#define KEY_JOY2AXIS6PLUS 0x1FE
#define KEY_JOY2AXIS6MINUS 0x1FF
#define KEY_JOY2AXIS7PLUS 0x200
#define KEY_JOY2AXIS7MINUS 0x201
#define KEY_JOY2AXIS8PLUS 0x202
#define KEY_JOY2AXIS8MINUS 0x203
#define KEY_JOY3AXIS1PLUS 0x204
#define KEY_JOY3AXIS1MINUS 0x205
#define KEY_JOY3AXIS2PLUS 0x206
#define KEY_JOY3AXIS2MINUS 0x207
#define KEY_JOY3AXIS3PLUS 0x208
#define KEY_JOY3AXIS3MINUS 0x209
#define KEY_JOY3AXIS4PLUS 0x20A
#define KEY_JOY3AXIS4MINUS 0x20B
#define KEY_JOY3AXIS5PLUS 0x20C
#define KEY_JOY3AXIS5MINUS 0x20D
#define KEY_JOY3AXIS6PLUS 0x20E
#define KEY_JOY3AXIS6MINUS 0x20F
#define KEY_JOY3AXIS7PLUS 0x210
#define KEY_JOY3AXIS7MINUS 0x211
#define KEY_JOY3AXIS8PLUS 0x212
#define KEY_JOY3AXIS8MINUS 0x213
#define KEY_JOY4AXIS1PLUS 0x214
#define KEY_JOY4AXIS1MINUS 0x215
#define KEY_JOY4AXIS2PLUS 0x216
#define KEY_JOY4AXIS2MINUS 0x217
#define KEY_JOY4AXIS3PLUS 0x218
#define KEY_JOY4AXIS3MINUS 0x219
#define KEY_JOY4AXIS4PLUS 0x21A
#define KEY_JOY4AXIS4MINUS 0x21B
#define KEY_JOY4AXIS5PLUS 0x21C
#define KEY_JOY4AXIS5MINUS 0x21D
#define KEY_JOY4AXIS6PLUS 0x21E
#define KEY_JOY4AXIS6MINUS 0x21F
#define KEY_JOY4AXIS7PLUS 0x220
#define KEY_JOY4AXIS7MINUS 0x221
#define KEY_JOY4AXIS8PLUS 0x222
#define KEY_JOY4AXIS8MINUS 0x223
#define NUM_KEYS 0x224
K_PRINT_SCR = 252, // SysRq / PrintScr
K_RIGHT_ALT = 253, // used by some languages as "Alt-Gr"
K_LAST_KEY = 254 // this better be < 256!
} keyNum_t;
#endif //QZDOOM_DOOMKEYS_H
#endif //DOOMKEYS_H

View file

@ -89,7 +89,7 @@ idCVar com_forceGenericSIMD( "com_forceGenericSIMD", "0", CVAR_BOOL | CVAR_SYSTE
idCVar com_developer( "developer", "1", CVAR_BOOL|CVAR_SYSTEM|CVAR_NOCHEAT, "developer mode" );
idCVar com_allowConsole( "com_allowConsole", "0", CVAR_BOOL | CVAR_SYSTEM | CVAR_NOCHEAT, "allow toggling console with the tilde key" );
idCVar com_speeds( "com_speeds", "0", CVAR_BOOL|CVAR_SYSTEM|CVAR_NOCHEAT, "show engine timings" );
idCVar com_showFPS( "com_showFPS", "1", CVAR_BOOL|CVAR_SYSTEM|CVAR_ARCHIVE|CVAR_NOCHEAT, "show frames rendered per second" );
idCVar com_showFPS( "com_showFPS", "0", CVAR_BOOL|CVAR_SYSTEM|CVAR_ARCHIVE|CVAR_NOCHEAT, "show frames rendered per second" );
idCVar com_showMemoryUsage( "com_showMemoryUsage", "0", CVAR_BOOL|CVAR_SYSTEM|CVAR_NOCHEAT, "show total and per frame memory usage" );
idCVar com_showAsyncStats( "com_showAsyncStats", "0", CVAR_BOOL|CVAR_SYSTEM|CVAR_NOCHEAT, "show async network stats" );
idCVar com_showSoundDecoders( "com_showSoundDecoders", "0", CVAR_BOOL|CVAR_SYSTEM|CVAR_NOCHEAT, "show sound decoders" );
@ -2396,8 +2396,13 @@ void idCommonLocal::Frame( void ) {
int inMenu = (((idSessionLocal*)session)->guiActive != 0);
int inGameGui = ( game && game->InGameGuiActive());
int objectiveActive = ( game && game->ObjectiveSystemActive());
int cinematic = ( game && game->InCinematic());
Android_PumpEvents(inMenu?1:0 + inGameGui?2:0 + objectiveActive?4:0);
Android_PumpEvents(inMenu?1:0 + inGameGui?2:0 + objectiveActive?4:0 + cinematic?8:0);
if (game) {
game->SetVRClientInfo(pVRClientInfo);
}
// write config file if anything changed
WriteConfiguration();

View file

@ -200,34 +200,49 @@ float SCR_DrawFPS( float y ) {
static int previousTimes[FPS_FRAMES];
static int index;
int i, total;
int fps;
static int fps = 0;
static int previous;
int t, frameTime;
static int stereoSide = 0;
// don't use serverTime, because that will be drifting to
// correct for internet lag changes, timescales, timedemos, etc
t = Sys_Milliseconds();
frameTime = t - previous;
previous = t;
int new_y = idMath::FtoiFast(y) + 300;
previousTimes[index % FPS_FRAMES] = frameTime;
index++;
if ( index > FPS_FRAMES ) {
// average multiple frames together to smooth changes out a bit
total = 0;
for ( i = 0 ; i < FPS_FRAMES ; i++ ) {
total += previousTimes[i];
if (stereoSide == 0) {
// don't use serverTime, because that will be drifting to
// correct for internet lag changes, timescales, timedemos, etc
t = Sys_Milliseconds();
frameTime = t - previous;
previous = t;
previousTimes[index % FPS_FRAMES] = frameTime;
index++;
if (index > FPS_FRAMES) {
// average multiple frames together to smooth changes out a bit
total = 0;
for (i = 0; i < FPS_FRAMES; i++) {
total += previousTimes[i];
}
if (!total) {
total = 1;
}
fps = 10000 * FPS_FRAMES / total;
fps = (fps + 5) / 10;
s = va("%ifps", fps);
w = strlen(s) * SMALLCHAR_WIDTH;
renderSystem->DrawSmallStringExt((634 / 2) - w, new_y, s, colorWhite, true,
localConsole.charSetShader);
}
if ( !total ) {
total = 1;
}
fps = 10000 * FPS_FRAMES / total;
fps = (fps + 5)/10;
s = va( "%ifps", fps );
w = strlen( s ) * BIGCHAR_WIDTH;
renderSystem->DrawBigStringExt( 635 - w, idMath::FtoiFast( y ) + 2, s, colorWhite, true, localConsole.charSetShader);
stereoSide = 1;
}
else {
//For right eye just use same value
s = va("%ifps", fps);
w = strlen(s) * SMALLCHAR_WIDTH;
renderSystem->DrawSmallStringExt((634 / 2) - w, new_y, s, colorWhite, true,
localConsole.charSetShader);
stereoSide = 0;
}
return y + BIGCHAR_HEIGHT + 4;

View file

@ -35,6 +35,8 @@ If you have questions concerning this license or the applicable additional terms
#include "renderer/RenderWorld.h"
#include "sound/sound.h"
#include "../../../Doom3Quest/VrClientInfo.h"
class idAASFileManager;
class idCollisionModelManager;
class idRenderSystem;
@ -88,6 +90,10 @@ public:
// Set the local client number. Distinguishes listen ( == 0 ) / dedicated ( == -1 )
virtual void SetLocalClient( int clientNum ) = 0;
virtual void SetVRClientInfo(vr_client_info_t *pVRClientInfo) = 0;
virtual bool InCinematic() = 0;
// Sets the user info for a client.
// if canModify is true, the game can modify the user info in the returned dictionary pointer, server will forward the change back
// canModify is never true on network client

View file

@ -2509,16 +2509,18 @@ void idSessionLocal::UpdateScreen( bool outOfSequence ) {
Sys_GrabMouseCursor( false );
}
renderSystem->BeginFrame( renderSystem->GetScreenWidth(), renderSystem->GetScreenHeight() );
for (int eye = 0; eye < 2; ++eye) {
renderSystem->BeginFrame(renderSystem->GetScreenWidth(), renderSystem->GetScreenHeight());
// draw everything
Draw();
// draw everything
Draw();
if ( com_speeds.GetBool() ) {
renderSystem->EndFrame( &time_frontend, &time_backend );
} else {
renderSystem->EndFrame( NULL, NULL );
}
if (com_speeds.GetBool()) {
renderSystem->EndFrame(&time_frontend, &time_backend);
} else {
renderSystem->EndFrame(NULL, NULL);
}
}
insideUpdateScreen = false;
}

View file

@ -456,7 +456,7 @@ void idUsercmdGenLocal::InhibitUsercmd( inhibit_t subsystem, bool inhibit ) {
}
}
extern "C" int Android_GetButton( int key );
//extern "C" int Android_GetButton( int key );
/*
===============
idUsercmdGenLocal::ButtonState
@ -465,11 +465,12 @@ Returns (the fraction of the frame) that the key was down
===============
*/
int idUsercmdGenLocal::ButtonState( int key ) {
return 0;
if ( key<0 || key>=UB_MAX_BUTTONS ) {
return -1;
}
return ( (buttonState[key] > 0) || Android_GetButton(key) ) ? 1 : 0;
//return ( (buttonState[key] > 0) || Android_GetButton(key) ) ? 1 : 0;
}
/*
@ -1117,7 +1118,7 @@ void idUsercmdGenLocal::MouseState( int *x, int *y, int *button, bool *down ) {
*down = mouseDown;
}
extern "C" int Android_GetNextImpulse();
//extern "C" int Android_GetNextImpulse();
/*
================
@ -1130,15 +1131,15 @@ usercmd_t idUsercmdGenLocal::GetDirectUsercmd( void ) {
InitCurrent();
// process the system mouse events
Mouse();
//Mouse();
// process the system keyboard events
Keyboard();
// process the system joystick events
Joystick();
//Joystick();
int imp = Android_GetNextImpulse();
/* int imp = Android_GetNextImpulse();
if( imp )
{
if ( !Inhibited() ) {
@ -1148,7 +1149,7 @@ usercmd_t idUsercmdGenLocal::GetDirectUsercmd( void ) {
}
}
}
*/
// create the usercmd
MakeCurrent();

View file

@ -50,6 +50,7 @@ If you have questions concerning this license or the applicable additional terms
#include "framework/Licensee.h" // DG: for ID__DATE__
#include "Game_local.h"
#include "../../../Doom3Quest/VrClientInfo.h"
const int NUM_RENDER_PORTAL_BITS = idMath::BitsForInteger( PS_BLOCK_ALL );
@ -268,6 +269,10 @@ bool IsDoom3DemoVersion()
return ret;
}
bool idGameLocal::InCinematic()
{
return inCinematic;
}
/*
@ -759,6 +764,12 @@ void idGameLocal::SetLocalClient( int clientNum ) {
localClientNum = clientNum;
}
void idGameLocal::SetVRClientInfo(vr_client_info_t *pVR)
{
pVRClientInfo = pVR;
}
/*
===========
idGameLocal::SetUserInfo
@ -2191,6 +2202,8 @@ gameReturn_t idGameLocal::RunFrame( const usercmd_t *clientCmds ) {
player = GetLocalPlayer();
player->SetVRClientInfo(pVRClientInfo);
if ( !isMultiplayer && g_stopTime.GetBool() ) {
// clear any debug lines from a previous frame
gameRenderWorld->DebugClearLines( time + 1 );

View file

@ -45,6 +45,8 @@ If you have questions concerning this license or the applicable additional terms
#include "Pvs.h"
#include "MultiplayerGame.h"
#include "../../../Doom3Quest/VrClientInfo.h"
#ifdef ID_DEBUG_UNINITIALIZED_MEMORY
// This is real evil but allows the code to inspect arbitrary class variables.
#define private public
@ -301,10 +303,12 @@ public:
virtual void Init( void );
virtual void Shutdown( void );
virtual void SetLocalClient( int clientNum );
virtual void SetVRClientInfo(vr_client_info_t *pVRClientInfo);
virtual void ThrottleUserInfo( void );
virtual const idDict * SetUserInfo( int clientNum, const idDict &userInfo, bool isClient, bool canModify );
virtual const idDict * GetUserInfo( int clientNum );
virtual void SetServerInfo( const idDict &serverInfo );
virtual bool InCinematic();
virtual const idDict & GetPersistentPlayerInfo( int clientNum );
virtual void SetPersistentPlayerInfo( int clientNum, const idDict &playerInfo );
@ -452,6 +456,8 @@ public:
private:
const static int INITIAL_SPAWN_COUNT = 1;
vr_client_info_t *pVRClientInfo;
idStr mapFileName; // name of the map, empty string if no map loaded
idMapFile * mapFile; // will be NULL during the game unless in-game editing is used
bool mapCycleLoaded;

View file

@ -1247,6 +1247,8 @@ void idPlayer::Init( void ) {
talkCursor = 0;
focusVehicle = NULL;
pVRClientInfo = NULL;
// remove any damage effects
playerView.ClearEffects();
@ -2649,7 +2651,7 @@ void idPlayer::DrawHUD( idUserInterface *_hud ) {
// weapon targeting crosshair
if ( !GuiActive() ) {
if ( cursor && weapon.GetEntity()->ShowCrosshair() ) {
cursor->Redraw( gameLocal.realClientTime );
//cursor->Redraw( gameLocal.realClientTime );
}
}
}
@ -7246,6 +7248,12 @@ idVec3 idPlayer::GetEyePosition( void ) const {
return org + ( GetPhysics()->GetGravityNormal() * -eyeOffset.z );
}
void idPlayer::SetVRClientInfo(vr_client_info_t *pVR)
{
pVRClientInfo = pVR;
}
/*
===============
idPlayer::GetViewPos
@ -7263,7 +7271,13 @@ void idPlayer::GetViewPos( idVec3 &origin, idMat3 &axis ) const {
origin = GetEyePosition();
} else {
origin = GetEyePosition() + viewBob;
angles = viewAngles + viewBobAngles + playerView.AngleOffset();
if (pVRClientInfo)
{
//Use pitch and roll from HMD
angles.Set(pVRClientInfo->hmdorientation[PITCH], viewAngles.yaw, pVRClientInfo->hmdorientation[ROLL]);
} else{
angles = viewAngles + viewBobAngles + playerView.AngleOffset();
}
axis = angles.ToMat3() * physicsObj.GetGravityAxis();

View file

@ -265,6 +265,8 @@ public:
idUserInterface * objectiveSystem;
bool objectiveSystemOpen;
vr_client_info_t *pVRClientInfo;
int weapon_soulcube;
int weapon_pda;
int weapon_fists;
@ -361,6 +363,9 @@ public:
idDict * GetUserInfo( void );
bool BalanceTDM( void );
void SetVRClientInfo(vr_client_info_t *pVRClientInfo);
void CacheWeapons( void );
void EnterCinematic( void );

View file

@ -702,22 +702,41 @@ void idPlayerView::InfluenceVision( idUserInterface *hud, const renderView_t *vi
idPlayerView::RenderPlayerView
===================
*/
static int eye = 0;
void idPlayerView::RenderPlayerView( idUserInterface *hud ) {
const renderView_t *view = player->GetRenderView();
if ( g_skipViewEffects.GetBool() ) {
SingleView( hud, view );
} else {
if ( player->GetInfluenceMaterial() || player->GetInfluenceEntity() ) {
InfluenceVision( hud, view );
} else if ( gameLocal.time < dvFinishTime ) {
DoubleVision( hud, view, dvFinishTime - gameLocal.time );
} else if ( player->PowerUpActive( BERSERK ) ) {
BerserkVision( hud, view );
{
renderView_t *eyeView = view ? new renderView_t(*view) : NULL;
if (eyeView) {
if (eye == 0) // left eye
{
eyeView->vieworg += eyeView->viewaxis[1] * 0.065f * 20.0f;
} else if (eye == 1) // right eye
{
eyeView->vieworg -= eyeView->viewaxis[1] * 0.065f * 20.0f;
}
}
eye = 1-eye;
if (g_skipViewEffects.GetBool()) {
SingleView(hud, eyeView);
} else {
SingleView( hud, view );
if (player->GetInfluenceMaterial() || player->GetInfluenceEntity()) {
InfluenceVision(hud, eyeView);
} else if (gameLocal.time < dvFinishTime) {
DoubleVision(hud, eyeView, dvFinishTime - gameLocal.time);
} else if (player->PowerUpActive(BERSERK)) {
BerserkVision(hud, eyeView);
} else {
SingleView(hud, eyeView);
}
ScreenFade();
}
ScreenFade();
delete eyeView;
}
if ( net_clientLagOMeter.GetBool() && lagoMaterial && gameLocal.isClient ) {

View file

@ -1,551 +1,28 @@
extern int main_android(int argc, char *argv[]);
#include "renderer/tr_local.h"
#include "sys/platform.h"
extern "C"
{
//#include "game_interface.h"
#include "SDL.h"
#include "SDL_keycode.h"
#define ACTION_DOWN 0
#define ACTION_UP 1
#define ACTION_MOVE 2
#define ACTION_MOVE_REL 3
#define ACTION_HOVER_MOVE 7
#define ACTION_SCROLL 8
#define BUTTON_PRIMARY 1
#define BUTTON_SECONDARY 2
#define BUTTON_TERTIARY 4
#define BUTTON_BACK 8
#define BUTTON_FORWARD 16
static char* consoleCmd = NULL;
static bool inMenu = false;
static bool inGameGuiActive = false;
static bool objectiveSystemActive = false;
extern int SDL_SendKeyboardKey(Uint8 state, SDL_Scancode scancode);
void Android_OnMouse( int androidButton, int action, float x, float y);
int PortableKeyEvent(int state, int code, int unicode){
LOGI("PortableKeyEvent %d %d %d",state,code,unicode);
if (state)
SDL_SendKeyboardKey(SDL_PRESSED, (SDL_Scancode)code);
else
SDL_SendKeyboardKey(SDL_RELEASED, (SDL_Scancode) code);
return 0;
}
void PortableBackButton()
{
PortableKeyEvent(1, SDL_SCANCODE_ESCAPE,0 );
PortableKeyEvent(0, SDL_SCANCODE_ESCAPE, 0);
}
static const char *cmd_to_run = NULL;
void PortableCommand(const char * cmd)
{
cmd_to_run = cmd;
}
// Can only set one impulse per frame, this should be fine
static int nextImpulse = 0;
static void SetImpuse(int impulse)
{
nextImpulse = impulse;
}
typedef enum {
UB_NONE,
UB_UP,
UB_DOWN,
UB_LEFT,
UB_RIGHT,
UB_FORWARD,
UB_BACK,
UB_LOOKUP,
UB_LOOKDOWN,
UB_STRAFE,
UB_MOVELEFT,
UB_MOVERIGHT,
UB_BUTTON0,
UB_BUTTON1,
UB_BUTTON2,
UB_BUTTON3,
UB_BUTTON4,
UB_BUTTON5,
UB_BUTTON6,
UB_BUTTON7,
UB_ATTACK,
UB_SPEED,
UB_ZOOM,
UB_SHOWSCORES,
UB_MLOOK,
UB_IMPULSE0,
UB_IMPULSE1,
UB_IMPULSE2,
UB_IMPULSE3,
UB_IMPULSE4,
UB_IMPULSE5,
UB_IMPULSE6,
UB_IMPULSE7,
UB_IMPULSE8,
UB_IMPULSE9,
UB_IMPULSE10,
UB_IMPULSE11,
UB_IMPULSE12,
UB_IMPULSE13,
UB_IMPULSE14,
UB_IMPULSE15,
UB_IMPULSE16,
UB_IMPULSE17,
UB_IMPULSE18,
UB_IMPULSE19,
UB_IMPULSE20,
UB_IMPULSE21,
UB_IMPULSE22,
UB_IMPULSE23,
UB_IMPULSE24,
UB_IMPULSE25,
UB_IMPULSE26,
UB_IMPULSE27,
UB_IMPULSE28,
UB_IMPULSE29,
UB_IMPULSE30,
UB_IMPULSE31,
UB_IMPULSE32,
UB_IMPULSE33,
UB_IMPULSE34,
UB_IMPULSE35,
UB_IMPULSE36,
UB_IMPULSE37,
UB_IMPULSE38,
UB_IMPULSE39,
UB_IMPULSE40,
UB_IMPULSE41,
UB_IMPULSE42,
UB_IMPULSE43,
UB_IMPULSE44,
UB_IMPULSE45,
UB_IMPULSE46,
UB_IMPULSE47,
UB_IMPULSE48,
UB_IMPULSE49,
UB_IMPULSE50,
UB_IMPULSE51,
UB_IMPULSE52,
UB_IMPULSE53,
UB_IMPULSE54,
UB_IMPULSE55,
UB_IMPULSE56,
UB_IMPULSE57,
UB_IMPULSE58,
UB_IMPULSE59,
UB_IMPULSE60,
UB_IMPULSE61,
UB_IMPULSE62,
UB_IMPULSE63,
UB_MAX_BUTTONS
} usercmdButton_t;
static int cmdButtons[UB_MAX_BUTTONS];
static void buttonChange(int state, int key )
{
cmdButtons[key] = !!state;
}
static int getButton(int key)
{
return cmdButtons[key];
}
/*
void PortableAction(int state, int action)
{
LOGI("PortableAction %d %d",state,action);
if ((action >= PORT_ACT_CUSTOM_0) && (action <= PORT_ACT_CUSTOM_17))
{
if( action <= PORT_ACT_CUSTOM_9 )
PortableKeyEvent(state, SDL_SCANCODE_KP_1 + action - PORT_ACT_CUSTOM_0, 0);
else if(action <= PORT_ACT_CUSTOM_17)
PortableKeyEvent(state, SDL_SCANCODE_A + action - PORT_ACT_CUSTOM_10, 0);
}
else if(( PortableGetScreenMode() == TS_MENU ) )
{
if (action >= PORT_ACT_MENU_UP && action <= PORT_ACT_MENU_BACK)
{
int sdl_code [] = { SDL_SCANCODE_UP, SDL_SCANCODE_DOWN, SDL_SCANCODE_LEFT,
SDL_SCANCODE_RIGHT, SDL_SCANCODE_RETURN, SDL_SCANCODE_ESCAPE };
PortableKeyEvent(state, sdl_code[action-PORT_ACT_MENU_UP], 0);
return;
}
// Allow gamepad fire button to select in the menu
if( action == PORT_ACT_ATTACK )
{
if( state )
{
Android_OnMouse(BUTTON_PRIMARY, ACTION_DOWN, 0, 0);
usleep(200 * 1000); // Need this for the PDA to work, needs a frame to react..
Android_OnMouse(BUTTON_PRIMARY, ACTION_UP,0, 0);
}
}
}
else if( PortableGetScreenMode() == TS_PDA )
{
// Allow gamepad fire button to select in the menu
if( action == PORT_ACT_ATTACK )
{
if( state )
{
Android_OnMouse(BUTTON_PRIMARY, ACTION_DOWN, 0, 0);
usleep(200 * 1000); // Need this for the PDA to work, needs a frame to react..
Android_OnMouse(BUTTON_PRIMARY, ACTION_UP,0, 0);
}
}
// Allow pda button to exit the PDA again
if(action == PORT_ACT_HELPCOMP )
{
if (state)
SetImpuse(UB_IMPULSE19);
}
}
else
{
switch (action)
{
case PORT_ACT_LEFT:
buttonChange(state, UB_LEFT);
break;
case PORT_ACT_RIGHT:
buttonChange(state, UB_RIGHT);
break;
case PORT_ACT_FWD:
buttonChange(state, UB_FORWARD);
break;
case PORT_ACT_BACK:
buttonChange(state,UB_BACK);
break;
case PORT_ACT_MOVE_LEFT:
buttonChange(state, UB_MOVELEFT);
break;
case PORT_ACT_MOVE_RIGHT:
buttonChange(state, UB_MOVERIGHT);
break;
case PORT_ACT_ATTACK:
buttonChange(state, UB_ATTACK);
break;
case PORT_ACT_ALT_ATTACK:
break;
case PORT_ACT_TOGGLE_ALT_ATTACK:
break;
case PORT_ACT_JUMP:
buttonChange(state, UB_UP);
break;
case PORT_ACT_DOWN:
buttonChange(state, UB_DOWN);
break;
case PORT_ACT_TOGGLE_CROUCH:
if(state)
getButton(UB_DOWN) ? buttonChange(0, UB_DOWN): buttonChange(1, UB_DOWN);
break;
case PORT_ACT_SPRINT: // Toggles on tap, down/up on long press
{
unsigned int timeNow = Sys_Milliseconds();
static unsigned int timeDown = 0;
static int wasActive = 0;
if(state)
{
wasActive = getButton(UB_SPEED);
buttonChange(1, UB_SPEED); // Need to active
timeDown = timeNow;
}
else
{
if((timeNow - timeDown) < 500) // Was a tap
{
wasActive ? buttonChange(0, UB_SPEED): buttonChange(1, UB_SPEED);
}
else // Long press, speed off
{
buttonChange(0, UB_SPEED);
}
}
}
break;
case PORT_ACT_NEXT_WEP:
if (state)
SetImpuse(UB_IMPULSE14);
break;
case PORT_ACT_PREV_WEP:
if (state)
SetImpuse(UB_IMPULSE15);
break;
case PORT_ACT_RELOAD:
if (state)
SetImpuse(UB_IMPULSE13);
break;
case PORT_ACT_WEAP0:
PortableKeyEvent(state, SDL_SCANCODE_0, 0);
break;
case PORT_ACT_WEAP1:
PortableKeyEvent(state, SDL_SCANCODE_1, 0);
break;
case PORT_ACT_WEAP2:
PortableKeyEvent(state, SDL_SCANCODE_2, 0);
break;
case PORT_ACT_WEAP3:
PortableKeyEvent(state, SDL_SCANCODE_3, 0);
break;
case PORT_ACT_WEAP4:
PortableKeyEvent(state, SDL_SCANCODE_4, 0);
break;
case PORT_ACT_WEAP5:
PortableKeyEvent(state, SDL_SCANCODE_5, 0);
break;
case PORT_ACT_WEAP6:
PortableKeyEvent(state, SDL_SCANCODE_6, 0);
break;
case PORT_ACT_WEAP7:
PortableKeyEvent(state, SDL_SCANCODE_7, 0);
break;
case PORT_ACT_WEAP8:
PortableKeyEvent(state, SDL_SCANCODE_8, 0);
break;
case PORT_ACT_WEAP9:
PortableKeyEvent(state, SDL_SCANCODE_9, 0);
break;
case PORT_ACT_FLASH_LIGHT:
if (state)
{
if(gameType == GAME_DOOM3)
SetImpuse(UB_IMPULSE11);
else if(gameType == GAME_DOOM3_ROE)
SetImpuse(UB_IMPULSE0);
}
break;
case PORT_ACT_ZOOM_IN:
if(state)
getButton(UB_ZOOM) ? buttonChange(0, UB_ZOOM): buttonChange(1, UB_ZOOM);
break;
case PORT_ACT_HELPCOMP:
if (state)
SetImpuse(UB_IMPULSE19);
break;
case PORT_ACT_QUICKLOAD:
if (state)
PortableCommand("loadgame quick");
break;
case PORT_ACT_QUICKSAVE:
if (state)
PortableCommand("savegame quick");
break;
case PORT_ACT_CONSOLE:
if (state)
PortableCommand("toggleconsole");
break;
}
}
}
*/
// =================== FORWARD and SIDE MOVMENT ==============
float forwardmove_android, sidemove_android; //Joystick mode
void PortableMoveFwd(float fwd)
{
if (fwd > 1)
fwd = 1;
else if (fwd < -1)
fwd = -1;
forwardmove_android = fwd;
}
void PortableMoveSide(float strafe)
{
if (strafe > 1)
strafe = 1;
else if (strafe < -1)
strafe = -1;
sidemove_android = strafe;
}
void PortableMove(float fwd, float strafe)
{
PortableMoveFwd(fwd);
PortableMoveSide(strafe);
}
//======================================================================
/*
//Look up and down
float look_pitch_mouse,look_pitch_abs,look_pitch_joy;
void PortableLookPitch(int mode, float pitch)
{
switch(mode)
{
case LOOK_MODE_MOUSE:
look_pitch_mouse += pitch;
break;
case LOOK_MODE_ABSOLUTE:
look_pitch_abs = pitch;
break;
case LOOK_MODE_JOYSTICK:
look_pitch_joy = pitch;
break;
}
}
//left right
float look_yaw_mouse,look_yaw_joy;
void PortableLookYaw(int mode, float yaw)
{
switch(mode)
{
case LOOK_MODE_MOUSE:
look_yaw_mouse += yaw;
break;
case LOOK_MODE_JOYSTICK:
look_yaw_joy = yaw;
break;
}
}
*/
void PortableInit(int argc,const char ** argv){
memset(cmdButtons,0,sizeof(cmdButtons));
main_android(argc,(char **)argv);
}
static float mouseAccumX = 0;
static float mouseAccumY = 0;
#define MIN_MOUSE_MOVE 1
void PortableMouse(float dx,float dy)
{
//LOGI("%f %f",dx,dy);
mouseAccumX += -dx * (float)glConfig.vidWidth * 2.f;
mouseAccumY += -dy * (float)glConfig.vidHeight * 2.f;
if(abs(mouseAccumX) > MIN_MOUSE_MOVE || abs(mouseAccumY) > MIN_MOUSE_MOVE)
{
Android_OnMouse(0, ACTION_MOVE_REL, mouseAccumX, mouseAccumY);
if(abs(mouseAccumX) > MIN_MOUSE_MOVE)
mouseAccumX = 0;
if(abs(mouseAccumY) > MIN_MOUSE_MOVE)
mouseAccumY = 0;
}
}
void PortableMouseButton(int state, int button, float dx,float dy)
{
LOGI("PortableMouseButton %d", state);
//PortableAction(state, PORT_ACT_ATTACK);
//return;
if( state )
Android_OnMouse(BUTTON_PRIMARY, ACTION_DOWN, 0, 0);
else
Android_OnMouse(BUTTON_PRIMARY, ACTION_UP,0, 0);
}
void PortableAutomapControl(float zoom, float x, float y)
{
}
/*
touchscreemode_t PortableGetScreenMode()
{
if(objectiveSystemActive)
return TS_PDA;
else if(inMenu)
return TS_MENU;
else
return TS_GAME;
}
*/
int PortableShowKeyboard(void)
{
return 0;
}
int Android_GetButton( int key )
{
return cmdButtons[key];
}
int Android_GetNextImpulse()
{
int impulse = nextImpulse;
nextImpulse = 0;
return impulse;
}
const char * Android_GetCommand()
{
// Potential race condition here to miss a command, however extremely unlikely to happen
const char *cmd = cmd_to_run;
cmd_to_run = NULL;
return cmd;
}
static bool inCinematic = false;
extern "C" void Doom3Quest_setUseScreenLayer(bool use);
extern "C" void Doom3Quest_processHaptics();
extern "C" void Doom3Quest_getHMDOrientation();
extern "C" void Doom3Quest_getTrackedRemotesOrientation(int);
extern "C" void Doom3Quest_FrameSetup();
void Android_PumpEvents(int screen)
{
inMenu = screen & 0x1;
inGameGuiActive = !!(screen & 0x2);
objectiveSystemActive = !!(screen & 0x4);
inCinematic = !!(screen & 0x8);
Doom3Quest_setUseScreenLayer(inMenu || objectiveSystemActive);
Doom3Quest_setUseScreenLayer(inMenu || objectiveSystemActive || inCinematic);
Doom3Quest_processHaptics();
//Just do all this here for now
Doom3Quest_getHMDOrientation();
Doom3Quest_getTrackedRemotesOrientation(0); // Only right handed for now
Doom3Quest_FrameSetup();
}
extern "C" int blockGamepad( void );
}

View file

@ -584,6 +584,7 @@ void idRenderSystemLocal::BeginFrame( int windowWidth, int windowHeight ) {
cmd->commandId = RC_SET_BUFFER;
cmd->frameCount = frameCount;
cmd->buffer = (int)GL_BACK;
}
void idRenderSystemLocal::WriteDemoPics() {
@ -843,6 +844,7 @@ void idRenderSystemLocal::RenderCommands(renderCrop_t *pc, byte *pix)
R_ClearCommandChain();
}
/*
=============
EndFrame

View file

@ -488,40 +488,7 @@ void RB_ComputeMVP( const drawSurf_t * const surf, float mvp[16] ) {
localProjectionMatrix[14] = backEnd.viewDef->projectionMatrix[14] - surf->space->modelDepthHack;
}
/* if (backEnd.viewDef->viewEntitys != NULL) {
// transform by the camera placement
idVec3 origin;
origin.Zero();
//
if (stereoSide == 0) // left eye
{
origin -= backEnd.viewDef->renderView.viewaxis[0] * 0.065f * 25.0f;
} else // right eye
{
origin += backEnd.viewDef->renderView.viewaxis[0] * 0.065f * 25.0f;
}
float viewerMatrix[16];
memset(viewerMatrix, 0, sizeof(float) * 16);
viewerMatrix[0] = 1;
viewerMatrix[5] = 1;
viewerMatrix[10] = 1;
viewerMatrix[12] = origin[0];
viewerMatrix[13] = origin[1];
viewerMatrix[14] = origin[2];
viewerMatrix[15] = 1;
float temp[16];
myGlMultMatrix(viewerMatrix, surf->space->modelViewMatrix, temp);
// precompute the MVP
myGlMultMatrix(temp, localProjectionMatrix, mvp);
}
else
*/ {
myGlMultMatrix(surf->space->modelViewMatrix, localProjectionMatrix, mvp);
}
myGlMultMatrix(surf->space->modelViewMatrix, localProjectionMatrix, mvp);
}
/*

View file

@ -306,8 +306,6 @@ static void RB_SetBuffer( const void *data ) {
GLimp_SetupFrame();
GLimp_SetupEyeBuffer();
// clear screen for debugging
// automatically enable this with several other debug tools
@ -388,8 +386,6 @@ void RB_ExecuteBackEndCommands( const emptyCommand_t *cmds ) {
return;
}
//Do this all twice.. once for each eye
for (int i = 0; i < 2; ++i)
{
const emptyCommand_t *cmd = cmds;

View file

@ -1078,7 +1078,6 @@ void GLimp_Shutdown( void );
// and resets the gamma ramps.
void GLimp_SetupFrame( void );
void GLimp_SetupEyeBuffer( void );
void GLimp_SwapBuffers( void );
// Calls the system specific swapbuffers routine, and may also perform

View file

@ -861,7 +861,6 @@ void R_SetViewMatrix( viewDef_t *viewDef ) {
0, 0, 0, 1
};
//for (int eye = 0; eye < 2; ++eye)
{
world = &(viewDef->worldSpace);
@ -875,16 +874,6 @@ void R_SetViewMatrix( viewDef_t *viewDef ) {
// transform by the camera placement
origin = viewDef->renderView.vieworg;
//
/* if (eye == 0) // left eye
{
origin -= viewDef->renderView.viewaxis[1] * 0.065f * 38.0f;
}
else if (eye == 1) // right eye
{
origin += viewDef->renderView.viewaxis[1] * 0.065f * 38.0f;
}
*/
viewerMatrix[0] = viewDef->renderView.viewaxis[0][0];
viewerMatrix[4] = viewDef->renderView.viewaxis[0][1];
viewerMatrix[8] = viewDef->renderView.viewaxis[0][2];

View file

@ -748,7 +748,6 @@ void Sys_ClearEvents() {
event_list.SetNum(0, false);
}
extern "C" const char * Android_GetCommand();
/*
================
Sys_GenerateEvents
@ -760,13 +759,13 @@ void Sys_GenerateEvents() {
if (s)
PushConsoleEvent(s);
const char * cmd = Android_GetCommand();
/* const char * cmd = Android_GetCommand();
if(cmd)
{
cmdSystem->BufferCommandText( CMD_EXEC_NOW, cmd );
//cmdSystem->BufferCommandText( CMD_EXEC_NOW, "\n" );
}
*/
//SDL_PumpEvents();
}

View file

@ -142,19 +142,12 @@ void GLimp_Shutdown() {
int stereoSide = 0;
void GLimp_SetupFrame() {
if (stereoSide == 0) {
Doom3Quest_FrameSetup();
Doom3Quest_processMessageQueue();
}
}
void GLimp_SetupEyeBuffer( void )
{
//Only do this if we have drawn both buffers and are back to the first buffer
if (stereoSide == 0) {
Doom3Quest_processMessageQueue();
Doom3Quest_prepareEyeBuffer(0);
} else {
Doom3Quest_prepareEyeBuffer(1);
}
}
@ -169,6 +162,7 @@ void GLimp_SwapBuffers() {
if (stereoSide == 0)
{
Doom3Quest_finishEyeBuffer(0);
Doom3Quest_prepareEyeBuffer(1);
stereoSide = 1;
}
else