void SbButtonReleaseEvent(int button, void *appdata) { SpaceballControlStruct *scs = (SpaceballControlStruct *)appdata; SpaceballAppDataStruct *ads = (SpaceballAppDataStruct *)(scs->appData); static char *BeepString = "CcC"; switch(button) { case SI_PICK_BUTTON: { /* * Reset view and center of rotation. * * We do the "pick" button reset here, on release, so we * get less motion artifact, since the button is on the * ball itself for the Spaceball 2003. */ float *appCTM = (ads->CTM); ResetWidgetView( (float(*)[4])appCTM, ads->center); SiBeep(scs->devHdl, BeepString); ads->redraw = TRUE; ads->centerRot.Coord[0] = Spw_WindowWidth / (float)2.0; ads->centerRot.Coord[1] = Spw_WindowHeight / (float)2.0; } break; default: break; } } /* end of SbButtonReleaseEvent */
// SpaceBallState(): XCALL_ (int) SpaceBallState( long version, GlobalFunc *global, void *local, void *serverData, bool new_state ) { if( version != LWLAYOUTGENERIC_VERSION ) return AFUNC_BADVERSION; if( new_state == enable_spaceball ) return AFUNC_OK; if( new_state == true ) { SiBeep( hdl, "aAaAc" ); } else { SiBeep( hdl, "cAcAf" ); } enable_spaceball = new_state; return AFUNC_OK; }
// Windows code to talk to Spaceball device static void vmd_setupwin32spaceball(wgldata *glwsrv) { SiOpenData oData; enum SpwRetVal res; // init the sball pointer to NULL by default, used to determine if we // had a healthy init later on. glwsrv->sball = NULL; switch (SiInitialize()) { case SPW_NO_ERROR: break; case SPW_DLL_LOAD_ERROR: msgInfo << "Spaceball driver not installed. Spaceball interface disabled." << sendmsg; return; default: msgInfo << "Spaceball did not initialize properly. Spaceball interface disabled." << sendmsg; return; } SiOpenWinInit(&oData, glwsrv->hWnd); // init win platform data SiSetUiMode(glwsrv->sball, SI_UI_ALL_CONTROLS); // config softbutton display // actually start a connection to the device now that the UI mode // and window system data are setup. glwsrv->sball = SiOpen("VMD", SI_ANY_DEVICE, SI_NO_MASK, SI_EVENT, &oData); if ((glwsrv->sball == NULL) || (glwsrv->sball == SI_NO_HANDLE)) { SiTerminate(); // shutdown spaceware input library msgInfo << "Spaceball is unresponsive. Spaceball interface disabled." << sendmsg; glwsrv->sball = NULL; // NULL out the handle for sure. return; } res = SiBeep(glwsrv->sball, "CcCc"); // beep the spaceball if ((glwsrv->sball != NULL) && (glwsrv->sball != SI_NO_HANDLE)) msgInfo << "Spaceball found, software interface initialized." << sendmsg; }
void SbButtonPressEvent(int button, void *appdata) { SpaceballControlStruct *scs = (SpaceballControlStruct *)appdata; /* * C - 3/16 sec delay * c - 3/16 sec tone * This is done in case the server should bunch our beep events * together, we'll still get our beeps. */ static char *BeepString = "CcC"; switch(button) { case 1: scs->sbAllowTranslation = !scs->sbAllowTranslation; if (scs->sbAllowTranslation == TRUE) { SiBeep(scs->devHdl, BeepString); } /* We don't want both trans and rotate off at the same time! */ if (scs->sbAllowRotation == FALSE && scs->sbAllowRotation == FALSE) { scs->sbAllowRotation = TRUE; } break; case 2: scs->sbAllowRotation = !scs->sbAllowRotation; if (scs->sbAllowRotation == TRUE) { SiBeep(scs->devHdl, BeepString); } /* We don't want both trans and rotate off at the same time! */ if (scs->sbAllowRotation == FALSE && scs->sbAllowRotation == FALSE) { scs->sbAllowTranslation = TRUE; } break; case 3: scs->sbDominant = !scs->sbDominant; if (scs->sbDominant == TRUE) SiBeep(scs->devHdl, BeepString); break; case 5: scs->sbScale /= (float)2.0; SiBeep(scs->devHdl, BeepString); break; case 6: scs->sbScale *= (float)2.0; SiBeep(scs->devHdl, BeepString); break; case 7: scs->sbScale = (float)1.0; scs->sbDominant = FALSE; scs->sbAllowTranslation = TRUE; scs->sbAllowRotation = TRUE; SiBeep(scs->devHdl, BeepString); break; case 8: SiRezero(scs->devHdl); SiBeep(scs->devHdl, BeepString); break; default: break; } }