12 CPhidget_getDeviceName(IFK, &name);
13 CPhidget_getSerialNumber(IFK, &serialNo);
15 if (
spatial->config->serialno == -1)
16 spatial->config->serialno = serialNo;
19 sprintf_s(msg, 99,
"Spatial::AttachHandler %s (%i) attached!", name, serialNo);
31 CPhidget_getDeviceName(IFK, &name);
32 CPhidget_getSerialNumber(IFK, &serialNo);
35 sprintf_s(msg, 99,
"Spatial::DetachHandler %s (%i) detached!", name, serialNo);
45 sprintf_s(msg, 99,
"Spatial::ErrorHandler Error handled. %s", unknown);
57 for (
int i = 0; i < count; i++)
59 spatial->cumulativeAcceleration += D3DXVECTOR3(
60 static_cast<float>(data[i]->acceleration[
spatial->xyzMapping[0]]) +
spatial->config->accelerationAxes[
spatial->xyzMapping[0]].bias,
61 static_cast<float>(data[i]->acceleration[
spatial->xyzMapping[1]]) +
spatial->config->accelerationAxes[
spatial->xyzMapping[1]].bias,
62 static_cast<float>(data[i]->acceleration[
spatial->xyzMapping[2]]) +
spatial->config->accelerationAxes[
spatial->xyzMapping[2]].bias);
63 spatial->cumulativeAccelSamples++;
74 int serialNo, version;
76 int numAccelAxes, numGyroAxes, numCompassAxes, dataRateMax, dataRateMin;
78 CPhidget_getDeviceType(phid, &ptr);
79 CPhidget_getSerialNumber(phid, &serialNo);
80 CPhidget_getDeviceVersion(phid, &version);
81 CPhidgetSpatial_getAccelerationAxisCount(reinterpret_cast<CPhidgetSpatialHandle>(phid), &numAccelAxes);
82 CPhidgetSpatial_getGyroAxisCount(reinterpret_cast<CPhidgetSpatialHandle>(phid), &numGyroAxes);
83 CPhidgetSpatial_getCompassAxisCount(reinterpret_cast<CPhidgetSpatialHandle>(phid), &numCompassAxes);
84 CPhidgetSpatial_getDataRateMax(reinterpret_cast<CPhidgetSpatialHandle>(phid), &dataRateMax);
85 CPhidgetSpatial_getDataRateMin(reinterpret_cast<CPhidgetSpatialHandle>(phid), &dataRateMin);
88 sprintf_s(msg, 99,
"Spatial::display_properties Type: %s", ptr);
90 sprintf_s(msg, 99,
"Spatial::display_properties Serial Number: %i", serialNo);
92 sprintf_s(msg, 99,
"Spatial::display_properties Version: %i", version);
94 sprintf_s(msg, 99,
"Spatial::display_properties Number of Accel Axes: %i", numAccelAxes);
96 sprintf_s(msg, 99,
"Spatial::display_properties Number of Gyro Axes: %i", numGyroAxes);
98 sprintf_s(msg, 99,
"Spatial::display_properties Number of Compass Axes: %i", numCompassAxes);
100 sprintf_s(msg, 99,
"Spatial::display_properties Maximum Datarate: %d", dataRateMax);
102 sprintf_s(msg, 99,
"Spatial::display_properties Minimum Datarate: %d", dataRateMin);
132 CPhidgetSpatial_create(&
spatial);
137 CPhidget_set_OnError_Handler(reinterpret_cast<CPhidgetHandle>(
spatial),
ErrorHandler,
this);
145 CPhidget_open(reinterpret_cast<CPhidgetHandle>(
spatial), -1);
148 logger->
Log(
"Spatial::ctor Waiting for spatial to be attached....");
149 result = CPhidget_waitForAttachment(reinterpret_cast<CPhidgetHandle>(
spatial), 5000);
152 CPhidget_getErrorDescription(result, &err);
154 sprintf_s(msg, 99,
"Spatial::ctor Problem waiting for attachment: %s", err);
163 CPhidget_getErrorDescription(result, &err);
165 sprintf_s(msg, 99,
"Spatial::ctor Problem %s setting sample rate: %i", err,
config->
sampleRateMs);
176 CPhidget_close(reinterpret_cast<CPhidgetHandle>(
spatial));
177 CPhidget_delete(reinterpret_cast<CPhidgetHandle>(
spatial));
int display_properties(CPhidgetHandle phid) const
static int CCONV DetachHandler(CPhidgetHandle IFK, void *userptr)
static int CCONV AttachHandler(CPhidgetHandle IFK, void *userptr)
void FrameMove(float fElapsed)
okay, the portable keyboard numbers don't work like the outside keypad because the outside keypad is ...
void Initialize(Logger *logger, SpatialConfig *config, Bus *prmBus)
static int CCONV SpatialDataHandler(CPhidgetSpatialHandle spatial, void *userptr, CPhidgetSpatial_SpatialEventDataHandle *data, int count)
float cumulativeAccelTime
CPhidgetSpatialHandle spatial
int cumulativeAccelSamples
void Log(const char *msg, Level level=Info, int errorCode=0)
These have to be in this order.
D3DXVECTOR3 PlatformAcceleration
std::vector< AccelerationAxis > accelerationAxes
static int CCONV ErrorHandler(CPhidgetHandle IFK, void *userptr, int ErrorCode, const char *unknown)
D3DXVECTOR3 cumulativeAcceleration