/*-------------------------------------------------------------------------- * Function: DispatchLoopNT() * * Description: * This function contains the main message loop which constantly checks for * SpaceBall Events and handles them apropriately. * * Args: None * * * Return Value: * int msg.wparam // event passed to window * *--------------------------------------------------------------------------*/ int DispatchLoopNT() { int num; /* number of button pressed */ MSG msg; /* incoming message to be evaluated */ BOOL handled; /* is message handled yet */ SiSpwEvent Event; /* SpaceWare Event */ SiGetEventData EData; /* SpaceWare Event Data */ handled = SPW_FALSE; /* init handled */ /* start message loop */ while ( GetMessage( &msg, NULL, 0, 0 ) ) { handled = SPW_FALSE; /* init Window platform specific data for a call to SiGetEvent */ SiGetEventWinInit(&EData, msg.message, msg.wParam, msg.lParam); /* check whether msg was a Spaceball event and process it */ if (SiGetEvent (devHdl, 0, &EData, &Event) == SI_IS_EVENT) { if (Event.type == SI_MOTION_EVENT) { SbMotionEvent(&Event); /* process Spaceball motion event */ } if (Event.type == SI_ZERO_EVENT) { SbZeroEvent(); /* process Spaceball zero event */ } if (Event.type == SI_BUTTON_EVENT) { if ((num = SiButtonPressed (&Event)) != SI_NO_BUTTON) { SbButtonPressEvent(num); /* process Spaceball button event */ } if ((num = SiButtonReleased (&Event)) != SI_NO_BUTTON) { SbButtonReleaseEvent(num); /* process Spaceball button event */ } } handled = SPW_TRUE; /* spaceball event handled */ } /* not a Spaceball event, let windows handle it */ if (handled == SPW_FALSE) { TranslateMessage( &msg ); DispatchMessage( &msg ); } } return( msg.wParam ); }
int SbButtonEvent(SiOpenData *pOData, SiGetEventData *pEData, SiSpwEvent *pEvent, void *pUData) { int button; if ((button = SiButtonReleased (pEvent)) != SI_NO_BUTTON) SbButtonReleaseEvent(button, pUData); if ((button = SiButtonPressed (pEvent)) != SI_NO_BUTTON) SbButtonPressEvent(button, pUData); return (0); }