mirror of
https://github.com/overte-org/overte.git
synced 2025-04-09 02:33:19 +02:00
Merge pull request #16562 from ctrlaltdavid/DEV-2442
DEV-2442: Fix main gamepad (XBox controller) controls
This commit is contained in:
commit
bb68f92d3e
5 changed files with 38 additions and 20 deletions
|
@ -52,7 +52,6 @@
|
|||
{ "from": "GamePad.DL", "to": "Standard.DL" },
|
||||
{ "from": "GamePad.DR", "to": "Standard.DR" },
|
||||
|
||||
{ "from": [ "GamePad.Y" ], "to": "Standard.RightPrimaryThumb", "peek": true },
|
||||
{ "from": "GamePad.A", "to": "Standard.A" },
|
||||
{ "from": "GamePad.B", "to": "Standard.B" },
|
||||
{ "from": "GamePad.X", "to": "Standard.X" },
|
||||
|
|
|
@ -5844,12 +5844,7 @@ void Application::centerUI() {
|
|||
|
||||
void Application::cycleCamera() {
|
||||
auto menu = Menu::getInstance();
|
||||
if (menu->isOptionChecked(MenuOption::FullscreenMirror)) {
|
||||
|
||||
menu->setIsOptionChecked(MenuOption::FullscreenMirror, false);
|
||||
menu->setIsOptionChecked(MenuOption::FirstPersonLookAt, true);
|
||||
|
||||
} else if (menu->isOptionChecked(MenuOption::FirstPersonLookAt)) {
|
||||
if (menu->isOptionChecked(MenuOption::FirstPersonLookAt)) {
|
||||
|
||||
menu->setIsOptionChecked(MenuOption::FirstPersonLookAt, false);
|
||||
menu->setIsOptionChecked(MenuOption::LookAtCamera, true);
|
||||
|
@ -5857,12 +5852,16 @@ void Application::cycleCamera() {
|
|||
} else if (menu->isOptionChecked(MenuOption::LookAtCamera)) {
|
||||
|
||||
menu->setIsOptionChecked(MenuOption::LookAtCamera, false);
|
||||
menu->setIsOptionChecked(MenuOption::SelfieCamera, true);
|
||||
if (menu->getActionForOption(MenuOption::SelfieCamera)->isVisible()) {
|
||||
menu->setIsOptionChecked(MenuOption::SelfieCamera, true);
|
||||
} else {
|
||||
menu->setIsOptionChecked(MenuOption::FirstPersonLookAt, true);
|
||||
}
|
||||
|
||||
} else if (menu->isOptionChecked(MenuOption::SelfieCamera)) {
|
||||
|
||||
menu->setIsOptionChecked(MenuOption::SelfieCamera, false);
|
||||
menu->setIsOptionChecked(MenuOption::FullscreenMirror, true);
|
||||
menu->setIsOptionChecked(MenuOption::FirstPersonLookAt, true);
|
||||
|
||||
}
|
||||
cameraMenuChanged(); // handle the menu change
|
||||
|
|
|
@ -118,7 +118,6 @@ namespace MenuOption {
|
|||
const QString FixGaze = "Fix Gaze (no saccade)";
|
||||
const QString Forward = "Forward";
|
||||
const QString FrameTimer = "Show Timer";
|
||||
const QString FullscreenMirror = "Mirror";
|
||||
const QString Help = "Help...";
|
||||
const QString HomeLocation = "Home ";
|
||||
const QString IncreaseAvatarSize = "Increase Avatar Size";
|
||||
|
|
|
@ -176,8 +176,8 @@ namespace controller {
|
|||
* person view.</td></tr>
|
||||
* <tr><td><code>BoomOut</code></td><td>number</td><td>number</td><td>Zoom camera out from first person to third
|
||||
* person view.</td></tr>
|
||||
* <tr><td><code>CycleCamera</code></td><td>number</td><td>number</td><td>Cycle the camera view from first person, to
|
||||
* third person, to full screen mirror, then back to first person and repeat.</td></tr>
|
||||
* <tr><td><code>CycleCamera</code></td><td>number</td><td>number</td><td>Cycle the camera view from first person look
|
||||
* at, to (third person) look at, to selfie if in desktop mode, then back to first person and repeat.</td></tr>
|
||||
* <tr><td><code>ContextMenu</code></td><td>number</td><td>number</td><td>Show/hide the tablet.</td></tr>
|
||||
* <tr><td><code>ToggleMute</code></td><td>number</td><td>number</td><td>Toggle the microphone mute.</td></tr>
|
||||
* <tr><td><code>TogglePushToTalk</code></td><td>number</td><td>number</td><td>Toggle push to talk.</td></tr>
|
||||
|
|
|
@ -129,6 +129,7 @@ Script.include("/~/system/libraries/controllers.js");
|
|||
this.init = false;
|
||||
this.hand = hand;
|
||||
this.buttonValue = 0;
|
||||
this.buttonTeleporting = false; // True if buttonValue is controlling teleport.
|
||||
this.standardAxisLY = 0.0;
|
||||
this.standardAxisRY = 0.0;
|
||||
this.disabled = false; // used by the 'Hifi-Teleport-Disabler' message handler
|
||||
|
@ -687,8 +688,10 @@ Script.include("/~/system/libraries/controllers.js");
|
|||
};
|
||||
|
||||
this.buttonPress = function (value) {
|
||||
// Button press on gamepad.
|
||||
if (value === 0 || !_this.teleportLocked()) {
|
||||
_this.buttonValue = value;
|
||||
_this.buttonTeleporting = true;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -711,23 +714,23 @@ Script.include("/~/system/libraries/controllers.js");
|
|||
|
||||
this.getDominantHand = function () {
|
||||
return (MyAvatar.getDominantHand() === "left") ? LEFT_HAND : RIGHT_HAND;
|
||||
}
|
||||
};
|
||||
|
||||
this.getOffHand = function () {
|
||||
return (MyAvatar.getDominantHand() === "left") ? RIGHT_HAND : LEFT_HAND;
|
||||
}
|
||||
};
|
||||
|
||||
this.showReticle = function () {
|
||||
return (_this.getDominantY() > TELEPORT_DEADZONE) ? true : false;
|
||||
};
|
||||
|
||||
this.shouldTeleport = function () {
|
||||
return (_this.getDominantY() > TELEPORT_DEADZONE && _this.getOffhandY() > TELEPORT_DEADZONE) ? true : false;
|
||||
return ((_this.getDominantY() > TELEPORT_DEADZONE && _this.getOffhandY() > TELEPORT_DEADZONE)
|
||||
|| (_this.buttonTeleporting && _this.buttonValue === 0)) ? true : false;
|
||||
};
|
||||
|
||||
this.shouldCancel = function () {
|
||||
//return (_this.getDominantY() < -TELEPORT_DEADZONE || _this.getOffhandY() < -TELEPORT_DEADZONE) ? true : false;
|
||||
return (_this.getDominantY() <= TELEPORT_DEADZONE) ? true : false;
|
||||
return (_this.getDominantY() <= TELEPORT_DEADZONE && !_this.buttonTeleporting) ? true : false;
|
||||
};
|
||||
|
||||
this.parameters = makeDispatcherModuleParameters(
|
||||
|
@ -746,7 +749,8 @@ Script.include("/~/system/libraries/controllers.js");
|
|||
}
|
||||
|
||||
var otherModule = this.getOtherModule();
|
||||
if (!this.disabled && this.showReticle() && !otherModule.active && this.hand === this.getDominantHand()) {
|
||||
if (!this.disabled && !otherModule.active && (this.showReticle() && this.hand === this.getDominantHand()
|
||||
|| this.buttonValue !== 0)) {
|
||||
this.active = true;
|
||||
this.enterTeleport();
|
||||
return makeRunningValues(true, [], []);
|
||||
|
@ -843,6 +847,7 @@ Script.include("/~/system/libraries/controllers.js");
|
|||
|
||||
_this.disableLasers();
|
||||
_this.active = false;
|
||||
_this.buttonTeleporting = false;
|
||||
return makeRunningValues(false, [], []);
|
||||
};
|
||||
|
||||
|
@ -923,6 +928,7 @@ Script.include("/~/system/libraries/controllers.js");
|
|||
|
||||
var mappingName, teleportMapping;
|
||||
var isViveMapped = false;
|
||||
var isGamePadMapped = false;
|
||||
|
||||
function parseJSON(json) {
|
||||
try {
|
||||
|
@ -1009,11 +1015,25 @@ Script.include("/~/system/libraries/controllers.js");
|
|||
}
|
||||
}
|
||||
|
||||
function registerGamePadMapping(teleporter) {
|
||||
if (Controller.Hardware.GamePad) {
|
||||
var mappingName = 'Hifi-Teleporter-Dev-GamePad-' + Math.random();
|
||||
var teleportMapping = Controller.newMapping(mappingName);
|
||||
teleportMapping.from(Controller.Hardware.GamePad.Y).peek().to(rightTeleporter.buttonPress);
|
||||
Controller.enableMapping(mappingName);
|
||||
isGamePadMapped = true;
|
||||
}
|
||||
}
|
||||
|
||||
function onHardwareChanged() {
|
||||
// Controller.Hardware.Vive is not immediately available at Interface start-up.
|
||||
if (!isViveMapped && Controller.Hardware.Vive) {
|
||||
registerViveTeleportMapping();
|
||||
}
|
||||
|
||||
if (!isGamePadMapped && Controller.Hardware.GamePad) {
|
||||
registerGamePadMapping();
|
||||
}
|
||||
}
|
||||
|
||||
Controller.hardwareChanged.connect(onHardwareChanged);
|
||||
|
@ -1025,9 +1045,10 @@ Script.include("/~/system/libraries/controllers.js");
|
|||
// Vive teleport button lock-out.
|
||||
registerViveTeleportMapping();
|
||||
|
||||
// Gamepad "Y" button teleport.
|
||||
registerGamePadMapping();
|
||||
|
||||
// Teleport actions.
|
||||
teleportMapping.from(Controller.Standard.LeftPrimaryThumb).peek().to(leftTeleporter.buttonPress);
|
||||
teleportMapping.from(Controller.Standard.RightPrimaryThumb).peek().to(rightTeleporter.buttonPress);
|
||||
teleportMapping.from(Controller.Standard.LY).peek().to(leftTeleporter.getStandardLY);
|
||||
teleportMapping.from(Controller.Standard.RY).peek().to(leftTeleporter.getStandardRY);
|
||||
teleportMapping.from(Controller.Standard.LY).peek().to(rightTeleporter.getStandardLY);
|
||||
|
|
Loading…
Reference in a new issue