|
1 | 1 | package jp
|
2 | 2 |
|
3 | 3 | import (
|
| 4 | + "machine/usb/hid/keyboard" |
| 5 | + |
4 | 6 | "github.com/sago35/tinygo-keyboard/keycodes"
|
5 | 7 | )
|
6 | 8 |
|
| 9 | +func init() { |
| 10 | + keycodes.CharToKeyCodeMap = &CharToKeyCodeMap |
| 11 | +} |
| 12 | + |
7 | 13 | // for Japanese Keyboard
|
8 | 14 | // based on machine/usb/hid/keyboard/keycode.go
|
9 | 15 | const (
|
@@ -176,3 +182,135 @@ const (
|
176 | 182 | KeyTo4 = keycodes.KeyTo4
|
177 | 183 | KeyTo5 = keycodes.KeyTo5
|
178 | 184 | )
|
| 185 | + |
| 186 | +var CharToKeyCodeMap = [256]keyboard.Keycode{ |
| 187 | + keyboard.ASCII00, |
| 188 | + keyboard.ASCII01, |
| 189 | + keyboard.ASCII02, |
| 190 | + keyboard.ASCII03, |
| 191 | + keyboard.ASCII04, |
| 192 | + keyboard.ASCII05, |
| 193 | + keyboard.ASCII06, |
| 194 | + keyboard.ASCII07, |
| 195 | + keyboard.ASCII08, |
| 196 | + keyboard.ASCII09, |
| 197 | + keyboard.ASCII0A, |
| 198 | + keyboard.ASCII0B, |
| 199 | + keyboard.ASCII0C, |
| 200 | + keyboard.ASCII0D, |
| 201 | + keyboard.ASCII0E, |
| 202 | + keyboard.ASCII0F, |
| 203 | + keyboard.ASCII10, |
| 204 | + keyboard.ASCII11, |
| 205 | + keyboard.ASCII12, |
| 206 | + keyboard.ASCII13, |
| 207 | + keyboard.ASCII14, |
| 208 | + keyboard.ASCII15, |
| 209 | + keyboard.ASCII16, |
| 210 | + keyboard.ASCII17, |
| 211 | + keyboard.ASCII18, |
| 212 | + keyboard.ASCII19, |
| 213 | + keyboard.ASCII1A, |
| 214 | + keyboard.ASCII1B, |
| 215 | + keyboard.ASCII1C, |
| 216 | + keyboard.ASCII1D, |
| 217 | + keyboard.ASCII1E, |
| 218 | + keyboard.ASCII1F, |
| 219 | + |
| 220 | + KeySpace, // 32 SPACE |
| 221 | + Key1 | keycodes.ShiftMask, // 33 ! |
| 222 | + Key2 | keycodes.ShiftMask, // 34 " |
| 223 | + Key3 | keycodes.ShiftMask, // 35 # |
| 224 | + Key4 | keycodes.ShiftMask, // 36 $ |
| 225 | + Key5 | keycodes.ShiftMask, // 37 % |
| 226 | + Key6 | keycodes.ShiftMask, // 38 & |
| 227 | + Key7 | keycodes.ShiftMask, // 39 ' |
| 228 | + Key8 | keycodes.ShiftMask, // 40 ( |
| 229 | + Key9 | keycodes.ShiftMask, // 41 ) |
| 230 | + KeyColon | keycodes.ShiftMask, // 42 * |
| 231 | + KeySemicolon | keycodes.ShiftMask, // 43 + |
| 232 | + KeyComma, // 44 , |
| 233 | + KeyMinus, // 45 - |
| 234 | + KeyPeriod, // 46 . |
| 235 | + KeySlash, // 47 / |
| 236 | + Key0, // 48 0 |
| 237 | + Key1, // 49 1 |
| 238 | + Key2, // 50 2 |
| 239 | + Key3, // 51 3 |
| 240 | + Key4, // 52 4 |
| 241 | + Key5, // 53 5 |
| 242 | + Key6, // 54 6 |
| 243 | + Key7, // 55 7 |
| 244 | + Key8, // 55 8 |
| 245 | + Key9, // 57 9 |
| 246 | + KeyColon, // 58 : |
| 247 | + KeySemicolon, // 59 ; |
| 248 | + KeyComma | keycodes.ShiftMask, // 60 < |
| 249 | + KeyMinus | keycodes.ShiftMask, // 61 = |
| 250 | + KeyPeriod | keycodes.ShiftMask, // 62 > |
| 251 | + KeySlash | keycodes.ShiftMask, // 63 ? |
| 252 | + KeyAt, // 64 @ |
| 253 | + KeyA | keycodes.ShiftMask, // 65 A |
| 254 | + KeyB | keycodes.ShiftMask, // 66 B |
| 255 | + KeyC | keycodes.ShiftMask, // 67 C |
| 256 | + KeyD | keycodes.ShiftMask, // 68 D |
| 257 | + KeyE | keycodes.ShiftMask, // 69 E |
| 258 | + KeyF | keycodes.ShiftMask, // 70 F |
| 259 | + KeyG | keycodes.ShiftMask, // 71 G |
| 260 | + KeyH | keycodes.ShiftMask, // 72 H |
| 261 | + KeyI | keycodes.ShiftMask, // 73 I |
| 262 | + KeyJ | keycodes.ShiftMask, // 74 J |
| 263 | + KeyK | keycodes.ShiftMask, // 75 K |
| 264 | + KeyL | keycodes.ShiftMask, // 76 L |
| 265 | + KeyM | keycodes.ShiftMask, // 77 M |
| 266 | + KeyN | keycodes.ShiftMask, // 78 N |
| 267 | + KeyO | keycodes.ShiftMask, // 79 O |
| 268 | + KeyP | keycodes.ShiftMask, // 80 P |
| 269 | + KeyQ | keycodes.ShiftMask, // 81 Q |
| 270 | + KeyR | keycodes.ShiftMask, // 82 R |
| 271 | + KeyS | keycodes.ShiftMask, // 83 S |
| 272 | + KeyT | keycodes.ShiftMask, // 84 T |
| 273 | + KeyU | keycodes.ShiftMask, // 85 U |
| 274 | + KeyV | keycodes.ShiftMask, // 86 V |
| 275 | + KeyW | keycodes.ShiftMask, // 87 W |
| 276 | + KeyX | keycodes.ShiftMask, // 88 X |
| 277 | + KeyY | keycodes.ShiftMask, // 89 Y |
| 278 | + KeyZ | keycodes.ShiftMask, // 90 Z |
| 279 | + KeyLeftBrace, // 91 [ |
| 280 | + KeyBackslash, // 92 \ |
| 281 | + KeyRightBrace, // 93 ] |
| 282 | + KeyHat, // 94 ^ |
| 283 | + KeyBackslash | keycodes.ShiftMask, // 95 _ |
| 284 | + KeyAt | keycodes.ShiftMask, // 96 ` |
| 285 | + KeyA, // 97 a |
| 286 | + KeyB, // 98 b |
| 287 | + KeyC, // 99 c |
| 288 | + KeyD, // 100 d |
| 289 | + KeyE, // 101 e |
| 290 | + KeyF, // 102 f |
| 291 | + KeyG, // 103 g |
| 292 | + KeyH, // 104 h |
| 293 | + KeyI, // 105 i |
| 294 | + KeyJ, // 106 j |
| 295 | + KeyK, // 107 k |
| 296 | + KeyL, // 108 l |
| 297 | + KeyM, // 109 m |
| 298 | + KeyN, // 110 n |
| 299 | + KeyO, // 111 o |
| 300 | + KeyP, // 112 p |
| 301 | + KeyQ, // 113 q |
| 302 | + KeyR, // 114 r |
| 303 | + KeyS, // 115 s |
| 304 | + KeyT, // 116 t |
| 305 | + KeyU, // 117 u |
| 306 | + KeyV, // 118 v |
| 307 | + KeyW, // 119 w |
| 308 | + KeyX, // 120 x |
| 309 | + KeyY, // 121 y |
| 310 | + KeyZ, // 122 z |
| 311 | + KeyLeftBrace | keycodes.ShiftMask, // 123 { |
| 312 | + KeyBackslash2 | keycodes.ShiftMask, // 124 | |
| 313 | + KeyRightBrace | keycodes.ShiftMask, // 125 } |
| 314 | + KeyHat | keycodes.ShiftMask, // 126 ~ |
| 315 | + KeyDelete, // 127 DEL |
| 316 | +} |
0 commit comments