全部博文(166)
分类: LINUX
2008-04-17 21:51:19
struct timer_list { struct list_head list; unsigned long expires; //定时器到期时间 unsigned long data; //作为参数被传入定时器处理函数 void (*function)(unsigned long); }; |
void add_timer(struct timer_list * timer); |
int del_timer(struct timer_list * timer); |
int mod_timer(struct timer_list *timer, unsigned long expires); |
… #include … static struct timer_list key_autorepeat_timer = { function: key_callback }; static void kbd_processkeycode(unsigned char keycode, char up_flag, int autorepeat) { char raw_mode = (kbd->kbdmode == VC_RAW); if (up_flag) { rep = 0; if(!test_and_clear_bit(keycode, key_down)) up_flag = kbd_unexpected_up(keycode); } else { rep = test_and_set_bit(keycode, key_down); /* If the keyboard autorepeated for us, ignore it. * We do our own autorepeat processing. */ if (rep && !autorepeat) return; } if (kbd_repeatkeycode == keycode || !up_flag || raw_mode) { kbd_repeatkeycode = -1; del_timer(&key_autorepeat_timer); } … /* * Calculate the next time when we have to do some autorepeat * processing. Note that we do not do autorepeat processing * while in raw mode but we do do autorepeat processing in * medium raw mode. */ if (!up_flag && !raw_mode) { kbd_repeatkeycode = keycode; if (vc_kbd_mode(kbd, VC_REPEAT)) { if (rep) key_autorepeat_timer.expires = jiffies + kbd_repeatinterval; else key_autorepeat_timer.expires = jiffies + kbd_repeattimeout; add_timer(&key_autorepeat_timer); } } … } |