_kbhit() for linux
来源:互联网 发布:ping带端口的ip 编辑:程序博客网 时间:2024/05/22 08:24
传送门:http://cboard.cprogramming.com/c-programming/63166-kbhit-linux.html
#include <stdio.h>#include <unistd.h>#include <stdlib.h>#include <termios.h>#include <unistd.h>#include <fcntl.h> int kbhit(void){ struct termios oldt, newt; int ch; int oldf; tcgetattr(STDIN_FILENO, &oldt); newt = oldt; newt.c_lflag &= ~(ICANON | ECHO); tcsetattr(STDIN_FILENO, TCSANOW, &newt); oldf = fcntl(STDIN_FILENO, F_GETFL, 0); fcntl(STDIN_FILENO, F_SETFL, oldf | O_NONBLOCK); ch = getchar(); tcsetattr(STDIN_FILENO, TCSANOW, &oldt); fcntl(STDIN_FILENO, F_SETFL, oldf); if(ch != EOF) { ungetc(ch, stdin); return 1; } return 0;} main( int argc, char** argv ){ char *input = argv[0]; int nomor = argc; pid_t pid = 0; /* set stuff up */ /* accept command line args */ pid = fork(); if( pid == 0 ){ /* this is the "background" process. Execute process loop here */ int x=0; while(1) { if(kbhit()) printf("you hit keyboard"); } } else { /* "foreground" process exits */ exit(0); }}
具体含义,有的解释是等待键盘输入;但此处用意为在 ios下使用while( !kbhit()) 控制openal的音效的循环播放.
0 0
- _kbhit() for linux
- _kbhit() for Linux【在linux上实现类似_kbhit()的功能】
- _kbhit
- 汇编中调用_kbhit()函数
- mac下的一个类似“_kbhit()”实现
- _kbhit()----用于判断在循环时是否有按键
- CVS for linux安装!
- Firebird FOR LINUX
- Resources for Linux
- WPS2005 For Linux 序列号
- VNC settings for Linux
- uClinux for Linux Programmers
- WWW-Browsers for Linux
- emacs configuration for Linux
- 安装realplayer for linux
- Foxit Reader for Linux
- ora9i for linux安装
- HelixServer 11 for Linux
- unity3d socket( unity socket )客户端通信插件-在Unity3d中的简易实现网游客户端通信框架
- 2013总结-2014展望
- libcurl使用心得-包括下载文件不存在处理相关(转)
- XACT Q&A (转)
- pthread_create用法(转)
- _kbhit() for linux
- Oracle - ora-01034:oracle not available ora-27101:shared memory realm does not exist
- IOS调试技巧:当程序崩溃的时候怎么办 xcode调试
- lua的注释
- 有单例模式 Singleton 涉及的一些防止类被继承的东西
- 百万用户级游戏服务器架构设计(1)
- auto_ptr 浅析(转)
- Xcode 中设置部分文件ARC支持
- mqo动画探索1