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

📄 input.cpp

📁 EM8511s中使用的avi播放器
💻 CPP
字号:
#include <stdio.h>#include <fcntl.h>#include <unistd.h>#include <sys/ioctl.h>#include <sys/time.h>#include <termios.h>#include "input.h"#include "../../ir/ir_ioctl.h"#ifdef SUPPORT_IRstatic int ir_fd = -1;#endifstatic struct termios tio_save;int initinput (void){	struct termios tio;		if (tcgetattr(STDIN_FILENO, &tio_save) < 0) {		return 0;	}	tio = tio_save;	if (0) {		tio.c_lflag &= ~(ECHO | ICANON | ISIG);		tio.c_iflag &= ~(BRKINT);	} else {		tio.c_lflag |= (ISIG);		tio.c_lflag &= ~(ECHO | ICANON);		tio.c_iflag |= (BRKINT);		tio.c_iflag &= ~(IGNBRK);	}	tio.c_cc[VMIN] = 1;	tio.c_cc[VTIME] = 0;	tcsetattr(STDIN_FILENO, TCSAFLUSH, &tio);	return 0;}static int available_input_key (void){	struct timeval tv;	fd_set readfds;		tv.tv_sec = 0;	tv.tv_usec = 0;	FD_ZERO(&readfds);	FD_SET(STDIN_FILENO, &readfds);	return (select(STDIN_FILENO + 1, &readfds, NULL, NULL, &tv) > 0);}static int get_input_key (char *pKey){	if (!available_input_key())		return 0;	if (pKey == NULL)		return 0;	return (read(STDIN_FILENO, pKey, 1) == 1);}int getinput (void){	int scancode;	scancode = 0;#ifdef SUPPORT_IR		if (ir_fd == -1)		ir_fd = open("/dev/ir", O_RDONLY | O_NONBLOCK);	scancode = 0;	ioctl (ir_fd, IR_IOCTL_READ_KEY, &scancode);#endif	if (scancode == 0)	{		char c;		c = 0;		get_input_key (&c);		switch (c)		{		case 'x':			scancode = INPUT_STOP;			break;		default:			break;		}			}	return scancode;}int exitinput (void){	tcsetattr(STDIN_FILENO, TCSAFLUSH, &tio_save);}

⌨️ 快捷键说明

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