Permalink
Browse files

marmalade: implement accelerometer support

  • Loading branch information...
krnlyng committed Jul 23, 2014
1 parent ec876fa commit 64ff566e41e847ceab167f40173bc59d67fe3ba3
Showing with 23 additions and 0 deletions.
  1. +23 −0 modules/marmalade.c
View
@@ -187,6 +187,8 @@ struct SupportModulePriv {
dummy_jobject *theview;
jintArray *pixels;
+ int accel_started;
+
int orientation;
int width, height;
@@ -628,6 +630,20 @@ marmalade_CallVoidMethodV(JNIEnv* env, jobject p1, jmethodID p2, va_list p3)
// FIXME: do something to make runNative return (shutdownNative crashes)
exit(1);
}
+
+ if(marmalade_priv.accel_started) {
+ float x, y, z;
+ apkenv_accelerometer_get(&x,&y,&z);
+ if(marmalade_priv.global->module_hacks->gles_landscape_to_portrait)
+ {
+ marmalade_priv.loaderthread.onAccelNative(ENV(marmalade_priv.global),marmalade_priv.theloaderthread,y,x,z);
+ }
+ else
+ {
+ marmalade_priv.loaderthread.onAccelNative(ENV(marmalade_priv.global),marmalade_priv.theloaderthread,x,y,z);
+ }
+ }
+
marmalade_priv.global->platform->update();
}
else if(method_is(videoStop))
@@ -708,6 +724,11 @@ marmalade_CallVoidMethodV(JNIEnv* env, jobject p1, jmethodID p2, va_list p3)
*/
marmalade_priv.global->platform->update();
}
+ else if(method_is(accelStart))
+ {
+ marmalade_priv.accel_started = 1;
+ apkenv_accelerometer_init();
+ }
else
{
MODULE_DEBUG_PRINTF("marmalade_CallVoidMethodV(%s)\n",p2->name);
@@ -858,6 +879,8 @@ marmalade_init(struct SupportModule *self, int width, int height, const char *ho
self->priv->module = self;
self->priv->home = strdup(home);
+ self->priv->accel_started = 0;
+
self->priv->width = width;
self->priv->height = height;
self->priv->orientation = ORIENTATION_LANDSCAPE;

0 comments on commit 64ff566

Please sign in to comment.