void PlatformSpecificCore(const char **argv) { int l_temppath; char temppath[MAX_PATH]; l_temppath=GetTempPath(MAX_PATH,temppath); if(l_temppath>=MAX_PATH) _bprintf(error,BUFSIZE,"Path to temporary files is too long."); else { strcpy(argpart1,"RAIN=FILE "); strcpy(argpart2,","); if(!GetTempFileName(temppath,"raincmd",0,raincmdname)) _bprintf(error,BUFSIZE,"Unable to create temporary filename."); else { if(!GetTempFileName(temppath,"rainrep",0,rainrepname)) _bprintf(error,BUFSIZE,"Unable to create temporary filename."); else { rainout=fopen(rainrepname,"w+t"); if (!rainout) _bprintf(error,BUFSIZE,"Unable to open rain reply file."); else { setbuf(rainout,NULL); fprintf(rainout,FULL "\n"); if (remove(raincmdname)) _bprintf(error,BUFSIZE,"Unable to remove rain command file."); else { input[0]=0; if ( putenv(strcat(strcpy(argfull,argpart1),argpart2)) ) _bprintf(error,BUFSIZE,"Too small environment.\n"); else { if (!quiet) { printf("Resident Audio Interface installed.\n"); installed=1; } if ( AppStarted(argv) ) { while ( !endRain ) { TalkPoll(); Sleep(5); //max 15ms, longer sleep interrupts mp3 decoding } AppClose(); } putenv("RAIN="); } } if(rainin) fclose(rainin); } fclose(rainout); } remove(rainrepname); } remove(raincmdname); } }
LRESULT kGUISystemMINGW::Event(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; int key; int newtick,deltatick; // printf("in Event...!\n"); // fflush(stdout); switch (message) { case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: // printf("Done Event...!\n"); // fflush(stdout); return DefWindowProc(hWnd, message, wParam, lParam); break; case WM_PAINT: // Get the Windows update region // printf("Wait...!\n"); // fflush(stdout); // while(kGUI::GetInDraw()==true || kGUI::GetInThread()==true); // printf("Done Wait...!\n"); // fflush(stdout); // kGUI::SetInDraw(true); GetUpdateRect(hWnd, &m_UpdateWinRect, FALSE); hdc = BeginPaint(hWnd, &ps); Draw(hWnd,m_UpdateWinRect.left,m_UpdateWinRect.right,m_UpdateWinRect.top,m_UpdateWinRect.bottom); EndPaint(hWnd, &ps); // kGUI::SetInDraw(false); break; case WM_TIMER: newtick=GetTickCount(); deltatick=newtick-m_lasttickcount; if(deltatick<0) deltatick=0; m_lasttickcount=newtick; #if DEBUGPRINT kGUI::Trace("Delta tick=%d\n",deltatick); #endif kGUI::Tick(deltatick); if(GetAsyncKeyState(VK_LSHIFT) || GetAsyncKeyState(VK_RSHIFT)) kGUI::SetKeyShift(true); else kGUI::SetKeyShift(false); if(GetAsyncKeyState(VK_CONTROL)) kGUI::SetKeyControl(true); else kGUI::SetKeyControl(false); if(kGUI::GetTempMouse()>=0) { int t=kGUI::GetTempMouse(); kGUI::SetTempMouse(t-1); if(!t) kGUI::SetMouseCursor(MOUSECURSOR_DEFAULT); } if(kGUI::GetMouseCursor()!=MOUSECURSOR_DEFAULT) /* if not default arrow */ kGUI::ChangeMouse(); // printf("Calling Input!\n"); // fflush(stdout); kGUI::UpdateInput(); // printf("Done Calling Input!\n"); // fflush(stdout); m_mousewheeldelta=0; // printf("Wait...!\n"); // fflush(stdout); // while(kGUI::GetInDraw()==true || kGUI::GetInThread()==true); // printf("Done Wait...!\n"); // fflush(stdout); // kGUI::SetInDraw(true); Draw(hWnd,0,0,0,0); // kGUI::SetInDraw(false); /* is the application shutting down? */ if(kGUI::IsAppClosed()==true) DestroyWindow(hWnd); else SetTimer(hWnd, 0, 1000 / FRAMES_PER_SECOND, NULL); break; case WM_DESTROY: /* sometimes this event get's called more than once, so allow only once! */ if(m_waskilled==false) { m_waskilled=true; AppClose(); kGUI::Close(); PostQuitMessage(0); WSACleanup(); } break; case WM_MOUSEWHEEL: //values are incrments of 120 m_mousewheeldelta = GET_WHEEL_DELTA_WPARAM(wParam)/120; // m_mousewheeldelta = ( int ) ( ( short ) HIWORD( wParam ) )/120; kGUI::SetMouse(m_mousex,m_mousey,m_mousewheeldelta,m_mouseleftbutton,m_mouserightbutton); break; case WM_LBUTTONDOWN: case WM_LBUTTONUP: case WM_RBUTTONDOWN: case WM_RBUTTONUP: case WM_MOUSEMOVE: if(kGUI::GetMouseCursor()!=MOUSECURSOR_DEFAULT) /* if not default arrow */ kGUI::ChangeMouse(); m_mousex=GET_X_LPARAM(lParam); m_mousey=GET_Y_LPARAM(lParam); m_mouseleftbutton=(wParam&MK_LBUTTON)!=0; m_mouserightbutton=(wParam&MK_RBUTTON)!=0; /* this tells windows to keep updating me even if the mouse is moved off of */ /* my window area */ if(m_mouseleftbutton || m_mouserightbutton) SetCapture(hWnd); else ReleaseCapture(); kGUI::SetMouse(m_mousex,m_mousey,m_mousewheeldelta,m_mouseleftbutton,m_mouserightbutton); kGUI::Tick(0); kGUI::UpdateInput(); // printf("Done Event...!\n"); // fflush(stdout); return DefWindowProc(hWnd, message, wParam, lParam); break; case WM_CHAR: key=(int)wParam; switch(key) { case 1: //'ctrl-a' key=GUIKEY_SELECTALL; break; case 3: //'ctrl-c' key=GUIKEY_COPY; break; case 6: //'ctrl-f' key=GUIKEY_FIND; break; case 22: //'ctrl-v' key=GUIKEY_PASTE; break; case 24: //'ctrl-x' key=GUIKEY_CUT; break; case 26: //'ctrl-z' key=GUIKEY_UNDO; break; case 187: //'ctrl +' key=GUIKEY_CTRL_PLUS; break; case 189: //'ctrl -' key=GUIKEY_CTRL_MINUS; break; case VK_BACK: key=GUIKEY_BACKSPACE; break; case VK_RETURN: key=GUIKEY_RETURN; break; case VK_TAB: if(GetAsyncKeyState(VK_LSHIFT) || GetAsyncKeyState(VK_RSHIFT)) key=GUIKEY_SHIFTTAB; else key=GUIKEY_TAB; break; case VK_ESCAPE: key=GUIKEY_ESC; break; case VK_SHIFT: case VK_CONTROL: key=0; break; } if(key) kGUI::KeyPressed(key); break; case WM_KEYDOWN: key=ConvertKey((int)wParam,0); if(key) kGUI::KeyPressed(key); key=ConvertKey((int)wParam,(int)wParam); if(key) kGUI::SetKeyState(key,true); break; case WM_KEYUP: key=ConvertKey((int)wParam,(int)wParam); if(key) kGUI::SetKeyState(key,false); break; default: // printf("Done Event...!\n"); // fflush(stdout); return DefWindowProc(hWnd, message, wParam, lParam); break; } // printf("Done Event...!\n"); // fflush(stdout); return 0; }
// // FUNCTION: InitInstance(HINSTANCE, int) // // PURPOSE: Saves instance handle and creates main window // // COMMENTS: // // In this function, we save the instance handle in a global variable and // create and display the main program window. // BOOL InitInstance(HINSTANCE hInstance, int nCmdShow, LPTSTR lpCmdLine) { HWND hWnd; TCHAR szTitle[MAX_LOADSTRING]; // title bar text TCHAR szWindowClass[MAX_LOADSTRING]; // main window class name g_hInst = hInstance; // Store instance handle in our global variable #if defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP) // SHInitExtraControls should be called once during your application's initialization to initialize any // of the device specific controls such as CAPEDIT and SIPPREF. SHInitExtraControls(); #endif // WIN32_PLATFORM_PSPC || WIN32_PLATFORM_WFSP LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); LoadString(hInstance, IDC_WCEVP, szWindowClass, MAX_LOADSTRING); #if defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP) //If it is already running, then focus on the window, and exit hWnd = FindWindow(szWindowClass, szTitle); if (hWnd) { // set focus to foremost child window // The "| 0x00000001" is used to bring any owned windows to the foreground and // activate them. SetForegroundWindow((HWND)((ULONG) hWnd | 0x00000001)); return 0; } #endif // WIN32_PLATFORM_PSPC || WIN32_PLATFORM_WFSP if (!MyRegisterClass(hInstance, szWindowClass)) { return FALSE; } hWnd = CreateWindow(szWindowClass, szTitle, WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL); if (!hWnd) { return FALSE; } #ifdef WIN32_PLATFORM_PSPC // When the main window is created using CW_USEDEFAULT the height of the menubar (if one // is created is not taken into account). So we resize the window after creating it // if a menubar is present if (g_hWndMenuBar) { RECT rc; RECT rcMenuBar; GetWindowRect(hWnd, &rc); GetWindowRect(g_hWndMenuBar, &rcMenuBar); rc.bottom -= (rcMenuBar.bottom - rcMenuBar.top); MoveWindow(hWnd, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, FALSE); } #endif // WIN32_PLATFORM_PSPC if (!AppInit(hWnd, lpCmdLine)) { AppClose(); return FALSE; } ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); #ifndef SHELL_AYGSHELL if (g_hWndCommandBar) { CommandBar_Show(g_hWndCommandBar, TRUE); } #endif // !SHELL_AYGSHELL return TRUE; }