11 #include "GloveObject.h"
12 #include "GloveCalibration.h"
13 #include "GlovePlugin.h"
17 void GloveCallback(LPVOID param)
24 pGloveObject->UpdateGlove();
39 bCalibrationDone =
true;
40 pSensorValues =
new float[NUMBEROFSENSOR];
41 for (
int i = 0; i < NUMBEROFSENSOR; i++)
43 *(pSensorValues + i) = 0.0f;
53 fdSetCallback(pGlove, NULL, NULL);
60 delete[] pSensorValues;
78 int GloveObject::GetTypeID()
82 std::string GloveObject::GetTypeName()
87 int GloveObject::GetHandIndex()
92 std::string GloveObject::GetHandName()
97 int GloveObject::GetNbrOfSensors()
102 std::string GloveObject::GetSerialNumber()
107 int GloveObject::GetUSBPortIndex()
112 float* GloveObject::GetSensorValues()
114 return pSensorValues;
117 fdGlove* GloveObject::GetGlove()
123 int GloveObject::GetGestureIndex()
125 return this->gestureIndex;
128 void GloveObject::SetGestureIndex(
int driverGesture)
138 if (driverGesture != -1)
141 driverGesture = driverGesture<<1;
144 if (driverGesture & 0x60)
145 gestureIndex = driverGesture & (0x1E);
148 gestureIndex = driverGesture | 0x01;
154 bool GloveObject::Init()
157 unsigned short aPID[5];
158 int nNumFound = 5, nChosen = 0;
159 char portName[5] =
"USB";
160 bool bInitOk =
false;
164 fdScanUSB(aPID, nNumFound);
166 for (
int i = 0; i < nNumFound; i++)
169 sprintf(portName,
"USB%d", i);
172 pGlove = fdOpen(portName);
176 MMechostr(MSKDEBUG,
"-> Init ...failed : data glove n.%d already opened\n", i);
183 MMechostr(MSKDEBUG,
"-> Init ...successful\n");
192 MMechostr(MSKDEBUG,
"-> Init ...failed : couldn't open any data glove\n");
198 fdGetSerialNumber(pGlove, tmpserial);
199 MMechostr(MSKDEBUG,
"Glove 5DT serial : %s", tmpserial);
200 serialNumber = tmpserial;
206 iType = fdGetGloveType(pGlove);
221 sType=
"5DT Wireless Glove";
229 sType=
"16DT Wireless Glove";
233 sType=
"DG5 Ultra Series";
237 sType=
"DG5 Wireless Ultra Series";
241 sType=
"DG5 Ultra USB";
245 sType=
"DG14 Ultra Series";
249 sType=
"DG14 Wireless Ultra Series";
252 case FD_GLOVE14U_USB:
253 sType=
"DG14 Ultra USB";
256 iHand=fdGetGloveHand(pGlove);
257 if (iHand == FD_HAND_RIGHT)
263 NbrOfSensors = fdGetNumSensors(pGlove);
266 fdSetCallback(pGlove, (
void*)GloveCallback,
this);
271 void GloveObject::StartCalibration()
273 if (calibration == 0)
277 calibration->
start();
279 else if (!calibration->GetIsRunning())
281 calibration->
start();
286 MMechostr(MSKDEBUG,
"Calibration already running");
291 void GloveObject::UpdateGlove()
297 fdGetSensorScaledAll(pGlove, pSensorValues);
301 int oldGesture = gestureIndex;
302 SetGestureIndex(fdGetGestureA(pGlove));
303 if (gestureIndex != oldGesture)
306 OBJpostEvent(GLOVE_HAND_CB, (
int)
this, (LPARAM)gestureIndex);
310 float* rawMsg =
new float[NUMBEROFSENSOR];
311 for (
int i = 0; i < NUMBEROFSENSOR; i++)
313 rawMsg[i] = pSensorValues[i];
317 OBJpostEvent(GLOVE_NEWDATA_CB, (
int)
this, (LPARAM)rawMsg);
324 int GloveObject::Close()
326 int iErrorCode = fdClose(pGlove);