| 273 | } |
| 274 | |
| 275 | static void ProcessSensors(int32_t id) { |
| 276 | // If a sensor has data, process it now. |
| 277 | if (id == LOOPER_ID_USER) { |
| 278 | if (accelerometerSensor) { |
| 279 | ASensorEvent event; |
| 280 | while (ASensorEventQueue_getEvents(sensorEventQueue, &event, 1) > 0) { |
| 281 | /*float maginitude = event.acceleration.x * event.acceleration.x + event.acceleration.y * event.acceleration.y; |
| 282 | if (maginitude * 4 >= event.acceleration.z * event.acceleration.z) { |
| 283 | int32_t orientation = ORIENTATION_REVERSE_LANDSCAPE; |
| 284 | float angle = atan2f(-event.acceleration.y, event.acceleration.x); |
| 285 | if (angle <= -M_PI_2 - M_PI_4) { |
| 286 | orientation = ORIENTATION_REVERSE_LANDSCAPE; |
| 287 | } else if (angle <= -M_PI_4) { |
| 288 | orientation = ORIENTATION_PORTRAIT; |
| 289 | } else if (angle <= M_PI_4) { |
| 290 | orientation = ORIENTATION_LANDSCAPE; |
| 291 | } else if (angle <= M_PI_2 + M_PI_4) { |
| 292 | orientation = ORIENTATION_REVERSE_PORTRAIT; |
| 293 | } |
| 294 | LOGI( "orientation %f %d", angle, orientation); |
| 295 | }*/ |
| 296 | } |
| 297 | } |
| 298 | } |
| 299 | } |
| 300 | |
| 301 | static void ResumeSensors() { |
| 302 | // When our app gains focus, we start monitoring the accelerometer. |