mirror of
https://github.com/lubosz/overte.git
synced 2025-04-26 23:55:34 +02:00
Add support for oculus touch in help menu
This commit is contained in:
parent
06b7388930
commit
9f166d82ce
5 changed files with 84 additions and 18 deletions
interface
libraries/plugins/src/plugins
|
@ -47,25 +47,72 @@
|
|||
}
|
||||
</style>
|
||||
<script>
|
||||
var handControllerImageURL = null;
|
||||
|
||||
function showKbm() {
|
||||
document.getElementById("main_image").setAttribute("src", "img/controls-help-keyboard.png");
|
||||
}
|
||||
function showViveControllers() {
|
||||
document.getElementById("main_image").setAttribute("src", "img/controls-help-vive.png");
|
||||
|
||||
function showHandControllers() {
|
||||
document.getElementById("main_image").setAttribute("src", handControllerImageURL);
|
||||
}
|
||||
function showXboxController() {
|
||||
|
||||
function showGamepad() {
|
||||
document.getElementById("main_image").setAttribute("src", "img/controls-help-gamepad.png");
|
||||
}
|
||||
|
||||
// This is not meant to be a complete or hardened query string parser - it only
|
||||
// needs to handle the values we send in and have control over.
|
||||
//
|
||||
// queryString is a string of the form "key1=value1&key2=value2&key3&key4=value4"
|
||||
function parseQueryString(queryString) {
|
||||
var params = {};
|
||||
var paramsParts = queryString.split("&");
|
||||
for (var i = 0; i < paramsParts.length; ++i) {
|
||||
var paramKeyValue = paramsParts[i].split("=");
|
||||
if (paramKeyValue.length == 1) {
|
||||
params[paramKeyValue[0]] = undefined;
|
||||
} else if (paramKeyValue.length == 2) {
|
||||
console.log('found ' + paramKeyValue[0] + " " + paramKeyValue[1]);
|
||||
params[paramKeyValue[0]] = paramKeyValue[1];
|
||||
} else {
|
||||
console.error("Error parsing param keyvalue: ", paramParts);
|
||||
}
|
||||
}
|
||||
return params;
|
||||
}
|
||||
|
||||
function load() {
|
||||
console.log("In help.html: ", window.location.href);
|
||||
parts = window.location.href.split("?");
|
||||
var parts = window.location.href.split("?");
|
||||
var params = {};
|
||||
if (parts.length > 0) {
|
||||
var defaultTab = parts[1];
|
||||
if (defaultTab == "xbox") {
|
||||
showXboxController();
|
||||
} else if (defaultTab == "vive") {
|
||||
showViveControllers();
|
||||
}
|
||||
params = parseQueryString(parts[1]);
|
||||
}
|
||||
|
||||
switch (params.handControllerName) {
|
||||
case "oculus":
|
||||
console.log("Using oculus image");
|
||||
handControllerImageURL = "img/controls-help-oculus.png";
|
||||
break;
|
||||
|
||||
case "vive":
|
||||
default:
|
||||
handControllerImageURL = "img/controls-help-vive.png";
|
||||
}
|
||||
|
||||
switch (params.defaultTab) {
|
||||
case "gamepad":
|
||||
showGamepad();
|
||||
break;
|
||||
|
||||
case "handControllers":
|
||||
showHandControllers();
|
||||
break;
|
||||
|
||||
case "kbm":
|
||||
default:
|
||||
showKbm();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@ -75,8 +122,8 @@
|
|||
<div id="image_area">
|
||||
<img id="main_image" src="img/controls-help-keyboard.png" width="1024px" height="720px"></img>
|
||||
<a href="#" id="kbm_button" onmousedown="showKbm()"></a>
|
||||
<a href="#" id="hand_controllers_button" onmousedown="showViveControllers()"></a>
|
||||
<a href="#" id="game_controller_button" onmousedown="showXboxController()"></a>
|
||||
<a href="#" id="hand_controllers_button" onmousedown="showHandControllers()"></a>
|
||||
<a href="#" id="game_controller_button" onmousedown="showGamepad()"></a>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
|
|
BIN
interface/resources/html/img/controls-help-oculus.png
Normal file
BIN
interface/resources/html/img/controls-help-oculus.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 124 KiB |
|
@ -2180,17 +2180,31 @@ void Application::aboutApp() {
|
|||
}
|
||||
|
||||
void Application::showHelp() {
|
||||
static const QString QUERY_STRING_XBOX = "xbox";
|
||||
static const QString QUERY_STRING_VIVE = "vive";
|
||||
static const QString HAND_CONTROLLER_NAME_VIVE = "vive";
|
||||
static const QString HAND_CONTROLLER_NAME_OCULUS_TOUCH = "oculus";
|
||||
|
||||
static const QString TAB_KEYBOARD_MOUSE = "kbm";
|
||||
static const QString TAB_GAMEPAD = "gamepad";
|
||||
static const QString TAB_HAND_CONTROLLERS = "handControllers";
|
||||
|
||||
QString handControllerName = HAND_CONTROLLER_NAME_VIVE;
|
||||
QString defaultTab = TAB_KEYBOARD_MOUSE;
|
||||
|
||||
QString queryString = "";
|
||||
if (PluginUtils::isViveControllerAvailable()) {
|
||||
queryString = QUERY_STRING_VIVE;
|
||||
defaultTab = TAB_HAND_CONTROLLERS;
|
||||
handControllerName = HAND_CONTROLLER_NAME_VIVE;
|
||||
} else if (PluginUtils::isOculusTouchControllerAvailable()) {
|
||||
defaultTab = TAB_HAND_CONTROLLERS;
|
||||
handControllerName = HAND_CONTROLLER_NAME_OCULUS_TOUCH;
|
||||
} else if (PluginUtils::isXboxControllerAvailable()) {
|
||||
queryString = QUERY_STRING_XBOX;
|
||||
defaultTab = TAB_GAMEPAD;
|
||||
}
|
||||
|
||||
InfoView::show(INFO_HELP_PATH, false, queryString);
|
||||
QUrlQuery queryString;
|
||||
queryString.addQueryItem("handControllerName", handControllerName);
|
||||
queryString.addQueryItem("defaultTab", defaultTab);
|
||||
|
||||
InfoView::show(INFO_HELP_PATH, false, queryString.toString());
|
||||
}
|
||||
|
||||
void Application::resizeEvent(QResizeEvent* event) {
|
||||
|
|
|
@ -51,6 +51,10 @@ bool PluginUtils::isViveControllerAvailable() {
|
|||
return isSubdeviceContainingNameAvailable("OpenVR");
|
||||
};
|
||||
|
||||
bool PluginUtils::isOculusTouchControllerAvailable() {
|
||||
return isSubdeviceContainingNameAvailable("OculusTouch");
|
||||
};
|
||||
|
||||
bool PluginUtils::isXboxControllerAvailable() {
|
||||
return isSubdeviceContainingNameAvailable("X360 Controller");
|
||||
};
|
||||
|
|
|
@ -17,5 +17,6 @@ public:
|
|||
static bool isHMDAvailable(const QString& pluginName = "");
|
||||
static bool isHandControllerAvailable();
|
||||
static bool isViveControllerAvailable();
|
||||
static bool isOculusTouchControllerAvailable();
|
||||
static bool isXboxControllerAvailable();
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue