mirror of
https://github.com/DrBeef/JKXR.git
synced 2024-11-23 20:43:09 +00:00
Recognise Controllers
Index Saber Default Vive Vibration Adjustment
This commit is contained in:
parent
ee0f69e34b
commit
054b36c3d3
4 changed files with 62 additions and 19 deletions
|
@ -16,14 +16,6 @@ XrResult CheckXrResult(XrResult res, const char* originator) {
|
||||||
#define SIDE_RIGHT 1
|
#define SIDE_RIGHT 1
|
||||||
#define SIDE_COUNT 2
|
#define SIDE_COUNT 2
|
||||||
|
|
||||||
#define VIVE_CONTROLLERS 10
|
|
||||||
#define INDEX_CONTROLLERS 11
|
|
||||||
#define PICO_CONTROLLERS 12
|
|
||||||
#define TOUCH_CONTROLLERS 13
|
|
||||||
//Anything else will emulate touch
|
|
||||||
|
|
||||||
int controllersPresent;
|
|
||||||
|
|
||||||
XrActionSet actionSet = nullptr;
|
XrActionSet actionSet = nullptr;
|
||||||
XrAction grabAction;
|
XrAction grabAction;
|
||||||
XrAction gripAction;
|
XrAction gripAction;
|
||||||
|
@ -698,9 +690,6 @@ void TBXR_InitActions( void )
|
||||||
CHECK_XRCMD(xrAttachSessionActionSets(gAppState.Session, &attachInfo));
|
CHECK_XRCMD(xrAttachSessionActionSets(gAppState.Session, &attachInfo));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TBXR_SyncActions( void )
|
void TBXR_SyncActions( void )
|
||||||
|
@ -719,10 +708,57 @@ void TBXR_SyncActions( void )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TBXR_CheckControllers(void)
|
||||||
|
{
|
||||||
|
if (gAppState.controllersPresent == -1)
|
||||||
|
{
|
||||||
|
XrInteractionProfileState profileState = { XR_TYPE_INTERACTION_PROFILE_STATE };
|
||||||
|
XrResult _res = CHECK_XRCMD(xrGetCurrentInteractionProfile(gAppState.Session, handSubactionPath[SIDE_RIGHT], &profileState));
|
||||||
|
if (profileState.interactionProfile != XR_NULL_PATH)
|
||||||
|
{
|
||||||
|
uint32_t bufferLength = 0;
|
||||||
|
XrResult result = xrPathToString(gAppState.Instance, profileState.interactionProfile, 0, &bufferLength, nullptr);
|
||||||
|
|
||||||
|
if (result == XR_SUCCESS) {
|
||||||
|
// Allocate a buffer to store the string
|
||||||
|
char* pathString = new char[bufferLength];
|
||||||
|
|
||||||
|
// Convert XrPath to a string
|
||||||
|
result = xrPathToString(gAppState.Instance, profileState.interactionProfile, bufferLength, &bufferLength, pathString);
|
||||||
|
if (result == XR_SUCCESS) {
|
||||||
|
|
||||||
|
Com_Printf("Controllers Found: %s", pathString);
|
||||||
|
|
||||||
|
if (strcmp(pathString, "/interaction_profiles/valve/index_controller") == 0)
|
||||||
|
{
|
||||||
|
gAppState.controllersPresent = INDEX_CONTROLLERS;
|
||||||
|
}
|
||||||
|
else if (strcmp(pathString, "/interaction_profiles/htc/vive_controller") == 0)
|
||||||
|
{
|
||||||
|
gAppState.controllersPresent = VIVE_CONTROLLERS;
|
||||||
|
}
|
||||||
|
else if (strcmp(pathString, "/interaction_profiles/oculus/touch_controller") == 0)
|
||||||
|
{
|
||||||
|
gAppState.controllersPresent = TOUCH_CONTROLLERS;
|
||||||
|
}
|
||||||
|
else if (strcmp(pathString, "/interaction_profiles/bytedance/pico4_controller") == 0 ||
|
||||||
|
strcmp(pathString, "/interaction_profiles/bytedance/pico3_controller") == 0)
|
||||||
|
{
|
||||||
|
gAppState.controllersPresent = PICO_CONTROLLERS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TBXR_UpdateControllers( )
|
void TBXR_UpdateControllers( )
|
||||||
{
|
{
|
||||||
|
TBXR_CheckControllers();
|
||||||
TBXR_SyncActions();
|
TBXR_SyncActions();
|
||||||
|
|
||||||
//get controller poses
|
//get controller poses
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < 2; i++) {
|
||||||
XrSpaceVelocity vel = {};
|
XrSpaceVelocity vel = {};
|
||||||
|
@ -848,7 +884,7 @@ void TBXR_ProcessHaptics() {
|
||||||
vibration.amplitude = vibration_channel_intensity[i];
|
vibration.amplitude = vibration_channel_intensity[i];
|
||||||
vibration.duration = ToXrTime(vibration_channel_duration[i]);
|
vibration.duration = ToXrTime(vibration_channel_duration[i]);
|
||||||
|
|
||||||
if(controllersPresent == VIVE_CONTROLLERS)
|
if(gAppState.controllersPresent == VIVE_CONTROLLERS)
|
||||||
vibration.duration /= 100;
|
vibration.duration /= 100;
|
||||||
|
|
||||||
//Lets see what happens when the runtime decides it (as per https://registry.khronos.org/OpenXR/specs/1.0/man/html/XrHapticVibration.html)
|
//Lets see what happens when the runtime decides it (as per https://registry.khronos.org/OpenXR/specs/1.0/man/html/XrHapticVibration.html)
|
||||||
|
|
|
@ -136,8 +136,9 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
|
||||||
QuatToYawPitchRoll(pOff->Pose.orientation, rotation, vr.offhandangles[ANGLES_DEFAULT]);
|
QuatToYawPitchRoll(pOff->Pose.orientation, rotation, vr.offhandangles[ANGLES_DEFAULT]);
|
||||||
|
|
||||||
//If we are in a saberBlockDebounce thing then add on an angle
|
//If we are in a saberBlockDebounce thing then add on an angle
|
||||||
//Lerped upon how far from the start of the saber move
|
//Lerped upon how far from the start of the saber move
|
||||||
rotation[PITCH] = vr_saber_pitchadjust->value;
|
//Index default -> vr_saber_pitchadjust->value = -2.42187500
|
||||||
|
rotation[PITCH] = vr_saber_pitchadjust->value + (gAppState.controllersPresent == INDEX_CONTROLLERS ? 10.938125f : 0.0f);
|
||||||
if (vr.saberBlockDebounce > cl.serverTime) {
|
if (vr.saberBlockDebounce > cl.serverTime) {
|
||||||
float lerp = 0.0f;
|
float lerp = 0.0f;
|
||||||
//Where are we in the lerp
|
//Where are we in the lerp
|
||||||
|
@ -198,7 +199,7 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
|
||||||
|
|
||||||
QuatToYawPitchRoll(pWeapon->GripPose.orientation, rotation, vr.weaponangles[ANGLES_SABER]);
|
QuatToYawPitchRoll(pWeapon->GripPose.orientation, rotation, vr.weaponangles[ANGLES_SABER]);
|
||||||
QuatToYawPitchRoll(pOff->GripPose.orientation, rotation, vr.offhandangles[ANGLES_SABER]);
|
QuatToYawPitchRoll(pOff->GripPose.orientation, rotation, vr.offhandangles[ANGLES_SABER]);
|
||||||
|
// + (gAppState.controllersPresent == INDEX_CONTROLLERS ? -35
|
||||||
rotation[PITCH] = vr_weapon_pitchadjust->value;
|
rotation[PITCH] = vr_weapon_pitchadjust->value;
|
||||||
QuatToYawPitchRoll(pWeapon->Pose.orientation, rotation, vr.weaponangles[ANGLES_ADJUSTED]);
|
QuatToYawPitchRoll(pWeapon->Pose.orientation, rotation, vr.weaponangles[ANGLES_ADJUSTED]);
|
||||||
QuatToYawPitchRoll(pOff->Pose.orientation, rotation, vr.offhandangles[ANGLES_ADJUSTED]);
|
QuatToYawPitchRoll(pOff->Pose.orientation, rotation, vr.offhandangles[ANGLES_ADJUSTED]);
|
||||||
|
|
|
@ -45,7 +45,7 @@ void HandleInput_WeaponAlign( ovrInputStateTrackedRemote *pDominantTrackedRemote
|
||||||
|
|
||||||
//if we are in saber block debounce, don't update the saber angles
|
//if we are in saber block debounce, don't update the saber angles
|
||||||
if (vr.saberBlockDebounce < cl.serverTime) {
|
if (vr.saberBlockDebounce < cl.serverTime) {
|
||||||
rotation[PITCH] = vr_saber_pitchadjust->value;
|
rotation[PITCH] = vr_saber_pitchadjust->value + (gAppState.controllersPresent == INDEX_CONTROLLERS ? 10.938125f : 0.0f);
|
||||||
QuatToYawPitchRoll(pDominantTracking->GripPose.orientation, rotation, vr.weaponangles[ANGLES_SABER]);
|
QuatToYawPitchRoll(pDominantTracking->GripPose.orientation, rotation, vr.weaponangles[ANGLES_SABER]);
|
||||||
QuatToYawPitchRoll(pOffTracking->GripPose.orientation, rotation, vr.offhandangles[ANGLES_SABER]);
|
QuatToYawPitchRoll(pOffTracking->GripPose.orientation, rotation, vr.offhandangles[ANGLES_SABER]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -193,8 +193,8 @@ typedef struct
|
||||||
GLboolean SessionActive;
|
GLboolean SessionActive;
|
||||||
XrPosef xfStageFromHead;
|
XrPosef xfStageFromHead;
|
||||||
XrView* Views;
|
XrView* Views;
|
||||||
|
|
||||||
|
int controllersPresent = -1;
|
||||||
float currentDisplayRefreshRate;
|
float currentDisplayRefreshRate;
|
||||||
float* SupportedDisplayRefreshRates;
|
float* SupportedDisplayRefreshRates;
|
||||||
uint32_t RequestedDisplayRefreshRateIndex;
|
uint32_t RequestedDisplayRefreshRateIndex;
|
||||||
|
@ -267,4 +267,10 @@ void TBXR_prepareEyeBuffer(int eye );
|
||||||
void TBXR_finishEyeBuffer(int eye );
|
void TBXR_finishEyeBuffer(int eye );
|
||||||
void TBXR_submitFrame();
|
void TBXR_submitFrame();
|
||||||
|
|
||||||
|
#define VIVE_CONTROLLERS 10
|
||||||
|
#define INDEX_CONTROLLERS 11
|
||||||
|
#define PICO_CONTROLLERS 12
|
||||||
|
#define TOUCH_CONTROLLERS 13
|
||||||
|
//Anything else will emulate touch
|
||||||
|
|
||||||
#endif //vrcommon_h
|
#endif //vrcommon_h
|
Loading…
Reference in a new issue