mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 07:58:59 +02:00
Comments + connectedDevice
This commit is contained in:
parent
1a2fd4483b
commit
7c797449ab
5 changed files with 21 additions and 6 deletions
|
@ -398,15 +398,19 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
||||||
}
|
}
|
||||||
|
|
||||||
Application::~Application() {
|
Application::~Application() {
|
||||||
int DELAI_TIME = 1000;
|
// In order to get the end of the session, we nned to give the account manager enough time to send the packet.
|
||||||
QEventLoop loop;
|
QEventLoop loop;
|
||||||
QTimer timer;
|
// Here we connect the callbacks to stop the event loop
|
||||||
connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit);
|
|
||||||
JSONCallbackParameters params;
|
JSONCallbackParameters params;
|
||||||
params.jsonCallbackReceiver = &loop;
|
params.jsonCallbackReceiver = &loop;
|
||||||
params.errorCallbackReceiver = &loop;
|
params.errorCallbackReceiver = &loop;
|
||||||
params.jsonCallbackMethod = "quit";
|
params.jsonCallbackMethod = "quit";
|
||||||
params.errorCallbackMethod = "quit";
|
params.errorCallbackMethod = "quit";
|
||||||
|
// In case something goes wrong, we also setup a timer so that the delai is not greater than DELAI_TIME
|
||||||
|
int DELAI_TIME = 1000;
|
||||||
|
QTimer timer;
|
||||||
|
connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit);
|
||||||
|
// Now we can log it
|
||||||
UserActivityLogger::getInstance().close(params);
|
UserActivityLogger::getInstance().close(params);
|
||||||
timer.start(DELAI_TIME);
|
timer.start(DELAI_TIME);
|
||||||
loop.exec();
|
loop.exec();
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include <QOpenGLFramebufferObject>
|
#include <QOpenGLFramebufferObject>
|
||||||
|
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
|
#include <UserActivityLogger.h>
|
||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
#include "OculusManager.h"
|
#include "OculusManager.h"
|
||||||
|
@ -45,6 +46,9 @@ void OculusManager::connect() {
|
||||||
_hmdDevice = *_deviceManager->EnumerateDevices<HMDDevice>().CreateDevice();
|
_hmdDevice = *_deviceManager->EnumerateDevices<HMDDevice>().CreateDevice();
|
||||||
|
|
||||||
if (_hmdDevice) {
|
if (_hmdDevice) {
|
||||||
|
if (!_isConnected) {
|
||||||
|
UserActivityLogger::getInstance().connectedDevice("hmd", "oculus");
|
||||||
|
}
|
||||||
_isConnected = true;
|
_isConnected = true;
|
||||||
|
|
||||||
_sensorDevice = *_hmdDevice->GetSensor();
|
_sensorDevice = *_hmdDevice->GetSensor();
|
||||||
|
|
|
@ -40,6 +40,7 @@ SixenseManager::SixenseManager() {
|
||||||
|
|
||||||
sixenseInit();
|
sixenseInit();
|
||||||
#endif
|
#endif
|
||||||
|
_hydrasConnected = false;
|
||||||
_triggerPressed[0] = false;
|
_triggerPressed[0] = false;
|
||||||
_bumperPressed[0] = false;
|
_bumperPressed[0] = false;
|
||||||
_oldX[0] = -1;
|
_oldX[0] = -1;
|
||||||
|
@ -71,7 +72,11 @@ void SixenseManager::setFilter(bool filter) {
|
||||||
void SixenseManager::update(float deltaTime) {
|
void SixenseManager::update(float deltaTime) {
|
||||||
#ifdef HAVE_SIXENSE
|
#ifdef HAVE_SIXENSE
|
||||||
if (sixenseGetNumActiveControllers() == 0) {
|
if (sixenseGetNumActiveControllers() == 0) {
|
||||||
|
_hydrasConnected = false;
|
||||||
return;
|
return;
|
||||||
|
} else if (!_hydrasConnected) {
|
||||||
|
_hydrasConnected = true;
|
||||||
|
UserActivityLogger::getInstance().connectedDevice("spatial_controller", "hydra");
|
||||||
}
|
}
|
||||||
MyAvatar* avatar = Application::getInstance()->getAvatar();
|
MyAvatar* avatar = Application::getInstance()->getAvatar();
|
||||||
Hand* hand = avatar->getHand();
|
Hand* hand = avatar->getHand();
|
||||||
|
|
|
@ -71,6 +71,7 @@ private:
|
||||||
float _lastDistance;
|
float _lastDistance;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
bool _hydrasConnected;
|
||||||
quint64 _lastMovement;
|
quint64 _lastMovement;
|
||||||
glm::vec3 _amountMoved;
|
glm::vec3 _amountMoved;
|
||||||
|
|
||||||
|
|
|
@ -28,12 +28,13 @@ void UserActivityLogger::logAction(QString action, QJsonObject details, JSONCall
|
||||||
AccountManager& accountManager = AccountManager::getInstance();
|
AccountManager& accountManager = AccountManager::getInstance();
|
||||||
QHttpMultiPart* multipart = new QHttpMultiPart(QHttpMultiPart::FormDataType);
|
QHttpMultiPart* multipart = new QHttpMultiPart(QHttpMultiPart::FormDataType);
|
||||||
|
|
||||||
|
// Adding the action name
|
||||||
QHttpPart actionPart;
|
QHttpPart actionPart;
|
||||||
actionPart.setHeader(QNetworkRequest::ContentDispositionHeader, "form-data; name=\"action_name\"");
|
actionPart.setHeader(QNetworkRequest::ContentDispositionHeader, "form-data; name=\"action_name\"");
|
||||||
actionPart.setBody(QByteArray().append(action));
|
actionPart.setBody(QByteArray().append(action));
|
||||||
multipart->append(actionPart);
|
multipart->append(actionPart);
|
||||||
|
|
||||||
|
// If there are action details, add them to the multipart
|
||||||
if (!details.isEmpty()) {
|
if (!details.isEmpty()) {
|
||||||
QHttpPart detailsPart;
|
QHttpPart detailsPart;
|
||||||
detailsPart.setHeader(QNetworkRequest::ContentDispositionHeader, "form-data;"
|
detailsPart.setHeader(QNetworkRequest::ContentDispositionHeader, "form-data;"
|
||||||
|
@ -41,9 +42,9 @@ void UserActivityLogger::logAction(QString action, QJsonObject details, JSONCall
|
||||||
detailsPart.setBody(QJsonDocument(details).toJson(QJsonDocument::Compact));
|
detailsPart.setBody(QJsonDocument(details).toJson(QJsonDocument::Compact));
|
||||||
multipart->append(detailsPart);
|
multipart->append(detailsPart);
|
||||||
}
|
}
|
||||||
qDebug() << "Loging activity" << action;
|
qDebug() << "Logging activity" << action;
|
||||||
qDebug() << AccountManager::getInstance().getAuthURL() << ": " << AccountManager::getInstance().isLoggedIn();
|
|
||||||
|
|
||||||
|
// if no callbacks specified, call our owns
|
||||||
if (params.isEmpty()) {
|
if (params.isEmpty()) {
|
||||||
params.jsonCallbackReceiver = this;
|
params.jsonCallbackReceiver = this;
|
||||||
params.jsonCallbackMethod = "requestFinished";
|
params.jsonCallbackMethod = "requestFinished";
|
||||||
|
|
Loading…
Reference in a new issue