| 191 | } |
| 192 | |
| 193 | static bool LoadGyroCalibration(const char* serial) |
| 194 | { |
| 195 | if (!serial || serial[0] == '\0') |
| 196 | return false; |
| 197 | |
| 198 | std::string filePath = GetGyroCalibrationFilePath(serial); |
| 199 | if (filePath.empty()) |
| 200 | return false; |
| 201 | |
| 202 | std::ifstream file(filePath, std::ios::binary); |
| 203 | if (!file) |
| 204 | return false; |
| 205 | |
| 206 | file.seekg(0, std::ios::end); |
| 207 | if (file.tellg() != 0xC) |
| 208 | return false; |
| 209 | |
| 210 | file.seekg(0, std::ios::beg); |
| 211 | |
| 212 | float offsetX = 0.0, offsetY = 0.0, offsetZ = 0.0; |
| 213 | file.read(reinterpret_cast<char*>(&offsetX), sizeof(float)); |
| 214 | file.read(reinterpret_cast<char*>(&offsetY), sizeof(float)); |
| 215 | file.read(reinterpret_cast<char*>(&offsetZ), sizeof(float)); |
| 216 | |
| 217 | if (!file) |
| 218 | return false; |
| 219 | |
| 220 | s_gyroOffset.offsetX = offsetX; |
| 221 | s_gyroOffset.offsetY = offsetY; |
| 222 | s_gyroOffset.offsetZ = offsetZ; |
| 223 | s_gyroOffset.hasInitialCalibration = true; |
| 224 | |
| 225 | return true; |
| 226 | } |
| 227 | |
| 228 | // ========================================================== |
| 229 | // Frame Timing |
no test coverage detected