void drawXY()//绘制X和Y轴 { HWND hWnd=GetConsoleHwnd();//获取控制台窗口句柄,用于设置画笔颜色 HDC hDC=GetDC(hWnd); COORD dwSize;//记录窗体大小,用于设定坐标轴远点 HPEN hNewPen=CreatePen(PS_SOLID,1,RGB(255,0,0));//创建画笔对象 HPEN hOldPen=(HPEN)SelectObject(hDC,hNewPen);//选取画笔对象进行绘图 CONSOLE_SCREEN_BUFFER_INFO bInfo; // 窗口信息 HANDLE Hout=GetStdHandle(STD_OUTPUT_HANDLE);//获取控制台句柄 GetConsoleScreenBufferInfo(Hout, &bInfo );//获取控制台信息 dwSize=bInfo.dwMaximumWindowSize ;//获取窗口大小,此时获得的是字符模式下 //从字符到图像放大坐标轴8倍 dwSize.X *=8; dwSize.Y*=8; SetBkMode(hDC, TRANSPARENT);SetTextColor(hDC,255*255); //绘制X轴各个特殊坐标 TextOut(hDC,dwSize.X-15,dwSize.Y/2-15,"X",1); //Arc(hDC,100,100,300,300,350,500,350,500);//画圆 其中hDC表示画图句柄,100,100,300,300表示所使用的矩形区域,350,500表示画弧线的起点,350,500表明画弧线的终点 ; //绘制Y轴各个特殊坐标 TextOut(hDC,dwSize.X/2,0,"Y",1); MoveToEx(hDC,0,dwSize.Y /2,NULL); LineTo(hDC,dwSize.X,dwSize.Y/2); MoveToEx(hDC,dwSize.X/2,0,NULL); LineTo(hDC,dwSize.X/2,dwSize.Y); ReleaseDC(hWnd,hDC); }
static void check_cygwin_console(void) { char *term = getenv("TERM"); HANDLE hWnd; if (term == NULL) term = DEFAULT_TERM; if (term && strncmp(term, "cygwin", 6) == 0) { isWinConsole = TERM_CYGWIN; } if (isWinConsole) { hWnd = GetConsoleHwnd(); if (hWnd != INVALID_HANDLE_VALUE) { if (IsWindowVisible(hWnd)) { isLocalConsole = 1; } } if (strncmp(getenv("LANG"), "ja", 2) == 0) { isWinConsole = TERM_CYGWIN_RESERVE_IME; } #ifdef SUPPORT_WIN9X_CONSOLE_MBCS check_win9x(); if (isWin95 && ttyslot() != -1) { isLocalConsole = 0; } #endif } #if CYGWIN_VERSION_DLL_MAJOR < 1005 && defined(USE_MOUSE) if (cygwin_version() <= 1003015) { /* cygwin DLL 1.3.15 or earler */ cygwin_mouse_btn_swapped = 1; } #endif }
C_RESULT open_dx_keyboard(void) { HRESULT hr; HWND hDlg = GetConsoleHwnd(); // Register with the DirectInput subsystem and get a pointer // to a IDirectInput interface we can use. // Create a DInput object if (g_pDI==NULL) if( VP_FAILED( hr = DirectInput8Create( GetModuleHandle( NULL ), DIRECTINPUT_VERSION, IID_IDirectInput8, ( VOID** )&g_pDI, NULL ) ) ) return hr; // Create the connection to the keyboard device g_pDI->CreateDevice(GUID_SysKeyboard, &fDIKeyboard, NULL); if (fDIKeyboard) { fDIKeyboard->SetDataFormat(&c_dfDIKeyboard); fDIKeyboard->SetCooperativeLevel(hDlg,DISCL_FOREGROUND | DISCL_EXCLUSIVE); fDIKeyboard->Acquire(); } return C_OK; }
void draw(double p) { int i; double x,y; HWND hWnd=GetConsoleHwnd();//获取控制台窗口句柄,用于设置画笔颜色 HDC hDC=GetDC(hWnd); COORD dwSize;//记录窗体大小,用于设定坐标轴远点 HPEN hNewPen=CreatePen(PS_SOLID,1,RGB(255,0,0));//创建画笔对象 HPEN hOldPen=(HPEN)SelectObject(hDC,hNewPen);//选取画笔对象进行绘图 CONSOLE_SCREEN_BUFFER_INFO bInfo; // 窗口信息 HANDLE Hout=GetStdHandle(STD_OUTPUT_HANDLE);//获取控制台句柄 GetConsoleScreenBufferInfo(Hout, &bInfo );//获取控制台信息 dwSize=bInfo.dwMaximumWindowSize ;//获取窗口大小,此时获得的是字符模式下 //从字符到图像放大坐标轴8倍 dwSize.X *=8; dwSize.Y*=8; //MoveToEx(hDC,0,dwSize.Y/2,NULL); for(i=-180;i<=180;i++) { x=16*pow(sin(i*3.1415926/180),3.0)*p; y=(13*cos(i*3.1415926/180)-5*cos(2*i*3.1415926/180)-2*cos(3*i*3.1415926/180)-cos(4*i*3.1415926/180))*p; x=(x+16)*dwSize.X/32/2+dwSize.X/4; y=-y/16*dwSize.Y/2.3+dwSize.Y/2; x=x; y=y; MoveToEx(hDC,x,y,NULL); LineTo(hDC,x+1,y+1); } }
HWND mswindows_get_console_hwnd (void) { if (!mswindows_console_hwnd) mswindows_console_hwnd = GetConsoleHwnd (); return mswindows_console_hwnd; }
void *Audio_DirectX::open (AudioConfig &cfg, const char *name) { HWND hwnd; // Assume we have a console. Use other other // if we have a non console Window hwnd = GetConsoleHwnd (); return open (cfg, name, hwnd); }
bool CTextConsoleWin32::Init(IBaseSystem *system) { if (!AllocConsole()) m_System = system; SetTitle(m_System ? m_System->GetName() : "Console"); hinput = GetStdHandle(STD_INPUT_HANDLE); houtput = GetStdHandle(STD_OUTPUT_HANDLE); if (!SetConsoleCtrlHandler(&ConsoleHandlerRoutine, TRUE)) { Print("WARNING! TextConsole::Init: Could not attach console hook.\n"); } Attrib = FOREGROUND_GREEN | FOREGROUND_INTENSITY | BACKGROUND_INTENSITY; SetWindowPos(GetConsoleHwnd(), HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOREPOSITION | SWP_SHOWWINDOW); return CTextConsole::Init(system); }
int main(void) { printf("A sample on how to use RakVoice together with DirectSound.\n"); printf("You need a microphone for this sample.\n"); printf("RakVoice relies on Speex for voice encoding and decoding.\n"); printf("See DependentExtensions/RakVoice/speex-1.2beta3 for speex projects.\n"); printf("For windows, I had to define HAVE_CONFIG_H, include win32/config.h,\n"); printf("and include the files under libspeex, except those that start with test.\n"); printf("Difficulty: Advanced\n\n"); bool mute=false; bool quit; char ch; char port[256]; rakPeer = RakNetworkFactory::GetRakPeerInterface(); #if defined(INTERACTIVE) printf("Enter local port: "); gets(port); if (port[0]==0) #endif strcpy(port, "60000"); SocketDescriptor socketDescriptor(atoi(port),0); rakPeer->Startup(4, 30, &socketDescriptor, 1); rakPeer->SetMaximumIncomingConnections(4); rakPeer->AttachPlugin(&rakVoice); rakVoice.Init(SAMPLE_RATE, FRAMES_PER_BUFFER*sizeof(SAMPLE)); // Initialize our connection with DirectSound if (!DSoundVoiceAdapter::Instance()->SetupAdapter(&rakVoice, GetConsoleHwnd(), DSSCL_EXCLUSIVE)) { printf("An error occurred while initializing DirectSound.\n"); exit(-1); } Packet *p; quit=false; #if defined(INTERACTIVE) printf("(Q)uit. (C)onnect. (D)isconnect. (M)ute. ' ' for stats.\n"); printf("(+/-)encoder complexity. (N)oise filter on/off. (V)AD on/off. (B)vbr on/off.\n"); #else rakPeer->Connect("1.1.1.1", 60000, 0,0); #endif PrintParameters(); while (!quit) { #if defined(INTERACTIVE) if (kbhit()) { ch=getch(); if (ch=='+'){ // Increase encoder complexity int v = rakVoice.GetEncoderComplexity(); if (v<10) rakVoice.SetEncoderComplexity(v+1); PrintParameters(); } else if (ch=='-'){ // Decrease encoder complexity int v = rakVoice.GetEncoderComplexity(); if (v>0) rakVoice.SetEncoderComplexity(v-1); PrintParameters(); } else if (ch=='n'){ // Turn on/off noise filter rakVoice.SetNoiseFilter(!rakVoice.IsNoiseFilterActive()); PrintParameters(); } else if (ch=='v') { // Turn on/off Voice detection rakVoice.SetVAD(!rakVoice.IsVADActive()); PrintParameters(); } else if (ch=='b') { // Turn on/off VBR rakVoice.SetVBR(!rakVoice.IsVBRActive()); PrintParameters(); } else if (ch=='y') { quit=true; } else if (ch=='c') { char ip[256]; printf("\nEnter IP of remote system: "); gets(ip); if (ip[0]==0) strcpy(ip, "127.0.0.1"); printf("\nEnter port of remote system: "); gets(port); if (port[0]==0) strcpy(port, "60000"); rakPeer->Connect(ip, atoi(port), 0,0); } else if (ch=='m') { mute=!mute; DSoundVoiceAdapter::Instance()->SetMute(mute); if (mute) printf("\nNow muted.\n"); else printf("\nNo longer muted.\n"); } else if (ch=='d') { rakPeer->Shutdown(100,0); } else if (ch==' ') { char message[2048]; RakNetStatistics *rss=rakPeer->GetStatistics(rakPeer->GetSystemAddressFromIndex(0)); StatisticsToString(rss, message, 2); printf("%s", message); } else if (ch=='q') quit=true; ch=0; } #endif p=rakPeer->Receive(); while (p) { if (p->data[0]==ID_CONNECTION_REQUEST_ACCEPTED) { printf("\nID_CONNECTION_REQUEST_ACCEPTED from %s\n", p->systemAddress.ToString()); rakVoice.RequestVoiceChannel(p->systemAddress); } else if (p->data[0]==ID_RAKVOICE_OPEN_CHANNEL_REQUEST) { printf("\nOpen Channel request from %s\n", p->systemAddress.ToString()); } else if (p->data[0]==ID_RAKVOICE_OPEN_CHANNEL_REPLY) { printf("\nGot new channel from %s\n", p->systemAddress.ToString()); } rakPeer->DeallocatePacket(p); p=rakPeer->Receive(); } // Update our connection with DirectSound DSoundVoiceAdapter::Instance()->Update(); LogStats(); RakSleep(20); } // Release any FMOD resources we used, and shutdown FMOD itself DSoundVoiceAdapter::Instance()->Release(); rakPeer->Shutdown(300); RakNetworkFactory::DestroyRakPeerInterface(rakPeer); return 0; }
C_RESULT open_dx_gamepad(void) { HRESULT hr; HWND hDlg = GetConsoleHwnd(); // Register with the DirectInput subsystem and get a pointer // to a IDirectInput interface we can use. // Create a DInput object if (g_pDI==NULL) if( VP_FAILED( hr = DirectInput8Create( GetModuleHandle( NULL ), DIRECTINPUT_VERSION, IID_IDirectInput8, ( VOID** )&g_pDI, NULL ) ) ) return hr; if( g_bFilterOutXinputDevices ) SetupForIsXInputDevice(); DIJOYCONFIG PreferredJoyCfg = {0}; DI_ENUM_CONTEXT enumContext; enumContext.pPreferredJoyCfg = &PreferredJoyCfg; enumContext.bPreferredJoyCfgValid = false; IDirectInputJoyConfig8* pJoyConfig = NULL; if( VP_FAILED( hr = g_pDI->QueryInterface( IID_IDirectInputJoyConfig8, ( void** )&pJoyConfig ) ) ) return hr; PreferredJoyCfg.dwSize = sizeof( PreferredJoyCfg ); if( SUCCEEDED( pJoyConfig->GetConfig( 0, &PreferredJoyCfg, DIJC_GUIDINSTANCE ) ) ) // This function is expected to fail if no g_pJoystick is attached enumContext.bPreferredJoyCfgValid = true; SAFE_RELEASE( pJoyConfig ); // Look for a simple g_pJoystick we can use for this sample program. if( VP_FAILED( hr = g_pDI->EnumDevices( DI8DEVCLASS_GAMECTRL, Enumg_pJoysticksCallback, &enumContext, DIEDFL_ATTACHEDONLY ) ) ) return hr; if( g_bFilterOutXinputDevices ) CleanupForIsXInputDevice(); // Make sure we got a g_pJoystick if( g_pJoystick == NULL ) { //MessageBox( NULL, TEXT( "Joystick not found." ), // TEXT( "A.R. Drone"), // MB_ICONERROR | MB_OK ); // EndDialog( hDlg, 0 ); return C_FAIL; } // Set the data format to "simple g_pJoystick" - a predefined data format // // A data format specifies which controls on a device we are interested in, // and how they should be reported. This tells DInput that we will be // passing a DIJOYSTATE2 structure to IDirectInputDevice::GetDeviceState(). if( VP_FAILED( hr = g_pJoystick->SetDataFormat( &c_dfDIJoystick2 ) ) ) return C_FAIL; // Set the cooperative level to let DInput know how this device should // interact with the system and with other DInput applications. if( VP_FAILED( hr = g_pJoystick->SetCooperativeLevel( hDlg , DISCL_EXCLUSIVE | DISCL_FOREGROUND ) ) ) return C_FAIL; // Enumerate the g_pJoystick objects. The callback function enabled user // interface elements for objects that are found, and sets the min/max // values property for discovered axes. if( VP_FAILED( hr = g_pJoystick->EnumObjects( EnumObjectsCallback, ( VOID* )hDlg, DIDFT_ALL ) ) ) return C_FAIL; return C_OK; }
int __cdecl main(int argc, char** argv) { static struct wdi_device_info *ldev, dev = {NULL, VID, PID, FALSE, 0, DESC, NULL, NULL, NULL}; static struct wdi_options_create_list ocl = { 0 }; static struct wdi_options_prepare_driver opd = { 0 }; static struct wdi_options_install_driver oid = { 0 }; static struct wdi_options_install_cert oic = { 0 }; static int opt_silent = 0, opt_extract = 0, log_level = WDI_LOG_LEVEL_WARNING; static BOOL matching_device_found; int c, r; char *inf_name = INF_NAME; char *ext_dir = DEFAULT_DIR; char *cert_name = NULL; static struct option long_options[] = { {"name", required_argument, 0, 'n'}, {"inf", required_argument, 0, 'f'}, {"manufacturer", required_argument, 0, 'm'}, {"vid", required_argument, 0, 'v'}, {"pid", required_argument, 0, 'p'}, {"iid", required_argument, 0, 'i'}, {"type", required_argument, 0, 't'}, {"filter", no_argument, 0, 2}, {"wcid", no_argument, 0, 'w'}, {"dest", required_argument, 0, 'd'}, {"cert", required_argument, 0, 'c'}, {"extract", no_argument, 0, 'x'}, {"silent", no_argument, 0, 's'}, {"stealth-cert", no_argument, 0, 1}, {"progressbar", optional_argument, 0, 'b'}, {"log", required_argument, 0, 'l'}, {"timeout", required_argument, 0, 'o'}, {"help", no_argument, 0, 'h'}, {0, 0, 0, 0} }; ocl.list_all = TRUE; ocl.list_hubs = TRUE; ocl.trim_whitespaces = TRUE; opd.driver_type = WDI_WINUSB; while(1) { c = getopt_long(argc, argv, "n:f:m:d:c:v:p:i:l:t:o:hxsb", long_options, NULL); if (c == -1) break; switch(c) { case 1: // --stealth-cert oic.disable_warning = TRUE; break; case 2: // --filter oid.install_filter_driver = TRUE; break; case 'n': dev.desc = optarg; break; case 'm': opd.vendor_name = optarg; break; case 'f': inf_name = optarg; break; case 'd': ext_dir = optarg; break; case 'c': cert_name = optarg; break; case 'v': dev.vid = (unsigned short)strtol(optarg, NULL, 0); break; case 'o': oid.pending_install_timeout = (DWORD)strtoul(optarg, NULL, 0); break; case 'p': dev.pid = (unsigned short)strtol(optarg, NULL, 0); break; case 'i': dev.is_composite = TRUE; dev.mi = (unsigned char)strtol(optarg, NULL, 0); break; case 't': opd.driver_type = (int)strtol(optarg, NULL, 0); break; case 'w': opd.use_wcid_driver = TRUE; break; case 'h': usage(); exit(0); break; case 'x': opt_extract = 1; break; case 's': opt_silent = 1; log_level = WDI_LOG_LEVEL_NONE; break; case 'b': oid.hWnd = (optarg)?(HWND)strtol(optarg, NULL, 0):GetConsoleHwnd(); oic.hWnd = oid.hWnd; break; case 'l': log_level = (int)strtol(optarg, NULL, 0); break; default: usage(); exit(0); } } wdi_set_log_level(log_level); oprintf("Extracting driver files...\n"); r = wdi_prepare_driver(&dev, ext_dir, inf_name, &opd); oprintf(" %s\n", wdi_strerror(r)); if ((r != WDI_SUCCESS) || (opt_extract)) return r; if (cert_name != NULL) { oprintf("Installing certificate '%s' as a Trusted Publisher...\n", cert_name); r = wdi_install_trusted_certificate(cert_name, &oic); oprintf(" %s\n", wdi_strerror(r)); } oprintf("Installing driver(s)...\n"); // Try to match against a plugged device to avoid device manager prompts matching_device_found = FALSE; if (wdi_create_list(&ldev, &ocl) == WDI_SUCCESS) { r = WDI_SUCCESS; for (; (ldev != NULL) && (r == WDI_SUCCESS); ldev = ldev->next) { if ( (ldev->vid == dev.vid) && (ldev->pid == dev.pid) && (ldev->mi == dev.mi) ) { dev.hardware_id = ldev->hardware_id; dev.device_id = ldev->device_id; matching_device_found = TRUE; oprintf(" %s: ", dev.hardware_id); fflush(stdout); r = wdi_install_driver(&dev, ext_dir, inf_name, &oid); oprintf("%s\n", wdi_strerror(r)); } } } // No plugged USB device matches this one -> install driver if (!matching_device_found) { r = wdi_install_driver(&dev, ext_dir, inf_name, &oid); oprintf(" %s\n", wdi_strerror(r)); } return r; }
void CTextConsoleWin32::SetVisible(bool visible) { ShowWindow(GetConsoleHwnd(), visible ? SW_SHOW : SW_HIDE); m_ConsoleVisible = visible; }
int _tmain(int argc, _TCHAR* argv[]) { com_ptr<IDirectInput8> input(0); com_ptr<IDirectInputDevice8> device(0); HRESULT hr = 0; { IDirectInput8* ptr; hr = ::DirectInput8Create( ::GetModuleHandleA(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, reinterpret_cast<void**>(&ptr), 0); if (FAILED(hr)) { output("Failed to create DInput8 handle.\n"); return 0; } input = com_ptr<IDirectInput8>(ptr); } { IDirectInputDevice8* ptr; hr = input->CreateDevice(GUID_SysKeyboard, &ptr, 0); if (FAILED(hr)) { output("Failed to create keyboard device.\n"); return 0; } device = com_ptr<IDirectInputDevice8>(ptr); } hr = device->SetDataFormat(&c_dfDIKeyboard); if (FAILED(hr)) { output("Failed to set device data format.\n"); return 0; } hr = device->SetCooperativeLevel(GetConsoleHwnd(), DISCL_NONEXCLUSIVE | DISCL_FOREGROUND); if (FAILED(hr)) { output("Failed to set device cooperative level.\n"); return 0; } { DIPROPDWORD dipdw = {0}; dipdw.diph.dwSize = sizeof(DIPROPDWORD); dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER); dipdw.diph.dwObj = 0; dipdw.diph.dwHow = DIPH_DEVICE; dipdw.dwData = 8; // バッファのサイズ hr = device->SetProperty(DIPROP_BUFFERSIZE, &dipdw.diph); if (FAILED(hr)) { output("Failed to set device buffer size property.\n"); return 0; } } acquire_device acq(device.get()); keyboard kbd; while(!kbd.pressed(EscapeKey)) { kbd.reset(); HRESULT hr = device->GetDeviceState(KeyboardSize, kbd.data()); if (FAILED(hr)) { std::cout << "Failed to get keyboard device state\n"; break; } std::cout << std::hex; //for(byte_t i = 0; i != KeyboardSize; ++i) { byte_t i = 0; do { if (kbd.pressed(i)) std::cout << static_cast<size_t>(i) << " "; } while(i != KeyboardSize-1); //} std::cout << std::endl; ::Sleep(100); } return 0; }
void main(int argc, char **argv) { HWND hWin; vrpn_Sound_Server_A3D * soundServer = NULL; vrpn_Tracker_Remote * tracker_connection; char tracker_device[512]; char tracker_name[512]; vrpn_Connection * connection; vrpn_Connection * trackerCon; int got_report; int USE_TRACKER; char * config_file_name = "vrpn.cfg"; FILE * config_file; char * client_name = NULL; int client_port = 4150; int bail_on_error = 1; int verbose = 1; int auto_quit = 0; int realparams = 0; int loop = 0; int port = vrpn_DEFAULT_LISTEN_PORT_NO; connection = new vrpn_Synchronized_Connection (port); // Open the configuration file if (verbose) printf("Reading from config file %s\n", config_file_name); if ( (config_file = fopen(config_file_name, "r")) == NULL) { perror("Cannot open config file"); printf(" (filename %s)\n", config_file_name); return; } // Read the configuration file, creating a device for each entry. // Each entry is on one line, which starts with the name of the // class of the object that is to be created. // If we fail to open a certain device, print a message and decide // whether we should bail. { char line[512]; // Line read from the input file char *pch; char scrap[512], s2[512]; // Read lines from the file until we run out while ( fgets(line, sizeof(line), config_file) != NULL ) { // Make sure the line wasn't too long if (strlen(line) >= sizeof(line)-1) { printf("Line too long in config file: %s\n",line); if (bail_on_error) { return; } else { continue; } // Skip this line } if ((strlen(line)<3)||(line[0]=='#')) { // comment or empty line -- ignore continue; } // copy for strtok work strncpy(scrap, line, sizeof(line) - 1); // Figure out the device from the name and handle appropriately // WARNING: SUBSTRINGS WILL MATCH THE EARLIER STRING, SO // ADD AN EMPTY SPACE TO THE END OF STATIC STRINGS!!!! // #define isit(s) !strncmp(line,s,strlen(s)) #define isit(s) !strcmp(pch=strtok(scrap," \t"),s) #define next() pch += strlen(pch) + 1 #ifdef _WIN32 if(isit("vrpn_Sound_Server")) { printf("%s\n",pch); next(); printf("%s\n",pch); if (sscanf(pch,"%511s\t%d\t%511s\t%511s",s2,&USE_TRACKER,tracker_name, tracker_device) != 4) { printf("Bad vrpn_Server_Sound line: %s\n",line); if (bail_on_error) { return; } else { continue; } // Skip this line } hWin = GetConsoleHwnd(); printf("Begin initializing A3D Sound Server\n"); soundServer = NULL; soundServer = new vrpn_Sound_Server_A3D(s2, connection,hWin); if (soundServer == NULL) printf("Can't create sound server\n"); printf("End A3D Sound Server initialization\n"); } #endif } } fclose(config_file); // Open remote tracker if we are to use one if (USE_TRACKER) { char newname[1024]; sprintf(newname,"%s@%s",(const char*)tracker_device, (const char*)tracker_name); printf("Using tracker: %s\n",newname); trackerCon = vrpn_get_connection_by_name(tracker_name); tracker_connection = new vrpn_Tracker_Remote((const char *) newname); // SET UP TRACKER HANDLER if (trackerCon->doing_okay()) { printf( "TC OK.\n"); } else { printf( "TC Not OK.\n"); } } else printf("Not using tracker\n"); loop = 0; if (client_name) { printf( "vrpn_serv: connecting to client: %s:%d\n", client_name, client_port); if (connection->connect_to_client(client_name, client_port)) { printf( "server: could not connect to client %s:%d\n", client_name, client_port); } } // ******************************************************************** // ** ** // ** MAIN LOOP ** // ** ** // ******************************************************************** float fPrevTime = 0.0f; float fFrameTime; float fTime; int counter = 0; int stopNow = 0; int numconnections = 0; char buf[1024]; printf("Begin main loop\n"); while (!stopNow && !_kbhit()) { soundServer->GetLastError(buf); if (!strncmp(buf,"ERROR",5)) { printf("%s", buf); } counter++; // record time since last frame if (counter==NUM_SPIN) { fTime = (float)timeGetTime(); counter = 0; fFrameTime = (fTime - fPrevTime) * 0.001f; printf("Running at %4.2f Hz\n", (float) NUM_SPIN/fFrameTime); fPrevTime = fTime; } soundServer->mainloop(); // ensure we get a new report! if (USE_TRACKER) { tracker_connection->mainloop(); got_report = 0; if (trackerCon->doing_okay()) while (!got_report) tracker_connection->mainloop(); } // Send and receive all messages connection->mainloop(); if (numconnections==0 && connection->connected()) numconnections++; if (((numconnections!=0) & (!connection->connected())) | !connection->doing_okay()) { soundServer->shutDown(); numconnections=0; } } printf("about to shutdown\n"); // delete connection; delete soundServer; }