FB::variant hapticAPI::getPosition() { if (initialized){ hdPhantomGetPosition(deviceID, &position[0],&position[1],&position[2]); double buf[3]; if (strcmp(context.c_str(),"2d")==0){ buf[0] = position[1]+0.1+offsetX; buf[1] = -(position[2]-0.1)+offsetY; buf[2] = position[0]; double x = (buf[0]/pixelWidth); double y = (buf[1]/pixelWidth); mouseRenderPosition(x,y); if (leftButton()) mouseRenderLeftButton(); } else{ buf[0] = position[1]; buf[1] = -position[2]; buf[2] = -position[0]; } std::string pos = arrayToString(buf); return pos; } return NotInitializedString; }
//=========================================================================== int cPhantomDevice::getPosition(cVector3d& a_position) { // check if drivers are installed if (!m_driverInstalled) return (-1); double x,y,z; int error = hdPhantomGetPosition(m_deviceID, &x, &y, &z); a_position.set(x, y, z); estimateLinearVelocity(a_position); return (error); }