我的学习之旅 keyboard.h和keyboard.c

来源:互联网 发布:java无参方法构造 编辑:程序博客网 时间:2024/05/01 14:07

简化处理,只支持基本常用的按键操作。

keyboard.h源代码:

#ifndef __KEY_BOARD_H__#define __KEY_BOARD_H__/*shift键的按下和释放*/#define press_left_shift                0x2a#define press_right_shift              0x36#define release_left_shift             0xaa#define release_right_shift           0xb6/*alt键的按下和释放*/#define press_alt                           0x38#define release_alt                        0xb8/*ctrl键的按下和释放*/#define press_ctrl                          0x1d#define release_ctrl                       0x9d/*Caps Lock*/#define press_Caps                        0x3a#define release_Caps                     0xba/*Num Lock*/#define press_Num                         0x45#define release_Num                      0xc5#define SHIFT_MODE          ( 1 << 0 )#define ALT_MODE                        (1 << 1 )#define CTRL_MODE                       ( 1 << 2 )#define CAPS_MODE                      (1 << 3 )#define NUM_MODE                        (1 << 4 )#endif

keybaord.c源代码:

#include <system.h>#include <keyboard.h>#include <io.h>#include <pci_regs.h>#include <sched.h>#include <printk.h>#include <mem.h>#include <tty.h>#include <console.h>/*正常情况下key与ascii的映射表*/static unsigned char g_key2ascii_normal_map_table[] = {    0, 27, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', 127, 9,    'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', 0, 10, 0, 'a', 's',    'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', '`', 0, '\\', 'z', 'x', 'c',    'v', 'b', 'n', 'm', ',', '.', '/', 0, '*', 0, 32, 16, 1, 0, '-', 0, 0, 0,    '+', 0, 0, 0, 0, 0, 0, 0, '<', 10, 1, 0};/*按下shift键后key与ascii的映射表*/static unsigned char g_key2ascii_shift_map_table[] = {    0, 27, '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', 127, 9,    'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', 10, 0, 'A', 'S',    'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', '"', '~', 0, '|', 'Z', 'X', 'C',    'V', 'B', 'N', 'M', '<', '>', '?', 0, '\'', '*', 0, 32, 0, 0, 0, 0, 0, 0, 0,    0, 0, 0, 0, 0, 0, 0, 0, 0, '-', 0, 0, 0, '+', 0, 0, 0, 0, 0, 0, 0, '>', 0,    0, 0, 0, 0, 0, 0, 0, 0, 0};
0 0
原创粉丝点击