Radek Polak <[email protected]> writes:

> On Monday, September 10, 2012 08:17:05 PM Neil Jerram wrote:
>
>> I have some theoretical patches for that (attached), but I haven't
>> offered them to Radek because I haven't really got QX working much at
>> all, and so I couldn't be sure if the QX rotation support was working.
>> 
>> The first attached patch is for the main QtMoko repository; the second
>> is for the Arora submodule.
>
> Hi Neil,
> it's applied now. I tried in arora and it works good, so i expect QX to be 
> working too - i will try later on Freerunner.

I have one more accelerometer-patch, below.  It changes QtMaze so that
it doesn't run its own fast timer in parallel with the one in the
accelerometer library.

I've had this for a while, so I'm confident it's good for GTA04.  It
would be good to hear from GTA01/2 people that all accelerometer
functions are still working correctly there.

Regards,
        Neil

>From bc52c9b07bd05dfdad3a4dd2828a788b6f3fc3c9 Mon Sep 17 00:00:00 2001
From: Neil Jerram <[email protected]>
Date: Sun, 29 Jul 2012 20:34:43 +0200
Subject: [PATCH 05/14] QtMaze: use accelerometer callback instead of running
 own timer

---
 src/3rdparty/games/qtmaze/form.cpp |   23 ++++++++++-------------
 src/3rdparty/games/qtmaze/form.h   |    5 +++--
 2 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/src/3rdparty/games/qtmaze/form.cpp b/src/3rdparty/games/qtmaze/form.cpp
index f021414..c02c97a 100644
--- a/src/3rdparty/games/qtmaze/form.cpp
+++ b/src/3rdparty/games/qtmaze/form.cpp
@@ -195,15 +195,10 @@ void Form::apply_temp_phys_res()
     post_phys_res(tmp_px,tmp_py, tmp_vx,tmp_vy);
 }
 
-void Form::tout()
+void Form::tout(double ax, double ay)
 {
-    //printf("[acc] %.4f %.4f %.4f\n", getacx(), getacy(), getacz());
-
     new_game_state = GAME_STATE_NORMAL;
 
-    double ax = getacx();
-    double ay = getacy();
-
     double mid_px=px, mid_py=py;
     double mid_vx=vx, mid_vy=vy;
 
@@ -537,13 +532,13 @@ void Form::MoveBall(double x, double y)
     ballshadow_lbl->move(lpx+shadow_shift, lpy+shadow_shift);
 }
 
-void Form::acc_timerAction()
+void Form::acc_timerAction(double acx, double acy)
 {
     if (!fullscreen) return;
 
     if (game_state == GAME_STATE_NORMAL)
     {
-        tout();
+        tout(acx, acy);
         if (game_state != GAME_STATE_NORMAL)
         {
             int bshift = (qt_game_config.hole_r - qt_game_config.ball_r) / 3;
@@ -854,15 +849,11 @@ Form::Form(QWidget *parent, Qt::WFlags f)
     info1_lbl->setText( "<font color=\"#e0bc70\" size=\"" FONT_SIZE "\">Touch the screen to continue</font>" );
 
     InitState();
-    accelerometer_start(0, NULL, NULL);
+    accelerometer_start(PROC_ACC_DATA_INTERVAL, Form::accel_callback, this);
 
     timer = new QTimer(this);
     connect(timer, SIGNAL(timeout()), this, SLOT(timerAction()));
 
-    QTimer *acc_timer = new QTimer(this);
-    connect(acc_timer, SIGNAL(timeout()), this, SLOT(acc_timerAction()));
-    acc_timer->start(PROC_ACC_DATA_INTERVAL);
-
     installEventFilter(this);
     this->levelno_lbl->installEventFilter(this);
     this->info1_lbl->installEventFilter(this);
@@ -884,3 +875,9 @@ Form::~Form()
 {
     // no need to delete child widgets, Qt does it all for us
 }
+
+void Form::accel_callback(void *closure, double acx, double acy, double acz)
+{
+  Form *form = (Form *)closure;
+  form->acc_timerAction(acx, acy);
+}
diff --git a/src/3rdparty/games/qtmaze/form.h b/src/3rdparty/games/qtmaze/form.h
index 9af8422..68f2e17 100644
--- a/src/3rdparty/games/qtmaze/form.h
+++ b/src/3rdparty/games/qtmaze/form.h
@@ -49,12 +49,14 @@ private:
     void ProcessGameState();
     int testbump(double x,double y,   double mm_vx,double mm_vy);
     int edgebump(int tx,int ty,   double x,double y,   double mm_vx,double mm_vy);
-    void tout();
+    void tout(double ax, double ay);
     void apply_temp_phys_res();
     void post_temp_phys_res(double x, double y, double mm_vx, double mm_vy);
     void post_phys_res(double x, double y, double mm_vx, double mm_vy);
     void BumpVibrate(double speed);
     void setButtonsPics();
+    void acc_timerAction(double acx, double acy);
+    static void accel_callback(void *closure, double acx, double acy, double acz);
 
 public:
     Form( QWidget *parent = 0, Qt::WFlags f = 0 );
@@ -62,7 +64,6 @@ public:
 
 private slots:
     void timerAction();
-    void acc_timerAction();
     bool eventFilter(QObject *target, QEvent *event);
     void ScreenTouchedPause();
     void ScreenTouchedContinue();
-- 
1.7.10.4

_______________________________________________
Openmoko community mailing list
[email protected]
http://lists.openmoko.org/mailman/listinfo/community

Reply via email to