The code to handle event is given below
Code: Select all
void DispatchLoop()
{
MSG msg;
int handledEvent;
SiGetEventData EData;
SiSpwEvent Event;
BOOL getMsg;
// Process messages
if ((getMsg = GetMessage(&msg, NULL, 0, 0)) != 0)
//if (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
{
SpwReturnValue ret;
handledEvent = FALSE;
if (devHdl != SI_NO_HANDLE)
{
SiGetEventWinInit(&EData, msg.message, msg.wParam, msg.lParam);
if ((ret = SiGetEvent(devHdl, 0, &EData, &Event)) == SI_IS_EVENT)
{
if (Event.type == SI_MOTION_EVENT)
{
// Handle motion event
SbMotionEvent(&Event);
}
handledEvent = TRUE;
}
}
// If it wasn't a 3D mouse event, handle it through the normal channels.
if (handledEvent == FALSE)
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
}
}
void Delta3DApp::PreFrame(const double deltaSimTime)
{
// Dispatch message loop
DispatchLoop();
// Perform 3d model update
//.......
}
Thanks.