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
00036 #include <io/keycode.h>
00037 #include <stdint.h>
00038 #include <stdio.h>
00039 #include <usb/debug.h>
00040 #include "conv.h"
00041
00046 static int scanmap_simple[255] = {
00047
00048
00049
00050
00051
00052 [0x04] = KC_A,
00053 [0x05] = KC_B,
00054 [0x06] = KC_C,
00055 [0x07] = KC_D,
00056 [0x08] = KC_E,
00057 [0x09] = KC_F,
00058 [0x0a] = KC_G,
00059 [0x0b] = KC_H,
00060 [0x0c] = KC_I,
00061 [0x0d] = KC_J,
00062 [0x0e] = KC_K,
00063 [0x0f] = KC_L,
00064 [0x10] = KC_M,
00065 [0x11] = KC_N,
00066 [0x12] = KC_O,
00067 [0x13] = KC_P,
00068 [0x14] = KC_Q,
00069 [0x15] = KC_R,
00070 [0x16] = KC_S,
00071 [0x17] = KC_T,
00072 [0x18] = KC_U,
00073 [0x19] = KC_V,
00074 [0x1a] = KC_W,
00075 [0x1b] = KC_X,
00076 [0x1c] = KC_Y,
00077 [0x1d] = KC_Z,
00078
00079 [0x1e] = KC_1,
00080 [0x1f] = KC_2,
00081 [0x20] = KC_3,
00082 [0x21] = KC_4,
00083 [0x22] = KC_5,
00084 [0x23] = KC_6,
00085 [0x24] = KC_7,
00086 [0x25] = KC_8,
00087 [0x26] = KC_9,
00088 [0x27] = KC_0,
00089
00090 [0x28] = KC_ENTER,
00091 [0x29] = KC_ESCAPE,
00092 [0x2a] = KC_BACKSPACE,
00093 [0x2b] = KC_TAB,
00094 [0x2c] = KC_SPACE,
00095
00096 [0x2d] = KC_MINUS,
00097 [0x2e] = KC_EQUALS,
00098 [0x2f] = KC_LBRACKET,
00099 [0x30] = KC_RBRACKET,
00100 [0x31] = KC_BACKSLASH,
00101
00102 [0x32] = KC_BACKSLASH,
00103 [0x33] = KC_SEMICOLON,
00104 [0x34] = KC_QUOTE,
00105 [0x35] = KC_BACKTICK,
00106 [0x36] = KC_COMMA,
00107 [0x37] = KC_PERIOD,
00108 [0x38] = KC_SLASH,
00109
00110 [0x39] = KC_CAPS_LOCK,
00111
00112 [0x3a] = KC_F1,
00113 [0x3b] = KC_F2,
00114 [0x3c] = KC_F3,
00115 [0x3d] = KC_F4,
00116 [0x3e] = KC_F5,
00117 [0x3f] = KC_F6,
00118 [0x40] = KC_F7,
00119 [0x41] = KC_F8,
00120 [0x42] = KC_F9,
00121 [0x43] = KC_F10,
00122 [0x44] = KC_F11,
00123 [0x45] = KC_F12,
00124
00125 [0x46] = KC_PRTSCR,
00126 [0x47] = KC_SCROLL_LOCK,
00127 [0x48] = KC_PAUSE,
00128 [0x49] = KC_INSERT,
00129 [0x4a] = KC_HOME,
00130 [0x4b] = KC_PAGE_UP,
00131 [0x4c] = KC_DELETE,
00132 [0x4d] = KC_END,
00133 [0x4e] = KC_PAGE_DOWN,
00134 [0x4f] = KC_RIGHT,
00135 [0x50] = KC_LEFT,
00136 [0x51] = KC_DOWN,
00137 [0x52] = KC_UP,
00138
00139
00140
00141 [0xe0] = KC_LCTRL,
00142 [0xe1] = KC_LSHIFT,
00143 [0xe2] = KC_LALT,
00144
00145 [0xe4] = KC_RCTRL,
00146 [0xe5] = KC_RSHIFT,
00147 [0xe6] = KC_RALT,
00148
00149
00150 [0x53] = KC_NUM_LOCK,
00151 [0x54] = KC_NSLASH,
00152 [0x55] = KC_NTIMES,
00153 [0x56] = KC_NMINUS,
00154 [0x57] = KC_NPLUS,
00155 [0x58] = KC_NENTER,
00156 [0x59] = KC_N1,
00157 [0x5a] = KC_N2,
00158 [0x5b] = KC_N3,
00159 [0x5c] = KC_N4,
00160 [0x5d] = KC_N5,
00161 [0x5e] = KC_N6,
00162 [0x5f] = KC_N7,
00163 [0x60] = KC_N8,
00164 [0x61] = KC_N9,
00165 [0x62] = KC_N0,
00166 [0x63] = KC_NPERIOD
00167
00168 };
00169
00178 unsigned int usbhid_parse_scancode(int scancode)
00179 {
00180 unsigned int key;
00181 int *map = scanmap_simple;
00182 size_t map_length = sizeof(scanmap_simple) / sizeof(int);
00183
00184 if ((scancode < 0) || ((size_t) scancode >= map_length))
00185 return -1;
00186
00187 key = map[scancode];
00188
00189 return key;
00190 }
00191