A optical beam breaker detector that appears to aPC as a USB keyboard, typing characters when the beam is broken

Dependencies:   mbed

Committer:
chris
Date:
Thu May 12 16:44:09 2011 +0000
Revision:
0:9d0f47bc66da

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
chris 0:9d0f47bc66da 1 /* asciihid.h */
chris 0:9d0f47bc66da 2 /* ASCII to HID Keyboard lookup table */
chris 0:9d0f47bc66da 3 /* Copyright (c) Phil Wright 2008 */
chris 0:9d0f47bc66da 4
chris 0:9d0f47bc66da 5 #ifndef HIDTABLE_H
chris 0:9d0f47bc66da 6 #define HIDTABLE_H
chris 0:9d0f47bc66da 7
chris 0:9d0f47bc66da 8 /* Default is UK keyboard layout */
chris 0:9d0f47bc66da 9 /* #define US_KEYBOARD */
chris 0:9d0f47bc66da 10
chris 0:9d0f47bc66da 11 /* Modifiers */
chris 0:9d0f47bc66da 12 #define SHIFT (1<<1)
chris 0:9d0f47bc66da 13
chris 0:9d0f47bc66da 14 typedef struct {
chris 0:9d0f47bc66da 15 unsigned char usage;
chris 0:9d0f47bc66da 16 unsigned char modifier;
chris 0:9d0f47bc66da 17 } KEYMAP;
chris 0:9d0f47bc66da 18
chris 0:9d0f47bc66da 19 #ifdef US_KEYBOARD
chris 0:9d0f47bc66da 20 /* US keyboard (as HID standard) */
chris 0:9d0f47bc66da 21 #define KEYMAP_SIZE (128)
chris 0:9d0f47bc66da 22 const KEYMAP keymap[KEYMAP_SIZE] = {
chris 0:9d0f47bc66da 23 {0, 0}, /* NUL */
chris 0:9d0f47bc66da 24 {0, 0}, /* SOH */
chris 0:9d0f47bc66da 25 {0, 0}, /* STX */
chris 0:9d0f47bc66da 26 {0, 0}, /* ETX */
chris 0:9d0f47bc66da 27 {0, 0}, /* EOT */
chris 0:9d0f47bc66da 28 {0, 0}, /* ENQ */
chris 0:9d0f47bc66da 29 {0, 0}, /* ACK */
chris 0:9d0f47bc66da 30 {0, 0}, /* BEL */
chris 0:9d0f47bc66da 31 {0x2a, 0}, /* BS */ /* Keyboard Delete (Backspace) */
chris 0:9d0f47bc66da 32 {0x2b, 0}, /* TAB */ /* Keyboard Tab */
chris 0:9d0f47bc66da 33 {0x28, 0}, /* LF */ /* Keyboard Return (Enter) */
chris 0:9d0f47bc66da 34 {0, 0}, /* VT */
chris 0:9d0f47bc66da 35 {0, 0}, /* FF */
chris 0:9d0f47bc66da 36 {0, 0}, /* CR */
chris 0:9d0f47bc66da 37 {0, 0}, /* SO */
chris 0:9d0f47bc66da 38 {0, 0}, /* SI */
chris 0:9d0f47bc66da 39 {0, 0}, /* DEL */
chris 0:9d0f47bc66da 40 {0, 0}, /* DC1 */
chris 0:9d0f47bc66da 41 {0, 0}, /* DC2 */
chris 0:9d0f47bc66da 42 {0, 0}, /* DC3 */
chris 0:9d0f47bc66da 43 {0, 0}, /* DC4 */
chris 0:9d0f47bc66da 44 {0, 0}, /* NAK */
chris 0:9d0f47bc66da 45 {0, 0}, /* SYN */
chris 0:9d0f47bc66da 46 {0, 0}, /* ETB */
chris 0:9d0f47bc66da 47 {0, 0}, /* CAN */
chris 0:9d0f47bc66da 48 {0, 0}, /* EM */
chris 0:9d0f47bc66da 49 {0, 0}, /* SUB */
chris 0:9d0f47bc66da 50 {0, 0}, /* ESC */
chris 0:9d0f47bc66da 51 {0, 0}, /* FS */
chris 0:9d0f47bc66da 52 {0, 0}, /* GS */
chris 0:9d0f47bc66da 53 {0, 0}, /* RS */
chris 0:9d0f47bc66da 54 {0, 0}, /* US */
chris 0:9d0f47bc66da 55 {0x2c, 0}, /* */
chris 0:9d0f47bc66da 56 {0x1e, SHIFT}, /* ! */
chris 0:9d0f47bc66da 57 {0x34, SHIFT}, /* " */
chris 0:9d0f47bc66da 58 {0x20, SHIFT}, /* # */
chris 0:9d0f47bc66da 59 {0x21, SHIFT}, /* $ */
chris 0:9d0f47bc66da 60 {0x22, SHIFT}, /* % */
chris 0:9d0f47bc66da 61 {0x24, SHIFT}, /* & */
chris 0:9d0f47bc66da 62 {0x34, 0}, /* ' */
chris 0:9d0f47bc66da 63 {0x26, SHIFT}, /* ( */
chris 0:9d0f47bc66da 64 {0x27, SHIFT}, /* ) */
chris 0:9d0f47bc66da 65 {0x25, SHIFT}, /* * */
chris 0:9d0f47bc66da 66 {0x2e, SHIFT}, /* + */
chris 0:9d0f47bc66da 67 {0x36, 0}, /* , */
chris 0:9d0f47bc66da 68 {0x2d, 0}, /* - */
chris 0:9d0f47bc66da 69 {0x37, 0}, /* . */
chris 0:9d0f47bc66da 70 {0x38, 0}, /* / */
chris 0:9d0f47bc66da 71 {0x27, 0}, /* 0 */
chris 0:9d0f47bc66da 72 {0x1e, 0}, /* 1 */
chris 0:9d0f47bc66da 73 {0x1f, 0}, /* 2 */
chris 0:9d0f47bc66da 74 {0x20, 0}, /* 3 */
chris 0:9d0f47bc66da 75 {0x21, 0}, /* 4 */
chris 0:9d0f47bc66da 76 {0x22, 0}, /* 5 */
chris 0:9d0f47bc66da 77 {0x23, 0}, /* 6 */
chris 0:9d0f47bc66da 78 {0x24, 0}, /* 7 */
chris 0:9d0f47bc66da 79 {0x25, 0}, /* 8 */
chris 0:9d0f47bc66da 80 {0x26, 0}, /* 9 */
chris 0:9d0f47bc66da 81 {0x33, SHIFT}, /* : */
chris 0:9d0f47bc66da 82 {0x33, 0}, /* ; */
chris 0:9d0f47bc66da 83 {0x36, SHIFT}, /* < */
chris 0:9d0f47bc66da 84 {0x2e, 0}, /* = */
chris 0:9d0f47bc66da 85 {0x37, SHIFT}, /* > */
chris 0:9d0f47bc66da 86 {0x38, SHIFT}, /* ? */
chris 0:9d0f47bc66da 87 {0x1f, SHIFT}, /* @ */
chris 0:9d0f47bc66da 88 {0x04, SHIFT}, /* A */
chris 0:9d0f47bc66da 89 {0x05, SHIFT}, /* B */
chris 0:9d0f47bc66da 90 {0x06, SHIFT}, /* C */
chris 0:9d0f47bc66da 91 {0x07, SHIFT}, /* D */
chris 0:9d0f47bc66da 92 {0x08, SHIFT}, /* E */
chris 0:9d0f47bc66da 93 {0x09, SHIFT}, /* F */
chris 0:9d0f47bc66da 94 {0x0a, SHIFT}, /* G */
chris 0:9d0f47bc66da 95 {0x0b, SHIFT}, /* H */
chris 0:9d0f47bc66da 96 {0x0c, SHIFT}, /* I */
chris 0:9d0f47bc66da 97 {0x0d, SHIFT}, /* J */
chris 0:9d0f47bc66da 98 {0x0e, SHIFT}, /* K */
chris 0:9d0f47bc66da 99 {0x0f, SHIFT}, /* L */
chris 0:9d0f47bc66da 100 {0x10, SHIFT}, /* M */
chris 0:9d0f47bc66da 101 {0x11, SHIFT}, /* N */
chris 0:9d0f47bc66da 102 {0x12, SHIFT}, /* O */
chris 0:9d0f47bc66da 103 {0x13, SHIFT}, /* P */
chris 0:9d0f47bc66da 104 {0x14, SHIFT}, /* Q */
chris 0:9d0f47bc66da 105 {0x15, SHIFT}, /* R */
chris 0:9d0f47bc66da 106 {0x16, SHIFT}, /* S */
chris 0:9d0f47bc66da 107 {0x17, SHIFT}, /* T */
chris 0:9d0f47bc66da 108 {0x18, SHIFT}, /* U */
chris 0:9d0f47bc66da 109 {0x19, SHIFT}, /* V */
chris 0:9d0f47bc66da 110 {0x1a, SHIFT}, /* W */
chris 0:9d0f47bc66da 111 {0x1b, SHIFT}, /* X */
chris 0:9d0f47bc66da 112 {0x1c, SHIFT}, /* Y */
chris 0:9d0f47bc66da 113 {0x1d, SHIFT}, /* Z */
chris 0:9d0f47bc66da 114 {0x2f, 0}, /* [ */
chris 0:9d0f47bc66da 115 {0x31, 0}, /* \ */
chris 0:9d0f47bc66da 116 {0x30, 0}, /* ] */
chris 0:9d0f47bc66da 117 {0x23, SHIFT}, /* ^ */
chris 0:9d0f47bc66da 118 {0x2d, SHIFT}, /* _ */
chris 0:9d0f47bc66da 119 {0x35, 0}, /* ` */
chris 0:9d0f47bc66da 120 {0x04, 0}, /* a */
chris 0:9d0f47bc66da 121 {0x05, 0}, /* b */
chris 0:9d0f47bc66da 122 {0x06, 0}, /* c */
chris 0:9d0f47bc66da 123 {0x07, 0}, /* d */
chris 0:9d0f47bc66da 124 {0x08, 0}, /* e */
chris 0:9d0f47bc66da 125 {0x09, 0}, /* f */
chris 0:9d0f47bc66da 126 {0x0a, 0}, /* g */
chris 0:9d0f47bc66da 127 {0x0b, 0}, /* h */
chris 0:9d0f47bc66da 128 {0x0c, 0}, /* i */
chris 0:9d0f47bc66da 129 {0x0d, 0}, /* j */
chris 0:9d0f47bc66da 130 {0x0e, 0}, /* k */
chris 0:9d0f47bc66da 131 {0x0f, 0}, /* l */
chris 0:9d0f47bc66da 132 {0x10, 0}, /* m */
chris 0:9d0f47bc66da 133 {0x11, 0}, /* n */
chris 0:9d0f47bc66da 134 {0x12, 0}, /* o */
chris 0:9d0f47bc66da 135 {0x13, 0}, /* p */
chris 0:9d0f47bc66da 136 {0x14, 0}, /* q */
chris 0:9d0f47bc66da 137 {0x15, 0}, /* r */
chris 0:9d0f47bc66da 138 {0x16, 0}, /* s */
chris 0:9d0f47bc66da 139 {0x17, 0}, /* t */
chris 0:9d0f47bc66da 140 {0x18, 0}, /* u */
chris 0:9d0f47bc66da 141 {0x19, 0}, /* v */
chris 0:9d0f47bc66da 142 {0x1a, 0}, /* w */
chris 0:9d0f47bc66da 143 {0x1b, 0}, /* x */
chris 0:9d0f47bc66da 144 {0x1c, 0}, /* y */
chris 0:9d0f47bc66da 145 {0x1d, 0}, /* z */
chris 0:9d0f47bc66da 146 {0x2f, SHIFT}, /* { */
chris 0:9d0f47bc66da 147 {0x31, SHIFT}, /* | */
chris 0:9d0f47bc66da 148 {0x30, SHIFT}, /* } */
chris 0:9d0f47bc66da 149 {0x35, SHIFT}, /* ~ */
chris 0:9d0f47bc66da 150 {0,0}, /* DEL */
chris 0:9d0f47bc66da 151 };
chris 0:9d0f47bc66da 152
chris 0:9d0f47bc66da 153 #else
chris 0:9d0f47bc66da 154 /* UK keyboard */
chris 0:9d0f47bc66da 155 #define KEYMAP_SIZE (128)
chris 0:9d0f47bc66da 156 const KEYMAP keymap[KEYMAP_SIZE] = {
chris 0:9d0f47bc66da 157 {0, 0}, /* NUL */
chris 0:9d0f47bc66da 158 {0, 0}, /* SOH */
chris 0:9d0f47bc66da 159 {0, 0}, /* STX */
chris 0:9d0f47bc66da 160 {0, 0}, /* ETX */
chris 0:9d0f47bc66da 161 {0, 0}, /* EOT */
chris 0:9d0f47bc66da 162 {0, 0}, /* ENQ */
chris 0:9d0f47bc66da 163 {0, 0}, /* ACK */
chris 0:9d0f47bc66da 164 {0, 0}, /* BEL */
chris 0:9d0f47bc66da 165 {0x2a, 0}, /* BS */ /* Keyboard Delete (Backspace) */
chris 0:9d0f47bc66da 166 {0x2b, 0}, /* TAB */ /* Keyboard Tab */
chris 0:9d0f47bc66da 167 {0x28, 0}, /* LF */ /* Keyboard Return (Enter) */
chris 0:9d0f47bc66da 168 {0, 0}, /* VT */
chris 0:9d0f47bc66da 169 {0, 0}, /* FF */
chris 0:9d0f47bc66da 170 {0, 0}, /* CR */
chris 0:9d0f47bc66da 171 {0, 0}, /* SO */
chris 0:9d0f47bc66da 172 {0, 0}, /* SI */
chris 0:9d0f47bc66da 173 {0, 0}, /* DEL */
chris 0:9d0f47bc66da 174 {0, 0}, /* DC1 */
chris 0:9d0f47bc66da 175 {0, 0}, /* DC2 */
chris 0:9d0f47bc66da 176 {0, 0}, /* DC3 */
chris 0:9d0f47bc66da 177 {0, 0}, /* DC4 */
chris 0:9d0f47bc66da 178 {0, 0}, /* NAK */
chris 0:9d0f47bc66da 179 {0, 0}, /* SYN */
chris 0:9d0f47bc66da 180 {0, 0}, /* ETB */
chris 0:9d0f47bc66da 181 {0, 0}, /* CAN */
chris 0:9d0f47bc66da 182 {0, 0}, /* EM */
chris 0:9d0f47bc66da 183 {0, 0}, /* SUB */
chris 0:9d0f47bc66da 184 {0, 0}, /* ESC */
chris 0:9d0f47bc66da 185 {0, 0}, /* FS */
chris 0:9d0f47bc66da 186 {0, 0}, /* GS */
chris 0:9d0f47bc66da 187 {0, 0}, /* RS */
chris 0:9d0f47bc66da 188 {0, 0}, /* US */
chris 0:9d0f47bc66da 189 {0x2c, 0}, /* */
chris 0:9d0f47bc66da 190 {0x1e, SHIFT}, /* ! */
chris 0:9d0f47bc66da 191 {0x1f, SHIFT}, /* " */
chris 0:9d0f47bc66da 192 {0x32, 0}, /* # */
chris 0:9d0f47bc66da 193 {0x21, SHIFT}, /* $ */
chris 0:9d0f47bc66da 194 {0x22, SHIFT}, /* % */
chris 0:9d0f47bc66da 195 {0x24, SHIFT}, /* & */
chris 0:9d0f47bc66da 196 {0x34, 0}, /* ' */
chris 0:9d0f47bc66da 197 {0x26, SHIFT}, /* ( */
chris 0:9d0f47bc66da 198 {0x27, SHIFT}, /* ) */
chris 0:9d0f47bc66da 199 {0x25, SHIFT}, /* * */
chris 0:9d0f47bc66da 200 {0x2e, SHIFT}, /* + */
chris 0:9d0f47bc66da 201 {0x36, 0}, /* , */
chris 0:9d0f47bc66da 202 {0x2d, 0}, /* - */
chris 0:9d0f47bc66da 203 {0x37, 0}, /* . */
chris 0:9d0f47bc66da 204 {0x38, 0}, /* / */
chris 0:9d0f47bc66da 205 {0x27, 0}, /* 0 */
chris 0:9d0f47bc66da 206 {0x1e, 0}, /* 1 */
chris 0:9d0f47bc66da 207 {0x1f, 0}, /* 2 */
chris 0:9d0f47bc66da 208 {0x20, 0}, /* 3 */
chris 0:9d0f47bc66da 209 {0x21, 0}, /* 4 */
chris 0:9d0f47bc66da 210 {0x22, 0}, /* 5 */
chris 0:9d0f47bc66da 211 {0x23, 0}, /* 6 */
chris 0:9d0f47bc66da 212 {0x24, 0}, /* 7 */
chris 0:9d0f47bc66da 213 {0x25, 0}, /* 8 */
chris 0:9d0f47bc66da 214 {0x26, 0}, /* 9 */
chris 0:9d0f47bc66da 215 {0x33, SHIFT}, /* : */
chris 0:9d0f47bc66da 216 {0x33, 0}, /* ; */
chris 0:9d0f47bc66da 217 {0x36, SHIFT}, /* < */
chris 0:9d0f47bc66da 218 {0x2e, 0}, /* = */
chris 0:9d0f47bc66da 219 {0x37, SHIFT}, /* > */
chris 0:9d0f47bc66da 220 {0x38, SHIFT}, /* ? */
chris 0:9d0f47bc66da 221 {0x34, SHIFT}, /* @ */
chris 0:9d0f47bc66da 222 {0x04, SHIFT}, /* A */
chris 0:9d0f47bc66da 223 {0x05, SHIFT}, /* B */
chris 0:9d0f47bc66da 224 {0x06, SHIFT}, /* C */
chris 0:9d0f47bc66da 225 {0x07, SHIFT}, /* D */
chris 0:9d0f47bc66da 226 {0x08, SHIFT}, /* E */
chris 0:9d0f47bc66da 227 {0x09, SHIFT}, /* F */
chris 0:9d0f47bc66da 228 {0x0a, SHIFT}, /* G */
chris 0:9d0f47bc66da 229 {0x0b, SHIFT}, /* H */
chris 0:9d0f47bc66da 230 {0x0c, SHIFT}, /* I */
chris 0:9d0f47bc66da 231 {0x0d, SHIFT}, /* J */
chris 0:9d0f47bc66da 232 {0x0e, SHIFT}, /* K */
chris 0:9d0f47bc66da 233 {0x0f, SHIFT}, /* L */
chris 0:9d0f47bc66da 234 {0x10, SHIFT}, /* M */
chris 0:9d0f47bc66da 235 {0x11, SHIFT}, /* N */
chris 0:9d0f47bc66da 236 {0x12, SHIFT}, /* O */
chris 0:9d0f47bc66da 237 {0x13, SHIFT}, /* P */
chris 0:9d0f47bc66da 238 {0x14, SHIFT}, /* Q */
chris 0:9d0f47bc66da 239 {0x15, SHIFT}, /* R */
chris 0:9d0f47bc66da 240 {0x16, SHIFT}, /* S */
chris 0:9d0f47bc66da 241 {0x17, SHIFT}, /* T */
chris 0:9d0f47bc66da 242 {0x18, SHIFT}, /* U */
chris 0:9d0f47bc66da 243 {0x19, SHIFT}, /* V */
chris 0:9d0f47bc66da 244 {0x1a, SHIFT}, /* W */
chris 0:9d0f47bc66da 245 {0x1b, SHIFT}, /* X */
chris 0:9d0f47bc66da 246 {0x1c, SHIFT}, /* Y */
chris 0:9d0f47bc66da 247 {0x1d, SHIFT}, /* Z */
chris 0:9d0f47bc66da 248 {0x2f, 0}, /* [ */
chris 0:9d0f47bc66da 249 {0x64, 0}, /* \ */
chris 0:9d0f47bc66da 250 {0x30, 0}, /* ] */
chris 0:9d0f47bc66da 251 {0x23, SHIFT}, /* ^ */
chris 0:9d0f47bc66da 252 {0x2d, SHIFT}, /* _ */
chris 0:9d0f47bc66da 253 {0x35, 0}, /* ` */
chris 0:9d0f47bc66da 254 {0x04, 0}, /* a */
chris 0:9d0f47bc66da 255 {0x05, 0}, /* b */
chris 0:9d0f47bc66da 256 {0x06, 0}, /* c */
chris 0:9d0f47bc66da 257 {0x07, 0}, /* d */
chris 0:9d0f47bc66da 258 {0x08, 0}, /* e */
chris 0:9d0f47bc66da 259 {0x09, 0}, /* f */
chris 0:9d0f47bc66da 260 {0x0a, 0}, /* g */
chris 0:9d0f47bc66da 261 {0x0b, 0}, /* h */
chris 0:9d0f47bc66da 262 {0x0c, 0}, /* i */
chris 0:9d0f47bc66da 263 {0x0d, 0}, /* j */
chris 0:9d0f47bc66da 264 {0x0e, 0}, /* k */
chris 0:9d0f47bc66da 265 {0x0f, 0}, /* l */
chris 0:9d0f47bc66da 266 {0x10, 0}, /* m */
chris 0:9d0f47bc66da 267 {0x11, 0}, /* n */
chris 0:9d0f47bc66da 268 {0x12, 0}, /* o */
chris 0:9d0f47bc66da 269 {0x13, 0}, /* p */
chris 0:9d0f47bc66da 270 {0x14, 0}, /* q */
chris 0:9d0f47bc66da 271 {0x15, 0}, /* r */
chris 0:9d0f47bc66da 272 {0x16, 0}, /* s */
chris 0:9d0f47bc66da 273 {0x17, 0}, /* t */
chris 0:9d0f47bc66da 274 {0x18, 0}, /* u */
chris 0:9d0f47bc66da 275 {0x19, 0}, /* v */
chris 0:9d0f47bc66da 276 {0x1a, 0}, /* w */
chris 0:9d0f47bc66da 277 {0x1b, 0}, /* x */
chris 0:9d0f47bc66da 278 {0x1c, 0}, /* y */
chris 0:9d0f47bc66da 279 {0x1d, 0}, /* z */
chris 0:9d0f47bc66da 280 {0x2f, SHIFT}, /* { */
chris 0:9d0f47bc66da 281 {0x64, SHIFT}, /* | */
chris 0:9d0f47bc66da 282 {0x30, SHIFT}, /* } */
chris 0:9d0f47bc66da 283 {0x32, SHIFT}, /* ~ */
chris 0:9d0f47bc66da 284 {0,0}, /* DEL */
chris 0:9d0f47bc66da 285 };
chris 0:9d0f47bc66da 286 #endif
chris 0:9d0f47bc66da 287
chris 0:9d0f47bc66da 288
chris 0:9d0f47bc66da 289 #endif