Merge pull request #4362 from xhcnb/hotfix_android_setAccelerometerInterval

[ci skip]Fix: on android, Device::setAccelerometerInterval will causes dead loop
This commit is contained in:
minggo 2013-12-01 18:08:58 -08:00
commit 24f7819e99
3 changed files with 12 additions and 12 deletions

View File

@ -18,17 +18,17 @@ void Device::setAccelerometerEnabled(bool isEnabled)
{ {
if (isEnabled) if (isEnabled)
{ {
enableAccelerometer(); enableAccelerometerJni();
} }
else else
{ {
disableAccelerometer(); disableAccelerometerJni();
} }
} }
void Device::setAccelerometerInterval(float interval) void Device::setAccelerometerInterval(float interval)
{ {
setAccelerometerInterval(interval); setAccelerometerIntervalJni(interval);
} }
NS_CC_END NS_CC_END

View File

@ -471,8 +471,8 @@ static int32_t engine_handle_input(struct android_app* app, AInputEvent* event)
return 0; return 0;
} }
void enableAccelerometer(void) { void enableAccelerometerJni(void) {
LOGI("enableAccelerometer()"); LOGI("enableAccelerometerJni()");
if (engine.accelerometerSensor != NULL) { if (engine.accelerometerSensor != NULL) {
ASensorEventQueue_enableSensor(engine.sensorEventQueue, ASensorEventQueue_enableSensor(engine.sensorEventQueue,
@ -485,8 +485,8 @@ void enableAccelerometer(void) {
} }
} }
void disableAccelerometer(void) { void disableAccelerometerJni(void) {
LOGI("disableAccelerometer()"); LOGI("disableAccelerometerJni()");
if (engine.accelerometerSensor != NULL) { if (engine.accelerometerSensor != NULL) {
ASensorEventQueue_disableSensor(engine.sensorEventQueue, ASensorEventQueue_disableSensor(engine.sensorEventQueue,
@ -494,8 +494,8 @@ void disableAccelerometer(void) {
} }
} }
void setAccelerometerInterval(float interval) { void setAccelerometerIntervalJni(float interval) {
LOGI("setAccelerometerInterval(%f)", interval); LOGI("setAccelerometerIntervalJni(%f)", interval);
// We'd like to get 60 events per second (in us). // We'd like to get 60 events per second (in us).
ASensorEventQueue_setEventRate(engine.sensorEventQueue, ASensorEventQueue_setEventRate(engine.sensorEventQueue,
engine.accelerometerSensor, interval * 1000000L); engine.accelerometerSensor, interval * 1000000L);

View File

@ -5,8 +5,8 @@
* This is the interface to the Android native activity * This is the interface to the Android native activity
*/ */
void enableAccelerometer(void); void enableAccelerometerJni(void);
void disableAccelerometer(void); void disableAccelerometerJni(void);
void setAccelerometerInterval(float interval); void setAccelerometerIntervalJni(float interval);
#endif // __COCOSNATIVEACTIVITY_H__ #endif // __COCOSNATIVEACTIVITY_H__