2020-02-22 16:10:48 +00:00
/************************************************************************************
Filename : VrInputDefault . c
Content : Handles default controller input
Created : August 2019
Authors : Simon Brown
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
# include <VrApi.h>
# include <VrApi_Helpers.h>
# include <VrApi_SystemUtils.h>
# include <VrApi_Input.h>
# include <VrApi_Types.h>
2020-03-15 23:16:38 +00:00
# include <android/keycodes.h>
2020-02-22 16:10:48 +00:00
# include "VrInput.h"
2020-03-05 22:30:08 +00:00
# include "doomkeys.h"
2020-02-22 16:10:48 +00:00
2020-03-07 00:31:49 +00:00
int getGameState ( ) ;
2020-04-14 15:49:54 +00:00
int getMenuState ( ) ;
2020-03-07 00:31:49 +00:00
void Joy_GenerateButtonEvents ( int oldbuttons , int newbuttons , int numbuttons , int base ) ;
2020-06-07 21:32:20 +00:00
float getViewpointYaw ( ) ;
2020-03-07 00:31:49 +00:00
2021-02-20 23:37:24 +00:00
void HandleInput_Default ( int control_scheme , ovrInputStateTrackedRemote * pDominantTrackedRemoteNew , ovrInputStateTrackedRemote * pDominantTrackedRemoteOld , ovrTracking * pDominantTracking ,
2020-02-22 16:10:48 +00:00
ovrInputStateTrackedRemote * pOffTrackedRemoteNew , ovrInputStateTrackedRemote * pOffTrackedRemoteOld , ovrTracking * pOffTracking ,
int domButton1 , int domButton2 , int offButton1 , int offButton2 )
{
2020-03-15 08:36:32 +00:00
//Menu button - invoke menu
handleTrackedControllerButton ( & leftTrackedRemoteState_new , & leftTrackedRemoteState_old , ovrButton_Enter , KEY_ESCAPE ) ;
2021-03-15 23:05:58 +00:00
handleTrackedControllerButton ( & rightTrackedRemoteState_new , & rightTrackedRemoteState_old , ovrButton_Enter , KEY_ESCAPE ) ; // For users who have switched the buttons
2020-02-22 16:10:48 +00:00
2020-04-15 19:48:44 +00:00
if ( getGameState ( ) ! = 0 | | getMenuState ( ) = = 1 ) // If getMenuState returns 2, then we are waiting for a key mapping input, so send normal keymappings, don't send these
2020-02-22 16:10:48 +00:00
{
2020-03-07 00:31:49 +00:00
Joy_GenerateButtonEvents ( ( pOffTrackedRemoteOld - > Joystick . x > 0.7f ? 1 : 0 ) , ( pOffTrackedRemoteNew - > Joystick . x > 0.7f ? 1 : 0 ) , 1 , KEY_PAD_DPAD_RIGHT ) ;
2020-04-05 18:02:54 +00:00
Joy_GenerateButtonEvents ( ( pDominantTrackedRemoteOld - > Joystick . x > 0.7f ? 1 : 0 ) , ( pDominantTrackedRemoteNew - > Joystick . x > 0.7f ? 1 : 0 ) , 1 , KEY_PAD_DPAD_RIGHT ) ;
2020-03-07 00:31:49 +00:00
Joy_GenerateButtonEvents ( ( pOffTrackedRemoteOld - > Joystick . x < - 0.7f ? 1 : 0 ) , ( pOffTrackedRemoteNew - > Joystick . x < - 0.7f ? 1 : 0 ) , 1 , KEY_PAD_DPAD_LEFT ) ;
2020-04-05 18:02:54 +00:00
Joy_GenerateButtonEvents ( ( pDominantTrackedRemoteOld - > Joystick . x < - 0.7f ? 1 : 0 ) , ( pDominantTrackedRemoteNew - > Joystick . x < - 0.7f ? 1 : 0 ) , 1 , KEY_PAD_DPAD_LEFT ) ;
2020-03-07 00:31:49 +00:00
Joy_GenerateButtonEvents ( ( pOffTrackedRemoteOld - > Joystick . y < - 0.7f ? 1 : 0 ) , ( pOffTrackedRemoteNew - > Joystick . y < - 0.7f ? 1 : 0 ) , 1 , KEY_PAD_DPAD_DOWN ) ;
2020-04-05 18:02:54 +00:00
Joy_GenerateButtonEvents ( ( pDominantTrackedRemoteOld - > Joystick . y < - 0.7f ? 1 : 0 ) , ( pDominantTrackedRemoteNew - > Joystick . y < - 0.7f ? 1 : 0 ) , 1 , KEY_PAD_DPAD_DOWN ) ;
2020-02-22 16:10:48 +00:00
2020-03-07 00:31:49 +00:00
Joy_GenerateButtonEvents ( ( pOffTrackedRemoteOld - > Joystick . y > 0.7f ? 1 : 0 ) , ( pOffTrackedRemoteNew - > Joystick . y > 0.7f ? 1 : 0 ) , 1 , KEY_PAD_DPAD_UP ) ;
2020-04-05 18:02:54 +00:00
Joy_GenerateButtonEvents ( ( pDominantTrackedRemoteOld - > Joystick . y > 0.7f ? 1 : 0 ) , ( pDominantTrackedRemoteNew - > Joystick . y > 0.7f ? 1 : 0 ) , 1 , KEY_PAD_DPAD_UP ) ;
2020-04-14 15:49:54 +00:00
}
2020-03-07 00:31:49 +00:00
2020-04-14 15:49:54 +00:00
//Dominant Grip works like a shift key
2020-06-02 21:40:23 +00:00
bool dominantGripPushedOld = vr_secondarybuttonmappings ?
( pDominantTrackedRemoteOld - > Buttons & ovrButton_GripTrigger ) ! = 0 : false ;
bool dominantGripPushedNew = vr_secondarybuttonmappings ?
( pDominantTrackedRemoteNew - > Buttons & ovrButton_GripTrigger ) ! = 0 : false ;
2020-04-05 18:02:54 +00:00
2020-04-15 19:48:44 +00:00
ovrInputStateTrackedRemote * pPrimaryTrackedRemoteNew , * pPrimaryTrackedRemoteOld , * pSecondaryTrackedRemoteNew , * pSecondaryTrackedRemoteOld ;
if ( vr_switchsticks )
{
pPrimaryTrackedRemoteNew = pOffTrackedRemoteNew ;
pPrimaryTrackedRemoteOld = pOffTrackedRemoteOld ;
pSecondaryTrackedRemoteNew = pDominantTrackedRemoteNew ;
pSecondaryTrackedRemoteOld = pDominantTrackedRemoteOld ;
}
else
{
pPrimaryTrackedRemoteNew = pDominantTrackedRemoteNew ;
pPrimaryTrackedRemoteOld = pDominantTrackedRemoteOld ;
pSecondaryTrackedRemoteNew = pOffTrackedRemoteNew ;
pSecondaryTrackedRemoteOld = pOffTrackedRemoteOld ;
}
2021-02-20 23:37:24 +00:00
//All this to allow stick and button switching!
uint32_t primaryButtonsNew ;
uint32_t primaryButtonsOld ;
uint32_t secondaryButtonsNew ;
uint32_t secondaryButtonsOld ;
int primaryButton1 ;
int primaryButton2 ;
int secondaryButton1 ;
int secondaryButton2 ;
if ( control_scheme = = 11 ) // Left handed Alt
{
primaryButtonsNew = pOffTrackedRemoteNew - > Buttons ;
primaryButtonsOld = pOffTrackedRemoteOld - > Buttons ;
secondaryButtonsNew = pDominantTrackedRemoteNew - > Buttons ;
secondaryButtonsOld = pDominantTrackedRemoteOld - > Buttons ;
primaryButton1 = offButton1 ;
primaryButton2 = offButton2 ;
secondaryButton1 = domButton1 ;
secondaryButton2 = domButton2 ;
}
else // Left and right handed
{
primaryButtonsNew = pDominantTrackedRemoteNew - > Buttons ;
primaryButtonsOld = pDominantTrackedRemoteOld - > Buttons ;
secondaryButtonsNew = pOffTrackedRemoteNew - > Buttons ;
secondaryButtonsOld = pOffTrackedRemoteOld - > Buttons ;
primaryButton1 = domButton1 ;
primaryButton2 = domButton2 ;
secondaryButton1 = offButton1 ;
secondaryButton2 = offButton2 ;
}
2020-06-06 13:41:41 +00:00
//In cinema mode, right-stick controls mouse
2020-06-08 18:15:23 +00:00
const float mouseSpeed = 3.0f ;
2020-06-06 13:41:41 +00:00
if ( cinemamode )
{
2020-06-08 18:15:23 +00:00
if ( fabs ( pPrimaryTrackedRemoteNew - > Joystick . x ) > 0.1f ) {
cinemamodeYaw - = mouseSpeed * pPrimaryTrackedRemoteNew - > Joystick . x ;
2020-06-06 13:41:41 +00:00
}
2020-06-08 18:15:23 +00:00
if ( fabs ( pPrimaryTrackedRemoteNew - > Joystick . y ) > 0.1f ) {
cinemamodePitch - = mouseSpeed * pPrimaryTrackedRemoteNew - > Joystick . y ;
2020-06-06 13:41:41 +00:00
}
}
2020-04-14 15:49:54 +00:00
// Only do the following if we are definitely not in the menu
if ( getMenuState ( ) = = 0 )
2020-02-22 16:10:48 +00:00
{
2020-04-14 15:49:54 +00:00
float distance = sqrtf ( powf ( pOffTracking - > HeadPose . Pose . Position . x -
pDominantTracking - > HeadPose . Pose . Position . x , 2 ) +
powf ( pOffTracking - > HeadPose . Pose . Position . y -
pDominantTracking - > HeadPose . Pose . Position . y , 2 ) +
powf ( pOffTracking - > HeadPose . Pose . Position . z -
pDominantTracking - > HeadPose . Pose . Position . z , 2 ) ) ;
2020-02-22 16:10:48 +00:00
//Turn on weapon stabilisation?
2020-05-24 09:52:47 +00:00
if ( vr_twohandedweapons & &
( pOffTrackedRemoteNew - > Buttons & ovrButton_GripTrigger ) ! =
2020-02-22 16:10:48 +00:00
( pOffTrackedRemoteOld - > Buttons & ovrButton_GripTrigger ) ) {
2020-04-14 15:49:54 +00:00
if ( pOffTrackedRemoteNew - > Buttons & ovrButton_GripTrigger ) {
if ( distance < 0.50f ) {
2020-03-05 22:30:08 +00:00
weaponStabilised = true ;
2020-02-22 16:10:48 +00:00
}
2020-04-14 15:49:54 +00:00
} else {
2020-03-05 22:30:08 +00:00
weaponStabilised = false ;
2020-02-22 16:10:48 +00:00
}
}
//dominant hand stuff first
{
2020-04-14 15:49:54 +00:00
///Weapon location relative to view
2020-02-22 16:10:48 +00:00
weaponoffset [ 0 ] = pDominantTracking - > HeadPose . Pose . Position . x - hmdPosition [ 0 ] ;
weaponoffset [ 1 ] = pDominantTracking - > HeadPose . Pose . Position . y - hmdPosition [ 1 ] ;
weaponoffset [ 2 ] = pDominantTracking - > HeadPose . Pose . Position . z - hmdPosition [ 2 ] ;
2020-04-14 15:49:54 +00:00
{
vec2_t v ;
2020-06-07 21:32:20 +00:00
float yawRotation = cinemamode ? getViewpointYaw ( ) - hmdorientation [ YAW ] :
doomYaw - hmdorientation [ YAW ] ;
2020-04-14 15:49:54 +00:00
rotateAboutOrigin ( weaponoffset [ 0 ] , weaponoffset [ 2 ] ,
2020-06-07 21:32:20 +00:00
- yawRotation , v ) ;
2020-04-14 15:49:54 +00:00
weaponoffset [ 0 ] = v [ 1 ] ;
weaponoffset [ 2 ] = v [ 0 ] ;
}
2020-02-22 16:10:48 +00:00
2020-03-15 08:36:32 +00:00
//Set gun angles
2020-02-22 16:10:48 +00:00
const ovrQuatf quatRemote = pDominantTracking - > HeadPose . Pose . Orientation ;
2020-03-15 08:36:32 +00:00
vec3_t rotation = { 0 } ;
rotation [ PITCH ] = vr_weapon_pitchadjust ;
QuatToYawPitchRoll ( quatRemote , rotation , weaponangles ) ;
2020-02-22 16:10:48 +00:00
2020-04-14 15:49:54 +00:00
if ( weaponStabilised ) {
float z = pOffTracking - > HeadPose . Pose . Position . z -
pDominantTracking - > HeadPose . Pose . Position . z ;
float x = pOffTracking - > HeadPose . Pose . Position . x -
pDominantTracking - > HeadPose . Pose . Position . x ;
float y = pOffTracking - > HeadPose . Pose . Position . y -
pDominantTracking - > HeadPose . Pose . Position . y ;
2020-02-22 16:10:48 +00:00
float zxDist = length ( x , z ) ;
if ( zxDist ! = 0.0f & & z ! = 0.0f ) {
2020-04-14 15:49:54 +00:00
VectorSet ( weaponangles , - degrees ( atanf ( y / zxDist ) ) , - degrees ( atan2f ( x , - z ) ) ,
weaponangles [ ROLL ] ) ;
2020-02-22 16:10:48 +00:00
}
}
}
float controllerYawHeading = 0.0f ;
2020-03-09 23:59:38 +00:00
2020-02-22 16:10:48 +00:00
//off-hand stuff
{
2020-03-08 21:44:49 +00:00
offhandoffset [ 0 ] = pOffTracking - > HeadPose . Pose . Position . x - hmdPosition [ 0 ] ;
offhandoffset [ 1 ] = pOffTracking - > HeadPose . Pose . Position . y - hmdPosition [ 1 ] ;
offhandoffset [ 2 ] = pOffTracking - > HeadPose . Pose . Position . z - hmdPosition [ 2 ] ;
2020-02-22 16:10:48 +00:00
2020-04-14 15:49:54 +00:00
vec2_t v ;
rotateAboutOrigin ( offhandoffset [ 0 ] , offhandoffset [ 2 ] , - ( doomYaw - hmdorientation [ YAW ] ) ,
v ) ;
offhandoffset [ 0 ] = v [ 1 ] ;
offhandoffset [ 2 ] = v [ 0 ] ;
2020-02-22 16:10:48 +00:00
2020-03-15 08:36:32 +00:00
vec3_t rotation = { 0 } ;
QuatToYawPitchRoll ( pOffTracking - > HeadPose . Pose . Orientation , rotation , offhandangles ) ;
2020-02-22 16:10:48 +00:00
2020-04-14 15:49:54 +00:00
if ( vr_moveuseoffhand ! = 0 ) {
controllerYawHeading = offhandangles [ YAW ] - hmdorientation [ YAW ] ;
} else {
controllerYawHeading = 0.0f ;
}
2020-02-22 16:10:48 +00:00
}
2020-03-10 18:51:35 +00:00
//Positional movement
2020-02-22 16:10:48 +00:00
{
ALOGV ( " Right-Controller-Position: %f, %f, %f " ,
pDominantTracking - > HeadPose . Pose . Position . x ,
2020-04-14 15:49:54 +00:00
pDominantTracking - > HeadPose . Pose . Position . y ,
pDominantTracking - > HeadPose . Pose . Position . z ) ;
2020-02-22 16:10:48 +00:00
vec2_t v ;
2020-04-14 15:49:54 +00:00
rotateAboutOrigin ( positionDeltaThisFrame [ 0 ] , positionDeltaThisFrame [ 2 ] ,
- ( doomYaw - hmdorientation [ YAW ] ) , v ) ;
2020-03-14 07:59:17 +00:00
positional_movementSideways = v [ 1 ] ;
positional_movementForward = v [ 0 ] ;
2020-02-22 16:10:48 +00:00
ALOGV ( " positional_movementSideways: %f, positional_movementForward: %f " ,
positional_movementSideways ,
positional_movementForward ) ;
}
2020-03-09 23:59:38 +00:00
//Off-hand specific stuff
2020-02-22 16:10:48 +00:00
{
ALOGV ( " Left-Controller-Position: %f, %f, %f " ,
pOffTracking - > HeadPose . Pose . Position . x ,
2020-04-14 15:49:54 +00:00
pOffTracking - > HeadPose . Pose . Position . y ,
pOffTracking - > HeadPose . Pose . Position . z ) ;
2020-02-22 16:10:48 +00:00
2020-04-14 15:49:54 +00:00
//Teleport - only does anything if vr_teleport cvar is true
if ( vr_use_teleport ) {
2020-04-23 19:21:00 +00:00
if ( ( pSecondaryTrackedRemoteOld - > Joystick . y > 0.7f ) & & ! ready_teleport ) {
2020-04-11 23:34:29 +00:00
ready_teleport = true ;
2020-04-23 19:21:00 +00:00
} else if ( ( pSecondaryTrackedRemoteOld - > Joystick . y < 0.7f ) & & ready_teleport ) {
2020-04-11 23:34:29 +00:00
ready_teleport = false ;
trigger_teleport = true ;
}
2020-03-29 22:06:48 +00:00
}
2020-02-22 16:10:48 +00:00
2020-04-14 15:49:54 +00:00
//Apply a filter and quadratic scaler so small movements are easier to make
//and we don't get movement jitter when the joystick doesn't quite center properly
2020-04-15 19:48:44 +00:00
float dist = length ( pSecondaryTrackedRemoteNew - > Joystick . x , pSecondaryTrackedRemoteNew - > Joystick . y ) ;
2020-04-14 15:49:54 +00:00
float nlf = nonLinearFilter ( dist ) ;
2020-04-15 19:48:44 +00:00
float x = nlf * pSecondaryTrackedRemoteNew - > Joystick . x ;
float y = nlf * pSecondaryTrackedRemoteNew - > Joystick . y ;
2020-02-22 16:10:48 +00:00
2020-03-10 18:51:35 +00:00
//Apply a simple deadzone
2020-02-22 16:10:48 +00:00
player_moving = ( fabs ( x ) + fabs ( y ) ) > 0.05f ;
2020-03-10 18:51:35 +00:00
x = player_moving ? x : 0 ;
y = player_moving ? y : 0 ;
2020-02-22 16:10:48 +00:00
2020-04-14 15:49:54 +00:00
//Adjust to be off-hand controller oriented
2020-02-22 16:10:48 +00:00
vec2_t v ;
rotateAboutOrigin ( x , y , controllerYawHeading , v ) ;
remote_movementSideways = v [ 0 ] ;
remote_movementForward = v [ 1 ] ;
ALOGV ( " remote_movementSideways: %f, remote_movementForward: %f " ,
remote_movementSideways ,
remote_movementForward ) ;
2020-06-06 13:41:41 +00:00
if ( ! cinemamode )
{
// Turning logic
static int increaseSnap = true ;
if ( pPrimaryTrackedRemoteNew - > Joystick . x > 0.6f ) {
if ( increaseSnap ) {
resetDoomYaw = true ;
snapTurn - = vr_snapturn_angle ;
if ( vr_snapturn_angle > 10.0f ) {
increaseSnap = false ;
}
if ( snapTurn < - 180.0f ) {
snapTurn + = 360.f ;
}
2020-02-22 16:10:48 +00:00
}
2020-06-06 13:41:41 +00:00
} else if ( pPrimaryTrackedRemoteNew - > Joystick . x < 0.4f ) {
increaseSnap = true ;
2020-02-22 16:10:48 +00:00
}
2020-04-14 15:49:54 +00:00
2020-06-06 13:41:41 +00:00
static int decreaseSnap = true ;
if ( pPrimaryTrackedRemoteNew - > Joystick . x < - 0.6f ) {
if ( decreaseSnap ) {
resetDoomYaw = true ;
snapTurn + = vr_snapturn_angle ;
2020-02-22 16:10:48 +00:00
2020-06-06 13:41:41 +00:00
//If snap turn configured for less than 10 degrees
if ( vr_snapturn_angle > 10.0f ) {
decreaseSnap = false ;
}
2020-02-22 16:10:48 +00:00
2020-06-06 13:41:41 +00:00
if ( snapTurn > 180.0f ) {
snapTurn - = 360.f ;
}
2020-02-22 16:10:48 +00:00
}
2020-06-06 13:41:41 +00:00
} else if ( pPrimaryTrackedRemoteNew - > Joystick . x > - 0.4f ) {
decreaseSnap = true ;
2020-04-14 15:49:54 +00:00
}
}
2020-02-22 16:10:48 +00:00
}
2020-04-14 15:49:54 +00:00
}
2020-03-09 23:59:38 +00:00
2020-04-14 15:49:54 +00:00
{
2020-06-06 13:41:41 +00:00
//if in cinema mode, then the dominant joystick is used differently
if ( ! cinemamode ) {
//Now handle all the buttons - irrespective of menu state - we might be trying to remap stuff
{
{
//Default this is Weapon Chooser - This _could_ be remapped
static int itemSwitched = 0 ;
if ( between ( - 0.2f , pPrimaryTrackedRemoteNew - > Joystick . x , 0.2f ) & &
( between ( 0.8f , pPrimaryTrackedRemoteNew - > Joystick . y , 1.0f ) | |
between ( - 1.0f , pPrimaryTrackedRemoteNew - > Joystick . y , - 0.8f ) ) ) {
if ( itemSwitched = = 0 ) {
if ( between ( 0.8f , pPrimaryTrackedRemoteNew - > Joystick . y , 1.0f ) ) {
Joy_GenerateButtonEvents ( 0 , 1 , 1 , KEY_MWHEELDOWN ) ;
itemSwitched = 1 ;
} else {
Joy_GenerateButtonEvents ( 0 , 1 , 1 , KEY_MWHEELUP ) ;
itemSwitched = 2 ;
}
}
2020-04-14 15:49:54 +00:00
} else {
2020-06-06 13:41:41 +00:00
if ( itemSwitched = = 1 ) {
Joy_GenerateButtonEvents ( 1 , 0 , 1 , KEY_MWHEELDOWN ) ;
} else if ( itemSwitched = = 2 ) {
Joy_GenerateButtonEvents ( 1 , 0 , 1 , KEY_MWHEELUP ) ;
}
itemSwitched = 0 ;
2020-03-09 23:59:38 +00:00
}
}
2020-04-15 19:48:44 +00:00
2020-06-06 13:41:41 +00:00
//If snap turn set to 0, then we can use left/right on the stick as mappable functions
if ( vr_snapturn_angle = = 0.0 ) {
static int invSwitched = 0 ;
if ( between ( - 0.2f , pPrimaryTrackedRemoteNew - > Joystick . y , 0.2f ) & &
( between ( 0.8f , pPrimaryTrackedRemoteNew - > Joystick . x , 1.0f ) | |
between ( - 1.0f , pPrimaryTrackedRemoteNew - > Joystick . x , - 0.8f ) ) ) {
if ( invSwitched = = 0 ) {
if ( between ( 0.8f , pPrimaryTrackedRemoteNew - > Joystick . x , 1.0f ) ) {
Joy_GenerateButtonEvents ( 0 , 1 , 1 , KEY_MWHEELLEFT ) ;
invSwitched = 1 ;
} else {
Joy_GenerateButtonEvents ( 0 , 1 , 1 , KEY_MWHEELRIGHT ) ;
invSwitched = 2 ;
}
}
2020-04-15 19:48:44 +00:00
} else {
2020-06-06 13:41:41 +00:00
if ( invSwitched = = 1 ) {
Joy_GenerateButtonEvents ( 1 , 0 , 1 , KEY_MWHEELLEFT ) ;
} else if ( invSwitched = = 2 ) {
Joy_GenerateButtonEvents ( 1 , 0 , 1 , KEY_MWHEELRIGHT ) ;
}
invSwitched = 0 ;
2020-04-15 19:48:44 +00:00
}
}
}
2020-04-14 15:49:54 +00:00
}
{
//Dominant Hand - Primary keys (no grip pushed) - All keys are re-mappable, default bindngs are shown below
2020-03-15 23:16:38 +00:00
//Fire
2020-03-09 23:59:38 +00:00
Joy_GenerateButtonEvents ( ( ( pDominantTrackedRemoteOld - > Buttons & ovrButton_Trigger ) ! = 0 ) & & ! dominantGripPushedOld ? 1 : 0 ,
( ( pDominantTrackedRemoteNew - > Buttons & ovrButton_Trigger ) ! = 0 ) & & ! dominantGripPushedNew ? 1 : 0 ,
2020-03-15 23:16:38 +00:00
1 , KEY_PAD_RTRIGGER ) ;
2020-03-09 23:59:38 +00:00
2020-03-15 23:16:38 +00:00
//"Use" (open door, toggle switch etc)
2021-02-20 23:37:24 +00:00
Joy_GenerateButtonEvents ( ( ( primaryButtonsOld & primaryButton1 ) ! = 0 ) & & ! dominantGripPushedOld ? 1 : 0 ,
( ( primaryButtonsNew & primaryButton1 ) ! = 0 ) & & ! dominantGripPushedNew ? 1 : 0 ,
2020-03-15 23:16:38 +00:00
1 , KEY_PAD_A ) ;
2020-03-09 23:59:38 +00:00
2020-03-15 23:16:38 +00:00
//No Binding
2021-02-20 23:37:24 +00:00
Joy_GenerateButtonEvents ( ( ( primaryButtonsOld & primaryButton2 ) ! = 0 ) & & ! dominantGripPushedOld ? 1 : 0 ,
( ( primaryButtonsNew & primaryButton2 ) ! = 0 ) & & ! dominantGripPushedNew ? 1 : 0 ,
2020-03-09 23:59:38 +00:00
1 , KEY_PAD_B ) ;
2020-03-15 23:16:38 +00:00
// Inv Use
2020-03-09 23:59:38 +00:00
Joy_GenerateButtonEvents ( ( ( pDominantTrackedRemoteOld - > Buttons & ovrButton_Joystick ) ! = 0 ) & & ! dominantGripPushedOld ? 1 : 0 ,
( ( pDominantTrackedRemoteNew - > Buttons & ovrButton_Joystick ) ! = 0 ) & & ! dominantGripPushedNew ? 1 : 0 ,
2020-03-15 23:16:38 +00:00
1 , KEY_ENTER ) ;
2020-03-09 23:59:38 +00:00
2020-05-24 09:52:47 +00:00
if ( vr_secondarybuttonmappings ) {
//Dominant Hand - Secondary keys (grip pushed)
//Alt-Fire
Joy_GenerateButtonEvents (
( ( pDominantTrackedRemoteOld - > Buttons & ovrButton_Trigger ) ! = 0 ) & &
dominantGripPushedOld ? 1 : 0 ,
( ( pDominantTrackedRemoteNew - > Buttons & ovrButton_Trigger ) ! = 0 ) & &
dominantGripPushedNew ? 1 : 0 ,
1 , KEY_PAD_LTRIGGER ) ;
//Crouch
2021-02-20 23:37:24 +00:00
Joy_GenerateButtonEvents ( ( ( primaryButtonsOld & primaryButton1 ) ! = 0 ) & &
2020-05-24 09:52:47 +00:00
dominantGripPushedOld ? 1 : 0 ,
2021-02-20 23:37:24 +00:00
( ( primaryButtonsNew & primaryButton1 ) ! = 0 ) & &
2020-05-24 09:52:47 +00:00
dominantGripPushedNew ? 1 : 0 ,
1 , KEY_PAD_LTHUMB ) ;
//No Binding
2021-02-20 23:37:24 +00:00
Joy_GenerateButtonEvents ( ( ( primaryButtonsOld & primaryButton2 ) ! = 0 ) & &
2020-05-24 09:52:47 +00:00
dominantGripPushedOld ? 1 : 0 ,
2021-02-20 23:37:24 +00:00
( ( primaryButtonsNew & primaryButton2 ) ! = 0 ) & &
2020-05-24 09:52:47 +00:00
dominantGripPushedNew ? 1 : 0 ,
1 , KEY_RSHIFT ) ;
//No Binding
Joy_GenerateButtonEvents (
( ( pDominantTrackedRemoteOld - > Buttons & ovrButton_Joystick ) ! = 0 ) & &
dominantGripPushedOld ? 1 : 0 ,
( ( pDominantTrackedRemoteNew - > Buttons & ovrButton_Joystick ) ! = 0 ) & &
dominantGripPushedNew ? 1 : 0 ,
1 , KEY_TAB ) ;
} else {
//Use grip as an extra button
//Alt-Fire
Joy_GenerateButtonEvents (
2020-06-02 21:40:23 +00:00
( ( pDominantTrackedRemoteOld - > Buttons & ovrButton_GripTrigger ) ! = 0 ) ? 1 : 0 ,
( ( pDominantTrackedRemoteNew - > Buttons & ovrButton_GripTrigger ) ! = 0 ) ? 1 : 0 ,
2020-05-24 09:52:47 +00:00
1 , KEY_PAD_LTRIGGER ) ;
}
2020-03-09 23:59:38 +00:00
//Off Hand - Primary keys (no grip pushed)
2020-03-15 23:16:38 +00:00
//No Default Binding
2020-03-09 23:59:38 +00:00
Joy_GenerateButtonEvents ( ( ( pOffTrackedRemoteOld - > Buttons & ovrButton_Trigger ) ! = 0 ) & & ! dominantGripPushedOld ? 1 : 0 ,
( ( pOffTrackedRemoteNew - > Buttons & ovrButton_Trigger ) ! = 0 ) & & ! dominantGripPushedNew ? 1 : 0 ,
2020-03-14 07:59:17 +00:00
1 , KEY_LSHIFT ) ;
2020-03-09 23:59:38 +00:00
2020-03-15 23:16:38 +00:00
//No Default Binding
2021-02-20 23:37:24 +00:00
Joy_GenerateButtonEvents ( ( ( secondaryButtonsOld & secondaryButton1 ) ! = 0 ) & & ! dominantGripPushedOld ? 1 : 0 ,
( ( secondaryButtonsNew & secondaryButton1 ) ! = 0 ) & & ! dominantGripPushedNew ? 1 : 0 ,
2020-03-09 23:59:38 +00:00
1 , KEY_PAD_X ) ;
2020-04-13 16:38:29 +00:00
//Toggle Map
2021-02-20 23:37:24 +00:00
Joy_GenerateButtonEvents ( ( ( secondaryButtonsOld & secondaryButton2 ) ! = 0 ) & & ! dominantGripPushedOld ? 1 : 0 ,
( ( secondaryButtonsNew & secondaryButton2 ) ! = 0 ) & & ! dominantGripPushedNew ? 1 : 0 ,
2020-03-09 23:59:38 +00:00
1 , KEY_PAD_Y ) ;
2020-03-15 23:16:38 +00:00
//"Use" (open door, toggle switch etc) - Can be rebound for other uses
2020-03-09 23:59:38 +00:00
Joy_GenerateButtonEvents ( ( ( pOffTrackedRemoteOld - > Buttons & ovrButton_Joystick ) ! = 0 ) & & ! dominantGripPushedOld ? 1 : 0 ,
( ( pOffTrackedRemoteNew - > Buttons & ovrButton_Joystick ) ! = 0 ) & & ! dominantGripPushedNew ? 1 : 0 ,
1 , KEY_SPACE ) ;
2020-05-24 09:52:47 +00:00
if ( ! vr_twohandedweapons )
{
Joy_GenerateButtonEvents (
( ( pOffTrackedRemoteOld - > Buttons & ovrButton_GripTrigger ) ! = 0 ) & &
! dominantGripPushedOld ? 1 : 0 ,
( ( pOffTrackedRemoteNew - > Buttons & ovrButton_GripTrigger ) ! = 0 ) & &
! dominantGripPushedNew ? 1 : 0 ,
1 , KEY_PAD_RTHUMB ) ;
}
2020-03-09 23:59:38 +00:00
//Off Hand - Secondary keys (grip pushed)
2020-05-24 09:52:47 +00:00
if ( vr_secondarybuttonmappings ) {
//No Default Binding
Joy_GenerateButtonEvents (
( ( pOffTrackedRemoteOld - > Buttons & ovrButton_Trigger ) ! = 0 ) & &
dominantGripPushedOld ? 1 : 0 ,
( ( pOffTrackedRemoteNew - > Buttons & ovrButton_Trigger ) ! = 0 ) & &
dominantGripPushedNew ? 1 : 0 ,
1 , KEY_LALT ) ;
//Move Down
Joy_GenerateButtonEvents (
2021-02-20 23:37:24 +00:00
( ( secondaryButtonsOld & secondaryButton1 ) ! = 0 ) & & dominantGripPushedOld
2020-05-24 09:52:47 +00:00
? 1 : 0 ,
2021-02-20 23:37:24 +00:00
( ( secondaryButtonsNew & secondaryButton1 ) ! = 0 ) & & dominantGripPushedNew
2020-05-24 09:52:47 +00:00
? 1 : 0 ,
1 , KEY_PGDN ) ;
//Move Up
Joy_GenerateButtonEvents (
2021-02-20 23:37:24 +00:00
( ( secondaryButtonsOld & secondaryButton2 ) ! = 0 ) & & dominantGripPushedOld
2020-05-24 09:52:47 +00:00
? 1 : 0 ,
2021-02-20 23:37:24 +00:00
( ( secondaryButtonsNew & secondaryButton2 ) ! = 0 ) & & dominantGripPushedNew
2020-05-24 09:52:47 +00:00
? 1 : 0 ,
1 , KEY_PGUP ) ;
//Land
Joy_GenerateButtonEvents (
( ( pOffTrackedRemoteOld - > Buttons & ovrButton_Joystick ) ! = 0 ) & &
dominantGripPushedOld ? 1 : 0 ,
( ( pOffTrackedRemoteNew - > Buttons & ovrButton_Joystick ) ! = 0 ) & &
dominantGripPushedNew ? 1 : 0 ,
1 , KEY_HOME ) ;
if ( ! vr_twohandedweapons )
{
Joy_GenerateButtonEvents (
( ( pOffTrackedRemoteOld - > Buttons & ovrButton_GripTrigger ) ! = 0 ) & &
dominantGripPushedOld ? 1 : 0 ,
( ( pOffTrackedRemoteNew - > Buttons & ovrButton_GripTrigger ) ! = 0 ) & &
dominantGripPushedNew ? 1 : 0 ,
1 , KEY_PAD_DPAD_UP ) ;
}
}
2020-03-09 23:59:38 +00:00
}
2020-02-22 16:10:48 +00:00
}
2020-03-05 22:30:08 +00:00
2020-02-22 16:10:48 +00:00
//Save state
rightTrackedRemoteState_old = rightTrackedRemoteState_new ;
leftTrackedRemoteState_old = leftTrackedRemoteState_new ;
}