mirror of
https://github.com/lubosz/overte.git
synced 2025-04-24 09:43:25 +02:00
invert the structure and make it work with oculus
This commit is contained in:
parent
09cd0b8f4a
commit
1eaac8605f
3 changed files with 70 additions and 30 deletions
|
@ -11,7 +11,7 @@
|
|||
[
|
||||
{ "type": "deadZone", "min": 0.15 },
|
||||
"constrainToInteger",
|
||||
{ "type": "pulse", "interval": 0.5 },
|
||||
{ "type": "pulse", "interval": 0.25 },
|
||||
{ "type": "scale", "scale": 22.5 }
|
||||
]
|
||||
},
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
{
|
||||
"name": "Vive to Standard",
|
||||
"channels": [
|
||||
{ "from": "Vive.LY", "when": "Vive.LSY", "filters": ["invert"], "to": "Standard.LY" },
|
||||
{ "from": "Vive.LX", "when": "Vive.LSX", "to": "Standard.LX" },
|
||||
{
|
||||
"from": "Vive.LT", "to": "Standard.LT",
|
||||
"filters": [
|
||||
"from": "Vive.LT", "to": "Standard.LT",
|
||||
"filters": [
|
||||
{ "type": "deadZone", "min": 0.05 }
|
||||
]
|
||||
},
|
||||
|
@ -13,10 +15,11 @@
|
|||
{ "from": "Vive.LS", "to": "Standard.LS" },
|
||||
{ "from": "Vive.LSTouch", "to": "Standard.LSTouch" },
|
||||
|
||||
{ "from": "Vive.RY", "when": "Vive.RSY", "filters": ["invert"], "to": "Standard.RY" },
|
||||
{ "from": "Vive.RX", "when": "Vive.RSX", "to": "Standard.RX" },
|
||||
{
|
||||
"from": "Vive.RT", "to": "Standard.RT",
|
||||
"filters": [
|
||||
"from": "Vive.RT", "to": "Standard.RT",
|
||||
"filters": [
|
||||
{ "type": "deadZone", "min": 0.05 }
|
||||
]
|
||||
},
|
||||
|
@ -34,4 +37,4 @@
|
|||
{ "from": "Vive.LeftHand", "to": "Standard.LeftHand" },
|
||||
{ "from": "Vive.RightHand", "to": "Standard.RightHand" }
|
||||
]
|
||||
}
|
||||
}
|
|
@ -1,54 +1,78 @@
|
|||
var mappingName, advancedMapping;
|
||||
//advanced movements settings are in individual controller json files
|
||||
//what we do is check the status of the 'advance movement' checkbox when you enter HMD mode
|
||||
//if 'advanced movement' is checked...we give you the defaults that are in the json.
|
||||
//if 'advanced movement' is not checked... we override the advanced controls with basic ones.
|
||||
//when the script stops,
|
||||
|
||||
//todo: store in prefs
|
||||
//
|
||||
|
||||
|
||||
var mappingName, basicMapping;
|
||||
|
||||
function addAdvancedMovementItemToSettingsMenu() {
|
||||
Menu.addMenuItem({
|
||||
menuName: "Settings",
|
||||
menuItemName: "Advanced Movement (Vive)",
|
||||
menuItemName: "Advanced Movement For Hand Controllers",
|
||||
isCheckable: true,
|
||||
isChecked: false
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function addTranslationToLeftStick() {
|
||||
Controller.enableMapping(mappingName);
|
||||
function rotate180() {
|
||||
MyAvatar.orientation = Quat.inverse(MyAvatar.orientation);
|
||||
}
|
||||
|
||||
function registerMappings() {
|
||||
function registerBasicMapping() {
|
||||
mappingName = 'Hifi-AdvancedMovement-Dev-' + Math.random();
|
||||
advancedMapping = Controller.newMapping(mappingName);
|
||||
advancedMapping.from(Controller.Hardware.Vive.LY).when(Controller.getValue(Controller.Hardware.Vive.LSY) === 1).invert().to(function(val) {
|
||||
testPrint('ly:' + val)
|
||||
});
|
||||
advancedMapping.from(Controller.Hardware.Vive.LX).when(Controller.getValue(Controller.Hardware.Vive.LSX) === 1).to(function(val) {
|
||||
testPrint('lx:' + val)
|
||||
});
|
||||
advancedMapping.from(Controller.Hardware.Vive.RY).when(Controller.getValue(Controller.Hardware.Vive.RSY) === 1).invert().to(function(val) {
|
||||
testPrint('ry:' + val)
|
||||
basicMapping = Controller.newMapping(mappingName);
|
||||
basicMapping.from(Controller.Standard.LY).to(function(value) {
|
||||
var stick = Controller.getValue(Controller.Standard.LS);
|
||||
if (value === 1) {
|
||||
rotate180();
|
||||
}
|
||||
print('should do LY stuff' + value + ":stick:" + stick);
|
||||
return;
|
||||
});
|
||||
basicMapping.from(Controller.Standard.LX).to(Controller.Standard.RX);
|
||||
basicMapping.from(Controller.Standard.RY).to(function(value) {
|
||||
var stick = Controller.getValue(Controller.Standard.RS);
|
||||
if (value === 1) {
|
||||
rotate180();
|
||||
}
|
||||
print('should do RY stuff' + value + ":stick:" + stick);
|
||||
return;
|
||||
})
|
||||
}
|
||||
|
||||
function testPrint(what) {
|
||||
print('it was controller: ' + what)
|
||||
}
|
||||
|
||||
function removeTranslationFromLeftStick() {
|
||||
function enableMappings() {
|
||||
Controller.enableMapping(mappingName);
|
||||
}
|
||||
|
||||
function disableMappings() {
|
||||
Controller.disableMapping(mappingName);
|
||||
}
|
||||
|
||||
function scriptEnding() {
|
||||
Menu.removeMenuItem("Settings", "Advanced Movement (Vive)");
|
||||
removeTranslationFromLeftStick();
|
||||
Menu.removeMenuItem("Settings", "Advanced Movement For Hand Controllers");
|
||||
disableMappings();
|
||||
}
|
||||
|
||||
var isChecked = false;
|
||||
|
||||
function menuItemEvent(menuItem) {
|
||||
if (menuItem == "Advanced Movement (Vive)") {
|
||||
print(" checked=" + Menu.isOptionChecked("Advanced Movement (Vive)"));
|
||||
var isChecked = Menu.isOptionChecked("Advanced Movement (Vive)");
|
||||
if (menuItem == "Advanced Movement For Hand Controllers") {
|
||||
print(" checked=" + Menu.isOptionChecked("Advanced Movement For Hand Controllers"));
|
||||
isChecked = Menu.isOptionChecked("Advanced Movement For Hand Controllers");
|
||||
if (isChecked === true) {
|
||||
addTranslationToLeftStick();
|
||||
disableMappings();
|
||||
} else if (isChecked === false) {
|
||||
removeTranslationFromLeftStick();
|
||||
enableMappings();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,9 +80,22 @@ function menuItemEvent(menuItem) {
|
|||
|
||||
addAdvancedMovementItemToSettingsMenu();
|
||||
|
||||
// register our scriptEnding callback
|
||||
Script.scriptEnding.connect(scriptEnding);
|
||||
|
||||
Menu.menuItemEvent.connect(menuItemEvent);
|
||||
|
||||
registerMappings();
|
||||
registerBasicMapping();
|
||||
enableMappings();
|
||||
|
||||
HMD.displayModeChanged.connect(function(isHMDMode) {
|
||||
if (isHMDMode) {
|
||||
if (Controller.Hardware.Vive !== undefined || Controller.Hardware.OculusTouch !== undefined) {
|
||||
if (isChecked === true) {
|
||||
disableMappings();
|
||||
} else if (isChecked === false) {
|
||||
enableMappings();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
});
|
Loading…
Reference in a new issue