#include "StdAfx.h"#include "process.h"#include "..\win2vcc\cmnhdr.h"Go to the source code of this file.
Defines | |
| #define | CLIENTNAME TEXT("Client0") | 
Functions | |
| MouseClient | mouseIn (TEXT("Client0")) | 
| The mouse Pipe. | |
| ScreenClient | screenOut (TEXT("Client0")) | 
| The screen Pipe. | |
| DWORD WINAPI | screenThread (LPVOID) | 
| int APIENTRY | WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) | 
Variables | |
| BYTE | palette0 [256 *3] | 
| An array of palette bytes. | |
| BYTE | screen0 [240 *320] | 
| An array of screen bytes. | |
| BYTE | palette1 [256 *3] | 
| An array of screen bytes. | |
| BYTE | screen1 [240 *320] | 
| An array of palette bytes. | |
Definition in file stubTest.cpp.
      
  | 
  
| 
 The screen pipe test thread Definition at line 146 of file stubTest.cpp. References palette0, palette1, screen0, screen1, and ScreenClient::write(). Referenced by WinMain(). 
 00147 {
00148     while( true ){
00149         if(!screenOut.write(240, 320, 256, 8, (RGBTRIPLE*) palette0, screen0))
00150             break;
00151         Sleep(1000);
00152 
00153         if(!screenOut.write(240, 320, 256, 8, (RGBTRIPLE*) palette1, screen1))
00154             break;
00155         Sleep(1000);
00156 
00157         if(!screenOut.write(240, 320, 256, 8, (RGBTRIPLE*) palette0, screen1))
00158             break;
00159         Sleep(1000);
00160 
00161         if(!screenOut.write(240, 320, 256, 8, (RGBTRIPLE*) palette1, screen0))
00162             break;
00163         Sleep(1000);
00164     }
00165     HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
00166     CHString msgString;
00167     msgString.Format(TEXT("\nSCREEN DIDN'T WRITE\n"));
00168     WriteConsole(console, msgString, msgString.GetLength(), NULL, NULL);
00169 
00170     return true;
00171 }
 | 
  
      
  | 
  ||||||||||||||||||||
| 
 StubTest entry point function. Definition at line 25 of file stubTest.cpp. References mouseMessage::button, PClient::connect(), MouseClient::connect(), MouseClient::deQueueMessage(), PClient::disconnect(), MouseClient::disconnect(), MI_NO_MESSAGE, MI_NOT_CONNECTED, MI_SUCCESS, MI_UNKNOWN_ERROR, palette0, palette1, PC_ALREADY_CONNECTED, PC_BUSY, PC_CONNECTED, PC_FAILED, screen0, screen1, screenThread(), mouseMessage::x, and mouseMessage::y. 
 00030 {
00031     AllocConsole();
00032     HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
00033     SetConsoleTitle(TEXT("VCC pipe IO Stub"));
00034     
00035     // Initialise the 2 screen buffers and palettes
00036 
00037     int i;
00038     for(i=0; i<256*3;){
00039         palette0[i] = i % 256;
00040         i++;
00041         palette0[i] = i % 128;
00042         i++;
00043         palette0[i] = (i % 60) * 4;
00044         i++;
00045     }
00046     
00047     for(i=0; i<240*320; i++){
00048         screen0[i] = i % 256;
00049     }
00050 
00051     
00052     srand( (unsigned)time( NULL ) );
00053     for(i=0; i<256*3;){
00054         palette1[i] = rand() % 256;
00055         i++;
00056         palette1[i] = rand() % 128 + 64;
00057         i++;
00058         palette1[i] = i % 256;
00059         i++;
00060     }
00061     
00062     for(i=0; i<240*320; i++){
00063         screen1[i] = rand() % 256;
00064     }
00065 
00066     CHString msgString;
00067 
00068     switch( mouseIn.connect() ){
00069     case PC_ALREADY_CONNECTED:
00070     case PC_CONNECTED:
00071         msgString.Format(TEXT("Mouse Connected\n"));
00072         WriteConsole(console, msgString, msgString.GetLength(), NULL, NULL);
00073         break;
00074     case PC_FAILED:
00075         msgString.Format(TEXT("Error Connecting Mouse\nExit in 4 seconds\n"));
00076         WriteConsole(console, msgString, msgString.GetLength(), NULL, NULL);
00077         Sleep(4000);
00078         return 1;
00079         break;
00080     case PC_BUSY:   
00081         msgString.Format(TEXT("Error - Mouse Pipe already connected\nExit in 4 seconds\n"));
00082         WriteConsole(console, msgString, msgString.GetLength(), NULL, NULL);
00083         Sleep(4000);
00084         return 1;
00085         break;
00086     }
00087 
00088     switch( screenOut.connect() ){
00089     case PC_ALREADY_CONNECTED:
00090     case PC_CONNECTED:
00091         msgString.Format(TEXT("Screen Connected\n"));
00092         WriteConsole(console, msgString, msgString.GetLength(), NULL, NULL);
00093         break;
00094     case PC_FAILED:
00095         msgString.Format(TEXT("Error Connecting Screen\nExit in 4 seconds\n"));
00096         WriteConsole(console, msgString, msgString.GetLength(), NULL, NULL);
00097         Sleep(4000);
00098         return 1;
00099         break;
00100     case PC_BUSY:   
00101         msgString.Format(TEXT("Error - Screen Pipe already connected\nExit in 4 seconds\n"));
00102         WriteConsole(console, msgString, msgString.GetLength(), NULL, NULL);
00103         Sleep(4000);
00104         return 1;
00105         break;
00106     }
00107 
00108 
00109     chBEGINTHREADEX(NULL, 0, &screenThread, NULL, 0, NULL);
00110 
00111     mouseMessage msg;
00112     bool exit = false;
00113     for(i = 1; i>0 && !exit;){
00114         switch( mouseIn.deQueueMessage(&msg) ){
00115         case MI_SUCCESS:
00116             msgString.Format(TEXT("%d: {%.3i,%.3i} %i\n"), i++, msg.x, msg.y, msg.button);
00117             WriteConsole(console, msgString, msgString.GetLength(), NULL, NULL);
00118             if( i % 9 == 0 ){ // simulate slow vcc
00119                 Sleep(1000);
00120             }
00121             break;
00122         case MI_NO_MESSAGE:
00123             Sleep(100);
00124             break;
00125         case MI_NOT_CONNECTED:
00126             msgString.Format(TEXT("Server Disconnected\n"));
00127             WriteConsole(console, msgString, msgString.GetLength(), NULL, NULL);
00128         case MI_UNKNOWN_ERROR:
00129         default:
00130             msgString.Format(TEXT("Error getting Message\n"));
00131             WriteConsole(console, msgString, msgString.GetLength(), NULL, NULL);
00132             Sleep(5000);
00133             exit = true;
00134         }
00135     }
00136 
00137     mouseIn.disconnect();
00138     screenOut.disconnect();
00139 
00140     FreeConsole();
00141     CloseHandle(console);
00142     return 0;
00143 }
 | 
  
1.2.13.1 written by Dimitri van Heesch,
 © 1997-2001