| 130 | } |
| 131 | |
| 132 | static void ProcessSensors(int32_t id) { |
| 133 | // If a sensor has data, process it now. |
| 134 | if (id == LOOPER_ID_USER) { |
| 135 | if (accelerometerSensor) { |
| 136 | ASensorEvent event; |
| 137 | while (ASensorEventQueue_getEvents(sensorEventQueue, &event, 1) > 0) { |
| 138 | /*float maginitude = event.acceleration.x * event.acceleration.x + event.acceleration.y * event.acceleration.y; |
| 139 | if (maginitude * 4 >= event.acceleration.z * event.acceleration.z) { |
| 140 | int32_t orientation = ORIENTATION_REVERSE_LANDSCAPE; |
| 141 | float angle = atan2f(-event.acceleration.y, event.acceleration.x); |
| 142 | if (angle <= -M_PI_2 - M_PI_4) { |
| 143 | orientation = ORIENTATION_REVERSE_LANDSCAPE; |
| 144 | } else if (angle <= -M_PI_4) { |
| 145 | orientation = ORIENTATION_PORTRAIT; |
| 146 | } else if (angle <= M_PI_4) { |
| 147 | orientation = ORIENTATION_LANDSCAPE; |
| 148 | } else if (angle <= M_PI_2 + M_PI_4) { |
| 149 | orientation = ORIENTATION_REVERSE_PORTRAIT; |
| 150 | } |
| 151 | LOGI( "orientation %f %d", angle, orientation); |
| 152 | }*/ |
| 153 | } |
| 154 | } |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | static void ResumeSensors() { |
| 159 | // When our app gains focus, we start monitoring the accelerometer. |