Switch selector on offhand using offhand thumbstick

This commit is contained in:
Simon 2023-04-11 08:49:42 +01:00
parent 3b2ffd7289
commit 6314561b52

View file

@ -307,22 +307,42 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
//Left/right to switch between which selector we are using //Left/right to switch between which selector we are using
if (vr.item_selector) { if (vr.item_selector == 1) {
static bool itemSwitched = false; static bool selectorSwitched = false;
if (between(-0.2f, pPrimaryJoystick->y, 0.2f) && if (between(-0.2f, pPrimaryJoystick->y, 0.2f) &&
(primaryJoystickX > 0.8f || primaryJoystickX < -0.8f)) { (primaryJoystickX > 0.8f || primaryJoystickX < -0.8f)) {
if (!itemSwitched) { if (!selectorSwitched) {
if (primaryJoystickX > 0.8f) { if (primaryJoystickX > 0.8f) {
sendButtonActionSimple("itemselectornext"); sendButtonActionSimple("itemselectornext");
itemSwitched = true; selectorSwitched = true;
} else if (primaryJoystickX < -0.8f) { } else if (primaryJoystickX < -0.8f) {
sendButtonActionSimple("itemselectorprev"); sendButtonActionSimple("itemselectorprev");
itemSwitched = true; selectorSwitched = true;
} }
} }
} else if (between(-0.4f, primaryJoystickX, 0.4f)) { } else if (between(-0.4f, primaryJoystickX, 0.4f)) {
itemSwitched = false; selectorSwitched = false;
}
}
//Left/right to switch between which selector we are using
if (vr.item_selector == 2) {
static bool selectorSwitched = false;
if (between(-0.2f, pSecondaryJoystick->y, 0.2f) &&
(pSecondaryJoystick->x > 0.8f || pSecondaryJoystick->x < -0.8f)) {
if (!selectorSwitched) {
if (pSecondaryJoystick->x > 0.8f) {
sendButtonActionSimple("itemselectornext");
selectorSwitched = true;
} else if (pSecondaryJoystick->x < -0.8f) {
sendButtonActionSimple("itemselectorprev");
selectorSwitched = true;
}
}
} else if (between(-0.4f, pSecondaryJoystick->x, 0.4f)) {
selectorSwitched = false;
} }
} }
@ -776,7 +796,11 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
{ {
//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 = 0;
if (vr.item_selector != 2)
{
dist = length(pSecondaryJoystick->x, pSecondaryJoystick->y);
}
float nlf = nonLinearFilter(dist); float nlf = nonLinearFilter(dist);
dist = (dist > 1.0f) ? dist : 1.0f; dist = (dist > 1.0f) ? dist : 1.0f;
float x = nlf * (pSecondaryJoystick->x / dist); float x = nlf * (pSecondaryJoystick->x / dist);