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

📄 getch.c

📁 BIOS emulator and interface to Realmode X86 Emulator Library Can emulate a PCI Graphic Controller V
💻 C
📖 第 1 页 / 共 2 页
字号:
	{KB_leftSquareBrace     ,"KB_leftSquareBrace"},	{KB_rightSquareBrace	,"KB_rightSquareBrace"},	{KB_enter               ,"KB_enter"},	{KB_A                   ,"KB_A"},	{KB_S                   ,"KB_S"},	{KB_D                   ,"KB_D"},	{KB_F                   ,"KB_F"},	{KB_G                   ,"KB_G"},	{KB_H                   ,"KB_H"},	{KB_J                   ,"KB_J"},	{KB_K                   ,"KB_K"},	{KB_L                   ,"KB_L"},	{KB_semicolon           ,"KB_semicolon"},	{KB_apostrophe          ,"KB_apostrophe"},	{KB_Z                   ,"KB_Z"},	{KB_X                   ,"KB_X"},	{KB_C                   ,"KB_C"},	{KB_V                   ,"KB_V"},	{KB_B                   ,"KB_B"},	{KB_N                   ,"KB_N"},	{KB_M                   ,"KB_M"},	{KB_comma               ,"KB_comma"},	{KB_period              ,"KB_period"},	{KB_divide              ,"KB_divide"},	{KB_space               ,"KB_space"},	{KB_tilde               ,"KB_tilde"},	{0						,"KB_unknown"},	};/****************************************************************************PARAMETERS:x	- X coordinate of the mouse cursor position (screen coordinates)y	- Y coordinate of the mouse cursor position (screen coordinates)REMARKS:This gets called periodically to move the mouse. It will get called whenthe mouse may not have actually moved, so check if it has before redrawingit.****************************************************************************/void EVTAPI moveMouse(	int x,	int y){}/****************************************************************************PARAMETERS:code	- Code to translatekeys	- Table of translation key values to look upREMARKS:Simple function to look up the printable name for the keyboard code.****************************************************************************/KeyEntry *FindKey(	int code,	KeyEntry *keys){	KeyEntry	*key;	for (key = keys; key->code != 0; key++) {		if (key->code == code)			break;		}	return key;}/****************************************************************************PARAMETERS:evt	- Event to display modifiers forREMARKS:Function to display shift modifiers flags****************************************************************************/void DisplayModifiers(	event_t *evt){	if (evt->modifiers & EVT_LEFTBUT)		printf(", LBUT");	if (evt->modifiers & EVT_RIGHTBUT)		printf(", RBUT");	if (evt->modifiers & EVT_MIDDLEBUT)		printf(", MBUT");	if (evt->modifiers & EVT_SHIFTKEY) {		if (evt->modifiers & EVT_LEFTSHIFT)			printf(", LSHIFT");		if (evt->modifiers & EVT_RIGHTSHIFT)			printf(", RSHIFT");		}	if (evt->modifiers & EVT_CTRLSTATE) {		if (evt->modifiers & EVT_LEFTCTRL)			printf(", LCTRL");		if (evt->modifiers & EVT_RIGHTCTRL)			printf(", RCTRL");		}	if (evt->modifiers & EVT_ALTSTATE) {		if (evt->modifiers & EVT_LEFTALT)			printf(", LALT");		if (evt->modifiers & EVT_RIGHTALT)			printf(", RALT");		}}/****************************************************************************PARAMETERS:msg	- Message to display for type of eventevt	- Event to displayREMARKS:Function to display the status of the keyboard event to the screen.****************************************************************************/void DisplayKey(	char *msg,	event_t *evt){	KeyEntry	*ascii,*scan;	char		ch = EVT_asciiCode(evt->message);	ascii = FindKey(ch,ASCIICodes);	scan = FindKey(EVT_scanCode(evt->message),ScanCodes);	printf("%s: 0x%04X -> %s, %s, '%c'",		msg, (int)evt->message & 0xFFFF, scan->name, ascii->name, isprint(ch) ? ch : ' ');	DisplayModifiers(evt);	printf("\n");}/****************************************************************************PARAMETERS:msg	- Message to display for type of eventevt	- Event to displayREMARKS:Function to display the status of the mouse event to the screen.****************************************************************************/void DisplayMouse(	char *msg,	event_t *evt){	printf("%s: ", msg);	if (evt->message & EVT_LEFTBMASK)		printf("LEFT ");	if (evt->message & EVT_RIGHTBMASK)		printf("RIGHT ");	if (evt->message & EVT_MIDDLEBMASK)		printf("MIDDLE ");	printf("abs(%d,%d), rel(%d,%d)", evt->where_x, evt->where_y, evt->relative_x, evt->relative_y);	DisplayModifiers(evt);	if (evt->message & EVT_DBLCLICK)		printf(", DBLCLICK");	printf("\n");}/****************************************************************************PARAMETERS:msg	- Message to display for type of eventevt	- Event to displayREMARKS:Function to display the status of the joystick event to the screen.****************************************************************************/void DisplayJoy(	char *msg,	event_t *evt){	printf("%s: Joy1(%4d,%4d,%c%c), Joy2(%4d,%4d,%c%c)\n", msg,		evt->where_x,evt->where_y,		(evt->message & EVT_JOY1_BUTTONA) ? 'A' : 'a',		(evt->message & EVT_JOY1_BUTTONB) ? 'B' : 'b',		evt->relative_x,evt->relative_y,		(evt->message & EVT_JOY2_BUTTONA) ? 'A' : 'a',		(evt->message & EVT_JOY2_BUTTONB) ? 'B' : 'b');}/****************************************************************************REMARKS:Joystick calibration routine****************************************************************************/void CalibrateJoy(void){  event_t evt;  if(EVT_joyIsPresent()){	printf("Joystick Calibration\nMove the joystick to the upper left corner and press any button.\n");	EVT_halt(&evt, EVT_JOYCLICK);	EVT_halt(&evt, EVT_JOYCLICK);	EVT_joySetUpperLeft();	printf("Move the joystick to the lower right corner and press any button.\n");	EVT_halt(&evt, EVT_JOYCLICK);	EVT_halt(&evt, EVT_JOYCLICK);	EVT_joySetLowerRight();	printf("Move the joystick to center position and press any button.\n");	EVT_halt(&evt, EVT_JOYCLICK);	EVT_halt(&evt, EVT_JOYCLICK);	EVT_joySetCenter();	printf("Joystick calibrated\n");  }}/****************************************************************************REMARKS:Main program entry point****************************************************************************/int main(void){	event_t		evt;	ibool		done = false;	PM_HWND		hwndConsole;	hwndConsole = PM_openConsole(0,0,0,0,0,true);	EVT_init(&moveMouse);	EVT_setMouseRange(1024,768);	CalibrateJoy();	do {		EVT_pollJoystick();		if (EVT_getNext(&evt,EVT_EVERYEVT)) {			switch (evt.what) {				case EVT_KEYDOWN:					DisplayKey("EVT_KEYDOWN  ", &evt);					if (EVT_scanCode(evt.message) == KB_esc)						done = true;					break;				case EVT_KEYREPEAT:					DisplayKey("EVT_KEYREPEAT", &evt);					break;				case EVT_KEYUP:					DisplayKey("EVT_KEYUP    ", &evt);					break;				case EVT_MOUSEDOWN:					DisplayMouse("EVT_MOUSEDOWN", &evt);					break;				case EVT_MOUSEAUTO:					DisplayMouse("EVT_MOUSEAUTO", &evt);					break;				case EVT_MOUSEUP:					DisplayMouse("EVT_MOUSEUP  ", &evt);					break;				case EVT_MOUSEMOVE:					DisplayMouse("EVT_MOUSEMOVE", &evt);					break;				case EVT_JOYCLICK:					DisplayJoy("EVT_JOYCLICK ", &evt);					break;				case EVT_JOYMOVE:					DisplayJoy("EVT_JOYMOVE  ", &evt);					break;				}			}		} while (!done);	EVT_exit();	PM_closeConsole(hwndConsole);	return 0;}

⌨️ 快捷键说明

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