aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Matthews <josh@joshmatthews.net>2019-03-15 13:49:49 -0400
committerJosh Matthews <josh@joshmatthews.net>2019-05-01 18:57:40 -0400
commitdaabda7fe14cb79ddc1b06019bec77f953eb9cf8 (patch)
treee095b2c103485967b1f519a26f93e08d2c93126c
parent0a5aab6cc2d23b6b9bf5de142e7a8a5b84e32380 (diff)
downloadservo-daabda7fe14cb79ddc1b06019bec77f953eb9cf8.tar.gz
servo-daabda7fe14cb79ddc1b06019bec77f953eb9cf8.zip
Support launching Servo2d with a URI.
-rw-r--r--support/magicleap/Servo2D/code/inc/Servo2D.h3
-rw-r--r--support/magicleap/Servo2D/code/src/Servo2D.cpp6
-rw-r--r--support/magicleap/Servo2D/code/src/main.cpp25
3 files changed, 29 insertions, 5 deletions
diff --git a/support/magicleap/Servo2D/code/inc/Servo2D.h b/support/magicleap/Servo2D/code/inc/Servo2D.h
index e127332b52d..61f1ee333e3 100644
--- a/support/magicleap/Servo2D/code/inc/Servo2D.h
+++ b/support/magicleap/Servo2D/code/inc/Servo2D.h
@@ -29,7 +29,7 @@ public:
/**
* Constructs the Landscape Application.
*/
- Servo2D();
+ Servo2D(const char* uri);
/**
* Destroys the Landscape Application.
@@ -144,4 +144,5 @@ private:
glm::quat controller_orientation_; // The last recorded orientation of the controller (in world coords)
bool controller_trigger_down_ = false; // Is the controller trigger currently down?
ServoInstance* servo_ = nullptr; // the servo instance we're embedding
+ const char* uri_ = nullptr;
};
diff --git a/support/magicleap/Servo2D/code/src/Servo2D.cpp b/support/magicleap/Servo2D/code/src/Servo2D.cpp
index 6056ebcada2..6d7ddb8df9e 100644
--- a/support/magicleap/Servo2D/code/src/Servo2D.cpp
+++ b/support/magicleap/Servo2D/code/src/Servo2D.cpp
@@ -78,7 +78,9 @@ extern "C" void navigate_servo(ServoInstance*, const char* text);
extern "C" void discard_servo(ServoInstance*);
// Create a Servo2D instance
-Servo2D::Servo2D() {
+Servo2D::Servo2D(const char* uri)
+: uri_(uri ? uri : HOME_PAGE)
+{
ML_LOG(Debug, "Servo2D Constructor.");
}
@@ -171,7 +173,7 @@ int Servo2D::init() {
EGLDisplay dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
// Hook into servo
- servo_ = init_servo(ctx, surf, dpy, this, logger, history, url, keyboard, HOME_PAGE, VIEWPORT_W, VIEWPORT_H, HIDPI);
+ servo_ = init_servo(ctx, surf, dpy, this, logger, history, url, keyboard, uri_, VIEWPORT_W, VIEWPORT_H, HIDPI);
if (!servo_) {
ML_LOG(Error, "Servo2D Failed to init servo instance");
abort();
diff --git a/support/magicleap/Servo2D/code/src/main.cpp b/support/magicleap/Servo2D/code/src/main.cpp
index 93b40866f4f..9daa85e4eda 100644
--- a/support/magicleap/Servo2D/code/src/main.cpp
+++ b/support/magicleap/Servo2D/code/src/main.cpp
@@ -3,11 +3,32 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
#include <Servo2D.h>
+#include <ml_lifecycle.h>
#include <ml_logging.h>
int main(int argc, char **argv)
{
ML_LOG(Debug, "Servo2D Starting.");
- Servo2D myApp;
- return myApp.run();
+
+ // Handle optional initialization string passed via 'mldb launch'
+ MLLifecycleInitArgList* list = NULL;
+ MLLifecycleGetInitArgList(&list);
+ const char* uri = NULL;
+ if (nullptr != list) {
+ int64_t list_length = 0;
+ MLLifecycleGetInitArgListLength(list, &list_length);
+ if (list_length > 0) {
+ const MLLifecycleInitArg* iarg = NULL;
+ MLLifecycleGetInitArgByIndex(list, 0, &iarg);
+ if (nullptr != iarg) {
+ MLLifecycleGetInitArgUri(iarg, &uri);
+ }
+ }
+ }
+
+ Servo2D myApp(uri);
+ int rv = myApp.run();
+
+ MLLifecycleFreeInitArgList(&list);
+ return rv;
}