aboutsummaryrefslogtreecommitdiffstats
path: root/support
diff options
context:
space:
mode:
authorJosh Matthews <josh@joshmatthews.net>2019-03-20 16:41:20 -0400
committerJosh Matthews <josh@joshmatthews.net>2019-05-02 19:20:02 -0400
commita207574b4c948e94f11fd61e17ebb2515295f56b (patch)
tree712425d9b0a64295828e55f6172620c93dc46378 /support
parentd0e9acf1eb81c2b535a01c42b7541d2b33a0acb2 (diff)
downloadservo-a207574b4c948e94f11fd61e17ebb2515295f56b.tar.gz
servo-a207574b4c948e94f11fd61e17ebb2515295f56b.zip
Support passing in arguments from embedding. Read arguments for Magic Leap from SERVO_ARGS env var.
Diffstat (limited to 'support')
-rw-r--r--support/magicleap/Servo2D/code/inc/Servo2D.h3
-rw-r--r--support/magicleap/Servo2D/code/src/Servo2D.cpp7
-rw-r--r--support/magicleap/Servo2D/code/src/main.cpp4
3 files changed, 9 insertions, 5 deletions
diff --git a/support/magicleap/Servo2D/code/inc/Servo2D.h b/support/magicleap/Servo2D/code/inc/Servo2D.h
index 61f1ee333e3..1e526bb2b94 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(const char* uri);
+ Servo2D(const char* uri, const char* args);
/**
* Destroys the Landscape Application.
@@ -145,4 +145,5 @@ private:
bool controller_trigger_down_ = false; // Is the controller trigger currently down?
ServoInstance* servo_ = nullptr; // the servo instance we're embedding
const char* uri_ = nullptr;
+ const char* args_ = nullptr;
};
diff --git a/support/magicleap/Servo2D/code/src/Servo2D.cpp b/support/magicleap/Servo2D/code/src/Servo2D.cpp
index 6d7ddb8df9e..a1859c6411d 100644
--- a/support/magicleap/Servo2D/code/src/Servo2D.cpp
+++ b/support/magicleap/Servo2D/code/src/Servo2D.cpp
@@ -68,7 +68,7 @@ void keyboard(Servo2D* app, bool visible) {
// The functions Servo provides for hooking up to the ML.
extern "C" ServoInstance* init_servo(EGLContext, EGLSurface, EGLDisplay,
Servo2D*, MLLogger, MLHistoryUpdate, MLURLUpdate, MLKeyboard,
- const char* url, int width, int height, float hidpi);
+ const char* url, const char* args, int width, int height, float hidpi);
extern "C" void heartbeat_servo(ServoInstance*);
extern "C" void keyboard_servo(ServoInstance*, char32_t code, lumin::ui::KeyType keyType);
extern "C" void trigger_servo(ServoInstance*, float x, float y, bool down);
@@ -78,8 +78,9 @@ extern "C" void navigate_servo(ServoInstance*, const char* text);
extern "C" void discard_servo(ServoInstance*);
// Create a Servo2D instance
-Servo2D::Servo2D(const char* uri)
+Servo2D::Servo2D(const char* uri, const char* args)
: uri_(uri ? uri : HOME_PAGE)
+, args_(args)
{
ML_LOG(Debug, "Servo2D Constructor.");
}
@@ -173,7 +174,7 @@ int Servo2D::init() {
EGLDisplay dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
// Hook into servo
- servo_ = init_servo(ctx, surf, dpy, this, logger, history, url, keyboard, uri_, VIEWPORT_W, VIEWPORT_H, HIDPI);
+ servo_ = init_servo(ctx, surf, dpy, this, logger, history, url, keyboard, uri_, args_, 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 9daa85e4eda..a93c692e364 100644
--- a/support/magicleap/Servo2D/code/src/main.cpp
+++ b/support/magicleap/Servo2D/code/src/main.cpp
@@ -26,7 +26,9 @@ int main(int argc, char **argv)
}
}
- Servo2D myApp(uri);
+ const char* args = getenv("SERVO_ARGS");
+
+ Servo2D myApp(uri, args);
int rv = myApp.run();
MLLifecycleFreeInitArgList(&list);