mirror of
https://github.com/DrBeef/JKXR.git
synced 2024-11-10 06:42:17 +00:00
Step to make the code reuseable
Tried to separate out the game specific logic in the JKVR files from the generic OpenXR and other boilerplate stuff that each port will need
This commit is contained in:
parent
6e61785dcd
commit
23121a528b
22 changed files with 2532 additions and 2580 deletions
File diff suppressed because it is too large
Load diff
|
@ -141,7 +141,7 @@ qboolean useSimpleProfile = qfalse;
|
|||
float vibration_channel_duration[2] = {0.0f, 0.0f};
|
||||
float vibration_channel_intensity[2] = {0.0f, 0.0f};
|
||||
|
||||
void JKVR_InitActions( void )
|
||||
void TBXR_InitActions( void )
|
||||
{
|
||||
// Actions
|
||||
runningActionSet = CreateActionSet(1, "running_action_set", "Action Set used on main loop");
|
||||
|
@ -358,7 +358,7 @@ void JKVR_InitActions( void )
|
|||
inputInitialized = qtrue;
|
||||
}
|
||||
|
||||
void JKVR_SyncActions( void )
|
||||
void TBXR_SyncActions( void )
|
||||
{
|
||||
// sync action data
|
||||
XrActiveActionSet activeActionSet = {};
|
||||
|
@ -379,9 +379,9 @@ void JKVR_SyncActions( void )
|
|||
getInfo.subactionPath = XR_NULL_PATH;
|
||||
}
|
||||
|
||||
void JKVR_UpdateControllers( )
|
||||
void TBXR_UpdateControllers( )
|
||||
{
|
||||
JKVR_SyncActions();
|
||||
TBXR_SyncActions();
|
||||
|
||||
//get controller poses
|
||||
XrAction controller[] = {handPoseLeftAction, handPoseRightAction};
|
||||
|
@ -440,7 +440,7 @@ void JKVR_UpdateControllers( )
|
|||
rightTrackedRemoteState_new.Joystick.y = moveJoystickState.currentState.y;
|
||||
}
|
||||
|
||||
void JKVR_Vibrate( int duration, int chan, float intensity )
|
||||
void TBXR_Vibrate( int duration, int chan, float intensity )
|
||||
{
|
||||
for (int i = 0; i < 2; ++i)
|
||||
{
|
||||
|
@ -459,7 +459,7 @@ void JKVR_Vibrate( int duration, int chan, float intensity )
|
|||
}
|
||||
}
|
||||
|
||||
void JKVR_processHaptics() {
|
||||
void TBXR_ProcessHaptics() {
|
||||
static float lastFrameTime = 0.0f;
|
||||
float timestamp = (float)(Sys_Milliseconds( ));
|
||||
float frametime = timestamp - lastFrameTime;
|
||||
|
|
|
@ -104,7 +104,7 @@ XrActionStateVector2f GetActionStateVector2(XrAction action, int hand) {
|
|||
return state;
|
||||
}
|
||||
|
||||
void JKVR_InitActions( void )
|
||||
void TBXR_InitActions( void )
|
||||
{
|
||||
// Create an action set.
|
||||
{
|
||||
|
@ -505,7 +505,7 @@ void JKVR_InitActions( void )
|
|||
CHECK_XRCMD(xrAttachSessionActionSets(gAppState.Session, &attachInfo));
|
||||
}
|
||||
|
||||
void JKVR_SyncActions( void )
|
||||
void TBXR_SyncActions( void )
|
||||
{
|
||||
XrActiveActionSet activeActionSet = {};
|
||||
activeActionSet.actionSet = actionSet;
|
||||
|
@ -517,9 +517,9 @@ void JKVR_SyncActions( void )
|
|||
CHECK_XRCMD(xrSyncActions(gAppState.Session, &syncInfo));
|
||||
}
|
||||
|
||||
void JKVR_UpdateControllers( )
|
||||
void TBXR_UpdateControllers( )
|
||||
{
|
||||
JKVR_SyncActions();
|
||||
TBXR_SyncActions();
|
||||
|
||||
//get controller poses
|
||||
for (int i = 0; i < 2; i++) {
|
||||
|
@ -576,7 +576,7 @@ void JKVR_UpdateControllers( )
|
|||
float vibration_channel_duration[2] = {0.0f, 0.0f};
|
||||
float vibration_channel_intensity[2] = {0.0f, 0.0f};
|
||||
|
||||
void JKVR_Vibrate( int duration, int chan, float intensity )
|
||||
void TBXR_Vibrate( int duration, int chan, float intensity )
|
||||
{
|
||||
for (int i = 0; i < 2; ++i)
|
||||
{
|
||||
|
@ -595,7 +595,7 @@ void JKVR_Vibrate( int duration, int chan, float intensity )
|
|||
}
|
||||
}
|
||||
|
||||
void JKVR_processHaptics() {
|
||||
void TBXR_processHaptics() {
|
||||
static float lastFrameTime = 0.0f;
|
||||
float timestamp = (float)(Sys_Milliseconds( ));
|
||||
float frametime = timestamp - lastFrameTime;
|
||||
|
|
2055
Projects/Android/jni/JKVR/TBXR_Common.cpp
Normal file
2055
Projects/Android/jni/JKVR/TBXR_Common.cpp
Normal file
File diff suppressed because it is too large
Load diff
331
Projects/Android/jni/JKVR/TBXR_Common.h
Normal file
331
Projects/Android/jni/JKVR/TBXR_Common.h
Normal file
|
@ -0,0 +1,331 @@
|
|||
#if !defined(tbxr_common_h)
|
||||
#define tbxr_common_h
|
||||
|
||||
//OpenXR
|
||||
#define XR_USE_GRAPHICS_API_OPENGL_ES 1
|
||||
#define XR_USE_PLATFORM_ANDROID 1
|
||||
#include <EGL/egl.h>
|
||||
#include <EGL/eglext.h>
|
||||
#include <GLES3/gl3.h>
|
||||
#include <GLES3/gl3ext.h>
|
||||
#include <jni.h>
|
||||
#include <openxr/openxr.h>
|
||||
#include <openxr/openxr_platform.h>
|
||||
#include <openxr/openxr_oculus_helpers.h>
|
||||
|
||||
#include <android/native_window_jni.h>
|
||||
#include <android/log.h>
|
||||
|
||||
#ifndef NDEBUG
|
||||
#define DEBUG 1
|
||||
#endif
|
||||
|
||||
#define LOG_TAG "TBXR"
|
||||
|
||||
|
||||
#define ALOGE(...) __android_log_print( ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__ )
|
||||
|
||||
#if DEBUG
|
||||
#define ALOGV(...) __android_log_print( ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__ )
|
||||
#else
|
||||
#define ALOGV(...)
|
||||
#endif
|
||||
|
||||
enum { ovrMaxLayerCount = 1 };
|
||||
enum { ovrMaxNumEyes = 2 };
|
||||
|
||||
typedef enum xrButton_ {
|
||||
xrButton_A = 0x00000001, // Set for trigger pulled on the Gear VR and Go Controllers
|
||||
xrButton_B = 0x00000002,
|
||||
xrButton_RThumb = 0x00000004,
|
||||
xrButton_RShoulder = 0x00000008,
|
||||
xrButton_X = 0x00000100,
|
||||
xrButton_Y = 0x00000200,
|
||||
xrButton_LThumb = 0x00000400,
|
||||
xrButton_LShoulder = 0x00000800,
|
||||
xrButton_Up = 0x00010000,
|
||||
xrButton_Down = 0x00020000,
|
||||
xrButton_Left = 0x00040000,
|
||||
xrButton_Right = 0x00080000,
|
||||
xrButton_Enter = 0x00100000,
|
||||
xrButton_Back = 0x00200000,
|
||||
xrButton_GripTrigger = 0x04000000,
|
||||
xrButton_Trigger = 0x20000000,
|
||||
xrButton_Joystick = 0x80000000,
|
||||
xrButton_EnumSize = 0x7fffffff
|
||||
} xrButton;
|
||||
|
||||
typedef struct {
|
||||
uint32_t Buttons;
|
||||
float IndexTrigger;
|
||||
float GripTrigger;
|
||||
XrVector2f Joystick;
|
||||
} ovrInputStateTrackedRemote;
|
||||
|
||||
typedef struct {
|
||||
GLboolean Active;
|
||||
XrPosef Pose;
|
||||
XrSpaceVelocity Velocity;
|
||||
} ovrTrackedController;
|
||||
|
||||
typedef enum control_scheme {
|
||||
RIGHT_HANDED_DEFAULT = 0,
|
||||
LEFT_HANDED_DEFAULT = 10,
|
||||
WEAPON_ALIGN = 99
|
||||
} control_scheme_t;
|
||||
|
||||
typedef struct {
|
||||
float M[4][4];
|
||||
} ovrMatrix4f;
|
||||
|
||||
|
||||
typedef struct {
|
||||
XrSwapchain Handle;
|
||||
uint32_t Width;
|
||||
uint32_t Height;
|
||||
} ovrSwapChain;
|
||||
|
||||
typedef struct {
|
||||
int Width;
|
||||
int Height;
|
||||
int Multisamples;
|
||||
uint32_t TextureSwapChainLength;
|
||||
uint32_t TextureSwapChainIndex;
|
||||
ovrSwapChain ColorSwapChain;
|
||||
XrSwapchainImageOpenGLESKHR* ColorSwapChainImage;
|
||||
GLuint* DepthBuffers;
|
||||
GLuint* FrameBuffers;
|
||||
} ovrFramebuffer;
|
||||
|
||||
/*
|
||||
================================================================================
|
||||
|
||||
ovrRenderer
|
||||
|
||||
================================================================================
|
||||
*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ovrFramebuffer FrameBuffer[ovrMaxNumEyes];
|
||||
} ovrRenderer;
|
||||
|
||||
/*
|
||||
================================================================================
|
||||
|
||||
ovrApp
|
||||
|
||||
================================================================================
|
||||
*/
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
MQ_WAIT_NONE, // don't wait
|
||||
MQ_WAIT_RECEIVED, // wait until the consumer thread has received the message
|
||||
MQ_WAIT_PROCESSED // wait until the consumer thread has processed the message
|
||||
} ovrMQWait;
|
||||
|
||||
#define MAX_MESSAGE_PARMS 8
|
||||
#define MAX_MESSAGES 1024
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int Id;
|
||||
ovrMQWait Wait;
|
||||
long long Parms[MAX_MESSAGE_PARMS];
|
||||
} srufaceMessage;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
srufaceMessage Messages[MAX_MESSAGES];
|
||||
volatile int Head; // dequeue at the head
|
||||
volatile int Tail; // enqueue at the tail
|
||||
ovrMQWait Wait;
|
||||
volatile bool EnabledFlag;
|
||||
volatile bool PostedFlag;
|
||||
volatile bool ReceivedFlag;
|
||||
volatile bool ProcessedFlag;
|
||||
pthread_mutex_t Mutex;
|
||||
pthread_cond_t PostedCondition;
|
||||
pthread_cond_t ReceivedCondition;
|
||||
pthread_cond_t ProcessedCondition;
|
||||
} surfaceMessageQueue;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
JavaVM * JavaVm;
|
||||
jobject ActivityObject;
|
||||
jclass ActivityClass;
|
||||
pthread_t Thread;
|
||||
surfaceMessageQueue MessageQueue;
|
||||
ANativeWindow * NativeWindow;
|
||||
} ovrAppThread;
|
||||
|
||||
|
||||
typedef union {
|
||||
XrCompositionLayerProjection Projection;
|
||||
XrCompositionLayerQuad Quad;
|
||||
} xrCompositorLayer_Union;
|
||||
|
||||
#define GL(func) func;
|
||||
|
||||
// Forward declarations
|
||||
XrInstance TBXR_GetXrInstance();
|
||||
|
||||
#if defined(DEBUG)
|
||||
static void
|
||||
OXR_CheckErrors(XrInstance instance, XrResult result, const char* function, bool failOnError) {
|
||||
if (XR_FAILED(result)) {
|
||||
char errorBuffer[XR_MAX_RESULT_STRING_SIZE];
|
||||
xrResultToString(instance, result, errorBuffer);
|
||||
if (failOnError) {
|
||||
ALOGE("OpenXR error: %s: %s\n", function, errorBuffer);
|
||||
} else {
|
||||
ALOGV("OpenXR error: %s: %s\n", function, errorBuffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(DEBUG)
|
||||
#define OXR(func) OXR_CheckErrors(TBXR_GetXrInstance(), func, #func, true);
|
||||
#else
|
||||
#define OXR(func) func;
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
EGLint MajorVersion;
|
||||
EGLint MinorVersion;
|
||||
EGLDisplay Display;
|
||||
EGLConfig Config;
|
||||
EGLSurface TinySurface;
|
||||
EGLSurface MainSurface;
|
||||
EGLContext Context;
|
||||
} ovrEgl;
|
||||
|
||||
/// Java details about an activity
|
||||
typedef struct ovrJava_ {
|
||||
JavaVM* Vm; //< Java Virtual Machine
|
||||
JNIEnv* Env; //< Thread specific environment
|
||||
jobject ActivityObject; //< Java activity object
|
||||
} ovrJava;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ovrJava Java;
|
||||
ovrEgl Egl;
|
||||
ANativeWindow* NativeWindow;
|
||||
bool Resumed;
|
||||
bool Focused;
|
||||
bool FrameSetup;
|
||||
|
||||
float Width;
|
||||
float Height;
|
||||
|
||||
XrInstance Instance;
|
||||
XrSession Session;
|
||||
XrViewConfigurationProperties ViewportConfig;
|
||||
XrViewConfigurationView ViewConfigurationView[ovrMaxNumEyes];
|
||||
XrSystemId SystemId;
|
||||
XrSpace HeadSpace;
|
||||
XrSpace StageSpace;
|
||||
XrSpace FakeStageSpace;
|
||||
XrSpace CurrentSpace;
|
||||
GLboolean SessionActive;
|
||||
XrPosef xfStageFromHead;
|
||||
XrView* Projections;
|
||||
XrMatrix4x4f ProjectionMatrices[2];
|
||||
|
||||
|
||||
float currentDisplayRefreshRate;
|
||||
float* SupportedDisplayRefreshRates;
|
||||
uint32_t RequestedDisplayRefreshRateIndex;
|
||||
uint32_t NumSupportedDisplayRefreshRates;
|
||||
PFN_xrGetDisplayRefreshRateFB pfnGetDisplayRefreshRate;
|
||||
PFN_xrRequestDisplayRefreshRateFB pfnRequestDisplayRefreshRate;
|
||||
|
||||
XrTime PredictedDisplayTime;
|
||||
int SwapInterval;
|
||||
int MainThreadTid;
|
||||
int RenderThreadTid;
|
||||
xrCompositorLayer_Union Layers[ovrMaxLayerCount];
|
||||
int LayerCount;
|
||||
ovrRenderer Renderer;
|
||||
ovrTrackedController TrackedController[2];
|
||||
} ovrApp;
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
MESSAGE_ON_CREATE,
|
||||
MESSAGE_ON_START,
|
||||
MESSAGE_ON_RESUME,
|
||||
MESSAGE_ON_PAUSE,
|
||||
MESSAGE_ON_STOP,
|
||||
MESSAGE_ON_DESTROY,
|
||||
MESSAGE_ON_SURFACE_CREATED,
|
||||
MESSAGE_ON_SURFACE_DESTROYED
|
||||
};
|
||||
|
||||
extern ovrAppThread * gAppThread;
|
||||
extern ovrApp gAppState;
|
||||
extern ovrJava java;
|
||||
|
||||
|
||||
void ovrTrackedController_Clear(ovrTrackedController* controller);
|
||||
|
||||
void * AppThreadFunction(void * parm );
|
||||
|
||||
void ovrAppThread_Create( ovrAppThread * appThread, JNIEnv * env, jobject activityObject, jclass activityClass );
|
||||
void ovrAppThread_Destroy( ovrAppThread * appThread, JNIEnv * env );
|
||||
|
||||
/*
|
||||
* Surface Lifecycle Message Queue
|
||||
*/
|
||||
void surfaceMessage_Init(srufaceMessage * message, const int id, const int wait );
|
||||
void * surfaceMessage_GetPointerParm(srufaceMessage * message, int index );
|
||||
void surfaceMessage_SetPointerParm(srufaceMessage * message, int index, void * ptr );
|
||||
|
||||
void surfaceMessageQueue_Create(surfaceMessageQueue * messageQueue );
|
||||
void surfaceMessageQueue_Destroy(surfaceMessageQueue * messageQueue );
|
||||
void surfaceMessageQueue_Enable(surfaceMessageQueue * messageQueue, const bool set );
|
||||
void surfaceMessageQueue_PostMessage(surfaceMessageQueue * messageQueue, const srufaceMessage * message );
|
||||
|
||||
//Functions that need to be implemented by the game specific code
|
||||
void VR_FrameSetup();
|
||||
bool VR_UseScreenLayer();
|
||||
float VR_GetScreenLayerDistance();
|
||||
bool VR_GetVRProjection(int eye, float zNear, float zFar, float* projection);
|
||||
void VR_HandleControllerInput();
|
||||
void VR_SetHMDOrientation(float pitch, float yaw, float roll );
|
||||
void VR_SetHMDPosition(float x, float y, float z );
|
||||
void VR_HapticEvent(const char* event, int position, int flags, int intensity, float angle, float yHeight );
|
||||
void VR_HapticUpdateEvent(const char* event, int intensity, float angle );
|
||||
void VR_HapticEndFrame();
|
||||
void VR_HapticStopEvent(const char* event);
|
||||
void VR_HapticEnable();
|
||||
void VR_HapticDisable();
|
||||
extern "C" void VR_Shutdown();
|
||||
|
||||
|
||||
//Reusable Team Beef OpenXR stuff (in TBXR_Common.cpp)
|
||||
double TBXR_GetTimeInMilliSeconds();
|
||||
int TBXR_GetRefresh();
|
||||
void TBXR_Recenter();
|
||||
void TBXR_InitialiseOpenXR();
|
||||
void TBXR_WaitForSessionActive();
|
||||
void TBXR_InitRenderer();
|
||||
void TBXR_EnterVR();
|
||||
void TBXR_GetScreenRes(int *width, int *height);
|
||||
void TBXR_InitActions( void );
|
||||
void TBXR_Vibrate(int duration, int channel, float intensity );
|
||||
void TBXR_ProcessHaptics();
|
||||
void TBXR_FrameSetup();
|
||||
void TBXR_updateProjections();
|
||||
void TBXR_UpdateControllers( );
|
||||
void TBXR_prepareEyeBuffer(int eye );
|
||||
void TBXR_finishEyeBuffer(int eye );
|
||||
void TBXR_submitFrame();
|
||||
|
||||
#endif //vrcommon_h
|
|
@ -1,240 +1,18 @@
|
|||
#if !defined(vrcommon_h)
|
||||
#define vrcommon_h
|
||||
|
||||
//OpenXR
|
||||
#define XR_USE_GRAPHICS_API_OPENGL_ES 1
|
||||
#define XR_USE_PLATFORM_ANDROID 1
|
||||
#include <EGL/egl.h>
|
||||
#include <EGL/eglext.h>
|
||||
#include <GLES3/gl3.h>
|
||||
#include <GLES3/gl3ext.h>
|
||||
#include <jni.h>
|
||||
#include <openxr/openxr.h>
|
||||
#include <openxr/openxr_platform.h>
|
||||
#include <openxr/openxr_oculus_helpers.h>
|
||||
|
||||
#include <android/native_window_jni.h>
|
||||
#include <android/log.h>
|
||||
|
||||
#include "../qcommon/q_shared.h"
|
||||
#include "../qcommon/qcommon.h"
|
||||
|
||||
#include "VrClientInfo.h"
|
||||
|
||||
#define LOG_TAG "JKVR"
|
||||
|
||||
#ifndef NDEBUG
|
||||
#define DEBUG 1
|
||||
#endif
|
||||
|
||||
#define ALOGE(...) __android_log_print( ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__ )
|
||||
|
||||
#if DEBUG
|
||||
#define ALOGV(...) __android_log_print( ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__ )
|
||||
#else
|
||||
#define ALOGV(...)
|
||||
#endif
|
||||
|
||||
enum { ovrMaxLayerCount = 1 };
|
||||
enum { ovrMaxNumEyes = 2 };
|
||||
|
||||
typedef enum xrButton_ {
|
||||
xrButton_A = 0x00000001, // Set for trigger pulled on the Gear VR and Go Controllers
|
||||
xrButton_B = 0x00000002,
|
||||
xrButton_RThumb = 0x00000004,
|
||||
xrButton_RShoulder = 0x00000008,
|
||||
xrButton_X = 0x00000100,
|
||||
xrButton_Y = 0x00000200,
|
||||
xrButton_LThumb = 0x00000400,
|
||||
xrButton_LShoulder = 0x00000800,
|
||||
xrButton_Up = 0x00010000,
|
||||
xrButton_Down = 0x00020000,
|
||||
xrButton_Left = 0x00040000,
|
||||
xrButton_Right = 0x00080000,
|
||||
xrButton_Enter = 0x00100000,
|
||||
xrButton_Back = 0x00200000,
|
||||
xrButton_GripTrigger = 0x04000000,
|
||||
xrButton_Trigger = 0x20000000,
|
||||
xrButton_Joystick = 0x80000000,
|
||||
xrButton_EnumSize = 0x7fffffff
|
||||
} xrButton;
|
||||
|
||||
typedef struct ovrInputStateTrackedRemote_ {
|
||||
uint32_t Buttons;
|
||||
float IndexTrigger;
|
||||
float GripTrigger;
|
||||
XrVector2f Joystick;
|
||||
} ovrInputStateTrackedRemote;
|
||||
|
||||
typedef struct {
|
||||
GLboolean Active;
|
||||
XrPosef Pose;
|
||||
XrSpaceVelocity Velocity;
|
||||
} ovrTrackedController;
|
||||
|
||||
typedef enum control_scheme {
|
||||
RIGHT_HANDED_DEFAULT = 0,
|
||||
LEFT_HANDED_DEFAULT = 10,
|
||||
WEAPON_ALIGN = 99
|
||||
} control_scheme_t;
|
||||
|
||||
typedef struct {
|
||||
float M[4][4];
|
||||
} ovrMatrix4f;
|
||||
#include "TBXR_Common.h"
|
||||
|
||||
|
||||
typedef struct {
|
||||
XrSwapchain Handle;
|
||||
uint32_t Width;
|
||||
uint32_t Height;
|
||||
} ovrSwapChain;
|
||||
|
||||
typedef struct {
|
||||
int Width;
|
||||
int Height;
|
||||
int Multisamples;
|
||||
uint32_t TextureSwapChainLength;
|
||||
uint32_t TextureSwapChainIndex;
|
||||
ovrSwapChain ColorSwapChain;
|
||||
XrSwapchainImageOpenGLESKHR* ColorSwapChainImage;
|
||||
GLuint* DepthBuffers;
|
||||
GLuint* FrameBuffers;
|
||||
} ovrFramebuffer;
|
||||
|
||||
|
||||
/*
|
||||
================================================================================
|
||||
|
||||
ovrRenderer
|
||||
|
||||
================================================================================
|
||||
*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ovrFramebuffer FrameBuffer[ovrMaxNumEyes];
|
||||
ovrMatrix4f ProjectionMatrix;
|
||||
int NumBuffers;
|
||||
} ovrRenderer;
|
||||
|
||||
/*
|
||||
================================================================================
|
||||
|
||||
ovrApp
|
||||
|
||||
================================================================================
|
||||
*/
|
||||
|
||||
typedef union {
|
||||
XrCompositionLayerProjection Projection;
|
||||
XrCompositionLayerQuad Quad;
|
||||
} ovrCompositorLayer_Union;
|
||||
|
||||
#define GL(func) func;
|
||||
|
||||
// Forward declarations
|
||||
XrInstance ovrApp_GetInstance();
|
||||
|
||||
#if defined(DEBUG)
|
||||
static void
|
||||
OXR_CheckErrors(XrInstance instance, XrResult result, const char* function, bool failOnError) {
|
||||
if (XR_FAILED(result)) {
|
||||
char errorBuffer[XR_MAX_RESULT_STRING_SIZE];
|
||||
xrResultToString(instance, result, errorBuffer);
|
||||
if (failOnError) {
|
||||
ALOGE("OpenXR error: %s: %s\n", function, errorBuffer);
|
||||
} else {
|
||||
ALOGV("OpenXR error: %s: %s\n", function, errorBuffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(DEBUG)
|
||||
#define OXR(func) OXR_CheckErrors(ovrApp_GetInstance(), func, #func, true);
|
||||
#else
|
||||
#define OXR(func) func;
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
EGLint MajorVersion;
|
||||
EGLint MinorVersion;
|
||||
EGLDisplay Display;
|
||||
EGLConfig Config;
|
||||
EGLSurface TinySurface;
|
||||
EGLSurface MainSurface;
|
||||
EGLContext Context;
|
||||
} ovrEgl;
|
||||
|
||||
/// Java details about an activity
|
||||
typedef struct ovrJava_ {
|
||||
JavaVM* Vm; //< Java Virtual Machine
|
||||
JNIEnv* Env; //< Thread specific environment
|
||||
jobject ActivityObject; //< Java activity object
|
||||
} ovrJava;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ovrJava Java;
|
||||
ovrEgl Egl;
|
||||
ANativeWindow* NativeWindow;
|
||||
bool Resumed;
|
||||
bool Focused;
|
||||
bool FrameSetup;
|
||||
|
||||
XrInstance Instance;
|
||||
XrSession Session;
|
||||
XrViewConfigurationProperties ViewportConfig;
|
||||
XrViewConfigurationView ViewConfigurationView[ovrMaxNumEyes];
|
||||
XrSystemId SystemId;
|
||||
XrSpace HeadSpace;
|
||||
XrSpace StageSpace;
|
||||
XrSpace FakeStageSpace;
|
||||
XrSpace CurrentSpace;
|
||||
GLboolean SessionActive;
|
||||
XrPosef xfStageFromHead;
|
||||
XrView* Projections;
|
||||
XrMatrix4x4f ProjectionMatrices[2];
|
||||
|
||||
|
||||
float currentDisplayRefreshRate;
|
||||
float* SupportedDisplayRefreshRates;
|
||||
uint32_t RequestedDisplayRefreshRateIndex;
|
||||
uint32_t NumSupportedDisplayRefreshRates;
|
||||
PFN_xrGetDisplayRefreshRateFB pfnGetDisplayRefreshRate;
|
||||
PFN_xrRequestDisplayRefreshRateFB pfnRequestDisplayRefreshRate;
|
||||
|
||||
XrTime PredictedDisplayTime;
|
||||
long long FrameIndex;
|
||||
int SwapInterval;
|
||||
int CpuLevel;
|
||||
int GpuLevel;
|
||||
int MainThreadTid;
|
||||
int RenderThreadTid;
|
||||
ovrCompositorLayer_Union Layers[ovrMaxLayerCount];
|
||||
int LayerCount;
|
||||
ovrRenderer Renderer;
|
||||
ovrTrackedController TrackedController[2];
|
||||
} ovrApp;
|
||||
|
||||
|
||||
extern bool openjk_initialised;
|
||||
extern long long global_time;
|
||||
extern int ducked;
|
||||
extern vr_client_info_t vr;
|
||||
|
||||
void ovrTrackedController_Clear(ovrTrackedController* controller);
|
||||
|
||||
ovrMatrix4f ovrMatrix4f_Multiply(const ovrMatrix4f* a, const ovrMatrix4f* b);
|
||||
ovrMatrix4f ovrMatrix4f_CreateRotation(const float radiansX, const float radiansY, const float radiansZ);
|
||||
ovrMatrix4f ovrMatrix4f_CreateFromQuaternion(const XrQuaternionf* q);
|
||||
|
||||
XrVector4f XrVector4f_MultiplyMatrix4f(const ovrMatrix4f* a, const XrVector4f* v);
|
||||
|
||||
float radians(float deg);
|
||||
float degrees(float rad);
|
||||
bool isMultiplayer();
|
||||
double GetTimeInMilliSeconds();
|
||||
float length(float x, float y);
|
||||
float nonLinearFilter(float in);
|
||||
bool between(float min, float val, float max);
|
||||
|
@ -242,34 +20,5 @@ void rotateAboutOrigin(float v1, float v2, float rotation, vec2_t out);
|
|||
void QuatToYawPitchRoll(XrQuaternionf q, vec3_t rotation, vec3_t out);
|
||||
void handleTrackedControllerButton(ovrInputStateTrackedRemote * trackedRemoteState, ovrInputStateTrackedRemote * prevTrackedRemoteState, uint32_t button, int key);
|
||||
void interactWithTouchScreen(bool reset, ovrInputStateTrackedRemote *newState, ovrInputStateTrackedRemote *oldState);
|
||||
int GetRefresh();
|
||||
|
||||
void VR_Recenter();
|
||||
|
||||
//Called from engine code
|
||||
bool JKVR_useScreenLayer();
|
||||
bool JKVR_GetVRProjection(int eye, float zNear, float zFar, float* projection);
|
||||
void JKVR_GetScreenRes(int *width, int *height);
|
||||
void JKVR_InitActions( void );
|
||||
void JKVR_Vibrate(int duration, int channel, float intensity );
|
||||
void JKVR_Haptic(int duration, int channel, float intensity, char *description, float yaw, float height);
|
||||
void JKVR_HapticEvent(const char* event, int position, int flags, int intensity, float angle, float yHeight );
|
||||
void JKVR_HapticUpdateEvent(const char* event, int intensity, float angle );
|
||||
void JKVR_HapticEndFrame();
|
||||
void JKVR_HapticStopEvent(const char* event);
|
||||
void JKVR_HapticEnable();
|
||||
void JKVR_HapticDisable();
|
||||
void JKVR_processMessageQueue();
|
||||
void JKVR_FrameSetup();
|
||||
void JKVR_processHaptics();
|
||||
void JKVR_getHMDOrientation( );
|
||||
void JKVR_getTrackedRemotesOrientation();
|
||||
void JKVR_updateProjections();
|
||||
void JKVR_UpdateControllers( );
|
||||
|
||||
bool JKVR_useScreenLayer();
|
||||
void JKVR_prepareEyeBuffer(int eye );
|
||||
void JKVR_finishEyeBuffer(int eye );
|
||||
void JKVR_submitFrame();
|
||||
|
||||
#endif //vrcommon_h
|
|
@ -48,7 +48,6 @@ float remote_movementForward;
|
|||
float remote_movementUp;
|
||||
float positional_movementSideways;
|
||||
float positional_movementForward;
|
||||
bool openjk_initialised;
|
||||
long long global_time;
|
||||
int ducked;
|
||||
vr_client_info_t vr;
|
||||
|
@ -63,7 +62,6 @@ void handleTrackedControllerButton(ovrInputStateTrackedRemote * trackedRemoteSta
|
|||
if ((trackedRemoteState->Buttons & button) != (prevTrackedRemoteState->Buttons & button))
|
||||
{
|
||||
Sys_QueEvent( 0, SE_KEY, key, (trackedRemoteState->Buttons & button) != 0, 0, NULL );
|
||||
// Key_Event(key, (trackedRemoteState->Buttons & button) != 0, global_time);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -143,194 +141,3 @@ void interactWithTouchScreen(bool reset, ovrInputStateTrackedRemote *newState, o
|
|||
|
||||
PortableMouseAbs(cursorX, cursorY);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
================================================================================
|
||||
|
||||
ovrMatrix4f
|
||||
|
||||
================================================================================
|
||||
*/
|
||||
|
||||
ovrMatrix4f ovrMatrix4f_CreateProjectionFov(
|
||||
const float angleLeft,
|
||||
const float angleRight,
|
||||
const float angleUp,
|
||||
const float angleDown,
|
||||
const float nearZ,
|
||||
const float farZ) {
|
||||
|
||||
const float tanAngleLeft = tanf(angleLeft);
|
||||
const float tanAngleRight = tanf(angleRight);
|
||||
|
||||
const float tanAngleDown = tanf(angleDown);
|
||||
const float tanAngleUp = tanf(angleUp);
|
||||
|
||||
const float tanAngleWidth = tanAngleRight - tanAngleLeft;
|
||||
|
||||
// Set to tanAngleDown - tanAngleUp for a clip space with positive Y
|
||||
// down (Vulkan). Set to tanAngleUp - tanAngleDown for a clip space with
|
||||
// positive Y up (OpenGL / D3D / Metal).
|
||||
const float tanAngleHeight = tanAngleUp - tanAngleDown;
|
||||
|
||||
// Set to nearZ for a [-1,1] Z clip space (OpenGL / OpenGL ES).
|
||||
// Set to zero for a [0,1] Z clip space (Vulkan / D3D / Metal).
|
||||
const float offsetZ = nearZ;
|
||||
|
||||
ovrMatrix4f result;
|
||||
if (farZ <= nearZ) {
|
||||
// place the far plane at infinity
|
||||
result.M[0][0] = 2 / tanAngleWidth;
|
||||
result.M[0][1] = 0;
|
||||
result.M[0][2] = (tanAngleRight + tanAngleLeft) / tanAngleWidth;
|
||||
result.M[0][3] = 0;
|
||||
|
||||
result.M[1][0] = 0;
|
||||
result.M[1][1] = 2 / tanAngleHeight;
|
||||
result.M[1][2] = (tanAngleUp + tanAngleDown) / tanAngleHeight;
|
||||
result.M[1][3] = 0;
|
||||
|
||||
result.M[2][0] = 0;
|
||||
result.M[2][1] = 0;
|
||||
result.M[2][2] = -1;
|
||||
result.M[2][3] = -(nearZ + offsetZ);
|
||||
|
||||
result.M[3][0] = 0;
|
||||
result.M[3][1] = 0;
|
||||
result.M[3][2] = -1;
|
||||
result.M[3][3] = 0;
|
||||
} else {
|
||||
// normal projection
|
||||
result.M[0][0] = 2 / tanAngleWidth;
|
||||
result.M[0][1] = 0;
|
||||
result.M[0][2] = (tanAngleRight + tanAngleLeft) / tanAngleWidth;
|
||||
result.M[0][3] = 0;
|
||||
|
||||
result.M[1][0] = 0;
|
||||
result.M[1][1] = 2 / tanAngleHeight;
|
||||
result.M[1][2] = (tanAngleUp + tanAngleDown) / tanAngleHeight;
|
||||
result.M[1][3] = 0;
|
||||
|
||||
result.M[2][0] = 0;
|
||||
result.M[2][1] = 0;
|
||||
result.M[2][2] = -(farZ + offsetZ) / (farZ - nearZ);
|
||||
result.M[2][3] = -(farZ * (nearZ + offsetZ)) / (farZ - nearZ);
|
||||
|
||||
result.M[3][0] = 0;
|
||||
result.M[3][1] = 0;
|
||||
result.M[3][2] = -1;
|
||||
result.M[3][3] = 0;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
ovrMatrix4f ovrMatrix4f_CreateFromQuaternion(const XrQuaternionf* q) {
|
||||
const float ww = q->w * q->w;
|
||||
const float xx = q->x * q->x;
|
||||
const float yy = q->y * q->y;
|
||||
const float zz = q->z * q->z;
|
||||
|
||||
ovrMatrix4f out;
|
||||
out.M[0][0] = ww + xx - yy - zz;
|
||||
out.M[0][1] = 2 * (q->x * q->y - q->w * q->z);
|
||||
out.M[0][2] = 2 * (q->x * q->z + q->w * q->y);
|
||||
out.M[0][3] = 0;
|
||||
|
||||
out.M[1][0] = 2 * (q->x * q->y + q->w * q->z);
|
||||
out.M[1][1] = ww - xx + yy - zz;
|
||||
out.M[1][2] = 2 * (q->y * q->z - q->w * q->x);
|
||||
out.M[1][3] = 0;
|
||||
|
||||
out.M[2][0] = 2 * (q->x * q->z - q->w * q->y);
|
||||
out.M[2][1] = 2 * (q->y * q->z + q->w * q->x);
|
||||
out.M[2][2] = ww - xx - yy + zz;
|
||||
out.M[2][3] = 0;
|
||||
|
||||
out.M[3][0] = 0;
|
||||
out.M[3][1] = 0;
|
||||
out.M[3][2] = 0;
|
||||
out.M[3][3] = 1;
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
/// Use left-multiplication to accumulate transformations.
|
||||
ovrMatrix4f ovrMatrix4f_Multiply(const ovrMatrix4f* a, const ovrMatrix4f* b) {
|
||||
ovrMatrix4f out;
|
||||
out.M[0][0] = a->M[0][0] * b->M[0][0] + a->M[0][1] * b->M[1][0] + a->M[0][2] * b->M[2][0] +
|
||||
a->M[0][3] * b->M[3][0];
|
||||
out.M[1][0] = a->M[1][0] * b->M[0][0] + a->M[1][1] * b->M[1][0] + a->M[1][2] * b->M[2][0] +
|
||||
a->M[1][3] * b->M[3][0];
|
||||
out.M[2][0] = a->M[2][0] * b->M[0][0] + a->M[2][1] * b->M[1][0] + a->M[2][2] * b->M[2][0] +
|
||||
a->M[2][3] * b->M[3][0];
|
||||
out.M[3][0] = a->M[3][0] * b->M[0][0] + a->M[3][1] * b->M[1][0] + a->M[3][2] * b->M[2][0] +
|
||||
a->M[3][3] * b->M[3][0];
|
||||
|
||||
out.M[0][1] = a->M[0][0] * b->M[0][1] + a->M[0][1] * b->M[1][1] + a->M[0][2] * b->M[2][1] +
|
||||
a->M[0][3] * b->M[3][1];
|
||||
out.M[1][1] = a->M[1][0] * b->M[0][1] + a->M[1][1] * b->M[1][1] + a->M[1][2] * b->M[2][1] +
|
||||
a->M[1][3] * b->M[3][1];
|
||||
out.M[2][1] = a->M[2][0] * b->M[0][1] + a->M[2][1] * b->M[1][1] + a->M[2][2] * b->M[2][1] +
|
||||
a->M[2][3] * b->M[3][1];
|
||||
out.M[3][1] = a->M[3][0] * b->M[0][1] + a->M[3][1] * b->M[1][1] + a->M[3][2] * b->M[2][1] +
|
||||
a->M[3][3] * b->M[3][1];
|
||||
|
||||
out.M[0][2] = a->M[0][0] * b->M[0][2] + a->M[0][1] * b->M[1][2] + a->M[0][2] * b->M[2][2] +
|
||||
a->M[0][3] * b->M[3][2];
|
||||
out.M[1][2] = a->M[1][0] * b->M[0][2] + a->M[1][1] * b->M[1][2] + a->M[1][2] * b->M[2][2] +
|
||||
a->M[1][3] * b->M[3][2];
|
||||
out.M[2][2] = a->M[2][0] * b->M[0][2] + a->M[2][1] * b->M[1][2] + a->M[2][2] * b->M[2][2] +
|
||||
a->M[2][3] * b->M[3][2];
|
||||
out.M[3][2] = a->M[3][0] * b->M[0][2] + a->M[3][1] * b->M[1][2] + a->M[3][2] * b->M[2][2] +
|
||||
a->M[3][3] * b->M[3][2];
|
||||
|
||||
out.M[0][3] = a->M[0][0] * b->M[0][3] + a->M[0][1] * b->M[1][3] + a->M[0][2] * b->M[2][3] +
|
||||
a->M[0][3] * b->M[3][3];
|
||||
out.M[1][3] = a->M[1][0] * b->M[0][3] + a->M[1][1] * b->M[1][3] + a->M[1][2] * b->M[2][3] +
|
||||
a->M[1][3] * b->M[3][3];
|
||||
out.M[2][3] = a->M[2][0] * b->M[0][3] + a->M[2][1] * b->M[1][3] + a->M[2][2] * b->M[2][3] +
|
||||
a->M[2][3] * b->M[3][3];
|
||||
out.M[3][3] = a->M[3][0] * b->M[0][3] + a->M[3][1] * b->M[1][3] + a->M[3][2] * b->M[2][3] +
|
||||
a->M[3][3] * b->M[3][3];
|
||||
return out;
|
||||
}
|
||||
|
||||
ovrMatrix4f ovrMatrix4f_CreateRotation(const float radiansX, const float radiansY, const float radiansZ) {
|
||||
const float sinX = sinf(radiansX);
|
||||
const float cosX = cosf(radiansX);
|
||||
const ovrMatrix4f rotationX = {
|
||||
{{1, 0, 0, 0}, {0, cosX, -sinX, 0}, {0, sinX, cosX, 0}, {0, 0, 0, 1}}};
|
||||
const float sinY = sinf(radiansY);
|
||||
const float cosY = cosf(radiansY);
|
||||
const ovrMatrix4f rotationY = {
|
||||
{{cosY, 0, sinY, 0}, {0, 1, 0, 0}, {-sinY, 0, cosY, 0}, {0, 0, 0, 1}}};
|
||||
const float sinZ = sinf(radiansZ);
|
||||
const float cosZ = cosf(radiansZ);
|
||||
const ovrMatrix4f rotationZ = {
|
||||
{{cosZ, -sinZ, 0, 0}, {sinZ, cosZ, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}}};
|
||||
const ovrMatrix4f rotationXY = ovrMatrix4f_Multiply(&rotationY, &rotationX);
|
||||
return ovrMatrix4f_Multiply(&rotationZ, &rotationXY);
|
||||
}
|
||||
|
||||
XrVector4f XrVector4f_MultiplyMatrix4f(const ovrMatrix4f* a, const XrVector4f* v) {
|
||||
XrVector4f out;
|
||||
out.x = a->M[0][0] * v->x + a->M[0][1] * v->y + a->M[0][2] * v->z + a->M[0][3] * v->w;
|
||||
out.y = a->M[1][0] * v->x + a->M[1][1] * v->y + a->M[1][2] * v->z + a->M[1][3] * v->w;
|
||||
out.z = a->M[2][0] * v->x + a->M[2][1] * v->y + a->M[2][2] * v->z + a->M[2][3] * v->w;
|
||||
out.w = a->M[3][0] * v->x + a->M[3][1] * v->y + a->M[3][2] * v->z + a->M[3][3] * v->w;
|
||||
return out;
|
||||
}
|
||||
|
||||
/*
|
||||
================================================================================
|
||||
|
||||
ovrTrackedController
|
||||
|
||||
================================================================================
|
||||
*/
|
||||
|
||||
void ovrTrackedController_Clear(ovrTrackedController* controller) {
|
||||
controller->Active = false;
|
||||
controller->Pose = XrPosef_Identity();
|
||||
}
|
||||
|
|
|
@ -22,11 +22,9 @@ Authors : Simon Brown
|
|||
|
||||
void SV_Trace( trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int passEntityNum, int contentmask, int capsule );
|
||||
|
||||
void JKVR_HapticEvent(const char* event, int position, int flags, int intensity, float angle, float yHeight );
|
||||
|
||||
static inline float AngleBetweenVectors(const vec3_t a, const vec3_t b)
|
||||
{
|
||||
return degrees(acosf(DotProduct(a, b)/(VectorLength(a) * VectorLength(b))));
|
||||
return RAD2DEG(acosf(DotProduct(a, b)/(VectorLength(a) * VectorLength(b))));
|
||||
}
|
||||
|
||||
void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew, ovrInputStateTrackedRemote *pDominantTrackedRemoteOld, ovrTrackedController* pDominantTracking,
|
||||
|
@ -122,7 +120,7 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
|
|||
handleTrackedControllerButton(&leftTrackedRemoteState_new, &leftTrackedRemoteState_old, xrButton_Enter, A_ESCAPE);
|
||||
|
||||
static bool resetCursor = qtrue;
|
||||
if ( JKVR_useScreenLayer() && !vr.misc_camera /*bit of a fiddle, but if we are in a misc camera, we are in the game and shouldn't be in here*/)
|
||||
if (VR_UseScreenLayer() && !vr.misc_camera /*bit of a fiddle, but if we are in a misc camera, we are in the game and shouldn't be in here*/)
|
||||
{
|
||||
interactWithTouchScreen(resetCursor, pDominantTrackedRemoteNew, pDominantTrackedRemoteOld);
|
||||
resetCursor = qfalse;
|
||||
|
@ -411,8 +409,8 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
|
|||
float zxDist = length(x, z);
|
||||
|
||||
if (zxDist != 0.0f && z != 0.0f) {
|
||||
VectorSet(vr.weaponangles, -degrees(atanf(y / zxDist)),
|
||||
-degrees(atan2f(x, -z)), 0);
|
||||
VectorSet(vr.weaponangles, -RAD2DEG(atanf(y / zxDist)),
|
||||
-RAD2DEG(atan2f(x, -z)), 0);
|
||||
}
|
||||
}
|
||||
else if (vr.cgzoommode == 2 || vr.cgzoommode == 4)
|
||||
|
@ -426,8 +424,8 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
|
|||
float zxDist = length(x, z);
|
||||
|
||||
if (zxDist != 0.0f && z != 0.0f) {
|
||||
VectorSet(vr.weaponangles, -degrees(atanf(y / zxDist)),
|
||||
-degrees(atan2f(x, -z)), vr.weaponangles[ROLL] /
|
||||
VectorSet(vr.weaponangles, -RAD2DEG(atanf(y / zxDist)),
|
||||
-RAD2DEG(atan2f(x, -z)), vr.weaponangles[ROLL] /
|
||||
2.0f); //Dampen roll on stabilised weapon
|
||||
|
||||
VectorCopy(vr.hmdposition, vr.weaponposition);
|
||||
|
@ -446,8 +444,8 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
|
|||
float zxDist = length(x, z);
|
||||
|
||||
if (zxDist != 0.0f && z != 0.0f) {
|
||||
VectorSet(vr.weaponangles, -degrees(atanf(y / zxDist)),
|
||||
-degrees(atan2f(x, -z)), vr.weaponangles[ROLL] /
|
||||
VectorSet(vr.weaponangles, -RAD2DEG(atanf(y / zxDist)),
|
||||
-RAD2DEG(atan2f(x, -z)), vr.weaponangles[ROLL] /
|
||||
2.0f); //Dampen roll on stabilised weapon
|
||||
}
|
||||
}
|
||||
|
@ -554,7 +552,7 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
|
|||
// Check quicksave
|
||||
if (canUseQuickSave) {
|
||||
int channel = (vr_control_scheme->integer >= 10) ? 1 : 0;
|
||||
JKVR_Vibrate(40, channel, 0.5); // vibrate to let user know they can switch
|
||||
TBXR_Vibrate(40, channel, 0.5); // vibrate to let user know they can switch
|
||||
|
||||
if (((pOffTrackedRemoteNew->Buttons & offButton1) !=
|
||||
(pOffTrackedRemoteOld->Buttons & offButton1)) &&
|
||||
|
@ -577,8 +575,8 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
|
|||
|
||||
//Positional movement speed correction for when we are not hitting target framerate
|
||||
static double lastframetime = 0;
|
||||
int refresh = GetRefresh();
|
||||
double newframetime = GetTimeInMilliSeconds();
|
||||
int refresh = TBXR_GetRefresh();
|
||||
double newframetime = TBXR_GetTimeInMilliSeconds();
|
||||
float multiplier = (float) ((1000.0 / refresh) / (newframetime - lastframetime));
|
||||
lastframetime = newframetime;
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ void HandleInput_WeaponAlign( ovrInputStateTrackedRemote *pDominantTrackedRemote
|
|||
handleTrackedControllerButton(&leftTrackedRemoteState_new, &leftTrackedRemoteState_old, xrButton_Enter, A_ESCAPE);
|
||||
|
||||
static bool resetCursor = qtrue;
|
||||
if ( JKVR_useScreenLayer() )
|
||||
if (VR_UseScreenLayer() )
|
||||
{
|
||||
interactWithTouchScreen(resetCursor, pDominantTrackedRemoteNew, pDominantTrackedRemoteOld);
|
||||
resetCursor = qfalse;
|
||||
|
|
|
@ -124,6 +124,7 @@ JK3_SRC = \
|
|||
|
||||
|
||||
JKVR_SRC_FILES := ${TOP_DIR}/JKVR/JKVR_SurfaceView.cpp \
|
||||
${TOP_DIR}/JKVR/TBXR_Common.cpp \
|
||||
${TOP_DIR}/JKVR/VrInputCommon.cpp \
|
||||
${TOP_DIR}/JKVR/VrInputDefault.cpp \
|
||||
${TOP_DIR}/JKVR/VrInputWeaponAlign.cpp \
|
||||
|
|
|
@ -124,6 +124,7 @@ JK3_SRC = \
|
|||
|
||||
|
||||
JKVR_SRC_FILES := ${TOP_DIR}/JKVR/JKVR_SurfaceView.cpp \
|
||||
${TOP_DIR}/JKVR/TBXR_Common.cpp \
|
||||
${TOP_DIR}/JKVR/VrInputCommon.cpp \
|
||||
${TOP_DIR}/JKVR/VrInputDefault.cpp \
|
||||
${TOP_DIR}/JKVR/VrInputWeaponAlign.cpp \
|
||||
|
|
|
@ -813,7 +813,7 @@ char *Sys_StripAppBundle( char *dir )
|
|||
|
||||
#include "../client/client.h"
|
||||
|
||||
void JKVR_Init();
|
||||
void VR_Init();
|
||||
qboolean shutdown;
|
||||
int VR_main( int argc, char* argv[] ) {
|
||||
// int oldtime, newtime; // bk001204 - unused
|
||||
|
@ -839,7 +839,7 @@ int VR_main( int argc, char* argv[] ) {
|
|||
|
||||
Com_Init( cmdline );
|
||||
NET_Init();
|
||||
JKVR_Init();
|
||||
VR_Init();
|
||||
|
||||
//Sys_ConsoleInputInit();
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ cvar_t *r_colorbits;
|
|||
cvar_t *r_ignorehwgamma;
|
||||
cvar_t *r_ext_multisample;
|
||||
|
||||
void JKVR_GetScreenRes(int *width, int *height);
|
||||
void TBXR_GetScreenRes(int *width, int *height);
|
||||
|
||||
|
||||
/*
|
||||
|
@ -138,11 +138,11 @@ void GLimp_Minimize(void)
|
|||
|
||||
}
|
||||
|
||||
void JKVR_submitFrame();
|
||||
void TBXR_submitFrame();
|
||||
|
||||
void WIN_Present( window_t *window )
|
||||
{
|
||||
JKVR_submitFrame();
|
||||
TBXR_submitFrame();
|
||||
}
|
||||
|
||||
|
||||
|
@ -188,7 +188,7 @@ window_t WIN_Init( const windowDesc_t *windowDesc, glconfig_t *glConfig )
|
|||
|
||||
int android_screen_width;
|
||||
int android_screen_height;
|
||||
JKVR_GetScreenRes(&android_screen_width, &android_screen_height);
|
||||
TBXR_GetScreenRes(&android_screen_width, &android_screen_height);
|
||||
glConfig->vidWidth = android_screen_width;
|
||||
glConfig->vidHeight = android_screen_height;
|
||||
glConfig->colorBits = 32;
|
||||
|
|
|
@ -225,12 +225,9 @@ void PortableMouse(float dx,float dy)
|
|||
}
|
||||
|
||||
int absx=0,absy=0;
|
||||
void JKVR_GetScreenRes(int *width, int *height);
|
||||
void TBXR_GetScreenRes(int *width, int *height);
|
||||
void PortableMouseAbs(float x,float y)
|
||||
{
|
||||
//int width;
|
||||
//int height;
|
||||
//JKVR_GetScreenRes(&width, &height);
|
||||
absx = x * 640;
|
||||
absy = y * 480;
|
||||
|
||||
|
|
|
@ -1382,7 +1382,7 @@ Ghoul2 Insert End
|
|||
#endif
|
||||
|
||||
case CG_HAPTICEVENT:
|
||||
JKVR_HapticEvent( (const char*)VMA(1), args[2], args[3], args[4], VMF(5), VMF(6) );
|
||||
VR_HapticEvent((const char *) VMA(1), args[2], args[3], args[4], VMF(5), VMF(6));
|
||||
return 0;
|
||||
default:
|
||||
Com_Error( ERR_DROP, "Bad cgame system trap: %ld", (long int) args[0] );
|
||||
|
|
|
@ -71,8 +71,8 @@ qboolean in_mlooking;
|
|||
|
||||
extern cvar_t *in_joystick;
|
||||
|
||||
void JKVR_GetMove(float *forward, float *side, float *pos_forward, float *pos_side, float *up,
|
||||
float *yaw, float *pitch, float *roll);
|
||||
void VR_GetMove(float *forward, float *side, float *pos_forward, float *pos_side, float *up,
|
||||
float *yaw, float *pitch, float *roll);
|
||||
|
||||
typedef struct {
|
||||
float forward;
|
||||
|
@ -699,8 +699,8 @@ usercmd_t CL_CreateCmd( void ) {
|
|||
VectorCopy( cl.viewangles, oldAngles );
|
||||
|
||||
|
||||
JKVR_GetMove(&new_move.forward, &new_move.side, &new_move.pos_forward, &new_move.pos_side,
|
||||
&new_move.up, &new_move.yaw, &new_move.pitch, &new_move.roll);
|
||||
VR_GetMove(&new_move.forward, &new_move.side, &new_move.pos_forward, &new_move.pos_side,
|
||||
&new_move.up, &new_move.yaw, &new_move.pitch, &new_move.roll);
|
||||
|
||||
// keyboard angle adjustment
|
||||
CL_AdjustAngles ();
|
||||
|
|
|
@ -882,7 +882,7 @@ void CL_Frame ( int msec,float fractionMsec ) {
|
|||
|
||||
Con_RunConsole();
|
||||
|
||||
JKVR_HapticEndFrame();
|
||||
VR_HapticEndFrame();
|
||||
|
||||
cls.framecount++;
|
||||
}
|
||||
|
@ -1191,8 +1191,8 @@ void CL_InitRef( void ) {
|
|||
|
||||
rit.saved_game = &ojk::SavedGame::get_instance();
|
||||
|
||||
rit.JKVR_useScreenLayer = JKVR_useScreenLayer;
|
||||
rit.JKVR_GetVRProjection = JKVR_GetVRProjection;
|
||||
rit.TBXR_useScreenLayer = VR_UseScreenLayer;
|
||||
rit.TBXR_GetVRProjection = VR_GetVRProjection;
|
||||
|
||||
ret = GetRefAPI( REF_API_VERSION, &rit );
|
||||
|
||||
|
|
|
@ -508,11 +508,11 @@ void SCR_UpdateScreen( void ) {
|
|||
if ( cls.uiStarted )
|
||||
{
|
||||
//Try again here in case we've not done it yet
|
||||
JKVR_FrameSetup();
|
||||
TBXR_FrameSetup();
|
||||
|
||||
for (int eye = 0; eye < 2; ++eye)
|
||||
{
|
||||
JKVR_prepareEyeBuffer(eye);
|
||||
TBXR_prepareEyeBuffer(eye);
|
||||
|
||||
//Draw twice for Quest
|
||||
SCR_DrawScreenField(eye == 0 ? STEREO_LEFT : STEREO_RIGHT);
|
||||
|
@ -529,7 +529,7 @@ void SCR_UpdateScreen( void ) {
|
|||
}
|
||||
}
|
||||
|
||||
JKVR_finishEyeBuffer(eye);
|
||||
TBXR_finishEyeBuffer(eye);
|
||||
}
|
||||
|
||||
//And we're done
|
||||
|
|
|
@ -1364,7 +1364,7 @@ void Com_Frame( void ) {
|
|||
int timeVal;
|
||||
static int lastTime = 0, bias = 0;
|
||||
|
||||
JKVR_FrameSetup();
|
||||
TBXR_FrameSetup();
|
||||
|
||||
// write config file if anything changed
|
||||
Com_WriteConfiguration();
|
||||
|
|
|
@ -128,8 +128,8 @@ typedef struct {
|
|||
int (*com_frameTime) ( void );
|
||||
|
||||
//JKVR Functions
|
||||
bool (*JKVR_useScreenLayer) ( void );
|
||||
bool (*JKVR_GetVRProjection) (int eye, float zNear, float zFar, float* projection);
|
||||
bool (*TBXR_useScreenLayer) ( void );
|
||||
bool (*TBXR_GetVRProjection) (int eye, float zNear, float zFar, float* projection);
|
||||
|
||||
} refimport_t;
|
||||
|
||||
|
|
|
@ -540,7 +540,7 @@ void R_SetupProjection( void ) {
|
|||
zFar = tr.viewParms.zFar;
|
||||
|
||||
if (!tr.refdef.override_fov &&
|
||||
ri.JKVR_GetVRProjection((int)tr.stereoFrame, zNear, zFar, tr.viewParms.projectionMatrix))
|
||||
ri.TBXR_GetVRProjection((int)tr.stereoFrame, zNear, zFar, tr.viewParms.projectionMatrix))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -9164,7 +9164,7 @@ void Item_MouseEnter(itemDef_t *item, float x, float y)
|
|||
}
|
||||
}
|
||||
|
||||
void JKVR_HapticEvent(const char* event, int position, int flags, int intensity, float angle, float yHeight );
|
||||
void VR_HapticEvent(const char* event, int position, int flags, int intensity, float angle, float yHeight );
|
||||
|
||||
/*
|
||||
=================
|
||||
|
@ -9249,7 +9249,7 @@ qboolean Item_SetFocus(itemDef_t *item, float x, float y)
|
|||
if (playSound && sfx)
|
||||
{
|
||||
DC->startLocalSound( *sfx, CHAN_LOCAL_SOUND );
|
||||
JKVR_HapticEvent("selector_icon", 0, vr.right_handed ? 1 : 2, 60, 0, 0);
|
||||
VR_HapticEvent("selector_icon", 0, vr.right_handed ? 1 : 2, 60, 0, 0);
|
||||
}
|
||||
|
||||
for (i = 0; i < parent->itemCount; i++)
|
||||
|
|
Loading…
Reference in a new issue