mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-04-08 06:32:35 +02:00
Add setting to enable/disable the mini tablet
This commit is contained in:
parent
5e01314d85
commit
28097933ed
6 changed files with 74 additions and 7 deletions
|
@ -987,6 +987,7 @@ const bool DEFAULT_HMD_TABLET_BECOMES_TOOLBAR = false;
|
|||
const bool DEFAULT_PREFER_STYLUS_OVER_LASER = false;
|
||||
const bool DEFAULT_PREFER_AVATAR_FINGER_OVER_STYLUS = false;
|
||||
const QString DEFAULT_CURSOR_NAME = "DEFAULT";
|
||||
const bool DEFAULT_MINI_TABLET_ENABLED = true;
|
||||
|
||||
Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bool runningMarkerExisted) :
|
||||
QApplication(argc, argv),
|
||||
|
@ -1006,6 +1007,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
|||
_preferAvatarFingerOverStylusSetting("preferAvatarFingerOverStylus", DEFAULT_PREFER_AVATAR_FINGER_OVER_STYLUS),
|
||||
_constrainToolbarPosition("toolbar/constrainToolbarToCenterX", true),
|
||||
_preferredCursor("preferredCursor", DEFAULT_CURSOR_NAME),
|
||||
_miniTabletEnabledSetting("miniTabletEnabled", DEFAULT_MINI_TABLET_ENABLED),
|
||||
_scaleMirror(1.0f),
|
||||
_mirrorYawOffset(0.0f),
|
||||
_raiseMirror(0.0f),
|
||||
|
@ -3359,6 +3361,11 @@ void Application::setSettingConstrainToolbarPosition(bool setting) {
|
|||
DependencyManager::get<OffscreenUi>()->setConstrainToolbarToCenterX(setting);
|
||||
}
|
||||
|
||||
void Application::setMiniTabletEnabled(bool enabled) {
|
||||
_miniTabletEnabledSetting.set(enabled);
|
||||
emit miniTabletEnabledChanged(enabled);
|
||||
}
|
||||
|
||||
void Application::showHelp() {
|
||||
static const QString HAND_CONTROLLER_NAME_VIVE = "vive";
|
||||
static const QString HAND_CONTROLLER_NAME_OCULUS_TOUCH = "oculus";
|
||||
|
|
|
@ -228,6 +228,9 @@ public:
|
|||
bool getPreferAvatarFingerOverStylus() { return false; }
|
||||
void setPreferAvatarFingerOverStylus(bool value);
|
||||
|
||||
bool getMiniTabletEnabled() { return _miniTabletEnabledSetting.get(); }
|
||||
void setMiniTabletEnabled(bool enabled);
|
||||
|
||||
float getSettingConstrainToolbarPosition() { return _constrainToolbarPosition.get(); }
|
||||
void setSettingConstrainToolbarPosition(bool setting);
|
||||
|
||||
|
@ -338,6 +341,8 @@ signals:
|
|||
|
||||
void loginDialogPoppedUp();
|
||||
|
||||
void miniTabletEnabledChanged(bool enabled);
|
||||
|
||||
public slots:
|
||||
QVector<EntityItemID> pasteEntities(float x, float y, float z);
|
||||
bool exportEntities(const QString& filename, const QVector<EntityItemID>& entityIDs, const glm::vec3* givenOffset = nullptr);
|
||||
|
@ -629,6 +634,7 @@ private:
|
|||
Setting::Handle<bool> _preferAvatarFingerOverStylusSetting;
|
||||
Setting::Handle<bool> _constrainToolbarPosition;
|
||||
Setting::Handle<QString> _preferredCursor;
|
||||
Setting::Handle<bool> _miniTabletEnabledSetting;
|
||||
|
||||
float _scaleMirror;
|
||||
float _mirrorYawOffset;
|
||||
|
|
|
@ -27,6 +27,9 @@ HMDScriptingInterface::HMDScriptingInterface() {
|
|||
connect(qApp, &Application::activeDisplayPluginChanged, [this]{
|
||||
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 {
|
||||
|
@ -123,6 +126,15 @@ void HMDScriptingInterface::setShouldShowTablet(bool value) {
|
|||
_tabletContextualMode = false;
|
||||
}
|
||||
|
||||
void HMDScriptingInterface::setMiniTabletEnabled(bool enabled) {
|
||||
qApp->setMiniTabletEnabled(enabled);
|
||||
}
|
||||
|
||||
bool HMDScriptingInterface::getMiniTabletEnabled() {
|
||||
return qApp->getMiniTabletEnabled();
|
||||
}
|
||||
|
||||
|
||||
QScriptValue HMDScriptingInterface::getHUDLookAtPosition2D(QScriptContext* context, QScriptEngine* engine) {
|
||||
glm::vec3 hudIntersection;
|
||||
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 {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.
|
||||
* @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 {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 miniTabletScreenID READ getCurrentMiniTabletScreenID WRITE setCurrentMiniTabletScreenID)
|
||||
Q_PROPERTY(int miniTabletHand READ getCurrentMiniTabletHand WRITE setCurrentMiniTabletHand)
|
||||
Q_PROPERTY(bool miniTabletEnabled READ getMiniTabletEnabled WRITE setMiniTabletEnabled)
|
||||
Q_PROPERTY(QVariant playArea READ getPlayAreaRect);
|
||||
Q_PROPERTY(QVector<glm::vec3> sensorPositions READ getSensorPositions);
|
||||
|
||||
|
@ -355,6 +358,14 @@ signals:
|
|||
*/
|
||||
bool shouldShowHandControllersChanged();
|
||||
|
||||
/**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:
|
||||
HMDScriptingInterface();
|
||||
static QScriptValue getHUDLookAtPosition2D(QScriptContext* context, QScriptEngine* engine);
|
||||
|
@ -388,6 +399,9 @@ public:
|
|||
void setCurrentMiniTabletHand(int miniTabletHand) { _miniTabletHand = miniTabletHand; }
|
||||
int getCurrentMiniTabletHand() const { return _miniTabletHand; }
|
||||
|
||||
void setMiniTabletEnabled(bool enabled);
|
||||
bool getMiniTabletEnabled();
|
||||
|
||||
QVariant getPlayAreaRect();
|
||||
QVector<glm::vec3> getSensorPositions();
|
||||
|
||||
|
@ -402,6 +416,7 @@ private:
|
|||
QUuid _miniTabletID;
|
||||
QUuid _miniTabletScreenID;
|
||||
int _miniTabletHand { -1 };
|
||||
bool _miniTabletEnabled { true };
|
||||
|
||||
// Get the position of the HMD
|
||||
glm::vec3 getPosition() const;
|
||||
|
|
|
@ -119,6 +119,12 @@ void setupPreferences() {
|
|||
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" };
|
||||
{
|
||||
auto getter = [myAvatar]()->float { return myAvatar->getRealWorldFieldOfView(); };
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
ui = null,
|
||||
State,
|
||||
miniState = null,
|
||||
miniTabletEnabled = true,
|
||||
|
||||
// Hands.
|
||||
NO_HAND = -1,
|
||||
|
@ -1012,17 +1013,21 @@
|
|||
|
||||
if (message.action === "grab" && message.grabbedEntity === HMD.tabletID && HMD.active) {
|
||||
// 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) {
|
||||
miniHand = miniState.getHand();
|
||||
hand = message.joint === HAND_NAMES[miniHand] ? miniHand : otherHand(miniHand);
|
||||
miniState.setState(miniState.MINI_EXPANDING, { hand: hand, goto: false });
|
||||
if (miniTabletEnabled) {
|
||||
miniHand = miniState.getHand();
|
||||
hand = message.joint === HAND_NAMES[miniHand] ? miniHand : otherHand(miniHand);
|
||||
miniState.setState(miniState.MINI_EXPANDING, { hand: hand, goto: false });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onWentAway() {
|
||||
// Mini tablet only available when user is not away.
|
||||
if (HMD.active) {
|
||||
if (HMD.active && miniTabletEnabled) {
|
||||
miniState.setState(miniState.MINI_HIDDEN);
|
||||
}
|
||||
}
|
||||
|
@ -1030,8 +1035,21 @@
|
|||
function onDisplayModeChanged() {
|
||||
// Mini tablet only available when HMD is active.
|
||||
if (HMD.active) {
|
||||
miniState.setState(miniState.MINI_HIDDEN);
|
||||
} else {
|
||||
if (miniTabletEnabled && miniState.getState() !== miniState.MINI_HIDDEN) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -1039,12 +1057,14 @@
|
|||
|
||||
function setUp() {
|
||||
miniState = new State();
|
||||
miniTabletEnabled = HMD.miniTabletEnabled;
|
||||
|
||||
Messages.subscribe(HIFI_OBJECT_MANIPULATION_CHANNEL);
|
||||
Messages.messageReceived.connect(onMessageReceived);
|
||||
|
||||
MyAvatar.wentAway.connect(onWentAway);
|
||||
HMD.displayModeChanged.connect(onDisplayModeChanged);
|
||||
HMD.miniTabletEnabledChanged.connect(onMiniTabletEnabledChanged);
|
||||
if (HMD.active) {
|
||||
miniState.setState(miniState.MINI_HIDDEN);
|
||||
}
|
||||
|
@ -1053,6 +1073,7 @@
|
|||
function tearDown() {
|
||||
miniState.setState(miniState.MINI_DISABLED);
|
||||
|
||||
HMD.miniTabletEnabledChanged.disconnect(onMiniTabletEnabledChanged);
|
||||
HMD.displayModeChanged.disconnect(onDisplayModeChanged);
|
||||
MyAvatar.wentAway.disconnect(onWentAway);
|
||||
|
||||
|
|
Loading…
Reference in a new issue