open ( 打开文件 )
头文件:
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
定义函数:
int open(const char * pathname, int flags);
//int open(const char * pathname, int flags, mode_t mode);
参数分析:
pathname --> 需要打开的文件路径 + 名字
flags --> 所能使用的旗标:
O_RDONLY 以只读方式打开文件
O_WRONLY 以只写方式打开文件
O_RDWR 以可读写方式打开文件. 上述三种旗标是互斥的, 也就是不可同时使用, 但可与下列的旗标利用 OR(|)运算符组合.
返回:
成功文件描述符( int 整型 数字 编号 int fd )
失败返回-1 错误号码会被记录
printf("%s\n", );
perror();
==================================================
read ( 由已打开的文件读取数据 )
头文件:
#include <unistd.h>
定义函数:
ssize_t read(int fd, void * buf, size_t count);
参数分析:
fd --> 需要读取的文件描述符(open 的返回值)
buf --> 读取到的信息存放在哪里
count --> 需要读取的字节数
返回值:
成功 会返回实际读到的字节数 (最好能将返回值与参数 count 作比较, 若返回的字节数比要求读取的字节数少, 则有可能读到了文件尾)
失败 当有错误发生时则返回-1, 错误代码存入 errno 中
==================================================
close ( 关闭文件 )
头文件:
#include <unistd.h>
定义函数:
int close(int fd);
参数分析
fd --> 需要关闭的文件的文件描述符
返回值:
若文件顺利关闭则返回 0,
发生错误时返回-1.
========================================
头文件:
/usr/include/linux
/*
* The event structure itself
*/
struct input_event {
struct timeval time; //事件发生的时间
__u16 type; //事件发生的类型
__u16 code; //事件发生的编码
__s32 value; //事件发生的值
};
struct timeval
{
__time_t tv_sec; // 秒
long int tv_usec; // 微秒(1 微秒 = 10 -3 毫秒 = 10 -6 秒)
};
========================================================
time: 1420073444.658653 type: 3 code: 0 value:230
time: 1420073444.658659 type: 3 code: 1 value:228
time: 1420073444.658663 type: 3 code: 24 value:200
time: 1420073444.658667 type: 1 code: 330 value:1
time: 1420073444.658671 type: 0 code: 0 value:0
time: 1420073444.709150 type: 3 code: 24 value:0
time: 1420073444.709156 type: 1 code: 330 value:0
time: 1420073444.709159 type: 0 code: 0 value:0
/*
* Event types
*/
#define EV_SYN 0x00 //事件间的分割标志,有些事件可能会在时间和空间上产生延续,比如持续按住一个按键。为了更好地管理这些持续的事件,EV_SYN 用以将他们分割成一个个的小的数据包。
#define EV_KEY 0x01 //用以描述键盘,按键或者类似键盘的设备的状态变化。
#define EV_REL 0x02 //相对位移,比如鼠标的移动,滚轮的转动等。
#define EV_ABS 0x03 //绝对位移,比如触摸屏上的坐标值。
========================================================
time: 1420073444.658653 type: 3 code: 0 value:230 //触摸屏事件
time: 1420073444.658659 type: 3 code: 1 value:228 //触摸屏事件
time: 1420073444.658663 type: 3 code: 24 value:200 //触摸屏事件
time: 1420073444.658667 type: 1 code: 330 value:1 //键盘事件 按键被触摸了 被按下
tim========================================================
time: 1420073444.709150 type: 3 code: 24 value:0 //触摸屏事件
time: 1420073444.709156 type: 1 code: 330 value:0 //键盘事件 按键被触摸了 被放开
========================================================
/*
* Keys and buttons
*
* Most of the keys/buttons are modeled after USB HUT 1.12
* (see http://www.usb.org/developers/hidpage).
* Abbreviations in the comments:
* AC - Application Control
* AL - Application Launch Button
* SC - System Control
*/
#define BTN_TOUCH 0x14a //按键被触摸了
========================================================
time: 1420073444.658653 type: 3 code: 0 value:230 //触摸屏事件 x轴
time: 1420073444.658659 type: 3 code: 1 value:228 //触摸屏事件 y轴
time: 1420073444.658663 type: 3 code: 24 value:200 //触摸屏事件
time: 1420073444.658667 type: 1 code: 330 value:1 //键盘事件 按键被触摸了 被按下
tim========================================================
time: 1420073444.709150 type: 3 code: 24 value:0 //触摸屏事件
time: 1420073444.709156 type: 1 code: 330 value:0 //键盘事件 按键被触摸了 被放开
========================================================
/*
* Absolute axes
*/
#define ABS_X 0x00 //x轴
#define ABS_Y 0x01 //y轴
( 143, 174 ) ( 394,363 )