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 */
int WINAPI WinMain ( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow ) { SpaceballControlStruct scs; SpaceballAppDataStruct app; PointStr World[2]; char fname[256]; float CTM[4][4]; /* Current transformation matrix */ SiSpwHandlers DspHandlers; LONG addr = (long)&scs; HWND wndScreen; RECT screenRect; int size; DWORD dSizeNeeded; char appDir[256]; //int ssize; //char DirName[256]; ncmdshow = nCmdShow; //FILE *fp; /* * Figure out how big the screen is so that we can make our * window an appropriate size. */ wndScreen = GetDesktopWindow(); GetWindowRect ( wndScreen, &screenRect ); size = (int)(.8 * SPW_MIN( (screenRect.bottom - screenRect.top), (screenRect.right - screenRect.left) )); Spw_WindowWidth = size; Spw_WindowHeight = size; /* Add code to parse command line for alternate file --here-- */ /* Code that finds the default data file in its usual spot */ // if (0 != (dSizeNeeded = GetCurrentDirectory(256, appDir))) if (0 != (dSizeNeeded = GetModuleFileName(NULL, appDir, 256 ))) { char widgetUStr[] = "WIDGET\0"; char widgetLStr[] = "widget\0"; char DirName[256]; char *pdest; int result; FILE *fp; /* find "widget" in directory string */ pdest = strstr( appDir, widgetUStr ); if (pdest == NULL) { pdest = strstr( appDir, widgetLStr ); } if (pdest != NULL) { /* get the index of the end of "widget" */ result = pdest - appDir + strlen(widgetUStr); /* snip everything after "widget" */ appDir[result] = '\0'; /* build the file name */ strcpy(DirName, appDir); strcat(DirName, "\\dat\\widget.dat"); } /* see if we can open the file */ if (NULL != (fp=fopen(DirName, "r"))) { fclose(fp); /* close it back up */ strcpy(fname, DirName); /* save the file name */ } else /* file is in a non standard location; let user find it */ { strcpy(fname, "*.dat"); GetNTFileName( NULL, fname ); } } /* * Initialize the Spaceball data structures */ /* Spaceball tuning values */ scs.sbScaleFactor[0] = (float)0.05; scs.sbScaleFactor[1] = (float)0.05; scs.sbScaleFactor[2] = (float)0.005; scs.sbScaleFactor[3] = (float)0.0005; scs.sbScaleFactor[4] = (float)0.0005; scs.sbScaleFactor[5] = (float)0.0005; /* Initialize platform-independent data */ MainInitialize (fname, &scs, &app, (float *)CTM, World); MoveWindow(hWndMain, 300, 0, Spw_WindowWidth, Spw_WindowHeight, TRUE); SetClassLong(hWndMain, 0, (LONG)(&scs)); /* * Initialize the Spaceball, render initial scene */ InitializeSpaceball(0, hWndMain, &DspHandlers, &scs); ResetWidgetView( (float(*)[4])app.CTM, app.center ); app.redraw = TRUE; InvalidateRect(hWndMain, NULL, FALSE); return(DispatchLoopNT(&DspHandlers)); } /* end of WinMain */