00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00038 #include <kbd.h>
00039 #include <io/console.h>
00040 #include <io/keycode.h>
00041 #include <kbd_ctl.h>
00042
00043 #define KBD_KEY_RELEASE 0x80
00044
00045 static int scanmap[];
00046
00047 int kbd_ctl_init(void)
00048 {
00049 return 0;
00050 }
00051
00052 void kbd_ctl_parse_scancode(int scancode)
00053 {
00054 console_ev_type_t type;
00055 unsigned int key;
00056
00057 if (scancode < 0 || scancode >= 0x100)
00058 return;
00059
00060 if (scancode & KBD_KEY_RELEASE) {
00061 scancode &= ~KBD_KEY_RELEASE;
00062 type = KEY_RELEASE;
00063 } else {
00064 type = KEY_PRESS;
00065 }
00066
00067 key = scanmap[scancode];
00068 if (key != 0)
00069 kbd_push_ev(type, key);
00070 }
00071
00072 void kbd_ctl_set_ind(unsigned mods)
00073 {
00074 (void) mods;
00075 }
00076
00077 static int scanmap[] = {
00078 [0x00] = KC_A,
00079 [0x01] = KC_S,
00080 [0x02] = KC_D,
00081 [0x03] = KC_F,
00082 [0x04] = KC_H,
00083 [0x05] = KC_G,
00084 [0x06] = KC_Z,
00085 [0x07] = KC_X,
00086 [0x08] = KC_C,
00087 [0x09] = KC_V,
00088 [0x0a] = KC_BACKSLASH,
00089 [0x0b] = KC_B,
00090 [0x0c] = KC_Q,
00091 [0x0d] = KC_W,
00092 [0x0e] = KC_E,
00093 [0x0f] = KC_R,
00094 [0x10] = KC_Y,
00095 [0x11] = KC_T,
00096 [0x12] = KC_1,
00097 [0x13] = KC_2,
00098 [0x14] = KC_3,
00099 [0x15] = KC_4,
00100 [0x16] = KC_6,
00101 [0x17] = KC_5,
00102 [0x18] = KC_EQUALS,
00103 [0x19] = KC_9,
00104 [0x1a] = KC_7,
00105 [0x1b] = KC_MINUS,
00106 [0x1c] = KC_8,
00107 [0x1d] = KC_0,
00108 [0x1e] = KC_RBRACKET,
00109 [0x1f] = KC_O,
00110 [0x20] = KC_U,
00111 [0x21] = KC_LBRACKET,
00112 [0x22] = KC_I,
00113 [0x23] = KC_P,
00114 [0x24] = KC_ENTER,
00115 [0x25] = KC_L,
00116 [0x26] = KC_J,
00117 [0x27] = KC_QUOTE,
00118 [0x28] = KC_K,
00119 [0x29] = KC_SEMICOLON,
00120 [0x2a] = KC_BACKSLASH,
00121 [0x2b] = KC_COMMA,
00122 [0x2c] = KC_SLASH,
00123 [0x2d] = KC_N,
00124 [0x2e] = KC_M,
00125 [0x2f] = KC_PERIOD,
00126 [0x30] = KC_TAB,
00127 [0x31] = KC_SPACE,
00128 [0x32] = KC_BACKTICK,
00129 [0x33] = KC_BACKSPACE,
00130 [0x34] = 0,
00131 [0x35] = KC_ESCAPE,
00132 [0x36] = KC_LCTRL,
00133 [0x37] = 0,
00134 [0x38] = KC_LSHIFT,
00135 [0x39] = KC_CAPS_LOCK,
00136 [0x3a] = KC_LALT,
00137 [0x3b] = KC_LEFT,
00138 [0x3c] = KC_RIGHT,
00139 [0x3d] = KC_DOWN,
00140 [0x3e] = KC_UP,
00141 [0x3f] = 0,
00142 [0x40] = 0,
00143 [0x41] = KC_NPERIOD,
00144 [0x42] = 0,
00145 [0x43] = KC_NTIMES,
00146 [0x44] = 0,
00147 [0x45] = KC_NPLUS,
00148 [0x46] = 0,
00149 [0x47] = KC_NUM_LOCK,
00150 [0x48] = 0,
00151 [0x49] = 0,
00152 [0x4a] = 0,
00153 [0x4b] = KC_NSLASH,
00154 [0x4c] = KC_NENTER,
00155 [0x4d] = 0,
00156 [0x4e] = KC_NMINUS,
00157 [0x4f] = 0,
00158 [0x50] = 0,
00159 [0x51] = 0,
00160 [0x52] = KC_N0,
00161 [0x53] = KC_N1,
00162 [0x54] = KC_N2,
00163 [0x55] = KC_N3,
00164 [0x56] = KC_N4,
00165 [0x57] = KC_N5,
00166 [0x58] = KC_N6,
00167 [0x59] = KC_N7,
00168 [0x5a] = 0,
00169 [0x5b] = KC_N8,
00170 [0x5c] = KC_N9,
00171 [0x5d] = 0,
00172 [0x5e] = 0,
00173 [0x5f] = 0,
00174 [0x60] = KC_F5,
00175 [0x61] = KC_F6,
00176 [0x62] = KC_F7,
00177 [0x63] = KC_F3,
00178 [0x64] = KC_F8,
00179 [0x65] = KC_F9,
00180 [0x66] = 0,
00181 [0x67] = KC_F11,
00182 [0x68] = 0,
00183 [0x69] = 0,
00184 [0x6a] = 0,
00185 [0x6b] = KC_SCROLL_LOCK,
00186 [0x6c] = 0,
00187 [0x6d] = KC_F10,
00188 [0x6e] = 0,
00189 [0x6f] = KC_F12,
00190 [0x70] = 0,
00191 [0x71] = 0,
00192 [0x72] = KC_INSERT,
00193 [0x73] = KC_HOME,
00194 [0x74] = KC_PAGE_UP,
00195 [0x75] = KC_DELETE,
00196 [0x76] = KC_F4,
00197 [0x77] = KC_END,
00198 [0x78] = KC_F2,
00199 [0x79] = KC_PAGE_DOWN,
00200 [0x7a] = KC_F1,
00201 [0x7b] = KC_RSHIFT,
00202 [0x7c] = KC_RALT,
00203 [0x7d] = KC_RCTRL,
00204 [0x7e] = 0,
00205 [0x7f] = 0
00206 };
00207