From 6f465764e426f1531a1d53ba6c8fe16bcb1d9e5d Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 12 Jan 2021 20:58:36 +0000 Subject: [PATCH] More mouse cursor stuff Think it's not too bad now --- .../Android/jni/Doom3Quest/VrInputCommon.c | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/Projects/Android/jni/Doom3Quest/VrInputCommon.c b/Projects/Android/jni/Doom3Quest/VrInputCommon.c index d0ca8dd..fe6dc2e 100644 --- a/Projects/Android/jni/Doom3Quest/VrInputCommon.c +++ b/Projects/Android/jni/Doom3Quest/VrInputCommon.c @@ -152,6 +152,7 @@ void controlMouse(bool reset, ovrInputStateTrackedRemote *newState, ovrInputStat static int cursorX = 0; static int cursorY = 0; static bool firstTime = true; + static float yaw; int height = 0; int width = 0; @@ -159,17 +160,25 @@ void controlMouse(bool reset, ovrInputStateTrackedRemote *newState, ovrInputStat if (reset || firstTime) { - cursorX = 0; + cursorX = (float)(((pVRClientInfo->weaponangles_temp[YAW]-yaw) * width) / 60.0F); + cursorY = (float)((pVRClientInfo->weaponangles_temp[PITCH] * height) / 70.0F); + yaw = pVRClientInfo->weaponangles_temp[YAW]; + Sys_AddMouseMoveEvent(-10000, -10000); Sys_AddMouseMoveEvent((width / 2.0F), (height / 2.0F)); - firstTime = false; + + if (firstTime && between(-5, (pVRClientInfo->weaponangles_temp[PITCH]-30), 5)) { + firstTime = false; + } + return; } - //cursorX = (float)((-(pVRClientInfo->weaponangles_temp[YAW]-yaw) * width) / 60.0F) + (width / 2.0F); - cursorX = (float)(pVRClientInfo->weaponangles_delta_temp[YAW] * 18.0f); - cursorY = (float)(((pVRClientInfo->weaponangles_temp[PITCH]-30) * height) / 70.0F) + (height / 2.0F); + int newCursorX = (float)((-(pVRClientInfo->weaponangles_temp[YAW]-yaw) * width) / 70.0F); + int newCursorY = (float)((pVRClientInfo->weaponangles_temp[PITCH] * height) / 70.0F); - Sys_AddMouseMoveEvent(0, -10000); // reset cursor pitch position - Sys_AddMouseMoveEvent(cursorX, cursorY); + Sys_AddMouseMoveEvent(newCursorX - cursorX, newCursorY - cursorY); + + cursorY = newCursorY; + cursorX = newCursorX; } \ No newline at end of file