CyberShoes Support

This commit is contained in:
Grant Bagwell 2021-01-25 21:09:55 +01:00
parent 1bc947b132
commit 3283e8525c
4 changed files with 49 additions and 20 deletions

View File

@ -1544,6 +1544,9 @@ void * AppThreadFunction(void * parm ) {
ovrApp_Clear(&gAppState); ovrApp_Clear(&gAppState);
gAppState.Java = java; gAppState.Java = java;
// This app will handle android gamepad events itself.
vrapi_SetPropertyInt(&gAppState.Java, VRAPI_EAT_NATIVE_GAMEPAD_EVENTS, 0);
gAppState.CpuLevel = CPU_LEVEL; gAppState.CpuLevel = CPU_LEVEL;
gAppState.GpuLevel = GPU_LEVEL; gAppState.GpuLevel = GPU_LEVEL;
gAppState.MainThreadTid = gettid(); gAppState.MainThreadTid = gettid();
@ -1773,14 +1776,18 @@ void Doom3Quest_getTrackedRemotesOrientation(int controlscheme, int switch_stick
//Call additional control schemes here //Call additional control schemes here
if (controlscheme == RIGHT_HANDED_DEFAULT) { if (controlscheme == RIGHT_HANDED_DEFAULT) {
HandleInput_Default(controlscheme, switch_sticks, &rightTrackedRemoteState_new, HandleInput_Default(controlscheme, switch_sticks,
&rightTrackedRemoteState_old, &rightRemoteTracking_new, &footTrackedRemoteState_new, &footTrackedRemoteState_old,
&rightTrackedRemoteState_new, &rightTrackedRemoteState_old,
&rightRemoteTracking_new,
&leftTrackedRemoteState_new, &leftTrackedRemoteState_old, &leftTrackedRemoteState_new, &leftTrackedRemoteState_old,
&leftRemoteTracking_new, &leftRemoteTracking_new,
ovrButton_A, ovrButton_B, ovrButton_X, ovrButton_Y); ovrButton_A, ovrButton_B, ovrButton_X, ovrButton_Y);
} else { } else {
//Left handed //Left handed
HandleInput_Default(controlscheme, switch_sticks, &leftTrackedRemoteState_new, &leftTrackedRemoteState_old, HandleInput_Default(controlscheme, switch_sticks,
&footTrackedRemoteState_new, &footTrackedRemoteState_old,
&leftTrackedRemoteState_new, &leftTrackedRemoteState_old,
&leftRemoteTracking_new, &leftRemoteTracking_new,
&rightTrackedRemoteState_new, &rightTrackedRemoteState_old, &rightTrackedRemoteState_new, &rightTrackedRemoteState_old,
&rightRemoteTracking_new, &rightRemoteTracking_new,

View File

@ -19,6 +19,9 @@ ovrInputStateTrackedRemote rightTrackedRemoteState_old;
ovrInputStateTrackedRemote rightTrackedRemoteState_new; ovrInputStateTrackedRemote rightTrackedRemoteState_new;
ovrTracking rightRemoteTracking_new; ovrTracking rightRemoteTracking_new;
ovrInputStateGamepad footTrackedRemoteState_old;
ovrInputStateGamepad footTrackedRemoteState_new;
ovrDeviceID controllerIDs[2]; ovrDeviceID controllerIDs[2];
float remote_movementSideways; float remote_movementSideways;
@ -33,7 +36,7 @@ void sendButtonActionSimple(const char* action);
void acquireTrackedRemotesData(ovrMobile *Ovr, double displayTime); void acquireTrackedRemotesData(ovrMobile *Ovr, double displayTime);
void HandleInput_Default( int controlscheme, int switchsticks, ovrInputStateTrackedRemote *pDominantTrackedRemoteNew, ovrInputStateTrackedRemote *pDominantTrackedRemoteOld, ovrTracking* pDominantTracking, void HandleInput_Default( int controlscheme, int switchsticks, ovrInputStateGamepad *pFootTrackingNew, ovrInputStateGamepad *pFootTrackingOld, ovrInputStateTrackedRemote *pDominantTrackedRemoteNew, ovrInputStateTrackedRemote *pDominantTrackedRemoteOld, ovrTracking* pDominantTracking,
ovrInputStateTrackedRemote *pOffTrackedRemoteNew, ovrInputStateTrackedRemote *pOffTrackedRemoteOld, ovrTracking* pOffTracking, ovrInputStateTrackedRemote *pOffTrackedRemoteNew, ovrInputStateTrackedRemote *pOffTrackedRemoteOld, ovrTracking* pOffTracking,
int domButton1, int domButton2, int offButton1, int offButton2 ); int domButton1, int domButton2, int offButton1, int offButton2 );

View File

@ -105,7 +105,22 @@ void acquireTrackedRemotesData(ovrMobile *Ovr, double displayTime) {//The amount
break; break;
} }
if (capsHeader.Type == ovrControllerType_TrackedRemote) { if (capsHeader.Type == ovrControllerType_Gamepad) {
ovrInputGamepadCapabilities remoteCaps;
remoteCaps.Header = capsHeader;
if (vrapi_GetInputDeviceCapabilities(Ovr, &remoteCaps.Header) >= 0) {
// remote is connected
ovrInputStateGamepad remoteState;
remoteState.Header.ControllerType = ovrControllerType_Gamepad;
if ( vrapi_GetCurrentInputState( Ovr, capsHeader.DeviceID, &remoteState.Header ) >= 0 )
{
// act on device state returned in remoteState
footTrackedRemoteState_new = remoteState;
}
}
}
else if (capsHeader.Type == ovrControllerType_TrackedRemote) {
ovrTracking remoteTracking; ovrTracking remoteTracking;
ovrInputTrackedRemoteCapabilities remoteCaps; ovrInputTrackedRemoteCapabilities remoteCaps;
remoteCaps.Header = capsHeader; remoteCaps.Header = capsHeader;
@ -114,17 +129,20 @@ void acquireTrackedRemotesData(ovrMobile *Ovr, double displayTime) {//The amount
// remote is connected // remote is connected
ovrInputStateTrackedRemote remoteState; ovrInputStateTrackedRemote remoteState;
remoteState.Header.ControllerType = ovrControllerType_TrackedRemote; remoteState.Header.ControllerType = ovrControllerType_TrackedRemote;
if ( vrapi_GetInputTrackingState( Ovr, capsHeader.DeviceID, displayTime, &remoteTracking ) >= 0 )
{ if(vrapi_GetCurrentInputState(Ovr, capsHeader.DeviceID, &remoteState.Header) >= 0) {
// act on device state returned in remoteState if (vrapi_GetInputTrackingState(Ovr, capsHeader.DeviceID, displayTime,
if (remoteCaps.ControllerCapabilities & ovrControllerCaps_RightHand) { &remoteTracking) >= 0) {
rightTrackedRemoteState_new = remoteState; // act on device state returned in remoteState
rightRemoteTracking_new = remoteTracking; if (remoteCaps.ControllerCapabilities & ovrControllerCaps_RightHand) {
controllerIDs[1] = capsHeader.DeviceID; rightTrackedRemoteState_new = remoteState;
} else{ rightRemoteTracking_new = remoteTracking;
leftTrackedRemoteState_new = remoteState; controllerIDs[1] = capsHeader.DeviceID;
leftRemoteTracking_new = remoteTracking; } else {
controllerIDs[0] = capsHeader.DeviceID; leftTrackedRemoteState_new = remoteState;
leftRemoteTracking_new = remoteTracking;
controllerIDs[0] = capsHeader.DeviceID;
}
} }
} }
} }

View File

@ -62,7 +62,8 @@ extern bool objectiveSystemActive;
extern bool inCinematic; extern bool inCinematic;
void HandleInput_Default( int controlscheme, int switchsticks, ovrInputStateTrackedRemote *pDominantTrackedRemoteNew, ovrInputStateTrackedRemote *pDominantTrackedRemoteOld, ovrTracking* pDominantTracking,
void HandleInput_Default( int controlscheme, int switchsticks, ovrInputStateGamepad *pFootTrackingNew, ovrInputStateGamepad *pFootTrackingOld, ovrInputStateTrackedRemote *pDominantTrackedRemoteNew, ovrInputStateTrackedRemote *pDominantTrackedRemoteOld, ovrTracking* pDominantTracking,
ovrInputStateTrackedRemote *pOffTrackedRemoteNew, ovrInputStateTrackedRemote *pOffTrackedRemoteOld, ovrTracking* pOffTracking, ovrInputStateTrackedRemote *pOffTrackedRemoteNew, ovrInputStateTrackedRemote *pOffTrackedRemoteOld, ovrTracking* pOffTracking,
int domButton1, int domButton2, int offButton1, int offButton2 ) int domButton1, int domButton2, int offButton1, int offButton2 )
@ -458,10 +459,10 @@ void HandleInput_Default( int controlscheme, int switchsticks, ovrInputStateTrac
{ {
//Apply a filter and quadratic scaler so small movements are easier to make //Apply a filter and quadratic scaler so small movements are easier to make
float dist = length(pSecondaryJoystick->x, pSecondaryJoystick->y); float dist = length(pSecondaryJoystick->x - (pFootTrackingNew->LeftJoystick.x * 2), pSecondaryJoystick->y - (pFootTrackingNew->LeftJoystick.y * 2));
float nlf = nonLinearFilter(dist); float nlf = nonLinearFilter(dist);
float x = nlf * pSecondaryJoystick->x; float x = nlf * (pSecondaryJoystick->x - (pFootTrackingNew->LeftJoystick.x * 2));
float y = nlf * pSecondaryJoystick->y; float y = nlf * (pSecondaryJoystick->y - (pFootTrackingNew->LeftJoystick.y * 2));
pVRClientInfo->player_moving = (fabs(x) + fabs(y)) > 0.05f; pVRClientInfo->player_moving = (fabs(x) + fabs(y)) > 0.05f;