Overhaul of Weapon Selector

- Now provides a HMD locked weapon wheel option controlled with thumbstick
- Selector type can be chosen in the controls menu
This commit is contained in:
Simon 2022-03-12 12:01:59 +00:00
parent 8939a4f959
commit e16f625db0
13 changed files with 252 additions and 170 deletions

View file

@ -14,41 +14,13 @@ set cg_weaponbob 0
set sv_pure 0
set sv_master1 "13.36.227.32:27950"
//VR Button mappings
set vr_button_map_A "+moveup"
set vr_button_map_A_ALT ""
set vr_button_map_B "+movedown"
set vr_button_map_B_ALT ""
set vr_button_map_X "+button2"
set vr_button_map_X_ALT ""
set vr_button_map_Y "+button3"
set vr_button_map_Y_ALT ""
set vr_button_map_SECONDARYTHUMBSTICK "+scores"
set vr_button_map_SECONDARYTHUMBSTICK_ALT ""
set vr_button_map_PRIMARYTHUMBSTICK "+weapon_select"
set vr_button_map_PRIMARYTHUMBSTICK_ALT ""
set vr_button_map_RTHUMBFORWARD "+weapon_select"
//VR Button mappings - ONLY put overrides of defaults in here, such as alt key mappings
set vr_button_map_RTHUMBFORWARD_ALT "weapon 2"
set vr_button_map_RTHUMBFORWARDRIGHT ""
set vr_button_map_RTHUMBFORWARDRIGHT_ALT "weapon 3"
set vr_button_map_RTHUMBRIGHT ""
set vr_button_map_RTHUMBRIGHT_ALT "weapon 4"
set vr_button_map_RTHUMBBACKRIGHT ""
set vr_button_map_RTHUMBBACKRIGHT_ALT "weapon 5"
set vr_button_map_RTHUMBBACK "uturn"
set vr_button_map_RTHUMBBACK_ALT "weapon 6"
set vr_button_map_RTHUMBBACKLEFT ""
set vr_button_map_RTHUMBBACKLEFT_ALT "weapon 7"
set vr_button_map_RTHUMBLEFT ""
set vr_button_map_RTHUMBLEFT_ALT "weapon 8"
set vr_button_map_RTHUMBFORWARDLEFT ""
set vr_button_map_RTHUMBFORWARDLEFT_ALT "weapon 9"
set vr_button_map_SECONDARYTRIGGER "+moveup"
set vr_button_map_SECONDARYTRIGGER_ALT ""
set vr_button_map_PRIMARYTRIGGER "+attack"
set vr_button_map_PRIMARYTRIGGER_ALT ""
set vr_button_map_SECONDARYGRIP "+weapon_stabilise"
set vr_button_map_SECONDARYGRIP_ALT ""
set vr_button_map_PRIMARYGRIP "+alt"
set vr_button_map_PRIMARYGRIP_ALT ""

View file

