mirror of
https://github.com/DrBeef/RTCWQuest.git
synced 2024-11-14 16:41:20 +00:00
Menu cursor improvements
This commit is contained in:
parent
0c564179ea
commit
cfe7b8b8bc
6 changed files with 58 additions and 44 deletions
|
@ -53,7 +53,7 @@ qboolean between(float min, float val, float max);
|
|||
void rotateAboutOrigin(float v1, float v2, float rotation, vec2_t out);
|
||||
void QuatToYawPitchRoll(ovrQuatf q, vec3_t rotation, vec3_t out);
|
||||
void handleTrackedControllerButton(ovrInputStateTrackedRemote * trackedRemoteState, ovrInputStateTrackedRemote * prevTrackedRemoteState, uint32_t button, int key);
|
||||
void interactWithTouchScreen(qboolean reset, ovrInputStateTrackedRemote *newState, ovrInputStateTrackedRemote *oldState);
|
||||
void interactWithTouchScreen(float menuYaw, vec3_t controllerAngles);
|
||||
int GetRefresh();
|
||||
|
||||
//Called from engine code
|
||||
|
|
|
@ -171,20 +171,9 @@ inline float clamp(float _min, float _val, float _max)
|
|||
return max(min(_val, _max), _min);
|
||||
}
|
||||
|
||||
void interactWithTouchScreen(qboolean reset, ovrInputStateTrackedRemote *newState, ovrInputStateTrackedRemote *oldState) {
|
||||
static float cursorX = 0.25f;
|
||||
static float cursorY = 0.125f;
|
||||
|
||||
if (reset)
|
||||
{
|
||||
cursorX = 0.25f;
|
||||
cursorY = 0.125f;
|
||||
}
|
||||
|
||||
cursorX += (float)(vr.weaponangles_delta[YAW] / 180.0);
|
||||
cursorX = clamp(0.0, cursorX, 0.5);
|
||||
cursorY += (float)(-vr.weaponangles_delta[PITCH] / 220.0);
|
||||
cursorY = clamp(0.0, cursorY, 0.4);
|
||||
void interactWithTouchScreen(float menuYaw, vec3_t controllerAngles) {
|
||||
float cursorX = -sinf(DEG2RAD(controllerAngles[YAW] - menuYaw)) + 0.5f;
|
||||
float cursorY = (float)(controllerAngles[PITCH] / 90.0) + 0.5f;
|
||||
|
||||
PortableMouseAbs(cursorX, cursorY);
|
||||
}
|
|
@ -132,19 +132,32 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
|
|||
//Menu button
|
||||
handleTrackedControllerButton(&leftTrackedRemoteState_new, &leftTrackedRemoteState_old, ovrButton_Enter, K_ESCAPE);
|
||||
|
||||
static qboolean resetCursor = qtrue;
|
||||
static float menuYaw = 0;
|
||||
static bool switchedMenuControls = qfalse;
|
||||
if ( RTCWVR_useScreenLayer() )
|
||||
{
|
||||
interactWithTouchScreen(resetCursor, pDominantTrackedRemoteNew, pDominantTrackedRemoteOld);
|
||||
resetCursor = qfalse;
|
||||
|
||||
handleTrackedControllerButton(pDominantTrackedRemoteNew, pDominantTrackedRemoteOld, domButton1, K_MOUSE1);
|
||||
handleTrackedControllerButton(pDominantTrackedRemoteNew, pDominantTrackedRemoteOld, ovrButton_Trigger, K_MOUSE1);
|
||||
handleTrackedControllerButton(pDominantTrackedRemoteNew, pDominantTrackedRemoteOld, domButton2, K_ESCAPE);
|
||||
bool controlsLeftHanded = vr_control_scheme->integer >= 10;
|
||||
if ((controlsLeftHanded && !switchedMenuControls) || (!controlsLeftHanded && switchedMenuControls)) {
|
||||
interactWithTouchScreen(menuYaw, vr.offhandangles);
|
||||
handleTrackedControllerButton(pOffTrackedRemoteNew, pOffTrackedRemoteOld, offButton1, K_MOUSE1);
|
||||
handleTrackedControllerButton(pOffTrackedRemoteNew, pOffTrackedRemoteOld, ovrButton_Trigger, K_MOUSE1);
|
||||
handleTrackedControllerButton(pOffTrackedRemoteNew, pOffTrackedRemoteOld, offButton2, K_ESCAPE);
|
||||
if ((pDominantTrackedRemoteNew->Buttons & ovrButton_Trigger) != (pDominantTrackedRemoteOld->Buttons & ovrButton_Trigger) && (pDominantTrackedRemoteNew->Buttons & ovrButton_Trigger)) {
|
||||
switchedMenuControls = !switchedMenuControls;
|
||||
}
|
||||
} else {
|
||||
interactWithTouchScreen(menuYaw, vr.weaponangles);
|
||||
handleTrackedControllerButton(pDominantTrackedRemoteNew, pDominantTrackedRemoteOld, domButton1, K_MOUSE1);
|
||||
handleTrackedControllerButton(pDominantTrackedRemoteNew, pDominantTrackedRemoteOld, ovrButton_Trigger, K_MOUSE1);
|
||||
handleTrackedControllerButton(pDominantTrackedRemoteNew, pDominantTrackedRemoteOld, domButton2, K_ESCAPE);
|
||||
if ((pOffTrackedRemoteNew->Buttons & ovrButton_Trigger) != (pOffTrackedRemoteOld->Buttons & ovrButton_Trigger) && (pOffTrackedRemoteNew->Buttons & ovrButton_Trigger)) {
|
||||
switchedMenuControls = !switchedMenuControls;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
resetCursor = qtrue;
|
||||
menuYaw = vr.hmdorientation[YAW];
|
||||
|
||||
float distance = sqrtf(powf(pOff->HeadPose.Pose.Position.x - pWeapon->HeadPose.Pose.Position.x, 2) +
|
||||
powf(pOff->HeadPose.Pose.Position.y - pWeapon->HeadPose.Pose.Position.y, 2) +
|
||||
|
|
|
@ -64,19 +64,32 @@ void HandleInput_WeaponAlign( ovrInputStateTrackedRemote *pDominantTrackedRemote
|
|||
//Menu button
|
||||
handleTrackedControllerButton(&leftTrackedRemoteState_new, &leftTrackedRemoteState_old, ovrButton_Enter, K_ESCAPE);
|
||||
|
||||
static qboolean resetCursor = qtrue;
|
||||
static float menuYaw = 0;
|
||||
static bool switchedMenuControls = qfalse;
|
||||
if ( RTCWVR_useScreenLayer() )
|
||||
{
|
||||
interactWithTouchScreen(resetCursor, pDominantTrackedRemoteNew, pDominantTrackedRemoteOld);
|
||||
resetCursor = qfalse;
|
||||
|
||||
handleTrackedControllerButton(pDominantTrackedRemoteNew, pDominantTrackedRemoteOld, domButton1, K_MOUSE1);
|
||||
handleTrackedControllerButton(pDominantTrackedRemoteNew, pDominantTrackedRemoteOld, ovrButton_Trigger, K_MOUSE1);
|
||||
handleTrackedControllerButton(pDominantTrackedRemoteNew, pDominantTrackedRemoteOld, domButton2, K_ESCAPE);
|
||||
bool controlsLeftHanded = vr_control_scheme->integer >= 10;
|
||||
if ((controlsLeftHanded && !switchedMenuControls) || (!controlsLeftHanded && switchedMenuControls)) {
|
||||
interactWithTouchScreen(menuYaw, vr.offhandangles);
|
||||
handleTrackedControllerButton(pOffTrackedRemoteNew, pOffTrackedRemoteOld, offButton1, K_MOUSE1);
|
||||
handleTrackedControllerButton(pOffTrackedRemoteNew, pOffTrackedRemoteOld, ovrButton_Trigger, K_MOUSE1);
|
||||
handleTrackedControllerButton(pOffTrackedRemoteNew, pOffTrackedRemoteOld, offButton2, K_ESCAPE);
|
||||
if ((pDominantTrackedRemoteNew->Buttons & ovrButton_Trigger) != (pDominantTrackedRemoteOld->Buttons & ovrButton_Trigger) && (pDominantTrackedRemoteNew->Buttons & ovrButton_Trigger)) {
|
||||
switchedMenuControls = !switchedMenuControls;
|
||||
}
|
||||
} else {
|
||||
interactWithTouchScreen(menuYaw, vr.weaponangles);
|
||||
handleTrackedControllerButton(pDominantTrackedRemoteNew, pDominantTrackedRemoteOld, domButton1, K_MOUSE1);
|
||||
handleTrackedControllerButton(pDominantTrackedRemoteNew, pDominantTrackedRemoteOld, ovrButton_Trigger, K_MOUSE1);
|
||||
handleTrackedControllerButton(pDominantTrackedRemoteNew, pDominantTrackedRemoteOld, domButton2, K_ESCAPE);
|
||||
if ((pOffTrackedRemoteNew->Buttons & ovrButton_Trigger) != (pOffTrackedRemoteOld->Buttons & ovrButton_Trigger) && (pOffTrackedRemoteNew->Buttons & ovrButton_Trigger)) {
|
||||
switchedMenuControls = !switchedMenuControls;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
resetCursor = qtrue;
|
||||
menuYaw = vr.hmdorientation[YAW];
|
||||
|
||||
//dominant hand stuff first
|
||||
{
|
||||
|
|
|
@ -228,11 +228,8 @@ int absx=0,absy=0;
|
|||
RTCWVR_GetScreenRes(int *width, int *height);
|
||||
void PortableMouseAbs(float x,float y)
|
||||
{
|
||||
int width;
|
||||
int height;
|
||||
RTCWVR_GetScreenRes(&width, &height);
|
||||
absx = x * width;
|
||||
absy = y * height;
|
||||
absx = x * 640;
|
||||
absy = y * 480;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -6782,20 +6782,22 @@ void _UI_MouseEvent( int dx, int dy ) {
|
|||
UI_MouseEvent
|
||||
=================
|
||||
*/
|
||||
const int cursorSize = 16;
|
||||
void _UI_MouseEventAbs( int x, int y ) {
|
||||
// update mouse screen position
|
||||
// allow to hide cursor beyond the screen edges
|
||||
uiInfo.uiDC.cursorx = x;
|
||||
if ( uiInfo.uiDC.cursorx < 0 ) {
|
||||
uiInfo.uiDC.cursorx = 0;
|
||||
} else if ( uiInfo.uiDC.cursorx > SCREEN_WIDTH ) {
|
||||
uiInfo.uiDC.cursorx = SCREEN_WIDTH;
|
||||
if ( uiInfo.uiDC.cursorx < -cursorSize ) {
|
||||
uiInfo.uiDC.cursorx = -cursorSize;
|
||||
} else if ( uiInfo.uiDC.cursorx > SCREEN_WIDTH + cursorSize ) {
|
||||
uiInfo.uiDC.cursorx = SCREEN_WIDTH + cursorSize;
|
||||
}
|
||||
|
||||
uiInfo.uiDC.cursory = y;
|
||||
if ( uiInfo.uiDC.cursory < 0 ) {
|
||||
uiInfo.uiDC.cursory = 0;
|
||||
} else if ( uiInfo.uiDC.cursory > SCREEN_HEIGHT ) {
|
||||
uiInfo.uiDC.cursory = SCREEN_HEIGHT;
|
||||
if ( uiInfo.uiDC.cursory < -cursorSize ) {
|
||||
uiInfo.uiDC.cursory = -cursorSize;
|
||||
} else if ( uiInfo.uiDC.cursory > SCREEN_HEIGHT + cursorSize) {
|
||||
uiInfo.uiDC.cursory = SCREEN_HEIGHT + cursorSize;
|
||||
}
|
||||
|
||||
if ( Menu_Count() > 0 ) {
|
||||
|
|
Loading…
Reference in a new issue