aboutsummaryrefslogtreecommitdiffstats
path: root/support/magicleap/Servo2D/code/src
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2018-10-30 14:20:28 -0400
committerGitHub <noreply@github.com>2018-10-30 14:20:28 -0400
commitcc0ac89e1a3af52439cdb8a79d01e12224c8ad11 (patch)
treeb8a7acd4fbd05565b940be426c90afbb3a6244c7 /support/magicleap/Servo2D/code/src
parent7a715519a010e7539f3408896663750c0982a0ff (diff)
parentc8fa64b93a7596c9a1c57fec2655c8e938921052 (diff)
downloadservo-cc0ac89e1a3af52439cdb8a79d01e12224c8ad11.tar.gz
servo-cc0ac89e1a3af52439cdb8a79d01e12224c8ad11.zip
Auto merge of #22057 - asajeffrey:magicleap-fwd-back-buttons, r=jdm
Magic Leap history traversal <!-- Please describe your changes on the following line: --> Hook up the back and forward buttons in the Magic Leap Servo2D application to history traversal. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes do not require tests because we can't test ML <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22057) <!-- Reviewable:end -->
Diffstat (limited to 'support/magicleap/Servo2D/code/src')
-rw-r--r--support/magicleap/Servo2D/code/src/Servo2D.cpp30
1 files changed, 26 insertions, 4 deletions
diff --git a/support/magicleap/Servo2D/code/src/Servo2D.cpp b/support/magicleap/Servo2D/code/src/Servo2D.cpp
index 9b830ac6ca0..54600362d09 100644
--- a/support/magicleap/Servo2D/code/src/Servo2D.cpp
+++ b/support/magicleap/Servo2D/code/src/Servo2D.cpp
@@ -6,6 +6,7 @@
#include <lumin/node/RootNode.h>
#include <lumin/node/QuadNode.h>
#include <lumin/ui/Cursor.h>
+#include <lumin/ui/node/UiButton.h>
#include <ml_logging.h>
#include <scenesGen.h>
#include <SceneDescriptor.h>
@@ -36,11 +37,12 @@ void logger(MLLogLevel lvl, char* msg) {
// The functions Servo provides for hooking up to the ML.
// For the moment, this doesn't handle input events.
-extern "C" ServoInstance init_servo(EGLContext, EGLSurface, EGLDisplay, MLLogger,
+extern "C" ServoInstance* init_servo(EGLContext, EGLSurface, EGLDisplay, MLLogger,
const char* url, int width, int height, float hidpi);
-extern "C" void heartbeat_servo(ServoInstance);
-extern "C" void cursor_servo(ServoInstance, float x, float y, bool triggered);
-extern "C" void discard_servo(ServoInstance);
+extern "C" void heartbeat_servo(ServoInstance*);
+extern "C" void cursor_servo(ServoInstance*, float x, float y, bool triggered);
+extern "C" void traverse_servo(ServoInstance*, int delta);
+extern "C" void discard_servo(ServoInstance*);
// Create a Servo2D instance
Servo2D::Servo2D() {
@@ -125,6 +127,26 @@ int Servo2D::init() {
return 1;
}
+ // Add a callback to the back button
+ std::string back_button_id = Servo2D_exportedNodes::backButton;
+ lumin::ui::UiButton* back_button = lumin::ui::UiButton::CastFrom(prism_->findNode(back_button_id, root_node));
+ if (!back_button) {
+ ML_LOG(Error, "Servo2D Failed to get back button");
+ abort();
+ return 1;
+ }
+ back_button->onActivateSub(std::bind(traverse_servo, servo_, -1));
+
+ // Add a callback to the forward button
+ std::string fwd_button_id = Servo2D_exportedNodes::fwdButton;
+ lumin::ui::UiButton* fwd_button = lumin::ui::UiButton::CastFrom(prism_->findNode(fwd_button_id, root_node));
+ if (!fwd_button) {
+ ML_LOG(Error, "Servo2D Failed to get forward button");
+ abort();
+ return 1;
+ }
+ fwd_button->onActivateSub(std::bind(traverse_servo, servo_, +1));
+
return 0;
}