Exemplo n.º 1
0
//-----------------------------------------------------------------------------
// Test if a message comes from the SpaceNavigator device. If yes, dispatch
// it appropriately and return true. Otherwise, do nothing and return false.
//-----------------------------------------------------------------------------
static bool ProcessSpaceNavigatorMsg(MSG *msg) {
    if(SpaceNavigator == SI_NO_HANDLE) return false;

    SiGetEventData sged;
    SiSpwEvent sse;

    SiGetEventWinInit(&sged, msg->message, msg->wParam, msg->lParam);
    int ret = SiGetEvent(SpaceNavigator, 0, &sged, &sse);
    if(ret == SI_NOT_EVENT) return false;
    // So the device is a SpaceNavigator event, or a SpaceNavigator error.

    if(ret == SI_IS_EVENT) {
        if(sse.type == SI_MOTION_EVENT) {
            // The Z axis translation and rotation are both
            // backwards in the default mapping.
            double tx =  sse.u.spwData.mData[SI_TX]*1.0,
                   ty =  sse.u.spwData.mData[SI_TY]*1.0,
                   tz = -sse.u.spwData.mData[SI_TZ]*1.0,
                   rx =  sse.u.spwData.mData[SI_RX]*0.001,
                   ry =  sse.u.spwData.mData[SI_RY]*0.001,
                   rz = -sse.u.spwData.mData[SI_RZ]*0.001;
            SS.GW.SpaceNavigatorMoved(tx, ty, tz, rx, ry, rz,
                !!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
        } else if(sse.type == SI_BUTTON_EVENT) {
            int button;
            button = SiButtonReleased(&sse);
            if(button == SI_APP_FIT_BUTTON) SS.GW.SpaceNavigatorButtonUp();
        }
    }
    return true;
}
Exemplo n.º 2
0
/* translates a Win32 event to a SPW_InputEvent. */
int SPW_TranslateEventWin32(MSG * msg, SPW_InputEvent * sbEvent)
{
  SiSpwEvent spwEvent;
  SiGetEventData eventdata;

  if (Spw_DeviceHandle != SI_NO_HANDLE) {

    SiGetEventWinInit (&eventdata, msg->message, msg->wParam, msg->lParam);
    if (SiGetEvent (Spw_DeviceHandle, 0, &eventdata, &spwEvent) == SI_IS_EVENT) {

      int i;
      switch(spwEvent.type) {
        case SI_MOTION_EVENT:
          sbEvent->type = SPW_InputMotionEvent;      
          for(i=0; i<6; i++) {
            sbEvent->sData[i] = (short)spwEvent.u.spwData.mData[i];
          }  
          break;
        case SI_BUTTON_EVENT:
          sbEvent->type = SPW_InputButtonPressEvent;
          sbEvent->buttonState.pressed = (SiButtonPressed(&spwEvent) != SI_NO_BUTTON);
          sbEvent->buttonState.released = (SiButtonReleased(&spwEvent) != SI_NO_BUTTON);
          break;
      }
      return TRUE;
    }
  }
  return FALSE;
}
Exemplo n.º 3
0
// SpaceBallWindowProc():
LRESULT CALLBACK SpaceBallWindowProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) {
  SiGetEventWinInit (&eData, uMsg, wParam, lParam);
  if( SiGetEvent( hdl, 0, &eData, &siEvent ) == SI_IS_EVENT ) {
    if( enable_spaceball && is_safe ) {
      switch (siEvent.type) {
        case SI_MOTION_EVENT: {
          long *data = siEvent.u.spwData.mData;
          if( (data[SI_TX] != 0) || (data[SI_TY] != 0) || (data[SI_TZ] != 0) ) {
            if( move_rotate) {
              sprintf( command_buffer, "AddPosition %g %g %g", (double)data[ SI_TX ] / tscalar,
                                                               (double)data[ SI_TY ] / tscalar,
                                                               (double)data[ SI_TZ ] / tscalar );
            } else {
              sprintf( command_buffer, "AddScale %g %g %g", (double)data[ SI_TX ] / sscalar,
                                                            (double)data[ SI_TY ] / sscalar,
                                                            (double)data[ SI_TZ ] / sscalar );
            }

            command( command_buffer );
          }

          if( (data[SI_RX] != 0) || (data[SI_RY] != 0) || (data[SI_RZ] != 0) ) {
            sprintf( command_buffer, "AddRotation %g %g %g", (double)data[ SI_RY ] / -rscalar,
                                                             (double)data[ SI_RX ] / -rscalar,
                                                             (double)data[ SI_RZ ] / -rscalar );
            command( command_buffer );
          }
        } break;

        case SI_ZERO_EVENT:
        
          break;

        case SI_BUTTON_EVENT: {
          int index = SiButtonPressed( &siEvent );
          if( index == SI_NO_BUTTON )
            break;

//          if( index == SPW_ERROR )
//            break;

          if( (index < 1) && (index > 29) )
            break;

          index--;
          if( function_map[ index ] == NULL )
            break;

          command( function_map[ index ] );
//          command( "Generic_TM-P_SpaceBallToggle"DEBUG_PLUGIN_PLUGNAME );
        } break;

        default:
          break;
      }
    }
  }
    
  return CallWindowProc( orig_window_proc, hwnd, uMsg, wParam, lParam );
}
bool nativeEventFilter(const QByteArray & eventType, void * message, long * result) {
  // On Windows, eventType is set to "windows_generic_MSG" for messages sent
  // to toplevel windows, and "windows_dispatcher_MSG" for system - wide
  // messages such as messages from a registered hot key.In both cases, the
  // message can be casted to a MSG pointer.The result pointer is only used
  // on Windows, and corresponds to the LRESULT pointer.
  MSG & msg = *(MSG*)message;
  SiSpwEvent siEvent;
  vec3 tr, ro;
  long * md = siEvent.u.spwData.mData;
  SiGetEventWinInit(&getEventData, msg.message, msg.wParam, msg.lParam);
  if (SiGetEvent(si, 0, &getEventData, &siEvent) == SI_IS_EVENT) {
    switch (siEvent.type) {
    case SI_MOTION_EVENT:
      emit sixDof(
        vec3(md[SI_TX], md[SI_TY], -md[SI_TZ]),
        vec3(md[SI_RX], md[SI_RY], md[SI_RZ]));
      break;

    default:
      break;
    }
    return true;
  }
  return false;
}
Exemplo n.º 5
0
int DispatchLoopNT(SiSpwHandlers *DspHandlers)
{

   SiGetEventData EData;
   SiSpwEvent Event;
   MSG msg;
   BOOL handledEvent = FALSE;
   SpaceballControlStruct *scs = (SpaceballControlStruct *)
                                 (DspHandlers->motion.data);
  SpaceballAppDataStruct *ads = (SpaceballAppDataStruct *)(scs->appData);

  while ( GetMessage( &msg, NULL, 0, 0 ) )
    {
      handledEvent = FALSE;
      if (scs->devHdl)
         {
         SiGetEventWinInit (&EData, msg.message, msg.wParam, msg.lParam);
         if (SiGetEvent (scs->devHdl, 0, &EData, &Event) == SI_IS_EVENT)
            {
            SiDispatch (scs->devHdl, &EData, &Event, DspHandlers);
            handledEvent = TRUE;
            }
         }
      if (handledEvent == FALSE)
        {
          TranslateMessage( &msg );
          DispatchMessage( &msg );
        }

      if (ads->redraw == 1) 
         InvalidateRect(hWndMain, NULL, FALSE);
    }
  return( msg.wParam );
  
} /* end of DispatchLoopNT */
Exemplo n.º 6
0
/*--------------------------------------------------------------------------
 * 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 );
}
static int vmd_processwin32spaceballevent(wgldata *glwsrv, UINT msg, WPARAM wParam, LPARAM lParam) {

  if (glwsrv == NULL)
    return 0;

  if (glwsrv->sball == NULL) 
    return 0;  // no spaceball attached/running
 
  // Check to see if this message is a spaceball message
  SiGetEventWinInit(&glwsrv->spwedata, msg, wParam, lParam);

  if (SiGetEvent(glwsrv->sball, 0, &glwsrv->spwedata, &glwsrv->spwevent) == SI_IS_EVENT) {
    return 1;
  }

  return 0;
}