Basically, to use bbTablet once you've
installed it, you include the bbtablet header
with "#include <bbtablet.h>" in your C++ program and call a few lines
of code.
To use the tablet you should first initialize the bbTablet library with this
bit of code:
#include <bbtablet.h>
HWND wnd = << get the window's device somehow!* >>
bbTabletDevice &td = bbTabletDevice::getInstance( );
td.initTablet( wnd, bbTabletDevice::SYSTEM_POINTER );
The above code will make it so your system mouse is controlled by the tablet.
If you want to continue to use the mouse separately (e.g. for bi-manual input),
pass in 'bbTabletDevice::SEPARATE_POINTER' instead.
Getting the HWND can be a non-trivial task if you're using a higher level
toolkit that doesn't readily give you that sort of information, but there
are ways. For instance a call to GetForegroundWindow() at the right
time often seems to do the trick. If you're working with GLUT or OpenGL
this little bit of code does the trick:
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
static void* getCurrentHWND()
{
// get current DC from wgl
return WindowFromDC(wglGetCurrentDC());
}
You just need to be sure your GLUT window's GL context is current when you
call the above function.
Once initialized, you just have to periodically check for new tablet events
in your code:
bbTabletDevice &td = bbTabletDevice::getInstance();
bbTabletEvent evt;
if (!td.getNextEvent(evt));
return;
<< use evt >>
Where an evt has the following members:
evt.x // [0,1] x coord
evt.y // [0,1] y coord
evt.z // [0,1] z coord (usually not supported)
evt.pressure // [0,1] pressure value
evt.angle // angle&axis give 3D rotation
evt.axis[3] //
evt.id // unique physical id if supported
evt.buttons // bitmask of pressed buttons
evt.type // cursor type
The angle and axis parameters define a 3D transformation for the stylus.
This uses the tilt information from the stylus whenever available. Otherwise
it just acts like the pen is standing straight up.
More information may also be available in the README.txt in the zips below.
There is also a test program or two in the distribution you can play
with. Project files are available for MSVC++ 6.0 only.