Use absolute position for menu cursor (no need to "calibrate" pointer any more)

This commit is contained in:
Petr Bartos 2022-03-22 22:19:38 +01:00
parent 2500ffe780
commit 0e99425a79
4 changed files with 16 additions and 2 deletions

View file

@ -937,6 +937,9 @@ void UI_MouseEvent( int dx, int dy )
else if (uis.cursory > SCREEN_HEIGHT)
uis.cursory = SCREEN_HEIGHT;
vr->menuCursorX = &uis.cursorx;
vr->menuCursorY = &uis.cursory;
// region test the active menu items
for (i=0; i<uis.activemenu->nitems; i++)
{

View file

@ -5277,6 +5277,9 @@ void _UI_MouseEvent( int dx, int dy )
else if (uiInfo.uiDC.cursory > SCREEN_HEIGHT)
uiInfo.uiDC.cursory = SCREEN_HEIGHT;
vr->menuCursorX = &uiInfo.uiDC.cursorx;
vr->menuCursorY = &uiInfo.uiDC.cursory;
if (Menu_Count() > 0) {
//menuDef_t *menu = Menu_GetFocused();
//Menu_HandleMouseMove(menu, uiInfo.uiDC.cursorx, uiInfo.uiDC.cursory);

View file

@ -56,6 +56,9 @@ typedef struct {
vec3_t offhandposition;
vec2_t thumbstick_location[2]; //left / right thumbstick locations - used in cgame
int *menuCursorX;
int *menuCursorY;
} vr_clientinfo_t;
#endif //vr_clientinfo_h

View file

@ -452,8 +452,13 @@ static void IN_VRController( qboolean isRightController, ovrTracking remoteTrack
if (vr.virtual_screen ||
cl.snap.ps.pm_type == PM_INTERMISSION)
{
int mouse_multiplier = 10;
Com_QueueEvent(in_vrEventTime, SE_MOUSE, vr.weaponangles_delta[YAW] * mouse_multiplier, -vr.weaponangles_delta[PITCH] * mouse_multiplier, 0, NULL);
if (vr.menuCursorX && vr.menuCursorY)
{
int x = 320 - tan(vr.weaponangles[YAW] * (M_PI*2 / 360)) * 400;
int y = 240 + tan((vr.weaponangles[PITCH] + vr_weaponPitch->value) * (M_PI*2 / 360)) * 400;
*vr.menuCursorX = x;
*vr.menuCursorY = y;
}
}
} else {
vec3_t rotation = {0};