mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-06-03 07:51:13 +02:00
Do button mapping in C++ and simplify vive.json accordingly. Vive and
Hydra now use PrimaryThumb and SecondaryThumb. Fix warnings for Neuron.
This commit is contained in:
parent
6b606759aa
commit
a3f1ece978
7 changed files with 42 additions and 37 deletions
|
@ -16,12 +16,10 @@
|
||||||
{ "from": "Hydra.L0", "to": "Standard.Back" },
|
{ "from": "Hydra.L0", "to": "Standard.Back" },
|
||||||
{ "from": "Hydra.R0", "to": "Standard.Start" },
|
{ "from": "Hydra.R0", "to": "Standard.Start" },
|
||||||
|
|
||||||
{ "from": [ "Hydra.L1", "Hydra.L2" ], "to": "Standard.LeftPrimaryThumb" },
|
{ "from": [ "Hydra.L1", "Hydra.L3" ], "to": "Standard.LeftPrimaryThumb" },
|
||||||
{ "from": [ "Hydra.R1", "Hydra.R2" ], "to": "Standard.RightPrimaryThumb" },
|
{ "from": [ "Hydra.R1", "Hydra.R3" ], "to": "Standard.RightPrimaryThumb" },
|
||||||
{ "from": [ "Hydra.L3" ], "to": "Standard.L3" },
|
{ "from": [ "Hydra.R2", "Hydra.R4" ], "to": "Standard.RightSecondaryThumb" },
|
||||||
{ "from": [ "Hydra.R3" ], "to": "Standard.R3" },
|
{ "from": [ "Hydra.L2", "Hydra.L4" ], "to": "Standard.LeftSecondaryThumb" },
|
||||||
{ "from": [ "Hydra.R4" ], "to": "Standard.RightSecondaryThumb" },
|
|
||||||
{ "from": [ "Hydra.L4" ], "to": "Standard.LeftSecondaryThumb" },
|
|
||||||
|
|
||||||
{ "from": "Hydra.LeftHand", "to": "Standard.LeftHand" },
|
{ "from": "Hydra.LeftHand", "to": "Standard.LeftHand" },
|
||||||
{ "from": "Hydra.RightHand", "to": "Standard.RightHand" }
|
{ "from": "Hydra.RightHand", "to": "Standard.RightHand" }
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "Neuron to Standard",
|
"name": "Neuron to Standard",
|
||||||
"channels": [
|
"channels": [
|
||||||
{ "from": "Hydra.LeftHand", "to": "Standard.LeftHand" },
|
{ "from": "Neuron.LeftHand", "to": "Standard.LeftHand" },
|
||||||
{ "from": "Hydra.RightHand", "to": "Standard.RightHand" }
|
{ "from": "Neuron.RightHand", "to": "Standard.RightHand" }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,23 +1,25 @@
|
||||||
{
|
{
|
||||||
"name": "Vive to Standard",
|
"name": "Vive to Standard",
|
||||||
"channels": [
|
"channels": [
|
||||||
{ "from": "Vive.LY", "when": "Vive.LS", "filters": ["invert" ,{ "type": "deadZone", "min": 0.6 }], "to": "Standard.LY" },
|
{ "from": "Vive.LY", "when": "Vive.LSOuter", "filters": ["invert"], "to": "Standard.LY" },
|
||||||
{ "from": "Vive.LX", "when": "Vive.LS", "filters": [{ "type": "deadZone", "min": 0.6 }], "to": "Standard.LX" },
|
{ "from": "Vive.LX", "when": "Vive.LSOuter", "to": "Standard.LX" },
|
||||||
|
|
||||||
{ "from": "Vive.LT", "to": "Standard.LT" },
|
{ "from": "Vive.LT", "to": "Standard.LT" },
|
||||||
{ "from": "Vive.LeftGrip", "to": "Standard.LB" },
|
{ "from": "Vive.LeftGrip", "to": "Standard.LB" },
|
||||||
{ "from": "Vive.LS", "to": "Standard.LS" },
|
{ "from": "Vive.LS", "to": "Standard.LS" },
|
||||||
{ "from": "Vive.LSTouch", "to": "Standard.LSTouch" },
|
{ "from": "Vive.LSTouch", "to": "Standard.LSTouch" },
|
||||||
|
|
||||||
{ "from": "Vive.RY", "when": "Vive.RS", "filters": ["invert", { "type": "deadZone", "min": 0.6 }], "to": "Standard.RY" },
|
{ "from": "Vive.RY", "when": "Vive.RSOuter", "filters": ["invert"], "to": "Standard.RY" },
|
||||||
{ "from": "Vive.RX", "when": "Vive.RS", "filters": [{ "type": "deadZone", "min": 0.6 }], "to": "Standard.RX" },
|
{ "from": "Vive.RX", "when": "Vive.RSOuter", "to": "Standard.RX" },
|
||||||
|
|
||||||
{ "from": "Vive.RT", "to": "Standard.RT" },
|
{ "from": "Vive.RT", "to": "Standard.RT" },
|
||||||
{ "from": "Vive.RightGrip", "to": "Standard.RB" },
|
{ "from": "Vive.RightGrip", "to": "Standard.RB" },
|
||||||
{ "from": "Vive.RS", "to": "Standard.RS" },
|
{ "from": "Vive.RS", "to": "Standard.RS" },
|
||||||
{ "from": "Vive.RSTouch", "to": "Standard.RSTouch" },
|
{ "from": "Vive.RSTouch", "to": "Standard.RSTouch" },
|
||||||
|
|
||||||
|
{ "from": "Vive.LSCenter", "to": "Standard.LeftPrimaryThumb" },
|
||||||
{ "from": "Vive.LeftApplicationMenu", "to": "Standard.LeftSecondaryThumb" },
|
{ "from": "Vive.LeftApplicationMenu", "to": "Standard.LeftSecondaryThumb" },
|
||||||
|
{ "from": "Vive.RSCenter", "to": "Standard.RightPrimaryThumb" },
|
||||||
{ "from": "Vive.RightApplicationMenu", "to": "Standard.RightSecondaryThumb" },
|
{ "from": "Vive.RightApplicationMenu", "to": "Standard.RightSecondaryThumb" },
|
||||||
|
|
||||||
{ "from": "Vive.LeftHand", "to": "Standard.LeftHand" },
|
{ "from": "Vive.LeftHand", "to": "Standard.LeftHand" },
|
||||||
|
|
|
@ -43,6 +43,8 @@ namespace controller {
|
||||||
LEFT_SECONDARY_THUMB_TOUCH,
|
LEFT_SECONDARY_THUMB_TOUCH,
|
||||||
LS_TOUCH,
|
LS_TOUCH,
|
||||||
LEFT_THUMB_UP,
|
LEFT_THUMB_UP,
|
||||||
|
LS_CENTER,
|
||||||
|
LS_OUTER,
|
||||||
|
|
||||||
RIGHT_PRIMARY_THUMB,
|
RIGHT_PRIMARY_THUMB,
|
||||||
RIGHT_SECONDARY_THUMB,
|
RIGHT_SECONDARY_THUMB,
|
||||||
|
@ -50,6 +52,8 @@ namespace controller {
|
||||||
RIGHT_SECONDARY_THUMB_TOUCH,
|
RIGHT_SECONDARY_THUMB_TOUCH,
|
||||||
RS_TOUCH,
|
RS_TOUCH,
|
||||||
RIGHT_THUMB_UP,
|
RIGHT_THUMB_UP,
|
||||||
|
RS_CENTER,
|
||||||
|
RS_OUTER,
|
||||||
|
|
||||||
LEFT_PRIMARY_INDEX,
|
LEFT_PRIMARY_INDEX,
|
||||||
LEFT_SECONDARY_INDEX,
|
LEFT_SECONDARY_INDEX,
|
||||||
|
|
|
@ -282,10 +282,25 @@ void ViveControllerManager::InputDevice::handleHandController(float deltaTime, u
|
||||||
for (uint32_t i = 0; i < vr::k_unControllerStateAxisCount; i++) {
|
for (uint32_t i = 0; i < vr::k_unControllerStateAxisCount; i++) {
|
||||||
handleAxisEvent(deltaTime, i, controllerState.rAxis[i].x, controllerState.rAxis[i].y, isLeftHand);
|
handleAxisEvent(deltaTime, i, controllerState.rAxis[i].x, controllerState.rAxis[i].y, isLeftHand);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// pseudo buttons the depend on both of the above for-loops
|
||||||
|
partitionTouchpad(controller::LS, controller::LX, controller::LY, controller::LS_CENTER, controller::LS_OUTER);
|
||||||
|
partitionTouchpad(controller::RS, controller::RX, controller::RY, controller::RS_CENTER, controller::RS_OUTER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ViveControllerManager::InputDevice::partitionTouchpad(int sButton, int xAxis, int yAxis, int centerPseudoButton, int outerPseudoButton) {
|
||||||
|
// Populate the L/RS_CENTER/OUTER pseudo buttons, corresponding to a partition of the L/RS space based on the X/Y values.
|
||||||
|
const float CENTER_DEADBAND = 0.6f;
|
||||||
|
if (_buttonPressedMap.find(sButton) != _buttonPressedMap.end()) {
|
||||||
|
float absX = abs(_axisStateMap[xAxis]);
|
||||||
|
float absY = abs(_axisStateMap[yAxis]);
|
||||||
|
bool isCenter = (absX < CENTER_DEADBAND) && (absY < CENTER_DEADBAND); // square deadband
|
||||||
|
_buttonPressedMap.insert(isCenter ? centerPseudoButton : outerPseudoButton);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ViveControllerManager::InputDevice::focusOutEvent() {
|
void ViveControllerManager::InputDevice::focusOutEvent() {
|
||||||
_axisStateMap.clear();
|
_axisStateMap.clear();
|
||||||
_buttonPressedMap.clear();
|
_buttonPressedMap.clear();
|
||||||
|
@ -443,6 +458,11 @@ controller::Input::NamedVector ViveControllerManager::InputDevice::getAvailableI
|
||||||
// touch pad press
|
// touch pad press
|
||||||
makePair(LS, "LS"),
|
makePair(LS, "LS"),
|
||||||
makePair(RS, "RS"),
|
makePair(RS, "RS"),
|
||||||
|
// Differentiate where we are in the touch pad click
|
||||||
|
makePair(LS_CENTER, "LSCenter"),
|
||||||
|
makePair(LS_OUTER, "LSOuter"),
|
||||||
|
makePair(RS_CENTER, "RSCenter"),
|
||||||
|
makePair(RS_OUTER, "RSOuter"),
|
||||||
|
|
||||||
// triggers
|
// triggers
|
||||||
makePair(LT, "LT"),
|
makePair(LT, "LT"),
|
||||||
|
|
|
@ -61,6 +61,7 @@ private:
|
||||||
void handleAxisEvent(float deltaTime, uint32_t axis, float x, float y, bool isLeftHand);
|
void handleAxisEvent(float deltaTime, uint32_t axis, float x, float y, bool isLeftHand);
|
||||||
void handlePoseEvent(float deltaTime, const controller::InputCalibrationData& inputCalibrationData, const mat4& mat,
|
void handlePoseEvent(float deltaTime, const controller::InputCalibrationData& inputCalibrationData, const mat4& mat,
|
||||||
const vec3& linearVelocity, const vec3& angularVelocity, bool isLeftHand);
|
const vec3& linearVelocity, const vec3& angularVelocity, bool isLeftHand);
|
||||||
|
void ViveControllerManager::InputDevice::partitionTouchpad(int sButton, int xAxis, int yAxis, int centerPsuedoButton, int outerPseudoButton);
|
||||||
|
|
||||||
class FilteredStick {
|
class FilteredStick {
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -266,39 +266,19 @@ function toggleHand() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create clickMappings as needed, on demand.
|
|
||||||
var clickMapping = Controller.newMapping(Script.resolvePath('') + '-click');
|
var clickMapping = Controller.newMapping(Script.resolvePath('') + '-click');
|
||||||
Script.scriptEnding.connect(clickMapping.disable);
|
Script.scriptEnding.connect(clickMapping.disable);
|
||||||
|
|
||||||
// Move these to vive.json
|
clickMapping.from(Controller.Standard.RightPrimaryThumb).peek().to(Controller.Actions.ReticleClick);
|
||||||
function makeCenterClickWhen(click, x, y) {
|
clickMapping.from(Controller.Standard.LeftPrimaryThumb).peek().to(Controller.Actions.ReticleClick);
|
||||||
var clickKey = Controller.Standard[click],
|
|
||||||
xKey = Controller.Standard[x], // Standard after filtering by mapping
|
|
||||||
yKey = Controller.Standard[y];
|
|
||||||
return function () {
|
|
||||||
var clickValue = Controller.getValue(clickKey);
|
|
||||||
var xValue = Controller.getValue(xKey);
|
|
||||||
var yValue = Controller.getValue(yKey);
|
|
||||||
var answer = clickValue && !xValue && !yValue;
|
|
||||||
return answer;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
if (Controller.Hardware.Vive) {
|
|
||||||
clickMapping.from(Controller.Hardware.Vive.RS).when(makeCenterClickWhen('RS', 'RX', 'RY')).to(Controller.Standard.R3);
|
|
||||||
clickMapping.from(Controller.Hardware.Vive.LS).when(makeCenterClickWhen('LS', 'LX', 'LY')).to(Controller.Standard.L3);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
clickMapping.from(Controller.Standard.R3).peek().to(Controller.Actions.ReticleClick);
|
|
||||||
clickMapping.from(Controller.Standard.L3).peek().to(Controller.Actions.ReticleClick);
|
|
||||||
clickMapping.from(Controller.Standard.RightSecondaryThumb).peek().to(Controller.Actions.ContextMenu);
|
clickMapping.from(Controller.Standard.RightSecondaryThumb).peek().to(Controller.Actions.ContextMenu);
|
||||||
clickMapping.from(Controller.Standard.LeftSecondaryThumb).peek().to(Controller.Actions.ContextMenu);
|
clickMapping.from(Controller.Standard.LeftSecondaryThumb).peek().to(Controller.Actions.ContextMenu);
|
||||||
clickMapping.from(Controller.Standard.R3).peek().to(function (on) {
|
clickMapping.from(Controller.Standard.RightPrimaryThumb).peek().to(function (on) {
|
||||||
if (on && (activeHand !== Controller.Standard.RightHand)) {
|
if (on && (activeHand !== Controller.Standard.RightHand)) {
|
||||||
toggleHand();
|
toggleHand();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
clickMapping.from(Controller.Standard.L3).peek().to(function (on) {
|
clickMapping.from(Controller.Standard.LeftPrimaryThumb).peek().to(function (on) {
|
||||||
if (on && (activeHand !== Controller.Standard.LeftHand)) {
|
if (on && (activeHand !== Controller.Standard.LeftHand)) {
|
||||||
toggleHand();
|
toggleHand();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue