Hi ngomes
we try to get the spacenavigator initialized within the constructor
Code: Select all
SpaceNavigator::SpaceNavigator(){
//for global referencing if SpaceNavigator has been found!
deviceFound = false;
#ifdef __USE_SPACENAV__
//initializing input values from sensor
x_trans = 0.0, y_trans = 0.0, z_trans = 0.0;
x_vert = 0.0, y_vert = 0.0, z_vert = 0.0;
x_rot = 0.0, y_rot = 0.0, z_rot = 0.0, angle_rot = 0.0;
mMoveVolume = false; mMoveCamera = true; mMoveSlices = false;
//mHR = mPDevice.CreateInstance(__uuidof(Device));
mHR = mDevice.CoCreateInstance(__uuidof(Device));
if ( SUCCEEDED( mHR ) ) {
mHR = mPDevice->Connect(); //will always be true, when driver is found;
//even when there is no SpaveNavigator connected
if ( SUCCEEDED( mHR ) ) { // && mPDevice->Type == 6 SpaceNavigator has TypeId = 6
//registrate (hook_in) the functions to DevicePointers and internal Operations
mHR = __hook(&_ISimpleDeviceEvents::DeviceChange, mPDevice, &SpaceNavigator::OnDeviceChange);
mHR = mPDevice->get_Sensor (&mP3DSensor);
mHR = __hook(&_ISensorEvents::SensorInput, mP3DSensor, &SpaceNavigator::OnSensorInput);
mHR = mPDevice->get_Keyboard(&mP3DKeyboard);
mHR = __hook(&_IKeyboardEvents::KeyDown, mP3DKeyboard, &SpaceNavigator::OnKeyDown);
mHR = __hook(&_IKeyboardEvents::KeyUp, mP3DKeyboard, &SpaceNavigator::OnKeyUp);
//QTLogWindow::the()->addInfo( "SpaceNavigator::SpaceNavigator() - SpaceNavigator initialized correctly" );
std::cout << " JUHUHUHU" <<std>addError( "SpaceNavigator ::SpaceNavigator() - sorry, unknown device type detected" );
std::cout << " NaNaNaNa" <<std>addError( "SpaceNavigator ::SpaceNavigator() - driver not installed" );
std::cout << " NeinNÖNÖNÖ" << std::endl;
}
//initializeCOM();
#endif
}
we also tried to copy the initialize example from ATL3DCube as mentionend above....
the pointer are declared in the header
Code: Select all
IUnknownPtr mDevice; /*CComPtr<IUnknown> */
ISimpleDevicePtr mPDevice;
ISensorPtr mP3DSensor;
IKeyboardPtr mP3DKeyboard;
ITDxInfoPtr mP3DInfo;
As we are now working with vs2005 both declarations are possible... the framework is aiming to stay compatible also with vs2003 (which was not able to handle CComPtr<IUnknown>)
Greetings
Andreas
THANX for your quick replies[/code]