mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 07:17:43 +02:00
Merge pull request #14362 from ctrlaltdavid/M19768
Add option to enable/disable the mini tablet
This commit is contained in:
commit
41d8220cbd
6 changed files with 84 additions and 8 deletions
|
@ -993,6 +993,7 @@ const bool DEFAULT_HMD_TABLET_BECOMES_TOOLBAR = false;
|
||||||
const bool DEFAULT_PREFER_STYLUS_OVER_LASER = false;
|
const bool DEFAULT_PREFER_STYLUS_OVER_LASER = false;
|
||||||
const bool DEFAULT_PREFER_AVATAR_FINGER_OVER_STYLUS = false;
|
const bool DEFAULT_PREFER_AVATAR_FINGER_OVER_STYLUS = false;
|
||||||
const QString DEFAULT_CURSOR_NAME = "DEFAULT";
|
const QString DEFAULT_CURSOR_NAME = "DEFAULT";
|
||||||
|
const bool DEFAULT_MINI_TABLET_ENABLED = true;
|
||||||
|
|
||||||
Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bool runningMarkerExisted) :
|
Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bool runningMarkerExisted) :
|
||||||
QApplication(argc, argv),
|
QApplication(argc, argv),
|
||||||
|
@ -1012,6 +1013,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
||||||
_preferAvatarFingerOverStylusSetting("preferAvatarFingerOverStylus", DEFAULT_PREFER_AVATAR_FINGER_OVER_STYLUS),
|
_preferAvatarFingerOverStylusSetting("preferAvatarFingerOverStylus", DEFAULT_PREFER_AVATAR_FINGER_OVER_STYLUS),
|
||||||
_constrainToolbarPosition("toolbar/constrainToolbarToCenterX", true),
|
_constrainToolbarPosition("toolbar/constrainToolbarToCenterX", true),
|
||||||
_preferredCursor("preferredCursor", DEFAULT_CURSOR_NAME),
|
_preferredCursor("preferredCursor", DEFAULT_CURSOR_NAME),
|
||||||
|
_miniTabletEnabledSetting("miniTabletEnabled", DEFAULT_MINI_TABLET_ENABLED),
|
||||||
_scaleMirror(1.0f),
|
_scaleMirror(1.0f),
|
||||||
_mirrorYawOffset(0.0f),
|
_mirrorYawOffset(0.0f),
|
||||||
_raiseMirror(0.0f),
|
_raiseMirror(0.0f),
|
||||||
|
@ -3393,6 +3395,11 @@ void Application::setSettingConstrainToolbarPosition(bool setting) {
|
||||||
DependencyManager::get<OffscreenUi>()->setConstrainToolbarToCenterX(setting);
|
DependencyManager::get<OffscreenUi>()->setConstrainToolbarToCenterX(setting);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Application::setMiniTabletEnabled(bool enabled) {
|
||||||
|
_miniTabletEnabledSetting.set(enabled);
|
||||||
|
emit miniTabletEnabledChanged(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
void Application::showHelp() {
|
void Application::showHelp() {
|
||||||
static const QString HAND_CONTROLLER_NAME_VIVE = "vive";
|
static const QString HAND_CONTROLLER_NAME_VIVE = "vive";
|
||||||
static const QString HAND_CONTROLLER_NAME_OCULUS_TOUCH = "oculus";
|
static const QString HAND_CONTROLLER_NAME_OCULUS_TOUCH = "oculus";
|
||||||
|
|
|
@ -228,6 +228,9 @@ public:
|
||||||
bool getPreferAvatarFingerOverStylus() { return false; }
|
bool getPreferAvatarFingerOverStylus() { return false; }
|
||||||
void setPreferAvatarFingerOverStylus(bool value);
|
void setPreferAvatarFingerOverStylus(bool value);
|
||||||
|
|
||||||
|
bool getMiniTabletEnabled() { return _miniTabletEnabledSetting.get(); }
|
||||||
|
void setMiniTabletEnabled(bool enabled);
|
||||||
|
|
||||||
float getSettingConstrainToolbarPosition() { return _constrainToolbarPosition.get(); }
|
float getSettingConstrainToolbarPosition() { return _constrainToolbarPosition.get(); }
|
||||||
void setSettingConstrainToolbarPosition(bool setting);
|
void setSettingConstrainToolbarPosition(bool setting);
|
||||||
|
|
||||||
|
@ -338,6 +341,8 @@ signals:
|
||||||
|
|
||||||
void loginDialogPoppedUp();
|
void loginDialogPoppedUp();
|
||||||
|
|
||||||
|
void miniTabletEnabledChanged(bool enabled);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
QVector<EntityItemID> pasteEntities(float x, float y, float z);
|
QVector<EntityItemID> pasteEntities(float x, float y, float z);
|
||||||
bool exportEntities(const QString& filename, const QVector<EntityItemID>& entityIDs, const glm::vec3* givenOffset = nullptr);
|
bool exportEntities(const QString& filename, const QVector<EntityItemID>& entityIDs, const glm::vec3* givenOffset = nullptr);
|
||||||
|
@ -631,6 +636,7 @@ private:
|
||||||
Setting::Handle<bool> _preferAvatarFingerOverStylusSetting;
|
Setting::Handle<bool> _preferAvatarFingerOverStylusSetting;
|
||||||
Setting::Handle<bool> _constrainToolbarPosition;
|
Setting::Handle<bool> _constrainToolbarPosition;
|
||||||
Setting::Handle<QString> _preferredCursor;
|
Setting::Handle<QString> _preferredCursor;
|
||||||
|
Setting::Handle<bool> _miniTabletEnabledSetting;
|
||||||
|
|
||||||
float _scaleMirror;
|
float _scaleMirror;
|
||||||
float _mirrorYawOffset;
|
float _mirrorYawOffset;
|
||||||
|
|
|
@ -27,6 +27,9 @@ HMDScriptingInterface::HMDScriptingInterface() {
|
||||||
connect(qApp, &Application::activeDisplayPluginChanged, [this]{
|
connect(qApp, &Application::activeDisplayPluginChanged, [this]{
|
||||||
emit displayModeChanged(isHMDMode());
|
emit displayModeChanged(isHMDMode());
|
||||||
});
|
});
|
||||||
|
connect(qApp, &Application::miniTabletEnabledChanged, [this](bool enabled) {
|
||||||
|
emit miniTabletEnabledChanged(enabled);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 HMDScriptingInterface::calculateRayUICollisionPoint(const glm::vec3& position, const glm::vec3& direction) const {
|
glm::vec3 HMDScriptingInterface::calculateRayUICollisionPoint(const glm::vec3& position, const glm::vec3& direction) const {
|
||||||
|
@ -126,6 +129,15 @@ void HMDScriptingInterface::setShouldShowTablet(bool value) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HMDScriptingInterface::setMiniTabletEnabled(bool enabled) {
|
||||||
|
qApp->setMiniTabletEnabled(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool HMDScriptingInterface::getMiniTabletEnabled() {
|
||||||
|
return qApp->getMiniTabletEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QScriptValue HMDScriptingInterface::getHUDLookAtPosition2D(QScriptContext* context, QScriptEngine* engine) {
|
QScriptValue HMDScriptingInterface::getHUDLookAtPosition2D(QScriptContext* context, QScriptEngine* engine) {
|
||||||
glm::vec3 hudIntersection;
|
glm::vec3 hudIntersection;
|
||||||
auto instance = DependencyManager::get<HMDScriptingInterface>();
|
auto instance = DependencyManager::get<HMDScriptingInterface>();
|
||||||
|
|
|
@ -61,6 +61,8 @@ class QScriptEngine;
|
||||||
* @property {Uuid} miniTabletScreenID - The UUID of the mini tablet's screen overlay. <code>null</code> if not in HMD mode.
|
* @property {Uuid} miniTabletScreenID - The UUID of the mini tablet's screen overlay. <code>null</code> if not in HMD mode.
|
||||||
* @property {number} miniTabletHand - The hand that the mini tablet is displayed on: <code>0</code> for left hand,
|
* @property {number} miniTabletHand - The hand that the mini tablet is displayed on: <code>0</code> for left hand,
|
||||||
* <code>1</code> for right hand, <code>-1</code> if not in HMD mode.
|
* <code>1</code> for right hand, <code>-1</code> if not in HMD mode.
|
||||||
|
* @property {bool} miniTabletEnabled=true - <code>true</code> if the mini tablet is enabled to be displayed, otherwise
|
||||||
|
* <code>false</code>.
|
||||||
* @property {Rect} playArea=0,0,0,0 - The size and position of the HMD play area in sensor coordinates. <em>Read-only.</em>
|
* @property {Rect} playArea=0,0,0,0 - The size and position of the HMD play area in sensor coordinates. <em>Read-only.</em>
|
||||||
* @property {Vec3[]} sensorPositions=[]] - The positions of the VR system sensors in sensor coordinates. <em>Read-only.</em>
|
* @property {Vec3[]} sensorPositions=[]] - The positions of the VR system sensors in sensor coordinates. <em>Read-only.</em>
|
||||||
*/
|
*/
|
||||||
|
@ -77,6 +79,7 @@ class HMDScriptingInterface : public AbstractHMDScriptingInterface, public Depen
|
||||||
Q_PROPERTY(QUuid miniTabletID READ getCurrentMiniTabletID WRITE setCurrentMiniTabletID)
|
Q_PROPERTY(QUuid miniTabletID READ getCurrentMiniTabletID WRITE setCurrentMiniTabletID)
|
||||||
Q_PROPERTY(QUuid miniTabletScreenID READ getCurrentMiniTabletScreenID WRITE setCurrentMiniTabletScreenID)
|
Q_PROPERTY(QUuid miniTabletScreenID READ getCurrentMiniTabletScreenID WRITE setCurrentMiniTabletScreenID)
|
||||||
Q_PROPERTY(int miniTabletHand READ getCurrentMiniTabletHand WRITE setCurrentMiniTabletHand)
|
Q_PROPERTY(int miniTabletHand READ getCurrentMiniTabletHand WRITE setCurrentMiniTabletHand)
|
||||||
|
Q_PROPERTY(bool miniTabletEnabled READ getMiniTabletEnabled WRITE setMiniTabletEnabled)
|
||||||
Q_PROPERTY(QVariant playArea READ getPlayAreaRect);
|
Q_PROPERTY(QVariant playArea READ getPlayAreaRect);
|
||||||
Q_PROPERTY(QVector<glm::vec3> sensorPositions READ getSensorPositions);
|
Q_PROPERTY(QVector<glm::vec3> sensorPositions READ getSensorPositions);
|
||||||
|
|
||||||
|
@ -355,8 +358,22 @@ signals:
|
||||||
*/
|
*/
|
||||||
bool shouldShowHandControllersChanged();
|
bool shouldShowHandControllersChanged();
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Triggered when the tablet is shown or hidden.
|
||||||
|
* @function HMD.showTabletChanged
|
||||||
|
* @param {boolean} showTablet - <code>true</code> if the tablet is showing, otherwise <code>false</code>.
|
||||||
|
* @returns {Signal}
|
||||||
|
*/
|
||||||
void showTabletChanged(bool showTablet);
|
void showTabletChanged(bool showTablet);
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Triggered when the ability to display the mini tablet has changed.
|
||||||
|
* @function HMD.miniTabletEnabledChanged
|
||||||
|
* @param {boolean} enabled - <code>true</code> if the mini tablet is enabled to be displayed, otherwise <code>false</code>.
|
||||||
|
* @returns {Signal}
|
||||||
|
*/
|
||||||
|
bool miniTabletEnabledChanged(bool enabled);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
HMDScriptingInterface();
|
HMDScriptingInterface();
|
||||||
static QScriptValue getHUDLookAtPosition2D(QScriptContext* context, QScriptEngine* engine);
|
static QScriptValue getHUDLookAtPosition2D(QScriptContext* context, QScriptEngine* engine);
|
||||||
|
@ -390,6 +407,9 @@ public:
|
||||||
void setCurrentMiniTabletHand(int miniTabletHand) { _miniTabletHand = miniTabletHand; }
|
void setCurrentMiniTabletHand(int miniTabletHand) { _miniTabletHand = miniTabletHand; }
|
||||||
int getCurrentMiniTabletHand() const { return _miniTabletHand; }
|
int getCurrentMiniTabletHand() const { return _miniTabletHand; }
|
||||||
|
|
||||||
|
void setMiniTabletEnabled(bool enabled);
|
||||||
|
bool getMiniTabletEnabled();
|
||||||
|
|
||||||
QVariant getPlayAreaRect();
|
QVariant getPlayAreaRect();
|
||||||
QVector<glm::vec3> getSensorPositions();
|
QVector<glm::vec3> getSensorPositions();
|
||||||
|
|
||||||
|
@ -404,6 +424,7 @@ private:
|
||||||
QUuid _miniTabletID;
|
QUuid _miniTabletID;
|
||||||
QUuid _miniTabletScreenID;
|
QUuid _miniTabletScreenID;
|
||||||
int _miniTabletHand { -1 };
|
int _miniTabletHand { -1 };
|
||||||
|
bool _miniTabletEnabled { true };
|
||||||
|
|
||||||
// Get the position of the HMD
|
// Get the position of the HMD
|
||||||
glm::vec3 getPosition() const;
|
glm::vec3 getPosition() const;
|
||||||
|
|
|
@ -119,6 +119,12 @@ void setupPreferences() {
|
||||||
preferences->addPreference(new CheckPreference(UI_CATEGORY, "Use reticle cursor instead of arrow", getter, setter));
|
preferences->addPreference(new CheckPreference(UI_CATEGORY, "Use reticle cursor instead of arrow", getter, setter));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto getter = []()->bool { return qApp->getMiniTabletEnabled(); };
|
||||||
|
auto setter = [](bool value) { qApp->setMiniTabletEnabled(value); };
|
||||||
|
preferences->addPreference(new CheckPreference(UI_CATEGORY, "Use mini tablet", getter, setter));
|
||||||
|
}
|
||||||
|
|
||||||
static const QString VIEW_CATEGORY{ "View" };
|
static const QString VIEW_CATEGORY{ "View" };
|
||||||
{
|
{
|
||||||
auto getter = [myAvatar]()->float { return myAvatar->getRealWorldFieldOfView(); };
|
auto getter = [myAvatar]()->float { return myAvatar->getRealWorldFieldOfView(); };
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
ui = null,
|
ui = null,
|
||||||
State,
|
State,
|
||||||
miniState = null,
|
miniState = null,
|
||||||
|
miniTabletEnabled = true,
|
||||||
|
|
||||||
// Hands.
|
// Hands.
|
||||||
NO_HAND = -1,
|
NO_HAND = -1,
|
||||||
|
@ -1012,17 +1013,21 @@
|
||||||
|
|
||||||
if (message.action === "grab" && message.grabbedEntity === HMD.tabletID && HMD.active) {
|
if (message.action === "grab" && message.grabbedEntity === HMD.tabletID && HMD.active) {
|
||||||
// Tablet may have been grabbed after it replaced expanded mini tablet.
|
// Tablet may have been grabbed after it replaced expanded mini tablet.
|
||||||
miniState.setState(miniState.MINI_HIDDEN);
|
if (miniTabletEnabled) {
|
||||||
|
miniState.setState(miniState.MINI_HIDDEN);
|
||||||
|
}
|
||||||
} else if (message.action === "grab" && miniState.getState() === miniState.MINI_VISIBLE) {
|
} else if (message.action === "grab" && miniState.getState() === miniState.MINI_VISIBLE) {
|
||||||
miniHand = miniState.getHand();
|
if (miniTabletEnabled) {
|
||||||
hand = message.joint === HAND_NAMES[miniHand] ? miniHand : otherHand(miniHand);
|
miniHand = miniState.getHand();
|
||||||
miniState.setState(miniState.MINI_EXPANDING, { hand: hand, goto: false });
|
hand = message.joint === HAND_NAMES[miniHand] ? miniHand : otherHand(miniHand);
|
||||||
|
miniState.setState(miniState.MINI_EXPANDING, { hand: hand, goto: false });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onWentAway() {
|
function onWentAway() {
|
||||||
// Mini tablet only available when user is not away.
|
// Mini tablet only available when user is not away.
|
||||||
if (HMD.active) {
|
if (HMD.active && miniTabletEnabled) {
|
||||||
miniState.setState(miniState.MINI_HIDDEN);
|
miniState.setState(miniState.MINI_HIDDEN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1030,8 +1035,21 @@
|
||||||
function onDisplayModeChanged() {
|
function onDisplayModeChanged() {
|
||||||
// Mini tablet only available when HMD is active.
|
// Mini tablet only available when HMD is active.
|
||||||
if (HMD.active) {
|
if (HMD.active) {
|
||||||
miniState.setState(miniState.MINI_HIDDEN);
|
if (miniTabletEnabled && miniState.getState() !== miniState.MINI_HIDDEN) {
|
||||||
} else {
|
miniState.setState(miniState.MINI_HIDDEN);
|
||||||
|
}
|
||||||
|
} else if (miniState.getState() !== miniState.MINI_DISABLED) {
|
||||||
|
miniState.setState(miniState.MINI_DISABLED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onMiniTabletEnabledChanged(enabled) {
|
||||||
|
miniTabletEnabled = enabled;
|
||||||
|
if (miniTabletEnabled) {
|
||||||
|
if (HMD.active && miniState.getState() !== miniState.MINI_HIDDEN) {
|
||||||
|
miniState.setState(miniState.MINI_HIDDEN);
|
||||||
|
}
|
||||||
|
} else if (miniState.getState() !== miniState.MINI_DISABLED) {
|
||||||
miniState.setState(miniState.MINI_DISABLED);
|
miniState.setState(miniState.MINI_DISABLED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1040,12 +1058,16 @@
|
||||||
function setUp() {
|
function setUp() {
|
||||||
miniState = new State();
|
miniState = new State();
|
||||||
|
|
||||||
|
HMD.miniTabletEnabledChanged.connect(onMiniTabletEnabledChanged);
|
||||||
|
miniTabletEnabled = HMD.miniTabletEnabled;
|
||||||
|
|
||||||
Messages.subscribe(HIFI_OBJECT_MANIPULATION_CHANNEL);
|
Messages.subscribe(HIFI_OBJECT_MANIPULATION_CHANNEL);
|
||||||
Messages.messageReceived.connect(onMessageReceived);
|
Messages.messageReceived.connect(onMessageReceived);
|
||||||
|
|
||||||
MyAvatar.wentAway.connect(onWentAway);
|
MyAvatar.wentAway.connect(onWentAway);
|
||||||
HMD.displayModeChanged.connect(onDisplayModeChanged);
|
HMD.displayModeChanged.connect(onDisplayModeChanged);
|
||||||
if (HMD.active) {
|
|
||||||
|
if (HMD.active && miniTabletEnabled) {
|
||||||
miniState.setState(miniState.MINI_HIDDEN);
|
miniState.setState(miniState.MINI_HIDDEN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1059,6 +1081,8 @@
|
||||||
Messages.messageReceived.disconnect(onMessageReceived);
|
Messages.messageReceived.disconnect(onMessageReceived);
|
||||||
Messages.unsubscribe(HIFI_OBJECT_MANIPULATION_CHANNEL);
|
Messages.unsubscribe(HIFI_OBJECT_MANIPULATION_CHANNEL);
|
||||||
|
|
||||||
|
HMD.miniTabletEnabledChanged.disconnect(onMiniTabletEnabledChanged);
|
||||||
|
|
||||||
miniState.destroy();
|
miniState.destroy();
|
||||||
miniState = null;
|
miniState = null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue