static void vmd_closewin32spaceball(wgldata *glwsrv) {
  enum SpwRetVal res;

  if (glwsrv->sball != NULL) {
    res = SiClose(glwsrv->sball); // close spaceball device
    if (res != SPW_NO_ERROR) 
      msgInfo << "An error occured while shutting down the Spaceball device." << sendmsg;

    SiTerminate();          // shutdown spaceware input library
  }

  glwsrv->sball = NULL;   // NULL out the handle.
}
예제 #2
0
// SpaceBall_End():
void SpaceBall_End() {
  // Release the globals
  global( "LW Command Interface",   GFUSE_RELEASE );
  global( LWINSTUPDATE_GLOBAL,      GFUSE_RELEASE );
  global( LWHOSTDISPLAYINFO_GLOBAL, GFUSE_RELEASE );
  global( LWMESSAGEFUNCS_GLOBAL,    GFUSE_RELEASE );

  // Shutdown the SpaceBall
  SiClose( hdl );
  SiTerminate();

  // Restore the Layout's window function
  SetWindowLong( hdi->window, GWL_WNDPROC, (long)orig_window_proc );
}
예제 #3
0
/* Stop receiving input from the spaceball */
void SPW_disableSpaceBallWin32(void)
{
  SiClose(Spw_DeviceHandle);
  SiTerminate();
  Spw_DeviceHandle = SI_NO_HANDLE;
}
예제 #4
0
//-----------------------------------------------------------------------------
// Entry point into the program.
//-----------------------------------------------------------------------------
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    LPSTR lpCmdLine, INT nCmdShow)
{
    Instance = hInstance;

    InitCommonControls();

    // A monospaced font
    FixedFont = CreateFont(SS.TW.CHAR_HEIGHT, SS.TW.CHAR_WIDTH, 0, 0,
        FW_REGULAR, false,
        false, false, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
        DEFAULT_QUALITY, FF_DONTCARE, "Lucida Console");
    if(!FixedFont)
        FixedFont = (HFONT)GetStockObject(SYSTEM_FONT);

    // Create the root windows: one for control, with text, and one for
    // the graphics
    CreateMainWindows();

    ThawWindowPos(TextWnd);
    ThawWindowPos(GraphicsWnd);

    ShowWindow(TextWnd, SW_SHOWNOACTIVATE);
    ShowWindow(GraphicsWnd, SW_SHOW);

    glClearColor(0, 0, 0, 1);
    glClear(GL_COLOR_BUFFER_BIT);
    SwapBuffers(GetDC(GraphicsWnd));
    glClearColor(0, 0, 0, 1);
    glClear(GL_COLOR_BUFFER_BIT);
    SwapBuffers(GetDC(GraphicsWnd));

    // Create the heaps for all dynamic memory (AllocTemporary, MemAlloc)
    InitHeaps();

    // A filename may have been specified on the command line; if so, then
    // strip any quotation marks, and make it absolute.
    char file[MAX_PATH] = "";
    if(strlen(lpCmdLine)+1 < MAX_PATH) {
        char *s = lpCmdLine;
        while(*s == ' ' || *s == '"') s++;
        strcpy(file, s);
        s = strrchr(file, '"');
        if(s) *s = '\0';
    }
    if(*file != '\0') {
        GetAbsoluteFilename(file);
    }

#ifdef HAVE_SPACEWARE
    // Initialize the SpaceBall, if present. Test if the driver is running
    // first, to avoid a long timeout if it's not.
    HWND swdc = FindWindow("SpaceWare Driver Class", NULL);
    if(swdc != NULL) {
        SiOpenData sod;
        SiInitialize();
        SiOpenWinInit(&sod, GraphicsWnd);
        SpaceNavigator =
            SiOpen("GraphicsWnd", SI_ANY_DEVICE, SI_NO_MASK, SI_EVENT, &sod);
        SiSetUiMode(SpaceNavigator, SI_UI_NO_CONTROLS);
    }
#endif

    // Call in to the platform-independent code, and let them do their init
    SS.Init();
    if(strcmp(file, ""))
        SS.OpenFile(file);

    // And now it's the message loop. All calls in to the rest of the code
    // will be from the wndprocs.
    MSG msg;
    DWORD ret;
    while((ret = GetMessage(&msg, NULL, 0, 0)) != 0) {
#ifdef HAVE_SPACEWARE
        // Is it a message from the six degree of freedom input device?
        if(ProcessSpaceNavigatorMsg(&msg)) goto done;
#endif

        // A message from the keyboard, which should be processed as a keyboard
        // accelerator?
        if(msg.message == WM_KEYDOWN) {
            if(ProcessKeyDown(msg.wParam)) goto done;
        }
        if(msg.message == WM_SYSKEYDOWN && msg.hwnd == TextWnd) {
            // If the user presses the Alt key when the text window has focus,
            // then that should probably go to the graphics window instead.
            SetForegroundWindow(GraphicsWnd);
        }

        // None of the above; so just a normal message to process.
        TranslateMessage(&msg);
        DispatchMessage(&msg);
done:
        SS.DoLater();
    }

#ifdef HAVE_SPACEWARE
    if(swdc != NULL) {
        if(SpaceNavigator != SI_NO_HANDLE) SiClose(SpaceNavigator);
        SiTerminate();
    }
#endif

    // Write everything back to the registry
    FreezeWindowPos(TextWnd);
    FreezeWindowPos(GraphicsWnd);

    // Free the memory we've used; anything that remains is a leak.
    SK.Clear();
    SS.Clear();

    return 0;
}