⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pmdconio.c

📁 一个机器人的源代码.软件设计得超级好!是商业级代码.
💻 C
字号:
/*****************************************************************************   $Workfile: PMDconio.c $    $Revision: 7 $    Purpose: Console IO redirector/****************************************************************************/#include <stdio.h>#include <stdarg.h>#ifdef _LINUX#include "/usr/include/time.h"#include <sys/time.h>#else#include <sys/timeb.h>#endif#ifdef _CONSOLE    #include <conio.h>#elif _WINDOWS#include <windows.h>#elif _LINUX#ifdef __cplusplusextern "C" {#endif#ifdef WIN32#include "ConsFunc.h"   /* PLX utility */#endif#ifdef __cplusplus}#endif   //cplusplus#endif   // _LINUX#include "PMDconio.h"static PRINTFN (*reprintf)(const char*, ...) =//#ifndef WIN32// 			PlxPrintf;//#else 			printf;//#endif//*****************************************************************************void SetPMDprintf(PRINTFN (*fn)(const char*, ...)){    reprintf = fn;}//*****************************************************************************void PMDprintf( char *fmt, ... ){    char buff[200];    va_list arglist;    va_start( arglist, fmt );    vsprintf( buff, fmt, arglist );    va_end( arglist );    reprintf( buff );}//*****************************************************************************// check for a key to be hit on the keyboardint PMDkbhit(){#ifdef _CONSOLE     // call getch after kbhit to absorb the character    return (kbhit() && getch());#elif _WINDOWS    // If the most significant bit is set, the key is down, and if the least significant bit is set,     // the key was pressed after the previous call to GetAsyncKeyState.     return ((GetAsyncKeyState(VK_ESCAPE) & 0x8000) || (GetAsyncKeyState(VK_SPACE) & 0x8000));#elif _LINUX    //     return (Plx_kbhit() && getch());	#else    return 0;#endif}//*****************************************************************************void HostDelay(int milliseconds){#ifdef _LINUX	struct timeval currentTime;#else        struct timeb currentTime;#endif	unsigned long stopms;	unsigned long currentms;#ifdef _LINUX    gettimeofday(&currentTime, NULL);    stopms = currentTime.tv_sec * 1000l + currentTime.tv_usec/1000l;#else    ftime( &currentTime );    stopms = currentTime.time * 1000 + currentTime.millitm;#endif    stopms += milliseconds;	do	{#ifdef _LINUX    	    gettimeofday(&currentTime, NULL);    	    currentms = currentTime.tv_sec * 1000l + currentTime.tv_usec/1000l;#else            ftime( &currentTime );	    currentms = currentTime.time * 1000  + currentTime.millitm;#endif	}        while (currentms <= stopms);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -