22#include "include/TiltFiveNative.hpp"
48 auto glassesList = client->listGlasses();
50 return glassesList.error();
52 while (glassesList->empty()) {
57 glassesList = client->listGlasses();
59 return glassesList.error();
64 for (
auto& glassesInstance : *glassesList) {
76 auto start = std::chrono::steady_clock::now();
78 auto report = wand->getLatestReport();
80 }
while ((std::chrono::steady_clock::now() -
start) < 10000_ms);
90 auto wandHelper = glasses->getWandStreamHelper();
93 auto wands = wandHelper->listWands();
95 if (!wands->empty()) {
97 return wands->front();
101 return wands.error();
111 auto start = std::chrono::steady_clock::now();
116 std::cout <<
"\rPose unavailable - Is gameboard visible? ";
123 }
while ((std::chrono::steady_clock::now() -
start) < 10000_ms);
135 auto friendlyName = glasses->getFriendlyName();
139 std::cerr <<
"Couldn't get friendly name : Service reports it's not set" <<
std::endl;
146 auto ipd = glasses->getIpd();
158 auto wand = waitForWand(glasses);
160 auto result = doThingsWithWands(*wand);
163 return result.error();
173 auto connectionHelper = glasses->createConnectionHelper(
"Awesome game - Player 1");
174 auto connectionResult = connectionHelper->awaitConnection(10000_ms);
175 if (connectionResult) {
178 std::cerr <<
"Error connecting glasses for exclusive use : " << connectionResult
180 return connectionResult.error();
185 auto result = readPoses(glasses);
188 return result.error();
194 auto releaseResult = glasses->release();
195 if (!releaseResult) {
197 return releaseResult.error();
199 auto readPosesResult = readPoses(glasses);
200 if (readPosesResult) {
201 std::cerr <<
"Reading poses unexpectedly succeeded after glasses release\n";
203 std::cerr <<
"Unexpected pose read error: " << readPosesResult <<
"\n";
215 return result.error();
218 float width = result->viewableExtentPositiveX + result->viewableExtentNegativeX;
219 float length = result->viewableExtentPositiveY + result->viewableExtentNegativeY;
220 float height = result->viewableExtentPositiveZ;
222 std::cout <<
"LE Gameboard size : " << width <<
"m x " << length <<
"m x " << height <<
"m"
230 auto result = client->getServiceVersion();
232 return result.error();
242 auto result = client->isTiltFiveUiRequestingAttention();
244 return result.error();
246 std::cout <<
"Tilt Five UI (Attention Requested) : " << ((*result) ?
"TRUE" :
"FALSE")
258 bool waitingForService =
false;
260 auto result = func(client);
264 return result.error();
267 std::cout << (waitingForService ?
"." :
"Waiting for service...") << std::flush;
268 waitingForService =
true;
276 for (
const auto& param : changed) {
283 for (
const auto& param : changed) {
284 std::cout <<
"Glasses Parameter changed : " << glasses <<
" => [" << param <<
"]"
290int main(
int ,
char** ) {
296 std::exit(EXIT_FAILURE);
303 auto paramChangeHelper = (*client)->createParamChangedHelper(paramChangeListener);
306 auto result = printGameboardDimensions(*client);
309 std::exit(EXIT_FAILURE);
314 result = waitForService<void>(*client, printServiceVersion);
317 std::exit(EXIT_FAILURE);
322 result = waitForService<void>(*client, printUiStatusFlags);
325 std::exit(EXIT_FAILURE);
330 auto glasses = waitForService<Glasses>(*client, waitForGlasses);
333 std::exit(EXIT_FAILURE);
337 paramChangeHelper->registerGlasses(*glasses);
340 result = doThingsWithGlasses(*glasses);
duration< int64_t, milli > milliseconds
basic_ostream< _CharT, _Traits > & endl(basic_ostream< _CharT, _Traits > &__os)
basic_ostream< _CharT, _Traits > & flush(basic_ostream< _CharT, _Traits > &__os)
void sleep_for(const chrono::duration< _Rep, _Period > &__rtime)
Virtual base class for use with tiltfive::ParamChangeHelper.
virtual auto onSysParamChanged(const std::vector< T5_ParamSys > &changed) -> void=0
Called by a tiltfive::ParamChangeHelper when system-wide (T5_ParamSys) params have changed.
virtual auto onGlassesParamChanged(const std::shared_ptr< Glasses > &glasses, const std::vector< T5_ParamGlasses > &changed) -> void=0
Called by a tiltfive::ParamChangeHelper when glasses specific (T5_ParamGlasses) params have changed.
Specialization of tiltfive::Result for functions with 'no return'.
Templated return type with support for error conditions.
auto obtainClient(const std::string &applicationId, const std::string &applicationVersion, void *platformContext, const uint8_t sdkType=0) -> Result< std::shared_ptr< Client > >
Obtain an instance of the Tilt Five™ API client.
auto obtainGlasses(const std::string &identifier, const std::shared_ptr< Client > &client) -> Result< std::shared_ptr< Glasses > >
Obtain an instance of the Tilt Five™ Glasses.
@ kT5_GameboardType_LE
An LE gameboard.
@ kT5_GlassesPoseUsage_GlassesPresentation
The pose will be used to render images to be presented on the glasses.
@ kTryAgain
Target is temporarily unavailable.
@ kNotConnected
Target is not connected.
@ kSettingUnknown
The requested param is unknown.
@ kNoService
Service isn't connected.
static constexpr success_t kSuccess
Indicates 'success' for a Result<void> function.