mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 20:44:14 +02:00
Add menu item that enables / disables simulated eye tracking
This commit is contained in:
parent
72a590e34c
commit
f0ed8d8cef
5 changed files with 23 additions and 21 deletions
|
@ -595,12 +595,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
|||
loadScripts();
|
||||
}
|
||||
|
||||
#ifdef HAVE_IVIEWHMD
|
||||
// Do this before loading settings
|
||||
auto eyeTracker = DependencyManager::get<EyeTracker>();
|
||||
eyeTracker->init();
|
||||
#endif
|
||||
|
||||
loadSettings();
|
||||
int SAVE_SETTINGS_INTERVAL = 10 * MSECS_PER_SECOND; // Let's save every seconds for now
|
||||
connect(&_settingsTimer, &QTimer::timeout, this, &Application::saveSettings);
|
||||
|
@ -642,6 +636,12 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
|||
connect(ddeTracker.data(), &FaceTracker::muteToggled, this, &Application::faceTrackerMuteToggled);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_IVIEWHMD
|
||||
auto eyeTracker = DependencyManager::get<EyeTracker>();
|
||||
eyeTracker->init();
|
||||
setActiveEyeTracker();
|
||||
#endif
|
||||
|
||||
auto applicationUpdater = DependencyManager::get<AutoUpdater>();
|
||||
connect(applicationUpdater.data(), &AutoUpdater::newVersionIsAvailable, dialogsManager.data(), &DialogsManager::showUpdateDialog);
|
||||
applicationUpdater->checkForUpdate();
|
||||
|
@ -2020,7 +2020,8 @@ void Application::setActiveFaceTracker() {
|
|||
void Application::setActiveEyeTracker() {
|
||||
#ifdef HAVE_IVIEWHMD
|
||||
auto eyeTracker = DependencyManager::get<EyeTracker>();
|
||||
eyeTracker->setEnabled(Menu::getInstance()->isOptionChecked(MenuOption::SMIEyeTracking));
|
||||
eyeTracker->setEnabled(Menu::getInstance()->isOptionChecked(MenuOption::SMIEyeTracking),
|
||||
Menu::getInstance()->isOptionChecked(MenuOption::SimulateEyeTracking));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -439,9 +439,10 @@ Menu::Menu() {
|
|||
|
||||
#ifdef HAVE_IVIEWHMD
|
||||
MenuWrapper* eyeTrackingMenu = avatarDebugMenu->addMenu("Eye Tracking");
|
||||
QAction* smiEyeTracking = addCheckableActionToQMenuAndActionHash(eyeTrackingMenu, MenuOption::SMIEyeTracking, 0, false,
|
||||
addCheckableActionToQMenuAndActionHash(eyeTrackingMenu, MenuOption::SMIEyeTracking, 0, false,
|
||||
qApp, SLOT(setActiveEyeTracker()));
|
||||
addCheckableActionToQMenuAndActionHash(eyeTrackingMenu, MenuOption::SimulateEyeTracking, 0, false,
|
||||
qApp, SLOT(setActiveEyeTracker()));
|
||||
smiEyeTracking->setVisible(true);
|
||||
#endif
|
||||
|
||||
auto avatarManager = DependencyManager::get<AvatarManager>();
|
||||
|
|
|
@ -273,6 +273,7 @@ namespace MenuOption {
|
|||
const QString SixenseEnabled = "Enable Hydra Support";
|
||||
const QString SixenseMouseInput = "Enable Sixense Mouse Input";
|
||||
const QString ShiftHipsForIdleAnimations = "Shift hips for idle animations";
|
||||
const QString SimulateEyeTracking = "Simulate";
|
||||
const QString SMIEyeTracking = "SMI Eye Tracking";
|
||||
const QString Stars = "Stars";
|
||||
const QString Stats = "Stats";
|
||||
|
|
|
@ -59,26 +59,25 @@ void EyeTracker::init() {
|
|||
#endif
|
||||
}
|
||||
|
||||
void EyeTracker::setEnabled(bool enabled) {
|
||||
void EyeTracker::setEnabled(bool enabled, bool simulate) {
|
||||
if (!_isInitialized) {
|
||||
qCWarning(interfaceapp) << "Eye Tracker: Not initialized before setting enabled";
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef HAVE_IVIEWHMD
|
||||
qCDebug(interfaceapp) << "Eye Tracker: Set enabled =" << enabled;
|
||||
|
||||
if (enabled && !_isStreaming) {
|
||||
// There is no smi_stopStreaming() method so start streaming a maximum of once per program run.
|
||||
int result = smi_startStreaming(true);
|
||||
qCDebug(interfaceapp) << "Eye Tracker: Set enabled =" << enabled << ", simulate =" << simulate;
|
||||
bool success = true;
|
||||
int result = 0;
|
||||
if (enabled) {
|
||||
// There is no smi_stopStreaming() method so keep streaming once started in case tracking is re-enabled after stopping.
|
||||
result = smi_startStreaming(simulate);
|
||||
if (result != SMI_RET_SUCCESS) {
|
||||
qCWarning(interfaceapp) << "Eye Tracker: Error starting streaming:" << result;
|
||||
} else {
|
||||
_isStreaming = true;
|
||||
qCWarning(interfaceapp) << "Eye Tracker: Error starting streaming:" << smiReturnValueToString(result);
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
|
||||
_isEnabled = enabled && _isStreaming;
|
||||
_isEnabled = enabled && success;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ public:
|
|||
|
||||
public slots:
|
||||
void init();
|
||||
void setEnabled(bool enabled);
|
||||
void setEnabled(bool enabled, bool simulate);
|
||||
void reset();
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in a new issue