@ -470,7 +470,7 @@ static consoleCommand_t commands[] = {
{ "tcmd", CG_TargetCommand_f },
{ "tell_target", CG_TellTarget_f },
{ "tell_attacker", CG_TellAttacker_f },
{ "holster_select", CG_HolsterSelect_f },
{ "weapon_select", CG_WeaponSelectorSelect_f },
#ifdef MISSIONPACK
{ "vtell_target", CG_VoiceTellTarget_f },
{ "vtell_attacker", CG_VoiceTellAttacker_f },

View file

@ -2841,7 +2841,7 @@ void CG_DrawActive( stereoFrame_t stereoView ) {
VectorCopy( baseOrg, cg.refdef.vieworg );
//Don't draw HUD whilst selecting the weapon with the holster (it gets in the way)
if (cg.weaponHolsterTime == 0)
if (cg.weaponSelectorTime == 0)
{
// draw status bar and other floating elements
hudStereoView = stereoView;

View file

@ -620,11 +620,11 @@ typedef struct {
int weaponAnimation;
int weaponAnimationTime;
int weaponHolsterSelection;
int weaponHolsterTime;
vec3_t weaponHolsterAngles;
vec3_t weaponHolsterOrigin;
vec3_t weaponHolsterOffset;
int weaponSelectorSelection;
int weaponSelectorTime;
vec3_t weaponSelectorAngles;
vec3_t weaponSelectorOrigin;
vec3_t weaponSelectorOffset;
// blend blobs
float damageTime;
@ -1127,7 +1127,7 @@ extern vmCvar_t cg_drawFPS;
extern vmCvar_t cg_drawSnapshot;
extern vmCvar_t cg_draw3dIcons;
extern vmCvar_t cg_debugWeaponAiming;
extern vmCvar_t cg_holsterSimple2DIcons;
extern vmCvar_t cg_weaponSelectorSimple2DIcons;
extern vmCvar_t cg_drawIcons;
extern vmCvar_t cg_drawAmmoWarning;
extern vmCvar_t cg_drawCrosshair;
@ -1394,7 +1394,7 @@ void CG_PositionRotatedEntityOnTag( refEntity_t *entity, const refEntity_t *pare
void CG_NextWeapon_f( void );
void CG_PrevWeapon_f( void );
void CG_Weapon_f( void );
void CG_HolsterSelect_f( void );
void CG_WeaponSelectorSelect_f( void );
void rotateAboutOrigin(float x, float y, float rotation, vec2_t out);
void CG_CalculateVRWeaponPosition( vec3_t origin, vec3_t angles );
@ -1413,7 +1413,7 @@ void CG_Bullet( vec3_t origin, int sourceEntityNum, vec3_t normal, qboolean fles
void CG_RailTrail( clientInfo_t *ci, vec3_t start, vec3_t end );
void CG_GrappleTrail( centity_t *ent, const weaponInfo_t *wi );
void CG_AddViewWeapon (playerState_t *ps);
void CG_DrawHolsteredWeapons( void );
void CG_DrawWeaponSelector( void );
void CG_AddPlayerWeapon( refEntity_t *parent, playerState_t *ps, centity_t *cent, int team );
void CG_DrawWeaponSelect( void );
void CG_LaserSight( vec3_t start, vec3_t end, byte colour[4], float width );

View file

@ -117,7 +117,7 @@ vmCvar_t cg_drawAmmoWarning;
vmCvar_t cg_drawCrosshair;
vmCvar_t cg_drawCrosshairNames;
vmCvar_t cg_debugWeaponAiming;
vmCvar_t cg_holsterSimple2DIcons;
vmCvar_t cg_weaponSelectorSimple2DIcons;
vmCvar_t cg_fragMessage;
vmCvar_t cg_drawRewards;
vmCvar_t cg_crosshairSize;
@ -237,7 +237,7 @@ static cvarTable_t cvarTable[] = {
{ &cg_drawSnapshot, "cg_drawSnapshot", "0", CVAR_ARCHIVE },
{ &cg_draw3dIcons, "cg_draw3dIcons", "1", CVAR_ARCHIVE },
{ &cg_debugWeaponAiming, "cg_debugWeaponAiming", "0", CVAR_ARCHIVE },
{ &cg_holsterSimple2DIcons, "cg_holsterSimple2DIcons", "0", CVAR_ARCHIVE },
{ &cg_weaponSelectorSimple2DIcons, "cg_weaponSelectorSimple2DIcons", "0", CVAR_ARCHIVE },
{ &cg_drawIcons, "cg_drawIcons", "1", CVAR_ARCHIVE },
{ &cg_drawAmmoWarning, "cg_drawAmmoWarning", "1", CVAR_ARCHIVE },
{ &cg_drawAttacker, "cg_drawAttacker", "0", CVAR_ARCHIVE },

View file

@ -23,6 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
// cg_weapons.c -- events and effects dealing with weapons
#include "cg_local.h"
#include "../vr/vr_clientinfo.h"
#include "../vr/vr_types.h"
extern vr_clientinfo_t *vr;
@ -1708,7 +1709,7 @@ void CG_AddViewWeapon( playerState_t *ps ) {
if (vr->weapon_select)
{
CG_DrawHolsteredWeapons();
CG_DrawWeaponSelector();
return;
}
@ -2024,20 +2025,20 @@ void CG_Weapon_f( void ) {
cg.weaponSelect = num;
}
//Selects the currently selected holstered weapon (if one _is_ selected)
void CG_HolsterSelect_f( void )
//Selects the currently selected weapon (if one _is_ selected)
void CG_WeaponSelectorSelect_f( void )
{
cg.weaponHolsterTime = 0;
cg.weaponSelectorTime = 0;
if (cg.weaponHolsterSelection == WP_NONE ||
cg.weaponSelect == cg.weaponHolsterSelection)
if (cg.weaponSelectorSelection == WP_NONE ||
cg.weaponSelect == cg.weaponSelectorSelection)
{
return;
}
cg.weaponSelectTime = cg.time;
cg.weaponSelect = cg.weaponHolsterSelection;
cg.weaponHolsterSelection = WP_NONE;
cg.weaponSelect = cg.weaponSelectorSelection;
cg.weaponSelectorSelection = WP_NONE;
}
static float length(float x, float y)
@ -2045,47 +2046,82 @@ static float length(float x, float y)
return sqrtf(powf(x, 2.0f) + powf(y, 2.0f));
}
void CG_DrawHolsteredWeapons( void )
void CG_DrawWeaponSelector( void )
{
if (cg.weaponHolsterTime == 0)
if (cg.weaponSelectorTime == 0)
{
cg.weaponHolsterTime = cg.time;
VectorCopy(vr->weaponangles, cg.weaponHolsterAngles);
VectorCopy(vr->weaponposition, cg.weaponHolsterOrigin);
VectorCopy(vr->weaponoffset, cg.weaponHolsterOffset);
cg.weaponSelectorTime = cg.time;
VectorCopy(vr->weaponangles, cg.weaponSelectorAngles);
VectorCopy(vr->weaponposition, cg.weaponSelectorOrigin);
VectorCopy(vr->weaponoffset, cg.weaponSelectorOffset);
}
const int selectorMode = (int)trap_Cvar_VariableValue("vr_weaponSelectorMode");
float DEPTH = 5.0f;
float RAD = 5.0f;
if (selectorMode == WS_HMD) // HMD locked
{
VectorCopy(vr->hmdorientation, cg.weaponSelectorAngles);
VectorCopy(vr->hmdposition, cg.weaponSelectorOrigin);
VectorClear(cg.weaponSelectorOffset);
DEPTH = 7.0f;
RAD = 4.0f;
}
float SCALE = 0.05f;
const float DIST = 5.0f;
const float SEP = 360.0f / (WP_NUM_WEAPONS - 1); // Exclude grappling hook
float frac = (cg.time - cg.weaponHolsterTime) / (25 * DIST);
const float SEP = 360.0f / (WP_NUM_WEAPONS - 2); // Exclude grappling hook
float frac = (cg.time - cg.weaponSelectorTime) / (20 * DEPTH);
if (frac > 1.0f) frac = 1.0f;
vec3_t controllerOrigin, controllerAngles, controllerOffset, selectorOrigin;
CG_CalculateVRWeaponPosition(controllerOrigin, controllerAngles);
VectorSubtract(vr->weaponposition, cg.weaponHolsterOrigin, controllerOffset);
VectorSubtract(vr->weaponposition, cg.weaponSelectorOrigin, controllerOffset);
vec3_t holsterAngles, holsterOrigin, beamOrigin, holsterForward, holsterRight, holsterUp;
CG_CalculateVRPositionInWorld(cg.weaponHolsterOrigin, cg.weaponHolsterOffset, cg.weaponHolsterAngles, holsterOrigin, holsterAngles);
CG_CalculateVRPositionInWorld(cg.weaponSelectorOrigin, cg.weaponSelectorOffset, cg.weaponSelectorAngles, holsterOrigin, holsterAngles);
AngleVectors(holsterAngles, holsterForward, holsterRight, holsterUp);
VectorCopy(controllerOrigin, holsterOrigin);
VectorCopy(holsterOrigin, beamOrigin);
VectorMA(holsterOrigin, ((DIST*2.0f)*frac), holsterForward, holsterOrigin);
VectorCopy(holsterOrigin, selectorOrigin);
float x = (sinf(DEG2RAD(holsterAngles[YAW] - controllerAngles[YAW])) / sinf(DEG2RAD(22.5f)));
float y = ((holsterAngles[PITCH] - controllerAngles[PITCH]) / 22.5f);
float len = length(x, y);
if (len > 1.0f)
if (selectorMode == WS_CONTROLLER)
{
x *= (1.0f / len);
y *= (1.0f / len);
VectorCopy(controllerOrigin, holsterOrigin);
}
else
{
VectorMA(holsterOrigin, -2.0f, holsterUp, holsterOrigin);
}
VectorMA(selectorOrigin, DIST * x, holsterRight, selectorOrigin);
VectorMA(selectorOrigin, DIST * y, holsterUp, selectorOrigin);
VectorCopy(holsterOrigin, beamOrigin);
VectorMA(holsterOrigin, ((DEPTH*2.0f)*((selectorMode == WS_CONTROLLER) ? frac : 1.0f)), holsterForward, holsterOrigin);
VectorCopy(holsterOrigin, selectorOrigin);
float x = 0.0f;
float y = 0.0f;
if (selectorMode == WS_CONTROLLER)
{
x = (sinf(DEG2RAD(holsterAngles[YAW] - controllerAngles[YAW])) / sinf(DEG2RAD(22.5f)));
y = ((holsterAngles[PITCH] - controllerAngles[PITCH]) / 22.5f);
float len = length(x, y);
if (len > 1.0f)
{
x *= (1.0f / len);
y *= (1.0f / len);
}
}
else //selectorMode == WS_HMD
{
if (length(vr->thumbstick_location[0], vr->thumbstick_location[1]) > 0.95f)
{
float a = atan2(vr->thumbstick_location[0], vr->thumbstick_location[1]);
x = sinf(a) * 0.95f;
y = cosf(a) * 0.95f;
}
}
VectorMA(selectorOrigin, RAD * x, holsterRight, selectorOrigin);
VectorMA(selectorOrigin, RAD * y, holsterUp, selectorOrigin);
{
refEntity_t blob;
@ -2099,39 +2135,43 @@ void CG_DrawHolsteredWeapons( void )
blob.hModel = cgs.media.smallSphereModel;
trap_R_AddRefEntityToScene( &blob );
byte colour[4];
colour[0] = 0x00;
colour[1] = 0x00;
colour[2] = 0xff;
colour[3] = 0x40;
CG_LaserSight(beamOrigin, selectorOrigin, colour, 0.1f);
if (selectorMode == WS_CONTROLLER)
{
byte colour[4];
colour[0] = 0x00;
colour[1] = 0x00;
colour[2] = 0xff;
colour[3] = 0x40;
CG_LaserSight(beamOrigin, selectorOrigin, colour, 0.1f);
}
}
//float startingPositionYaw = AngleNormalize360(holsterAngles[YAW] + (((WP_NUM_WEAPONS-2)/2.0f) * SEP));
qboolean selected = qfalse;
int w = 0;
for (int c = 0; c < WP_NUM_WEAPONS-1; ++c, ++w)
int w = 1;
for (int c = 0; c < WP_NUM_WEAPONS-2; ++c, ++w)
{
if (w == WP_GRAPPLING_HOOK)
{
continue;
}
CG_RegisterWeapon(w);
{
qboolean selectable = CG_WeaponSelectable(w);
qboolean selectable = CG_WeaponSelectable(w) && cg.snap->ps.ammo[ w ];
//first calculate holster slot position
vec3_t angles, iconOrigin,iconBackground;
vec3_t angles, iconOrigin,iconBackground,iconForeground;
VectorClear(angles);
angles[YAW] = holsterAngles[YAW];
angles[PITCH] = holsterAngles[PITCH];
angles[ROLL] = AngleNormalize360(180 + (w * SEP) - 4); // add a few degrees as models aren't central
angles[ROLL] = AngleNormalize360((w * SEP));
vec3_t forward, up;
AngleVectors(angles, forward, NULL, up);
VectorMA(holsterOrigin, (DIST*frac), up, iconOrigin);
VectorMA(iconOrigin, 0.01f, forward, iconBackground);
VectorMA(holsterOrigin, (RAD*frac), up, iconOrigin);
VectorMA(iconOrigin, 0.1f, forward, iconBackground);
VectorMA(iconOrigin, -0.1f, forward, iconForeground);
//Float sprite above selected weapon
vec3_t diff;
@ -2141,51 +2181,48 @@ void CG_DrawHolsteredWeapons( void )
frac == 1.0f &&
selectable)
{
if (cg.weaponHolsterSelection != w)
if (cg.weaponSelectorSelection != w)
{
cg.weaponHolsterSelection = w;
cg.weaponSelectorSelection = w;
trap_HapticEvent("selector_icon", 0, 0, 100, 0, 0);
}
refEntity_t sprite;
memset( &sprite, 0, sizeof( sprite ) );
VectorCopy( iconOrigin, sprite.origin );
sprite.origin[2] += 2.5f + (0.5f * sinf(DEG2RAD(AngleNormalize360((cg.time - cg.weaponHolsterTime)/4))));
sprite.reType = RT_SPRITE;
sprite.customShader = cgs.media.friendShader;
sprite.radius = 0.5f;
sprite.shaderRGBA[0] = 255;
sprite.shaderRGBA[1] = 255;
sprite.shaderRGBA[2] = 255;
sprite.shaderRGBA[3] = 255;
trap_R_AddRefEntityToScene( &sprite );
selected = qtrue;
}
if (!cg_holsterSimple2DIcons.integer)
if (cg.weaponSelectorSelection == w)
{
//Wrap weapon in a small sphere - absent weapon will be a very small sphere
refEntity_t sprite;
memset( &sprite, 0, sizeof( sprite ) );
VectorCopy( iconOrigin, sprite.origin );
sprite.origin[2] += 2.5f + (0.5f * sinf(DEG2RAD(AngleNormalize360((cg.time - cg.weaponSelectorTime)/4))));
sprite.reType = RT_SPRITE;
sprite.customShader = cgs.media.friendShader;
sprite.radius = 0.5f;
sprite.shaderRGBA[0] = 255;
sprite.shaderRGBA[1] = 255;
sprite.shaderRGBA[2] = 255;
sprite.shaderRGBA[3] = 255;
trap_R_AddRefEntityToScene( &sprite );
}
if (!cg_weaponSelectorSimple2DIcons.integer)
{
/* if (selectable)
{
float f2 = 1.0f;
if (!selectable) f2 = 0.05f;
refEntity_t blob;
refEntity_t blob;
memset( &blob, 0, sizeof( blob ) );
VectorCopy( iconOrigin, blob.origin );
AnglesToAxis(vec3_origin, blob.axis);
VectorScale( blob.axis[0], (SCALE*frac*f2) + 0.05f + (cg.weaponHolsterSelection == w ? 0.035f : 0), blob.axis[0] );
VectorScale( blob.axis[1], (SCALE*frac*f2) + 0.05f + (cg.weaponHolsterSelection == w ? 0.035f : 0), blob.axis[1] );
VectorScale( blob.axis[2], (SCALE*frac*f2) + 0.05f + (cg.weaponHolsterSelection == w ? 0.035f : 0), blob.axis[2] );
float sphereScale = (SCALE*frac) + 0.05f + (cg.weaponSelectorSelection == w ? 0.035f : 0);
VectorScale( blob.axis[0], sphereScale, blob.axis[0] );
VectorScale( blob.axis[1], sphereScale, blob.axis[1] );
VectorScale( blob.axis[2], sphereScale, blob.axis[2] );
blob.nonNormalizedAxes = qtrue;
blob.hModel = cgs.media.smallSphereModel;
blob.customShader = cgs.media.invisShader;
blob.customShader = cgs.media.invisShader;
trap_R_AddRefEntityToScene( &blob );
}
if (!selectable)
{
continue;
}
}*/
refEntity_t ent;
memset(&ent, 0, sizeof(ent));
@ -2214,10 +2251,14 @@ void CG_DrawHolsteredWeapons( void )
{
iconAngles[ROLL] -= 90.0f;
}
float weaponScale = ((SCALE+0.02f)*frac) +
(cg.weaponSelectorSelection == w ? 0.04f : 0);
AnglesToAxis(iconAngles, ent.axis);
VectorScale(ent.axis[0], ((SCALE+0.01f)*frac) + (cg.weaponHolsterSelection == w ? 0.04f : 0), ent.axis[0]);
VectorScale(ent.axis[1], ((SCALE+0.01f)*frac) + (cg.weaponHolsterSelection == w ? 0.04f : 0), ent.axis[1]);
VectorScale(ent.axis[2], ((SCALE+0.01f)*frac) + (cg.weaponHolsterSelection == w ? 0.04f : 0), ent.axis[2]);
VectorScale(ent.axis[0], weaponScale, ent.axis[0]);
VectorScale(ent.axis[1], weaponScale, ent.axis[1]);
VectorScale(ent.axis[2], weaponScale, ent.axis[2]);
ent.nonNormalizedAxes = qtrue;
if( w == WP_RAILGUN ) {
@ -2235,6 +2276,10 @@ void CG_DrawHolsteredWeapons( void )
}
ent.hModel = cg_weapons[w].weaponModel;
if (!selectable)
{
ent.customShader = cgs.media.invisShader;
}
trap_R_AddRefEntityToScene(&ent);
if ( cg_weapons[w].barrelModel )
@ -2244,10 +2289,14 @@ void CG_DrawHolsteredWeapons( void )
barrel.hModel = cg_weapons[w].barrelModel;
vec3_t barrelAngles;
VectorClear(barrelAngles);
barrelAngles[ROLL] = AngleNormalize360((cg.time - cg.weaponHolsterTime) * 0.9f);
barrelAngles[ROLL] = AngleNormalize360((cg.time - cg.weaponSelectorTime) * 0.9f);
AnglesToAxis(barrelAngles, barrel.axis);
CG_PositionRotatedEntityOnTag(&barrel, &ent, cg_weapons[w].weaponModel,
"tag_barrel");
if (!selectable)
{
barrel.customShader = cgs.media.invisShader;
}
trap_R_AddRefEntityToScene(&barrel);
}
@ -2257,35 +2306,49 @@ void CG_DrawHolsteredWeapons( void )
refEntity_t sprite;
memset( &sprite, 0, sizeof( sprite ) );
if (selectable)
VectorCopy(iconOrigin, sprite.origin);
sprite.reType = RT_SPRITE;
sprite.customShader = cg_weapons[w].weaponIcon;
sprite.radius = 0.6f + (cg.weaponSelectorSelection == w ? 0.1f : 0);
sprite.shaderRGBA[0] = 255;
sprite.shaderRGBA[1] = 255;
sprite.shaderRGBA[2] = 255;
sprite.shaderRGBA[3] = 255;
trap_R_AddRefEntityToScene(&sprite);
//And now the selection background
memset( &sprite, 0, sizeof( sprite ) );
VectorCopy( iconBackground, sprite.origin );
sprite.reType = RT_SPRITE;
sprite.customShader = cgs.media.selectShader;
sprite.radius = 0.7f + (cg.weaponSelectorSelection == w ? 0.1f : 0);
sprite.shaderRGBA[0] = 255;
sprite.shaderRGBA[1] = 255;
sprite.shaderRGBA[2] = 255;
sprite.shaderRGBA[3] = 255;
trap_R_AddRefEntityToScene( &sprite );
if (!selectable)
{
VectorCopy(iconOrigin, sprite.origin);
sprite.reType = RT_SPRITE;
sprite.customShader = cg_weapons[w].weaponIcon;
sprite.radius = 0.6f + (cg.weaponHolsterSelection == w ? 0.1f : 0);
memset(&sprite, 0, sizeof(sprite));
VectorCopy(iconForeground, sprite.origin);
sprite.reType = RT_SPRITE;
sprite.customShader = cgs.media.noammoShader;
sprite.radius = 0.7f;
sprite.shaderRGBA[0] = 255;
sprite.shaderRGBA[1] = 255;
sprite.shaderRGBA[2] = 255;
sprite.shaderRGBA[3] = 255;
trap_R_AddRefEntityToScene(&sprite);
}
//And now the selection background
VectorCopy( iconBackground, sprite.origin );
sprite.customShader = cgs.media.selectShader;
sprite.radius = 0.7f + (cg.weaponHolsterSelection == w ? 0.1f : 0);
sprite.shaderRGBA[0] = 255;
sprite.shaderRGBA[1] = 255;
sprite.shaderRGBA[2] = 255;
sprite.shaderRGBA[3] = 255;
trap_R_AddRefEntityToScene( &sprite );
}
}
}
if (!selected)
//Only reset selection if using controller pointer
if (!selected && selectorMode == WS_CONTROLLER)
{
cg.weaponHolsterSelection = WP_NONE;
cg.weaponSelectorSelection = WP_NONE;
}
}

View file

@ -46,7 +46,7 @@ CONTROLS OPTIONS MENU
#define ID_SNAPTURN 131
#define ID_RIGHTHANDED 132
#define ID_WEAPONPITCH 133
#define ID_ALTKEY 134
#define ID_WEAPONSELECTORMODE 134
#define ID_BACK 135
@ -67,7 +67,7 @@ typedef struct {
menulist_s snapturn;
menuradiobutton_s righthanded;
menuslider_s weaponpitch;
menuradiobutton_s altkey;
menulist_s weaponselectormode;
menubitmap_s back;
} controls3_t;
@ -83,7 +83,7 @@ static void Controls3_SetMenuItems( void ) {
s_controls3.snapturn.curvalue = (int)trap_Cvar_VariableValue( "vr_snapturn" ) / 45;
s_controls3.righthanded.curvalue = trap_Cvar_VariableValue( "vr_righthanded" ) != 0;
s_controls3.weaponpitch.curvalue = trap_Cvar_VariableValue( "vr_weaponPitch" ) + 25;
s_controls3.altkey.curvalue = trap_Cvar_VariableValue( "vr_altKeyEnabled" ) != 0;
s_controls3.weaponselectormode.curvalue = (int)trap_Cvar_VariableValue( "vr_weaponSelectorMode" ) % 4;
}
@ -121,8 +121,33 @@ static void Controls3_MenuEvent( void* ptr, int notification ) {
trap_Cvar_SetValue( "vr_weaponPitch", s_controls3.weaponpitch.curvalue - 25 );
break;
case ID_ALTKEY:
trap_Cvar_SetValue( "vr_altKeyEnabled", s_controls3.altkey.curvalue );
case ID_WEAPONSELECTORMODE:
{
switch (s_controls3.weaponselectormode.curvalue)
{
case 0: //Controller
trap_Cvar_Set( "vr_button_map_PRIMARYGRIP", "+weapon_select");
trap_Cvar_Set( "vr_button_map_RTHUMBFORWARD", "");
trap_Cvar_Set( "vr_button_map_RTHUMBBACK", "uturn");
break;
case 1: //HMD
trap_Cvar_Set( "vr_button_map_PRIMARYGRIP", "+weapon_select");
trap_Cvar_Set( "vr_button_map_RTHUMBFORWARD", "");
trap_Cvar_Set( "vr_button_map_RTHUMBBACK", "uturn");
break;
case 2: //Alt-Key bindings
trap_Cvar_Set( "vr_button_map_PRIMARYGRIP", "+alt");
trap_Cvar_Set( "vr_button_map_RTHUMBFORWARD", "");
trap_Cvar_Set( "vr_button_map_RTHUMBBACK", "uturn");
break;
case 3: //Thumbstick
trap_Cvar_Set( "vr_button_map_PRIMARYGRIP", "");
trap_Cvar_Set( "vr_button_map_RTHUMBFORWARD", "weapnext");
trap_Cvar_Set( "vr_button_map_RTHUMBBACK", "weapprev");
break;
}
}
trap_Cvar_SetValue( "vr_weaponSelectorMode", s_controls3.weaponselectormode.curvalue );
break;
case ID_BACK:
@ -149,6 +174,15 @@ static void Controls3_MenuInit( void ) {
NULL
};
static const char *s_weaponselectormode[] =
{
"Controller Weapon Selector",
"HMD Weapon Wheel",
"Alt-Key Bindings",
"Thumbstick Forward/Back",
NULL
};
memset( &s_controls3, 0 ,sizeof(controls3_t) );
Controls3_Cache();
@ -248,14 +282,16 @@ static void Controls3_MenuInit( void ) {
s_controls3.weaponpitch.minvalue = 0;
s_controls3.weaponpitch.maxvalue = 30;
y += BIGCHAR_HEIGHT+2;
s_controls3.altkey.generic.type = MTYPE_RADIOBUTTON;
s_controls3.altkey.generic.x = VR_X_POS;
s_controls3.altkey.generic.y = y;
s_controls3.altkey.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_controls3.altkey.generic.name = "ALT Layout Trigger:";
s_controls3.altkey.generic.id = ID_ALTKEY;
s_controls3.altkey.generic.callback = Controls3_MenuEvent;
y += BIGCHAR_HEIGHT+2;
s_controls3.weaponselectormode.generic.type = MTYPE_SPINCONTROL;
s_controls3.weaponselectormode.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_controls3.weaponselectormode.generic.x = VR_X_POS;
s_controls3.weaponselectormode.generic.y = y;
s_controls3.weaponselectormode.generic.name = "Weapon Selector Mode:";
s_controls3.weaponselectormode.generic.callback = Controls3_MenuEvent;
s_controls3.weaponselectormode.generic.id = ID_WEAPONSELECTORMODE;
s_controls3.weaponselectormode.itemnames = s_weaponselectormode;
s_controls3.weaponselectormode.numitems = 4;
s_controls3.back.generic.type = MTYPE_BITMAP;
s_controls3.back.generic.name = ART_BACK0;
@ -279,7 +315,7 @@ static void Controls3_MenuInit( void ) {
Menu_AddItem( &s_controls3.menu, &s_controls3.snapturn );
Menu_AddItem( &s_controls3.menu, &s_controls3.righthanded );
Menu_AddItem( &s_controls3.menu, &s_controls3.weaponpitch );
Menu_AddItem( &s_controls3.menu, &s_controls3.altkey );
Menu_AddItem( &s_controls3.menu, &s_controls3.weaponselectormode );
Menu_AddItem( &s_controls3.menu, &s_controls3.back );

View file

@ -123,7 +123,7 @@ static void Preferences_SetMenuItems( void ) {
s_preferences.drawteamoverlay.curvalue = Com_Clamp( 0, 3, trap_Cvar_VariableValue( "cg_drawTeamOverlay" ) );
s_preferences.drawhud.curvalue = trap_Cvar_VariableValue( "cg_drawStatus" ) != 0;
// s_preferences.allowdownload.curvalue = trap_Cvar_VariableValue( "cl_allowDownload" ) != 0;
s_preferences.holster2d.curvalue = trap_Cvar_VariableValue( "cg_holsterSimple2DIcons" ) != 0;
s_preferences.holster2d.curvalue = trap_Cvar_VariableValue( "cg_weaponSelectorSimple2DIcons" ) != 0;
//GORE
{
int level = trap_Cvar_VariableValue( "com_blood" ) +
@ -199,7 +199,7 @@ static void Preferences_Event( void* ptr, int notification ) {
break;
case ID_HOLSTER2D:
trap_Cvar_SetValue( "cg_holsterSimple2DIcons", s_preferences.holster2d.curvalue);
trap_Cvar_SetValue( "cg_weaponSelectorSimple2DIcons", s_preferences.holster2d.curvalue);
break;
case ID_GORE: {

View file

@ -132,7 +132,7 @@ static void VR_SetMenuItems( void ) {
s_VR.sendroll.curvalue = trap_Cvar_VariableValue( "vr_sendRollToServer" ) != 0;
s_VR.lasersight.curvalue = trap_Cvar_VariableValue( "vr_lasersight" ) != 0;
s_VR.hapticintensity.curvalue = trap_Cvar_VariableValue( "vr_hapticIntensity" );
s_VR.holster2d.curvalue = trap_Cvar_VariableValue( "cg_holsterSimple2DIcons" ) != 0;
s_VR.holster2d.curvalue = trap_Cvar_VariableValue( "cg_weaponSelectorSimple2DIcons" ) != 0;
s_VR.bodyscale.curvalue = trap_Cvar_VariableValue( "cg_firstPersonBodyScale" );
//GORE
@ -233,7 +233,7 @@ static void VR_Event( void* ptr, int notification ) {
break;
case ID_HOLSTER2D:
trap_Cvar_SetValue( "cg_holsterSimple2DIcons", s_VR.holster2d.curvalue);
trap_Cvar_SetValue( "cg_weaponSelectorSimple2DIcons", s_VR.holster2d.curvalue);
break;
case ID_BODYSCALE:

View file

@ -27,7 +27,6 @@ cvar_t *vr_extralatencymode = NULL;
cvar_t *vr_directionMode = NULL;
cvar_t *vr_weaponPitch = NULL;
cvar_t *vr_twoHandedWeapons = NULL;
cvar_t *vr_altKeyEnabled = NULL;
cvar_t *vr_showItemInHand = NULL;
cvar_t *vr_refreshrate = NULL;
cvar_t *vr_weaponScope = NULL;
@ -37,6 +36,7 @@ cvar_t *vr_sendRollToServer = NULL;
cvar_t *vr_lasersight = NULL;
cvar_t *vr_hapticIntensity = NULL;
cvar_t *vr_comfortVignette = NULL;
cvar_t *vr_weaponSelectorMode = NULL;
engine_t* VR_Init( ovrJava java )
{
@ -65,7 +65,6 @@ void VR_InitCvars( void )
vr_weaponPitch = Cvar_Get ("vr_weaponPitch", "-20", CVAR_ARCHIVE);
vr_heightAdjust = Cvar_Get ("vr_heightAdjust", "0.0", CVAR_ARCHIVE);
vr_twoHandedWeapons = Cvar_Get ("vr_twoHandedWeapons", "1", CVAR_ARCHIVE);
vr_altKeyEnabled = Cvar_Get ("vr_altKeyEnabled", "0", CVAR_ARCHIVE);
vr_showItemInHand = Cvar_Get ("vr_showItemInHand", "1", CVAR_ARCHIVE);
vr_refreshrate = Cvar_Get ("vr_refreshrate", "72", CVAR_ARCHIVE);
vr_weaponScope = Cvar_Get ("vr_weaponScope", "1", CVAR_ARCHIVE);
@ -75,6 +74,7 @@ void VR_InitCvars( void )
vr_lasersight = Cvar_Get ("vr_lasersight", "0", CVAR_ARCHIVE);
vr_hapticIntensity = Cvar_Get ("vr_hapticIntensity", "1.0", CVAR_ARCHIVE);
vr_comfortVignette = Cvar_Get ("vr_comfortVignette", "0.0", CVAR_ARCHIVE);
vr_weaponSelectorMode = Cvar_Get ("vr_weaponSelectorMode", "0", CVAR_ARCHIVE);
// Values are: scale,right,up,forward,pitch,yaw,roll
// VALUES PROVIDED BY SkillFur - Thank-you!
@ -105,7 +105,7 @@ void VR_InitCvars( void )
Cvar_Get ("vr_button_map_SECONDARYTHUMBSTICK", "+scores", CVAR_ARCHIVE); // Scoreboard
Cvar_Get ("vr_button_map_SECONDARYTHUMBSTICK_ALT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_PRIMARYTHUMBSTICK", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_PRIMARYTHUMBSTICK_ALT", "weapon 1", CVAR_ARCHIVE); // Switch to gauntlet
Cvar_Get ("vr_button_map_PRIMARYTHUMBSTICK_ALT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBFORWARD", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBFORWARD_ALT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBFORWARDRIGHT", "", CVAR_ARCHIVE); // unmapped
@ -114,7 +114,7 @@ void VR_InitCvars( void )
Cvar_Get ("vr_button_map_RTHUMBRIGHT_ALT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBBACKRIGHT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBBACKRIGHT_ALT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBBACK", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBBACK", "uturn", CVAR_ARCHIVE); // U-Turn
Cvar_Get ("vr_button_map_RTHUMBBACK_ALT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBBACKLEFT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBBACKLEFT_ALT", "", CVAR_ARCHIVE); // unmapped
@ -128,11 +128,8 @@ void VR_InitCvars( void )
Cvar_Get ("vr_button_map_PRIMARYTRIGGER_ALT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_SECONDARYGRIP", "+weapon_stabilise", CVAR_ARCHIVE); // Weapon stabilisation
Cvar_Get ("vr_button_map_SECONDARYGRIP_ALT", "", CVAR_ARCHIVE); // unmapped
// enables the alt mapping of a button
Cvar_Get ("vr_button_map_PRIMARYGRIP", "+alt", CVAR_ARCHIVE);
Cvar_Get ("vr_button_map_PRIMARYGRIP", "+weapon_select", CVAR_ARCHIVE);
Cvar_Get ("vr_button_map_PRIMARYGRIP_ALT", "", CVAR_ARCHIVE);
}
void VR_Destroy( engine_t* engine )

View file

@ -50,6 +50,8 @@ typedef struct {
vec3_t offhandoffset_last[2];
vec3_t offhandposition;
vec2_t thumbstick_location;
//////////////////////////////////////
// Test stuff for weapon alignment
//////////////////////////////////////

View file

@ -250,8 +250,7 @@ static void IN_SendButtonAction(const char* action, qboolean pressed)
//handle our special actions first
if (strcmp(action, "+alt") == 0)
{
qboolean alt_key_enabled = Cvar_VariableValue( "vr_altKeyEnabled" ) != 0;
alt_key_mode_active = pressed && alt_key_enabled;
alt_key_mode_active = pressed;
}
else if (strcmp(action, "+weapon_stabilise") == 0)
{
@ -262,7 +261,7 @@ static void IN_SendButtonAction(const char* action, qboolean pressed)
vr.weapon_select = pressed;
if (!pressed)
{
Cbuf_AddText("holster_select");
Cbuf_AddText("weapon_select");
}
}
else if (action[0] == '+')
@ -458,6 +457,12 @@ static void IN_VRJoystick( qboolean isRightController, float joystickX, float jo
char action[256];
vrController_t* controller = isRightController == qtrue ? &rightController : &leftController;
if (isRightController)
{
vr.thumbstick_location[0] = joystickX;
vr.thumbstick_location[1] = joystickY;
}
if (vr.virtual_screen ||
cl.snap.ps.pm_type == PM_INTERMISSION)
{
@ -509,7 +514,7 @@ static void IN_VRJoystick( qboolean isRightController, float joystickX, float jo
//forward/back
Com_QueueEvent(in_vrEventTime, SE_JOYSTICK_AXIS, 1, joystick[1] * 127.0f + positional[1] * 127.0f, 0, NULL);
}
else //right controller
else if (!vr.weapon_select) //right controller
{
// up, up-left, up-right (use release threshold to be more sensitive)

View file

@ -31,4 +31,11 @@ typedef struct {
framebuffer_t framebuffers[VRAPI_FRAME_LAYER_EYE_MAX];
} engine_t;
typedef enum {
WS_CONTROLLER,
WS_HMD,
WS_ALTKEY,
WS_PREVNEXT
} weaponSelectorType_t;
#endif