Now that I managed to make things work in C#, I have to figure out C++ so that my colleague (who's old school) can use it too. Wonderful.
What I would like it to be able to poll the spaceball whenever I want. I will be using this within the OGRE framework, so I won't really have any control over threads etc - the info has to be there when I ask for it.
We can't use ATL or MFC, so I've been using the code from
viewtopic.php?t=676
which was most helpful.
I still can't get any actual results out though - everything is zero. It could just be (and I really hope it is) that I'm not setting something to allow polling.
My sample code is:
Code: Select all
#include <Windows>
#include <stdlib>
#include <iostream>
#import "progid:TDxInput.Device.1" no_namespace
using namespace std;
int main() {
HRESULT hr=::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED );
if (!SUCCEEDED(hr))
{
return -1;
}
// create device
ISimpleDevicePtr _3DxDevice;
ISensor* m_p3DSensor;
IKeyboard* m_p3DKeyboard;
hr = _3DxDevice.CreateInstance(__uuidof(Device));
if (SUCCEEDED(hr))
{
ISimpleDevicePtr pSimpleDevice = _3DxDevice;
if (pSimpleDevice != NULL)
{
// Get the interfaces to the sensor and the keyboard;
m_p3DSensor = pSimpleDevice->Sensor;
m_p3DKeyboard = pSimpleDevice->Keyboard;
pSimpleDevice->LoadPreferences("Cube3DPolling");
// Connect to the driver
pSimpleDevice->Connect();
cout << "Connected" <<endl>Translation;
rot = m_p3DSensor->Rotation;
cout <<trans>X << " " <<rot>Angle << endl;
}
}
return 0;
}
- I know about as much COM as you could write on the small crumpled remains of Don Box if I ever find him.
I only know slightly more C++ than I know COM