-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCardboardProfileDumper.cpp
76 lines (64 loc) · 2.29 KB
/
CardboardProfileDumper.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include <iostream>
#include <fstream>
#include <sstream>
#include <stdlib.h>
#include "CardboardDevice.pb.h"
using namespace std;
int main(int argc, char** argv)
{
cout << "Google Cardboard settings dumping tool 1.0\n";
char* fileName;
if ( argc > 1 ) // There are Command line parameters
{
fileName = argv[1];
cout << "Opening file: " << fileName << endl;
}
else
{
fileName = "current_device_params";
cout << "No input file defined, try to open: current_device_params" << endl;
}
fstream file(fileName, ios::in | ios::binary);
file.seekg(8, ios_base::beg);
DeviceParams devParams;
if (!devParams.ParseFromIstream(&file))
{
cerr << "Failed to parse file" << endl;
return -1;
}
cout << "--- Begin of dump ---" << endl << endl;
if (devParams.has_vendor())
cout << "Vendor: \t\t\t" << devParams.vendor() << endl;
if (devParams.has_model())
cout << "Model: \t\t\t\t" << devParams.model() << endl;
if (devParams.has_screen_to_lens_distance())
cout << "Screen to lens distance: \t" << devParams.screen_to_lens_distance() << endl;
if (devParams.has_inter_lens_distance())
cout << "Inter lens distance: \t\t" << devParams.inter_lens_distance() << endl;
if (devParams.left_eye_field_of_view_angles().size() != 0) //repeated float
{
cout << "Left eye field of view angles: \t";
for (size_t i = 0; i < devParams.left_eye_field_of_view_angles().size(); i++)
cout << devParams.left_eye_field_of_view_angles(i) << ", ";
cout << endl;
}
if (devParams.has_vertical_alignment())//enum
cout << "Vertical alignment: \t\t" << devParams.vertical_alignment() << endl;
if (devParams.has_tray_to_lens_distance())
cout << "Tray to lens distance: \t\t" << devParams.tray_to_lens_distance() << endl;
if (devParams.distortion_coefficients().size() != 0) //repeated float
{
cout << "Distortion coefficients: \t";
for (size_t i = 0; i < devParams.distortion_coefficients().size(); i++)
cout << devParams.distortion_coefficients(i) << ", ";
cout << endl;
}
if (devParams.has_has_magnet())
cout << "Magnet: \t\t" << devParams.has_magnet() << endl;
if (devParams.has_primary_button())//enum
cout << "Primary button: \t\t" << devParams.primary_button() << endl;
cout << endl << "--- dump complete ---" << endl;
google::protobuf::ShutdownProtobufLibrary();
file.close();
return 0;
}