MCPcopy Create free account
hub / github.com/PolygonTek/BlueshiftEngine / ProcessSensors

Function ProcessSensors

Source/TestRenderer/AndroidMain.cpp:132–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

130}
131
132static 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
158static void ResumeSensors() {
159 // When our app gains focus, we start monitoring the accelerometer.

Callers 1

android_mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected