2020-02-22 16:10:48 +00:00
/************************************************************************************
Filename : VrInputDefault . c
Content : Handles default controller input
Created : August 2019
Authors : Simon Brown
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2022-12-27 23:27:29 +00:00
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
2022-03-02 21:27:29 +00:00
extern ovrInputStateTrackedRemote leftTrackedRemoteState_old ;
extern ovrInputStateTrackedRemote leftTrackedRemoteState_new ;
2022-12-27 23:27:29 +00:00
extern ovrTrackedController leftRemoteTracking_new ;
2022-03-02 21:27:29 +00:00
extern ovrInputStateTrackedRemote rightTrackedRemoteState_old ;
extern ovrInputStateTrackedRemote rightTrackedRemoteState_new ;
2022-12-27 23:27:29 +00:00
extern ovrTrackedController rightRemoteTracking_new ;
2022-03-02 21:27:29 +00:00
extern float remote_movementSideways ;
extern float remote_movementForward ;
extern float remote_movementUp ;
extern float positional_movementSideways ;
extern float positional_movementForward ;
extern float snapTurn ;
extern float cinemamodeYaw ;
extern float cinemamodePitch ;
2022-12-27 23:27:29 +00:00
extern bool weaponStabilised ;
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
2022-12-27 23:27:29 +00:00
void HandleInput_Default ( int control_scheme , ovrInputStateTrackedRemote * pDominantTrackedRemoteNew , ovrInputStateTrackedRemote * pDominantTrackedRemoteOld , ovrTrackedController * pDominantTracking ,
ovrInputStateTrackedRemote * pOffTrackedRemoteNew , ovrInputStateTrackedRemote * pOffTrackedRemoteOld , ovrTrackedController * pOffTracking ,
2020-02-22 16:10:48 +00:00
int domButton1 , int domButton2 , int offButton1 , int offButton2 )
{
2020-03-15 08:36:32 +00:00
//Menu button - invoke menu
2022-12-27 23:27:29 +00:00
handleTrackedControllerButton ( & leftTrackedRemoteState_new , & leftTrackedRemoteState_old , xrButton_Enter , KEY_ESCAPE ) ;
handleTrackedControllerButton ( & rightTrackedRemoteState_new , & rightTrackedRemoteState_old , xrButton_Enter , KEY_ESCAPE ) ; // For users who have switched the buttons
2020-02-22 16:10:48 +00:00
2020-04-14 15:49:54 +00:00
//Dominant Grip works like a shift key
2022-12-27 23:27:29 +00:00
bool dominantGripPushedOld = vr_secondary_button_mappings ?
( pDominantTrackedRemoteOld - > Buttons & xrButton_GripTrigger ) : false ;
bool dominantGripPushedNew = vr_secondary_button_mappings ?
( pDominantTrackedRemoteNew - > Buttons & xrButton_GripTrigger ) : false ;
2020-04-05 18:02:54 +00:00
2020-04-15 19:48:44 +00:00
ovrInputStateTrackedRemote * pPrimaryTrackedRemoteNew , * pPrimaryTrackedRemoteOld , * pSecondaryTrackedRemoteNew , * pSecondaryTrackedRemoteOld ;
2022-12-27 23:27:29 +00:00
if ( vr_switch_sticks )
2020-04-15 19:48:44 +00:00
{
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
{
2022-12-27 23:27:29 +00:00
float distance = sqrtf ( powf ( pOffTracking - > Pose . position . x -
pDominantTracking - > Pose . position . x , 2 ) +
powf ( pOffTracking - > Pose . position . y -
pDominantTracking - > Pose . position . y , 2 ) +
powf ( pOffTracking - > Pose . position . z -
pDominantTracking - > Pose . position . z , 2 ) ) ;
2020-02-22 16:10:48 +00:00
//Turn on weapon stabilisation?
2022-12-27 23:27:29 +00:00
if ( vr_two_handed_weapons & &
( pOffTrackedRemoteNew - > Buttons & xrButton_GripTrigger ) ! =
( pOffTrackedRemoteOld - > Buttons & xrButton_GripTrigger ) ) {
2020-02-22 16:10:48 +00:00
2022-12-27 23:27:29 +00:00
if ( pOffTrackedRemoteNew - > Buttons & xrButton_GripTrigger ) {
2020-04-14 15:49:54 +00:00
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
2022-12-27 23:27:29 +00:00
weaponoffset [ 0 ] = pDominantTracking - > Pose . position . x - hmdPosition [ 0 ] ;
weaponoffset [ 1 ] = pDominantTracking - > Pose . position . y - hmdPosition [ 1 ] ;
weaponoffset [ 2 ] = pDominantTracking - > Pose . position . z - hmdPosition [ 2 ] ;
2020-02-22 16:10:48 +00:00
2021-09-25 15:08:50 +00:00
vec2_t v ;
float yawRotation = getViewpointYaw ( ) - hmdorientation [ YAW ] ;
rotateAboutOrigin ( weaponoffset [ 0 ] , weaponoffset [ 2 ] , - yawRotation , v ) ;
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
vec3_t rotation = { 0 } ;
2022-12-27 23:27:29 +00:00
rotation [ PITCH ] = vr_weaponRotate ;
QuatToYawPitchRoll ( pDominantTracking - > Pose . orientation , rotation , weaponangles ) ;
2020-02-22 16:10:48 +00:00
2020-04-14 15:49:54 +00:00
if ( weaponStabilised ) {
2022-12-27 23:27:29 +00:00
float z = pOffTracking - > Pose . position . z -
pDominantTracking - > Pose . position . z ;
float x = pOffTracking - > Pose . position . x -
pDominantTracking - > Pose . position . x ;
float y = pOffTracking - > Pose . position . y -
pDominantTracking - > Pose . position . y ;
2020-02-22 16:10:48 +00:00
float zxDist = length ( x , z ) ;
if ( zxDist ! = 0.0f & & z ! = 0.0f ) {
2022-12-27 23:27:29 +00:00
VectorSet ( weaponangles , - RAD2DEG ( atanf ( y / zxDist ) ) , - RAD2DEG ( atan2f ( x , - z ) ) ,
2020-04-14 15:49:54 +00:00
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
{
2022-12-27 23:27:29 +00:00
offhandoffset [ 0 ] = pOffTracking - > Pose . position . x - hmdPosition [ 0 ] ;
offhandoffset [ 1 ] = pOffTracking - > Pose . position . y - hmdPosition [ 1 ] ;
offhandoffset [ 2 ] = pOffTracking - > Pose . position . z - hmdPosition [ 2 ] ;
2020-02-22 16:10:48 +00:00
2020-04-14 15:49:54 +00:00
vec2_t v ;
2021-09-25 15:08:50 +00:00
float yawRotation = getViewpointYaw ( ) - hmdorientation [ YAW ] ;
rotateAboutOrigin ( offhandoffset [ 0 ] , offhandoffset [ 2 ] , - yawRotation , v ) ;
2020-04-14 15:49:54 +00:00
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 } ;
2022-12-27 23:27:29 +00:00
rotation [ PITCH ] = vr_weaponRotate ;
QuatToYawPitchRoll ( pOffTracking - > Pose . orientation , rotation , offhandangles ) ;
2020-02-22 16:10:48 +00:00
2022-12-27 23:27:29 +00:00
if ( vr_move_use_offhand ) {
2020-04-14 15:49:54 +00:00
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 " ,
2022-12-27 23:27:29 +00:00
pDominantTracking - > Pose . position . x ,
pDominantTracking - > Pose . position . y ,
pDominantTracking - > 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 " ,
2022-12-27 23:27:29 +00:00
pOffTracking - > Pose . position . x ,
pOffTracking - > Pose . position . y ,
pOffTracking - > 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
2022-12-27 23:27:29 +00:00
if ( vr_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 ) ;
2022-12-27 23:27:29 +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 ) ;
2021-10-18 15:08:56 +00:00
if ( ! cinemamode & & ! dominantGripPushedNew )
2020-06-06 13:41:41 +00:00
{
// Turning logic
static int increaseSnap = true ;
if ( pPrimaryTrackedRemoteNew - > Joystick . x > 0.6f ) {
if ( increaseSnap ) {
resetDoomYaw = true ;
2022-12-27 23:27:29 +00:00
snapTurn - = vr_snapTurn ;
if ( vr_snapTurn > 10.0f ) {
2020-06-06 13:41:41 +00:00
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 ;
2022-12-27 23:27:29 +00:00
snapTurn + = vr_snapTurn ;
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
2022-12-27 23:27:29 +00:00
if ( vr_snapTurn > 10.0f ) {
2020-06-06 13:41:41 +00:00
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
2021-10-18 14:02:43 +00:00
//if in cinema mode, then the dominant joystick is used differently
if ( ! cinemamode )
2020-04-14 15:49:54 +00:00
{
2021-10-18 14:02:43 +00:00
//Default this is Weapon Chooser - This _could_ be remapped
Joy_GenerateButtonEvents (
( pPrimaryTrackedRemoteOld - > Joystick . y < - 0.7f & & ! dominantGripPushedOld ? 1 : 0 ) ,
( pPrimaryTrackedRemoteNew - > Joystick . y < - 0.7f & & ! dominantGripPushedNew ? 1 : 0 ) ,
1 , KEY_MWHEELDOWN ) ;
//Default this is Weapon Chooser - This _could_ be remapped
Joy_GenerateButtonEvents (
( pPrimaryTrackedRemoteOld - > Joystick . y > 0.7f & & ! dominantGripPushedOld ? 1 : 0 ) ,
( pPrimaryTrackedRemoteNew - > Joystick . y > 0.7f & & ! dominantGripPushedNew ? 1 : 0 ) ,
1 , KEY_MWHEELUP ) ;
//If snap turn set to 0, then we can use left/right on the stick as mappable functions
Joy_GenerateButtonEvents (
2022-12-27 23:27:29 +00:00
( pPrimaryTrackedRemoteOld - > Joystick . x > 0.7f & & ! dominantGripPushedOld & & ! vr_snapTurn ? 1 : 0 ) ,
( pPrimaryTrackedRemoteNew - > Joystick . x > 0.7f & & ! dominantGripPushedNew & & ! vr_snapTurn ? 1 : 0 ) ,
2021-10-18 14:02:43 +00:00
1 , KEY_MWHEELLEFT ) ;
Joy_GenerateButtonEvents (
2022-12-27 23:27:29 +00:00
( pPrimaryTrackedRemoteOld - > Joystick . x < - 0.7f & & ! dominantGripPushedOld & & ! vr_snapTurn ? 1 : 0 ) ,
( pPrimaryTrackedRemoteNew - > Joystick . x < - 0.7f & & ! dominantGripPushedNew & & ! vr_snapTurn ? 1 : 0 ) ,
2021-10-18 14:02:43 +00:00
1 , KEY_MWHEELRIGHT ) ;
}
2020-03-09 23:59:38 +00:00
2021-10-18 14:02:43 +00:00
//Dominant Hand - Primary keys (no grip pushed) - All keys are re-mappable, default bindngs are shown below
{
//Fire
Joy_GenerateButtonEvents (
2022-12-27 23:27:29 +00:00
( ( pDominantTrackedRemoteOld - > Buttons & xrButton_Trigger ) ! = 0 ) & & ! dominantGripPushedOld ? 1 : 0 ,
( ( pDominantTrackedRemoteNew - > Buttons & xrButton_Trigger ) ! = 0 ) & & ! dominantGripPushedNew ? 1 : 0 ,
2021-10-18 14:02:43 +00:00
1 , KEY_PAD_RTRIGGER ) ;
//"Use" (open door, toggle switch etc)
Joy_GenerateButtonEvents (
( ( primaryButtonsOld & primaryButton1 ) ! = 0 ) & & ! dominantGripPushedOld ? 1 : 0 ,
( ( primaryButtonsNew & primaryButton1 ) ! = 0 ) & & ! dominantGripPushedNew ? 1 : 0 ,
1 , KEY_PAD_A ) ;
//No Binding
Joy_GenerateButtonEvents (
( ( primaryButtonsOld & primaryButton2 ) ! = 0 ) & & ! dominantGripPushedOld ? 1 : 0 ,
( ( primaryButtonsNew & primaryButton2 ) ! = 0 ) & & ! dominantGripPushedNew ? 1 : 0 ,
1 , KEY_PAD_B ) ;
// Inv Use
Joy_GenerateButtonEvents (
2022-12-27 23:27:29 +00:00
( ( pDominantTrackedRemoteOld - > Buttons & xrButton_Joystick ) ! = 0 ) & & ! dominantGripPushedOld ? 1 : 0 ,
( ( pDominantTrackedRemoteNew - > Buttons & xrButton_Joystick ) ! = 0 ) & & ! dominantGripPushedNew ? 1 : 0 ,
2021-10-18 14:02:43 +00:00
1 , KEY_ENTER ) ;
2022-12-27 23:27:29 +00:00
//Button touching (but not pressing) needs adding to OpenXR mappings
/*
2021-10-18 14:02:43 +00:00
//No Default Binding
Joy_GenerateButtonEvents (
( ( pDominantTrackedRemoteOld - > Touches & ovrTouch_ThumbRest ) ! = 0 ) & & ! dominantGripPushedOld ? 1 : 0 ,
( ( pDominantTrackedRemoteNew - > Touches & ovrTouch_ThumbRest ) ! = 0 ) & & ! dominantGripPushedNew ? 1 : 0 ,
1 , KEY_JOY5 ) ;
2022-12-27 23:27:29 +00:00
*/
2021-10-18 14:02:43 +00:00
}
//Dominant Hand - Secondary keys (grip pushed)
{
//Alt-Fire
Joy_GenerateButtonEvents (
2022-12-27 23:27:29 +00:00
( ( pDominantTrackedRemoteOld - > Buttons & xrButton_Trigger ) ! = 0 ) & & dominantGripPushedOld ? 1 : 0 ,
( ( pDominantTrackedRemoteNew - > Buttons & xrButton_Trigger ) ! = 0 ) & & dominantGripPushedNew ? 1 : 0 ,
2021-10-18 14:02:43 +00:00
1 , KEY_PAD_LTRIGGER ) ;
//Crouch
Joy_GenerateButtonEvents (
( ( primaryButtonsOld & primaryButton1 ) ! = 0 ) & & dominantGripPushedOld ? 1 : 0 ,
( ( primaryButtonsNew & primaryButton1 ) ! = 0 ) & & dominantGripPushedNew ? 1 : 0 ,
1 , KEY_PAD_LTHUMB ) ;
//No Binding
Joy_GenerateButtonEvents (
( ( primaryButtonsOld & primaryButton2 ) ! = 0 ) & & dominantGripPushedOld ? 1 : 0 ,
( ( primaryButtonsNew & primaryButton2 ) ! = 0 ) & & dominantGripPushedNew ? 1 : 0 ,
1 , KEY_RSHIFT ) ;
//No Binding
Joy_GenerateButtonEvents (
2022-12-27 23:27:29 +00:00
( ( pDominantTrackedRemoteOld - > Buttons & xrButton_Joystick ) ! = 0 ) & & dominantGripPushedOld ? 1 : 0 ,
( ( pDominantTrackedRemoteNew - > Buttons & xrButton_Joystick ) ! = 0 ) & & dominantGripPushedNew ? 1 : 0 ,
2021-10-18 14:02:43 +00:00
1 , KEY_TAB ) ;
2022-12-27 23:27:29 +00:00
//Button touching (but not pressing) needs adding to OpenXR mappings
/*
2021-10-18 14:02:43 +00:00
//No Default Binding
Joy_GenerateButtonEvents (
( ( pDominantTrackedRemoteOld - > Touches & ovrTouch_ThumbRest ) ! = 0 ) & & dominantGripPushedOld ? 1 : 0 ,
( ( pDominantTrackedRemoteNew - > Touches & ovrTouch_ThumbRest ) ! = 0 ) & & dominantGripPushedNew ? 1 : 0 ,
1 , KEY_JOY6 ) ;
2022-12-27 23:27:29 +00:00
*/
2021-10-18 14:02:43 +00:00
//Use grip as an extra button
//Alt-Fire
Joy_GenerateButtonEvents (
2022-12-27 23:27:29 +00:00
( ( pDominantTrackedRemoteOld - > Buttons & xrButton_GripTrigger ) ! = 0 ) & & ! dominantGripPushedOld ? 1 : 0 ,
( ( pDominantTrackedRemoteNew - > Buttons & xrButton_GripTrigger ) ! = 0 ) & & ! dominantGripPushedNew ? 1 : 0 ,
2021-10-18 14:02:43 +00:00
1 , KEY_PAD_LTRIGGER ) ;
}
2020-03-09 23:59:38 +00:00
2021-10-18 14:02:43 +00:00
//Off Hand - Primary keys (no grip pushed)
{
//No Default Binding
Joy_GenerateButtonEvents (
2022-12-27 23:27:29 +00:00
( ( pOffTrackedRemoteOld - > Buttons & xrButton_Trigger ) ! = 0 ) & & ! dominantGripPushedOld ? 1 : 0 ,
( ( pOffTrackedRemoteNew - > Buttons & xrButton_Trigger ) ! = 0 ) & & ! dominantGripPushedNew ? 1 : 0 ,
2021-10-18 14:02:43 +00:00
1 , KEY_LSHIFT ) ;
//No Default Binding
Joy_GenerateButtonEvents (
( ( secondaryButtonsOld & secondaryButton1 ) ! = 0 ) & & ! dominantGripPushedOld ? 1 : 0 ,
( ( secondaryButtonsNew & secondaryButton1 ) ! = 0 ) & & ! dominantGripPushedNew ? 1 : 0 ,
1 , KEY_PAD_X ) ;
//Toggle Map
Joy_GenerateButtonEvents (
( ( secondaryButtonsOld & secondaryButton2 ) ! = 0 ) & & ! dominantGripPushedOld ? 1 : 0 ,
( ( secondaryButtonsNew & secondaryButton2 ) ! = 0 ) & & ! dominantGripPushedNew ? 1 : 0 ,
1 , KEY_PAD_Y ) ;
//"Use" (open door, toggle switch etc) - Can be rebound for other uses
Joy_GenerateButtonEvents (
2022-12-27 23:27:29 +00:00
( ( pOffTrackedRemoteOld - > Buttons & xrButton_Joystick ) ! = 0 ) & & ! dominantGripPushedOld ? 1 : 0 ,
( ( pOffTrackedRemoteNew - > Buttons & xrButton_Joystick ) ! = 0 ) & & ! dominantGripPushedNew ? 1 : 0 ,
2021-10-18 14:02:43 +00:00
1 , KEY_SPACE ) ;
2022-12-27 23:27:29 +00:00
//Button touching (but not pressing) needs adding to OpenXR mappings
/*
2021-10-18 14:02:43 +00:00
//No Default Binding
Joy_GenerateButtonEvents (
( ( pOffTrackedRemoteOld - > Touches & ovrTouch_ThumbRest ) ! = 0 ) & & ! dominantGripPushedOld ? 1 : 0 ,
( ( pOffTrackedRemoteNew - > Touches & ovrTouch_ThumbRest ) ! = 0 ) & & ! dominantGripPushedNew ? 1 : 0 ,
1 , KEY_JOY7 ) ;
2022-12-27 23:27:29 +00:00
*/
2021-10-18 14:02:43 +00:00
Joy_GenerateButtonEvents (
2022-12-27 23:27:29 +00:00
( ( pOffTrackedRemoteOld - > Buttons & xrButton_GripTrigger ) ! = 0 ) & & ! dominantGripPushedOld ? 1 : 0 ,
( ( pOffTrackedRemoteNew - > Buttons & xrButton_GripTrigger ) ! = 0 ) & & ! dominantGripPushedNew ? 1 : 0 ,
2021-10-18 14:02:43 +00:00
1 , KEY_PAD_RTHUMB ) ;
2020-02-22 16:10:48 +00:00
}
2020-03-05 22:30:08 +00:00
2021-10-18 14:02:43 +00:00
//Off Hand - Secondary keys (grip pushed)
{
//No Default Binding
Joy_GenerateButtonEvents (
2022-12-27 23:27:29 +00:00
( ( pOffTrackedRemoteOld - > Buttons & xrButton_Trigger ) ! = 0 ) & & dominantGripPushedOld ? 1 : 0 ,
( ( pOffTrackedRemoteNew - > Buttons & xrButton_Trigger ) ! = 0 ) & & dominantGripPushedNew ? 1 : 0 ,
2021-10-18 14:02:43 +00:00
1 , KEY_LALT ) ;
//Move Down
Joy_GenerateButtonEvents (
( ( secondaryButtonsOld & secondaryButton1 ) ! = 0 ) & & dominantGripPushedOld ? 1 : 0 ,
( ( secondaryButtonsNew & secondaryButton1 ) ! = 0 ) & & dominantGripPushedNew ? 1 : 0 ,
1 , KEY_PGDN ) ;
//Move Up
Joy_GenerateButtonEvents (
( ( secondaryButtonsOld & secondaryButton2 ) ! = 0 ) & & dominantGripPushedOld ? 1 : 0 ,
( ( secondaryButtonsNew & secondaryButton2 ) ! = 0 ) & & dominantGripPushedNew ? 1 : 0 ,
1 , KEY_PGUP ) ;
//Land
Joy_GenerateButtonEvents (
2022-12-27 23:27:29 +00:00
( ( pOffTrackedRemoteOld - > Buttons & xrButton_Joystick ) ! = 0 ) & & dominantGripPushedOld ? 1 : 0 ,
( ( pOffTrackedRemoteNew - > Buttons & xrButton_Joystick ) ! = 0 ) & & dominantGripPushedNew ? 1 : 0 ,
2021-10-18 14:02:43 +00:00
1 , KEY_HOME ) ;
2022-12-27 23:27:29 +00:00
//Button touching (but not pressing) needs adding to OpenXR mappings
/*
2021-10-18 14:02:43 +00:00
//No Default Binding
Joy_GenerateButtonEvents (
( ( pOffTrackedRemoteOld - > Touches & ovrTouch_ThumbRest ) ! = 0 ) & & dominantGripPushedOld ? 1 : 0 ,
( ( pOffTrackedRemoteNew - > Touches & ovrTouch_ThumbRest ) ! = 0 ) & & dominantGripPushedNew ? 1 : 0 ,
1 , KEY_JOY8 ) ;
2022-12-27 23:27:29 +00:00
*/
2021-10-18 14:02:43 +00:00
Joy_GenerateButtonEvents (
2022-12-27 23:27:29 +00:00
( ( pOffTrackedRemoteOld - > Buttons & xrButton_GripTrigger ) ! = 0 ) & & dominantGripPushedOld & & ! vr_two_handed_weapons ? 1 : 0 ,
( ( pOffTrackedRemoteNew - > Buttons & xrButton_GripTrigger ) ! = 0 ) & & dominantGripPushedNew & & ! vr_two_handed_weapons ? 1 : 0 ,
2021-10-18 14:02:43 +00:00
1 , KEY_PAD_DPAD_UP ) ;
}
2021-10-11 16:35:38 +00:00
2021-10-18 14:02:43 +00:00
Joy_GenerateButtonEvents (
( pSecondaryTrackedRemoteOld - > Joystick . x > 0.7f & & ! dominantGripPushedOld ? 1 : 0 ) ,
( pSecondaryTrackedRemoteNew - > Joystick . x > 0.7f & & ! dominantGripPushedNew ? 1 : 0 ) ,
1 , KEY_JOYAXIS1PLUS ) ;
Joy_GenerateButtonEvents (
( pSecondaryTrackedRemoteOld - > Joystick . x < - 0.7f & & ! dominantGripPushedOld ? 1 : 0 ) ,
( pSecondaryTrackedRemoteNew - > Joystick . x < - 0.7f & & ! dominantGripPushedNew ? 1 : 0 ) ,
1 , KEY_JOYAXIS1MINUS ) ;
Joy_GenerateButtonEvents (
( pPrimaryTrackedRemoteOld - > Joystick . x > 0.7f & & ! dominantGripPushedOld ? 1 : 0 ) ,
( pPrimaryTrackedRemoteNew - > Joystick . x > 0.7f & & ! dominantGripPushedNew ? 1 : 0 ) ,
1 , KEY_JOYAXIS3PLUS ) ;
Joy_GenerateButtonEvents (
( pPrimaryTrackedRemoteOld - > Joystick . x < - 0.7f & & ! dominantGripPushedOld ? 1 : 0 ) ,
( pPrimaryTrackedRemoteNew - > Joystick . x < - 0.7f & & ! dominantGripPushedNew ? 1 : 0 ) ,
1 , KEY_JOYAXIS3MINUS ) ;
Joy_GenerateButtonEvents (
( pSecondaryTrackedRemoteOld - > Joystick . y < - 0.7f & & ! dominantGripPushedOld ? 1 : 0 ) ,
( pSecondaryTrackedRemoteNew - > Joystick . y < - 0.7f & & ! dominantGripPushedNew ? 1 : 0 ) ,
1 , KEY_JOYAXIS2MINUS ) ;
Joy_GenerateButtonEvents (
( pSecondaryTrackedRemoteOld - > Joystick . y > 0.7f & & ! dominantGripPushedOld ? 1 : 0 ) ,
( pSecondaryTrackedRemoteNew - > Joystick . y > 0.7f & & ! dominantGripPushedNew ? 1 : 0 ) ,
1 , KEY_JOYAXIS2PLUS ) ;
Joy_GenerateButtonEvents (
( pPrimaryTrackedRemoteOld - > Joystick . y < - 0.7f & & ! dominantGripPushedOld ? 1 : 0 ) ,
( pPrimaryTrackedRemoteNew - > Joystick . y < - 0.7f & & ! dominantGripPushedNew ? 1 : 0 ) ,
1 , KEY_JOYAXIS4MINUS ) ;
Joy_GenerateButtonEvents (
( pPrimaryTrackedRemoteOld - > Joystick . y > 0.7f & & ! dominantGripPushedOld ? 1 : 0 ) ,
( pPrimaryTrackedRemoteNew - > Joystick . y > 0.7f & & ! dominantGripPushedNew ? 1 : 0 ) ,
1 , KEY_JOYAXIS4PLUS ) ;
Joy_GenerateButtonEvents (
( pSecondaryTrackedRemoteOld - > Joystick . x > 0.7f & & dominantGripPushedOld ? 1 : 0 ) ,
( pSecondaryTrackedRemoteNew - > Joystick . x > 0.7f & & dominantGripPushedNew ? 1 : 0 ) ,
1 , KEY_JOYAXIS5PLUS ) ;
Joy_GenerateButtonEvents (
( pSecondaryTrackedRemoteOld - > Joystick . x < - 0.7f & & dominantGripPushedOld ? 1 : 0 ) ,
( pSecondaryTrackedRemoteNew - > Joystick . x < - 0.7f & & dominantGripPushedNew ? 1 : 0 ) ,
1 , KEY_JOYAXIS5MINUS ) ;
Joy_GenerateButtonEvents (
( pPrimaryTrackedRemoteOld - > Joystick . x > 0.7f & & dominantGripPushedOld ? 1 : 0 ) ,
( pPrimaryTrackedRemoteNew - > Joystick . x > 0.7f & & dominantGripPushedNew ? 1 : 0 ) ,
1 , KEY_JOYAXIS7PLUS ) ;
Joy_GenerateButtonEvents (
( pPrimaryTrackedRemoteOld - > Joystick . x < - 0.7f & & dominantGripPushedOld ? 1 : 0 ) ,
( pPrimaryTrackedRemoteNew - > Joystick . x < - 0.7f & & dominantGripPushedNew ? 1 : 0 ) ,
1 , KEY_JOYAXIS7MINUS ) ;
Joy_GenerateButtonEvents (
( pSecondaryTrackedRemoteOld - > Joystick . y < - 0.7f & & dominantGripPushedOld ? 1 : 0 ) ,
( pSecondaryTrackedRemoteNew - > Joystick . y < - 0.7f & & dominantGripPushedNew ? 1 : 0 ) ,
1 , KEY_JOYAXIS6MINUS ) ;
Joy_GenerateButtonEvents (
( pSecondaryTrackedRemoteOld - > Joystick . y > 0.7f & & dominantGripPushedOld ? 1 : 0 ) ,
( pSecondaryTrackedRemoteNew - > Joystick . y > 0.7f & & dominantGripPushedNew ? 1 : 0 ) ,
1 , KEY_JOYAXIS6PLUS ) ;
2021-10-11 16:35:38 +00:00
2021-10-18 14:02:43 +00:00
Joy_GenerateButtonEvents (
( pPrimaryTrackedRemoteOld - > Joystick . y < - 0.7f & & dominantGripPushedOld ? 1 : 0 ) ,
( pPrimaryTrackedRemoteNew - > Joystick . y < - 0.7f & & dominantGripPushedNew ? 1 : 0 ) ,
1 , KEY_JOYAXIS8MINUS ) ;
Joy_GenerateButtonEvents (
( pPrimaryTrackedRemoteOld - > Joystick . y > 0.7f & & dominantGripPushedOld ? 1 : 0 ) ,
( pPrimaryTrackedRemoteNew - > Joystick . y > 0.7f & & dominantGripPushedNew ? 1 : 0 ) ,
1 , KEY_JOYAXIS8PLUS ) ;
2021-10-11 16:35:38 +00:00
2020-02-22 16:10:48 +00:00
//Save state
rightTrackedRemoteState_old = rightTrackedRemoteState_new ;
leftTrackedRemoteState_old = leftTrackedRemoteState_new ;
}