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/keycode.h>
00040 #include <kbd_ctl.h>
00041 #include <gsp.h>
00042 #include <stroke.h>
00043
00045 static gsp_t sp;
00046
00048 static int ds;
00049
00050 #include <stdio.h>
00051
00052 int seq_defs[] = {
00053
00054
00055 0, KC_BACKTICK, 0x60, GSP_END,
00056
00057 0, KC_1, 0x31, GSP_END,
00058 0, KC_2, 0x32, GSP_END,
00059 0, KC_3, 0x33, GSP_END,
00060 0, KC_4, 0x34, GSP_END,
00061 0, KC_5, 0x35, GSP_END,
00062 0, KC_6, 0x36, GSP_END,
00063 0, KC_7, 0x37, GSP_END,
00064 0, KC_8, 0x38, GSP_END,
00065 0, KC_9, 0x39, GSP_END,
00066 0, KC_0, 0x30, GSP_END,
00067
00068 0, KC_MINUS, 0x2d, GSP_END,
00069 0, KC_EQUALS, 0x3d, GSP_END,
00070 0, KC_BACKSPACE, 0x08, GSP_END,
00071
00072 0, KC_TAB, 0x09, GSP_END,
00073
00074 0, KC_Q, 0x71, GSP_END,
00075 0, KC_W, 0x77, GSP_END,
00076 0, KC_E, 0x65, GSP_END,
00077 0, KC_R, 0x72, GSP_END,
00078 0, KC_T, 0x74, GSP_END,
00079 0, KC_Y, 0x79, GSP_END,
00080 0, KC_U, 0x75, GSP_END,
00081 0, KC_I, 0x69, GSP_END,
00082 0, KC_O, 0x6f, GSP_END,
00083 0, KC_P, 0x70, GSP_END,
00084
00085 0, KC_LBRACKET, 0x5b, GSP_END,
00086 0, KC_RBRACKET, 0x5d, GSP_END,
00087
00088 0, KC_A, 0x61, GSP_END,
00089 0, KC_S, 0x73, GSP_END,
00090 0, KC_D, 0x64, GSP_END,
00091 0, KC_F, 0x66, GSP_END,
00092 0, KC_G, 0x67, GSP_END,
00093 0, KC_H, 0x68, GSP_END,
00094 0, KC_J, 0x6a, GSP_END,
00095 0, KC_K, 0x6b, GSP_END,
00096 0, KC_L, 0x6c, GSP_END,
00097
00098 0, KC_SEMICOLON, 0x3b, GSP_END,
00099 0, KC_QUOTE, 0x27, GSP_END,
00100 0, KC_BACKSLASH, 0x5c, GSP_END,
00101
00102 0, KC_Z, 0x7a, GSP_END,
00103 0, KC_X, 0x78, GSP_END,
00104 0, KC_C, 0x63, GSP_END,
00105 0, KC_V, 0x76, GSP_END,
00106 0, KC_B, 0x62, GSP_END,
00107 0, KC_N, 0x6e, GSP_END,
00108 0, KC_M, 0x6d, GSP_END,
00109
00110 0, KC_COMMA, 0x2c, GSP_END,
00111 0, KC_PERIOD, 0x2e, GSP_END,
00112 0, KC_SLASH, 0x2f, GSP_END,
00113
00114
00115
00116 KM_SHIFT, KC_BACKTICK, 0x7e, GSP_END,
00117
00118 KM_SHIFT, KC_1, 0x21, GSP_END,
00119 KM_SHIFT, KC_2, 0x40, GSP_END,
00120 KM_SHIFT, KC_3, 0x23, GSP_END,
00121 KM_SHIFT, KC_4, 0x24, GSP_END,
00122 KM_SHIFT, KC_5, 0x25, GSP_END,
00123 KM_SHIFT, KC_6, 0x5e, GSP_END,
00124 KM_SHIFT, KC_7, 0x26, GSP_END,
00125 KM_SHIFT, KC_8, 0x2a, GSP_END,
00126 KM_SHIFT, KC_9, 0x28, GSP_END,
00127 KM_SHIFT, KC_0, 0x29, GSP_END,
00128
00129 KM_SHIFT, KC_MINUS, 0x5f, GSP_END,
00130 KM_SHIFT, KC_EQUALS, 0x2b, GSP_END,
00131
00132 KM_SHIFT, KC_Q, 0x51, GSP_END,
00133 KM_SHIFT, KC_W, 0x57, GSP_END,
00134 KM_SHIFT, KC_E, 0x45, GSP_END,
00135 KM_SHIFT, KC_R, 0x52, GSP_END,
00136 KM_SHIFT, KC_T, 0x54, GSP_END,
00137 KM_SHIFT, KC_Y, 0x59, GSP_END,
00138 KM_SHIFT, KC_U, 0x55, GSP_END,
00139 KM_SHIFT, KC_I, 0x49, GSP_END,
00140 KM_SHIFT, KC_O, 0x4f, GSP_END,
00141 KM_SHIFT, KC_P, 0x50, GSP_END,
00142
00143 KM_SHIFT, KC_LBRACKET, 0x7b, GSP_END,
00144 KM_SHIFT, KC_RBRACKET, 0x7d, GSP_END,
00145
00146 KM_SHIFT, KC_A, 0x41, GSP_END,
00147 KM_SHIFT, KC_S, 0x53, GSP_END,
00148 KM_SHIFT, KC_D, 0x44, GSP_END,
00149 KM_SHIFT, KC_F, 0x46, GSP_END,
00150 KM_SHIFT, KC_G, 0x47, GSP_END,
00151 KM_SHIFT, KC_H, 0x48, GSP_END,
00152 KM_SHIFT, KC_J, 0x4a, GSP_END,
00153 KM_SHIFT, KC_K, 0x4b, GSP_END,
00154 KM_SHIFT, KC_L, 0x4c, GSP_END,
00155
00156 KM_SHIFT, KC_SEMICOLON, 0x3a, GSP_END,
00157 KM_SHIFT, KC_QUOTE, 0x22, GSP_END,
00158 KM_SHIFT, KC_BACKSLASH, 0x7c, GSP_END,
00159
00160 KM_SHIFT, KC_Z, 0x5a, GSP_END,
00161 KM_SHIFT, KC_X, 0x58, GSP_END,
00162 KM_SHIFT, KC_C, 0x43, GSP_END,
00163 KM_SHIFT, KC_V, 0x56, GSP_END,
00164 KM_SHIFT, KC_B, 0x42, GSP_END,
00165 KM_SHIFT, KC_N, 0x4e, GSP_END,
00166 KM_SHIFT, KC_M, 0x4d, GSP_END,
00167
00168 KM_SHIFT, KC_COMMA, 0x3c, GSP_END,
00169 KM_SHIFT, KC_PERIOD, 0x3e, GSP_END,
00170 KM_SHIFT, KC_SLASH, 0x3f, GSP_END,
00171
00172
00173
00174 0, KC_SPACE, 0x20, GSP_END,
00175 0, KC_ENTER, 0x0a, GSP_END,
00176 0, KC_ENTER, 0x0d, GSP_END,
00177
00178 0, KC_ESCAPE, 0x1b, 0x1b, GSP_END,
00179
00180 0, KC_F1, 0x1b, 0x4f, 0x50, GSP_END,
00181 0, KC_F2, 0x1b, 0x4f, 0x51, GSP_END,
00182 0, KC_F3, 0x1b, 0x4f, 0x52, GSP_END,
00183 0, KC_F4, 0x1b, 0x4f, 0x53, GSP_END,
00184 0, KC_F5, 0x1b, 0x5b, 0x31, 0x35, 0x7e, GSP_END,
00185 0, KC_F6, 0x1b, 0x5b, 0x31, 0x37, 0x7e, GSP_END,
00186 0, KC_F7, 0x1b, 0x5b, 0x31, 0x38, 0x7e, GSP_END,
00187 0, KC_F8, 0x1b, 0x5b, 0x31, 0x39, 0x7e, GSP_END,
00188 0, KC_F9, 0x1b, 0x5b, 0x32, 0x30, 0x7e, GSP_END,
00189 0, KC_F10, 0x1b, 0x5b, 0x32, 0x31, 0x7e, GSP_END,
00190 0, KC_F11, 0x1b, 0x5b, 0x32, 0x33, 0x7e, GSP_END,
00191 0, KC_F12, 0x1b, 0x5b, 0x32, 0x34, 0x7e, GSP_END,
00192
00193 0, KC_INSERT, 0x1b, 0x5b, 0x32, 0x7e, GSP_END,
00194 0, KC_HOME, 0x1b, 0x5b, 0x48, GSP_END,
00195 0, KC_PAGE_UP, 0x1b, 0x5b, 0x35, 0x7e, GSP_END,
00196 0, KC_DELETE, 0x1b, 0x5b, 0x33, 0x7e, GSP_END,
00197 0, KC_END, 0x1b, 0x5b, 0x46, GSP_END,
00198 0, KC_PAGE_DOWN, 0x1b, 0x5b, 0x36, 0x7e, GSP_END,
00199
00200 0, KC_UP, 0x1b, 0x5b, 0x41, GSP_END,
00201 0, KC_LEFT, 0x1b, 0x5b, 0x44, GSP_END,
00202 0, KC_DOWN, 0x1b, 0x5b, 0x42, GSP_END,
00203 0, KC_RIGHT, 0x1b, 0x5b, 0x43, GSP_END,
00204
00205 0, 0
00206 };
00207
00208 int kbd_ctl_init(void)
00209 {
00210 ds = 0;
00211
00212 gsp_init(&sp);
00213 return gsp_insert_defs(&sp, seq_defs);
00214 }
00215
00216 void kbd_ctl_parse_scancode(int scancode)
00217 {
00218 unsigned mods, key;
00219
00220 ds = gsp_step(&sp, ds, scancode, &mods, &key);
00221 if (key != 0) {
00222 stroke_sim(mods, key);
00223 }
00224 }
00225
00226 void kbd_ctl_set_ind(unsigned mods)
00227 {
00228 (void) mods;
00229 }
00230