mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 14:58:03 +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 },
|
{ "type": "deadZone", "min": 0.15 },
|
||||||
"constrainToInteger",
|
"constrainToInteger",
|
||||||
{ "type": "pulse", "interval": 0.5 },
|
{ "type": "pulse", "interval": 0.25 },
|
||||||
{ "type": "scale", "scale": 22.5 }
|
{ "type": "scale", "scale": 22.5 }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
{
|
{
|
||||||
"name": "Vive to Standard",
|
"name": "Vive to Standard",
|
||||||
"channels": [
|
"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",
|
"from": "Vive.LT", "to": "Standard.LT",
|
||||||
"filters": [
|
"filters": [
|
||||||
|
@ -13,6 +15,7 @@
|
||||||
{ "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.RSY", "filters": ["invert"], "to": "Standard.RY" },
|
||||||
{ "from": "Vive.RX", "when": "Vive.RSX", "to": "Standard.RX" },
|
{ "from": "Vive.RX", "when": "Vive.RSX", "to": "Standard.RX" },
|
||||||
{
|
{
|
||||||
"from": "Vive.RT", "to": "Standard.RT",
|
"from": "Vive.RT", "to": "Standard.RT",
|
||||||
|
|
|
@ -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() {
|
function addAdvancedMovementItemToSettingsMenu() {
|
||||||
Menu.addMenuItem({
|
Menu.addMenuItem({
|
||||||
menuName: "Settings",
|
menuName: "Settings",
|
||||||
menuItemName: "Advanced Movement (Vive)",
|
menuItemName: "Advanced Movement For Hand Controllers",
|
||||||
isCheckable: true,
|
isCheckable: true,
|
||||||
isChecked: false
|
isChecked: false
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function addTranslationToLeftStick() {
|
function rotate180() {
|
||||||
Controller.enableMapping(mappingName);
|
MyAvatar.orientation = Quat.inverse(MyAvatar.orientation);
|
||||||
}
|
}
|
||||||
|
|
||||||
function registerMappings() {
|
function registerBasicMapping() {
|
||||||
mappingName = 'Hifi-AdvancedMovement-Dev-' + Math.random();
|
mappingName = 'Hifi-AdvancedMovement-Dev-' + Math.random();
|
||||||
advancedMapping = Controller.newMapping(mappingName);
|
basicMapping = Controller.newMapping(mappingName);
|
||||||
advancedMapping.from(Controller.Hardware.Vive.LY).when(Controller.getValue(Controller.Hardware.Vive.LSY) === 1).invert().to(function(val) {
|
basicMapping.from(Controller.Standard.LY).to(function(value) {
|
||||||
testPrint('ly:' + val)
|
var stick = Controller.getValue(Controller.Standard.LS);
|
||||||
});
|
if (value === 1) {
|
||||||
advancedMapping.from(Controller.Hardware.Vive.LX).when(Controller.getValue(Controller.Hardware.Vive.LSX) === 1).to(function(val) {
|
rotate180();
|
||||||
testPrint('lx:' + val)
|
}
|
||||||
});
|
print('should do LY stuff' + value + ":stick:" + stick);
|
||||||
advancedMapping.from(Controller.Hardware.Vive.RY).when(Controller.getValue(Controller.Hardware.Vive.RSY) === 1).invert().to(function(val) {
|
return;
|
||||||
testPrint('ry:' + val)
|
|
||||||
});
|
});
|
||||||
|
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) {
|
function testPrint(what) {
|
||||||
print('it was controller: ' + what)
|
print('it was controller: ' + what)
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeTranslationFromLeftStick() {
|
function enableMappings() {
|
||||||
|
Controller.enableMapping(mappingName);
|
||||||
|
}
|
||||||
|
|
||||||
|
function disableMappings() {
|
||||||
Controller.disableMapping(mappingName);
|
Controller.disableMapping(mappingName);
|
||||||
}
|
}
|
||||||
|
|
||||||
function scriptEnding() {
|
function scriptEnding() {
|
||||||
Menu.removeMenuItem("Settings", "Advanced Movement (Vive)");
|
Menu.removeMenuItem("Settings", "Advanced Movement For Hand Controllers");
|
||||||
removeTranslationFromLeftStick();
|
disableMappings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var isChecked = false;
|
||||||
|
|
||||||
function menuItemEvent(menuItem) {
|
function menuItemEvent(menuItem) {
|
||||||
if (menuItem == "Advanced Movement (Vive)") {
|
if (menuItem == "Advanced Movement For Hand Controllers") {
|
||||||
print(" checked=" + Menu.isOptionChecked("Advanced Movement (Vive)"));
|
print(" checked=" + Menu.isOptionChecked("Advanced Movement For Hand Controllers"));
|
||||||
var isChecked = Menu.isOptionChecked("Advanced Movement (Vive)");
|
isChecked = Menu.isOptionChecked("Advanced Movement For Hand Controllers");
|
||||||
if (isChecked === true) {
|
if (isChecked === true) {
|
||||||
addTranslationToLeftStick();
|
disableMappings();
|
||||||
} else if (isChecked === false) {
|
} else if (isChecked === false) {
|
||||||
removeTranslationFromLeftStick();
|
enableMappings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,9 +80,22 @@ function menuItemEvent(menuItem) {
|
||||||
|
|
||||||
addAdvancedMovementItemToSettingsMenu();
|
addAdvancedMovementItemToSettingsMenu();
|
||||||
|
|
||||||
// register our scriptEnding callback
|
|
||||||
Script.scriptEnding.connect(scriptEnding);
|
Script.scriptEnding.connect(scriptEnding);
|
||||||
|
|
||||||
Menu.menuItemEvent.connect(menuItemEvent);
|
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