Linux的Input Device
Linux 的 Input Device 是重要的一個 subsystem,在進行實例介紹前,先大略了解一下相關的 API。input.c是Linux的输入驅動程式,主要支援鍵盤與滑鼠的輸入;input.c介面特殊的地方是採用了事件(event)的方式來處理輸入,以下是input.c介面重要的資料結構與函數:
* struct input_dev
* void input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
* void input_register_device(struct input_dev *);
* void input_unregister_device(struct input_dev *);
* void input_register_handler(struct input_handler *);
* void input_unregister_handler(struct input_handler *);
(1) struct input_dev是用來描述輸入事件的重要資料結構,其原型如下:
struct input_dev {
const char *name;
const char *phys;
const char *uniq;
struct input_id id;
unsigned long evbit[BITS_TO_LONGS(EV_CNT)];
unsigned long keybit[BITS_TO_LONGS(KEY_CNT)];
unsigned long relbit[BITS_TO_LONGS(REL_CNT)];
unsigned long absbit[BITS_TO_LONGS(ABS_CNT)];
unsigned long mscbit[BITS_TO_LONGS(MSC_CNT)];
unsigned long ledbit[BITS_TO_LONGS(LED_CNT)];
unsigned long sndbit[BITS_TO_LONGS(SND_CNT)];
unsigned long ffbit[BITS_TO_LONGS(FF_CNT)];
unsigned long swbit[BITS_TO_LONGS(SW_CNT)];
unsigned int keycodemax;
unsigned int keycodesize;
void *keycode;
int (*setkeycode)(struct input_dev *dev, int scancode, int keycode);
int (*getkeycode)(struct input_dev *dev, int scancode, int *keycode);
struct ff_device *ff;
unsigned int repeat_key;
struct timer_list timer;
int sync;
int abs[ABS_MAX + 1];
int rep[REP_MAX + 1];
unsigned long key[BITS_TO_LONGS(KEY_CNT)];
unsigned long led[BITS_TO_LONGS(LED_CNT)];
unsigned long snd[BITS_TO_LONGS(SND_CNT)];
u
相关文档:
无论什么编程语言都离不开条件判断。SHELL也不例外。
if list then
do something here
elif list then
do another thing here
......
在linux内核的源代码中,以汇编语言编写的程序或程序段,有两种不同的形式。
第一种事完全的汇编代码,这样的代码采用.s作为文件的后缀。事实上,尽管是完全的汇编代码,现代的汇编工具也吸收了C语言的长处,也在汇编之前加上了一趟预处理,而预处理之前的文件则以.s为后缀。此类(.s)文件也和C程序一样,可以使用#includ ......
(1)
linux下的批处理文件,基本就是shell脚本文件。
1.一个最简单的脚本书写方法为:
新建一个文件,名字为clean(自己定义的名字),在里面编写
rm -fv *.o;ls -al;
(可以写一些shell普通命令,命令用分号隔开)
2.执行方法
(1)在控制台输入:
sh clean
(2)先给与脚本可执行权限:
......
无论微软如何专注于桌面,X的设计还是能让他们汗颜。比较一下Windows远程桌面(2008Server终于有所改进)和X转发的效果就可以理解,为什么*nix的世界里显示GUI环境依靠的竟然是Server-Client架构。
在Windows下,只要实现两个要素就可以实现X的转发:1.X Server服务;2.ssh客户端。前者可以用Xming,后者可以用putty或openS ......