Keyboard firmwares for Atmel AVR and Cortex-M
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

m0110.c 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591
  1. /*
  2. Copyright 2011,2012 Jun WAKO <[email protected]>
  3. This software is licensed with a Modified BSD License.
  4. All of this is supposed to be Free Software, Open Source, DFSG-free,
  5. GPL-compatible, and OK to use in both free and proprietary applications.
  6. Additions and corrections to this file are welcome.
  7. Redistribution and use in source and binary forms, with or without
  8. modification, are permitted provided that the following conditions are met:
  9. * Redistributions of source code must retain the above copyright
  10. notice, this list of conditions and the following disclaimer.
  11. * Redistributions in binary form must reproduce the above copyright
  12. notice, this list of conditions and the following disclaimer in
  13. the documentation and/or other materials provided with the
  14. distribution.
  15. * Neither the name of the copyright holders nor the names of
  16. contributors may be used to endorse or promote products derived
  17. from this software without specific prior written permission.
  18. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  19. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  20. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  21. ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  22. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  23. CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  24. SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  25. INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  26. CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  27. ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  28. POSSIBILITY OF SUCH DAMAGE.
  29. */
  30. /* M0110A Support was contributed by skagon@github */
  31. #include <stdbool.h>
  32. #include <avr/io.h>
  33. #include <avr/interrupt.h>
  34. #include <util/delay.h>
  35. #include "m0110.h"
  36. #include "debug.h"
  37. static inline uint8_t raw2scan(uint8_t raw);
  38. static inline uint8_t inquiry(void);
  39. static inline uint8_t instant(void);
  40. static inline void clock_lo(void);
  41. static inline void clock_hi(void);
  42. static inline bool clock_in(void);
  43. static inline void data_lo(void);
  44. static inline void data_hi(void);
  45. static inline bool data_in(void);
  46. static inline uint16_t wait_clock_lo(uint16_t us);
  47. static inline uint16_t wait_clock_hi(uint16_t us);
  48. static inline uint16_t wait_data_lo(uint16_t us);
  49. static inline uint16_t wait_data_hi(uint16_t us);
  50. static inline void idle(void);
  51. static inline void request(void);
  52. #define WAIT_US(stat, us, err) do { \
  53. if (!wait_##stat(us)) { \
  54. m0110_error = err; \
  55. goto ERROR; \
  56. } \
  57. } while (0)
  58. #define WAIT_MS(stat, ms, err) do { \
  59. uint16_t _ms = ms; \
  60. while (_ms) { \
  61. if (wait_##stat(1000)) { \
  62. break; \
  63. } \
  64. _ms--; \
  65. } \
  66. if (_ms == 0) { \
  67. m0110_error = err; \
  68. goto ERROR; \
  69. } \
  70. } while (0)
  71. #define KEY(raw) ((raw) & 0x7f)
  72. #define IS_BREAK(raw) (((raw) & 0x80) == 0x80)
  73. uint8_t m0110_error = 0;
  74. void m0110_init(void)
  75. {
  76. idle();
  77. _delay_ms(1000);
  78. /* Not needed to initialize in fact.
  79. uint8_t data;
  80. m0110_send(M0110_MODEL);
  81. data = m0110_recv();
  82. print("m0110_init model: "); phex(data); print("\n");
  83. m0110_send(M0110_TEST);
  84. data = m0110_recv();
  85. print("m0110_init test: "); phex(data); print("\n");
  86. */
  87. }
  88. uint8_t m0110_send(uint8_t data)
  89. {
  90. m0110_error = 0;
  91. request();
  92. WAIT_MS(clock_lo, 250, 1); // keyboard may block long time
  93. for (uint8_t bit = 0x80; bit; bit >>= 1) {
  94. WAIT_US(clock_lo, 250, 3);
  95. if (data&bit) {
  96. data_hi();
  97. } else {
  98. data_lo();
  99. }
  100. WAIT_US(clock_hi, 200, 4);
  101. }
  102. _delay_us(100); // hold last bit for 80us
  103. idle();
  104. return 1;
  105. ERROR:
  106. print("m0110_send err: "); phex(m0110_error); print("\n");
  107. _delay_ms(500);
  108. idle();
  109. return 0;
  110. }
  111. uint8_t m0110_recv(void)
  112. {
  113. uint8_t data = 0;
  114. m0110_error = 0;
  115. WAIT_MS(clock_lo, 250, 1); // keyboard may block long time
  116. for (uint8_t i = 0; i < 8; i++) {
  117. data <<= 1;
  118. WAIT_US(clock_lo, 200, 2);
  119. WAIT_US(clock_hi, 200, 3);
  120. if (data_in()) {
  121. data |= 1;
  122. }
  123. }
  124. idle();
  125. return data;
  126. ERROR:
  127. print("m0110_recv err: "); phex(m0110_error); print("\n");
  128. _delay_ms(500);
  129. idle();
  130. return 0xFF;
  131. }
  132. /*
  133. Handling for exceptional case of key combinations for M0110A
  134. Shift and Calc/Arrow key could be operated simultaneously:
  135. Case Shift Arrow Events Interpret
  136. -------------------------------------------------------------------
  137. 1 Down Down 71, 79, DD Calc(d)*a *b
  138. 2 Down Up 71, 79, UU Arrow&Calc(u)*a
  139. 3 Up Down F1, 79, DD Shift(u) *c
  140. 4 Up Up F1, 79, UU Shift(u) and Arrow&Calc(u)*a
  141. Case Shift Calc Events Interpret
  142. -------------------------------------------------------------------
  143. 5(1) Down Down 71, 71, 79, DD Shift(d) and Cacl(d)
  144. 6(2) Down Up F1, 71, 79, UU Shift(u) and Arrow&Calc(u)*a
  145. 7(1) Up Down F1, 71, 79, DD Shift(u) and Calc(d)
  146. 8(4) Up Up F1, F1, 79, UU Shift(ux2) and Arrow&Calc(u)*a
  147. During Calc key is hold:
  148. Case Shift Arrow Events Interpret
  149. -------------------------------------------------------------------
  150. A(3) ---- Down F1, 79, DD Shift(u) *c
  151. B ---- Up 79, UU Arrow&Calc(u)*a
  152. C Down ---- F1, 71 Shift(u) and Shift(d)
  153. D Up ---- F1 Shift(u)
  154. E Hold Down 79, DD Normal
  155. F Hold Up 79, UU Arrow&Calc(u)*a
  156. G(1) Down Down F1, 71, 79, DD Shift(u)*b and Calc(d)*a
  157. H(2) Down Up F1, 71, 79, UU Shift(u) and Arrow&Calc(u)*a
  158. I(3) Up Down F1, F1, 79, DD Shift(ux2) *c
  159. J(4) Up Up F1, 79, UU Shift(u) and Arrow&Calc(u)*a
  160. Case Shift Calc Events Interpret
  161. -------------------------------------------------------------------
  162. K(1) ---- Down 71, 79, DD Calc(d)*a
  163. L(4) ---- Up F1, 79, UU Shift(u) and Arrow&Calc(u)*a
  164. M(1) Hold Down 71, 79, DD Calc(d)*a
  165. N Hold Up 79, UU Arrow&Calc(u)*a
  166. Where DD/UU indicates part of Keypad Down/Up event.
  167. *a: Impossible to distinguish btween Arrow and Calc event.
  168. *b: Shift(d) event is ignored.
  169. *c: Arrow/Calc(d) event is ignored.
  170. */
  171. uint8_t m0110_recv_key(void)
  172. {
  173. static uint8_t keybuf = 0x00;
  174. static uint8_t keybuf2 = 0x00;
  175. static uint8_t rawbuf = 0x00;
  176. uint8_t raw, raw2, raw3;
  177. if (keybuf) {
  178. raw = keybuf;
  179. keybuf = 0x00;
  180. return raw;
  181. }
  182. if (keybuf2) {
  183. raw = keybuf2;
  184. keybuf2 = 0x00;
  185. return raw;
  186. }
  187. if (rawbuf) {
  188. raw = rawbuf;
  189. rawbuf = 0x00;
  190. } else {
  191. raw = instant(); // Use INSTANT for better response. Should be INQUIRY ?
  192. }
  193. switch (KEY(raw)) {
  194. case M0110_KEYPAD:
  195. raw2 = instant();
  196. switch (KEY(raw2)) {
  197. case M0110_ARROW_UP:
  198. case M0110_ARROW_DOWN:
  199. case M0110_ARROW_LEFT:
  200. case M0110_ARROW_RIGHT:
  201. if (IS_BREAK(raw2)) {
  202. // Case B,F,N:
  203. keybuf = (raw2scan(raw2) | M0110_CALC_OFFSET); // Calc(u)
  204. return (raw2scan(raw2) | M0110_KEYPAD_OFFSET); // Arrow(u)
  205. }
  206. break;
  207. }
  208. // Keypad or Arrow
  209. return (raw2scan(raw2) | M0110_KEYPAD_OFFSET);
  210. break;
  211. case M0110_SHIFT:
  212. raw2 = instant();
  213. switch (KEY(raw2)) {
  214. case M0110_SHIFT:
  215. // Case: 5-8,C,G,H
  216. rawbuf = raw2;
  217. return raw2scan(raw); // Shift(d/u)
  218. break;
  219. case M0110_KEYPAD:
  220. // Shift + Arrow, Calc, or etc.
  221. raw3 = instant();
  222. switch (KEY(raw3)) {
  223. case M0110_ARROW_UP:
  224. case M0110_ARROW_DOWN:
  225. case M0110_ARROW_LEFT:
  226. case M0110_ARROW_RIGHT:
  227. if (IS_BREAK(raw)) {
  228. if (IS_BREAK(raw3)) {
  229. // Case 4:
  230. print("(4)\n");
  231. keybuf2 = raw2scan(raw); // Shift(u)
  232. keybuf = (raw2scan(raw3) | M0110_CALC_OFFSET); // Calc(u)
  233. return (raw2scan(raw3) | M0110_KEYPAD_OFFSET); // Arrow(u)
  234. } else {
  235. // Case 3:
  236. print("(3)\n");
  237. return (raw2scan(raw)); // Shift(u)
  238. }
  239. } else {
  240. if (IS_BREAK(raw3)) {
  241. // Case 2:
  242. print("(2)\n");
  243. keybuf = (raw2scan(raw3) | M0110_CALC_OFFSET); // Calc(u)
  244. return (raw2scan(raw3) | M0110_KEYPAD_OFFSET); // Arrow(u)
  245. } else {
  246. // Case 1:
  247. print("(1)\n");
  248. return (raw2scan(raw3) | M0110_CALC_OFFSET); // Calc(d)
  249. }
  250. }
  251. break;
  252. default:
  253. // Shift + Keypad
  254. keybuf = (raw2scan(raw3) | M0110_KEYPAD_OFFSET);
  255. return raw2scan(raw); // Shift(d/u)
  256. break;
  257. }
  258. break;
  259. default:
  260. // Shift + Normal keys
  261. keybuf = raw2scan(raw2);
  262. return raw2scan(raw); // Shift(d/u)
  263. break;
  264. }
  265. break;
  266. default:
  267. // Normal keys
  268. return raw2scan(raw);
  269. break;
  270. }
  271. }
  272. static inline uint8_t raw2scan(uint8_t raw) {
  273. return (raw == M0110_NULL) ? M0110_NULL : (
  274. (raw == M0110_ERROR) ? M0110_ERROR : (
  275. ((raw&0x80) | ((raw&0x7F)>>1))
  276. )
  277. );
  278. }
  279. static inline uint8_t inquiry(void)
  280. {
  281. m0110_send(M0110_INQUIRY);
  282. return m0110_recv();
  283. }
  284. static inline uint8_t instant(void)
  285. {
  286. m0110_send(M0110_INSTANT);
  287. uint8_t data = m0110_recv();
  288. if (data != M0110_NULL) {
  289. debug_hex(data); debug(" ");
  290. }
  291. return data;
  292. }
  293. static inline void clock_lo()
  294. {
  295. M0110_CLOCK_PORT &= ~(1<<M0110_CLOCK_BIT);
  296. M0110_CLOCK_DDR |= (1<<M0110_CLOCK_BIT);
  297. }
  298. static inline void clock_hi()
  299. {
  300. /* input with pull up */
  301. M0110_CLOCK_DDR &= ~(1<<M0110_CLOCK_BIT);
  302. M0110_CLOCK_PORT |= (1<<M0110_CLOCK_BIT);
  303. }
  304. static inline bool clock_in()
  305. {
  306. M0110_CLOCK_DDR &= ~(1<<M0110_CLOCK_BIT);
  307. M0110_CLOCK_PORT |= (1<<M0110_CLOCK_BIT);
  308. _delay_us(1);
  309. return M0110_CLOCK_PIN&(1<<M0110_CLOCK_BIT);
  310. }
  311. static inline void data_lo()
  312. {
  313. M0110_DATA_PORT &= ~(1<<M0110_DATA_BIT);
  314. M0110_DATA_DDR |= (1<<M0110_DATA_BIT);
  315. }
  316. static inline void data_hi()
  317. {
  318. /* input with pull up */
  319. M0110_DATA_DDR &= ~(1<<M0110_DATA_BIT);
  320. M0110_DATA_PORT |= (1<<M0110_DATA_BIT);
  321. }
  322. static inline bool data_in()
  323. {
  324. M0110_DATA_DDR &= ~(1<<M0110_DATA_BIT);
  325. M0110_DATA_PORT |= (1<<M0110_DATA_BIT);
  326. _delay_us(1);
  327. return M0110_DATA_PIN&(1<<M0110_DATA_BIT);
  328. }
  329. static inline uint16_t wait_clock_lo(uint16_t us)
  330. {
  331. while (clock_in() && us) { asm(""); _delay_us(1); us--; }
  332. return us;
  333. }
  334. static inline uint16_t wait_clock_hi(uint16_t us)
  335. {
  336. while (!clock_in() && us) { asm(""); _delay_us(1); us--; }
  337. return us;
  338. }
  339. static inline uint16_t wait_data_lo(uint16_t us)
  340. {
  341. while (data_in() && us) { asm(""); _delay_us(1); us--; }
  342. return us;
  343. }
  344. static inline uint16_t wait_data_hi(uint16_t us)
  345. {
  346. while (!data_in() && us) { asm(""); _delay_us(1); us--; }
  347. return us;
  348. }
  349. static inline void idle(void)
  350. {
  351. clock_hi();
  352. data_hi();
  353. }
  354. static inline void request(void)
  355. {
  356. clock_hi();
  357. data_lo();
  358. }
  359. /*
  360. Primitive M0110 Library for AVR
  361. ==============================
  362. Signaling
  363. ---------
  364. CLOCK is always from KEYBOARD. DATA are sent with MSB first.
  365. 1) IDLE: both lines are high.
  366. CLOCK ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  367. DATA ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  368. 2) KEYBOARD->HOST: HOST reads bit on rising edge.
  369. CLOCK ~~~~~~~~~~~~|__|~~~|__|~~~|__|~~~|__|~~~|__|~~~|__|~~~|__|~~~|__|~~~~~~~~~~~
  370. DATA ~~~~~~~~~~~~X777777X666666X555555X444444X333333X222222X111111X000000X~~~~~~~
  371. <--> 160us(clock low)
  372. <---> 180us(clock high)
  373. 3) HOST->KEYBOARD: HOST asserts bit on falling edge.
  374. CLOCK ~~~~~~~~~~~~|__|~~~|__|~~~|__|~~~|__|~~~|__|~~~|__|~~~|__|~~~|__|~~~~~~~~~~~
  375. DATA ~~~~~~|_____X777777X666666X555555X444444X333333X222222X111111X000000X~~~~~~~
  376. <----> 840us(request to send by host) <---> 80us(hold DATA)
  377. <--> 180us(clock low)
  378. <---> 220us(clock high)
  379. Protocol
  380. --------
  381. COMMAND:
  382. Inquiry 0x10 get key event with block
  383. Instant 0x12 get key event
  384. Model 0x14 get model number(M0110 responds with 0x09)
  385. bit 7 1 if another device connected(used when keypad exists?)
  386. bit4-6 next device model number
  387. bit1-3 keyboard model number
  388. bit 0 always 1
  389. Test 0x16 test(ACK:0x7D/NAK:0x77)
  390. KEY EVENT:
  391. bit 7 key state(0:press 1:release)
  392. bit 6-1 scan code(see below)
  393. bit 0 always 1
  394. To get scan code use this: ((bits&(1<<7)) | ((bits&0x7F))>>1).
  395. Note: On the M0110A, Keypad keys and Arrow keys are preceded by 0x79.
  396. Moreover, some Keypad keys(=, /, * and +) are preceded by 0x71 on press and 0xF1 on release.
  397. ARROW KEYS:
  398. Arrow keys and Calc keys(+,*,/,= on keypad) share same byte sequence and preceding byte of
  399. Calc keys(0x71 and 0xF1) means press and release event of SHIFT. This causes a very confusing situation,
  400. it is difficult or impossible to tell Calc key from Arrow key plus SHIFT in some cases.
  401. Raw key events:
  402. press release
  403. ---------------- ----------------
  404. Left: 0x79, 0x0D 0x79, 0x8D
  405. Right: 0x79, 0x05 0x79, 0x85
  406. Up: 0x79, 0x1B 0x79, 0x9B
  407. Down: 0x79, 0x11 0x79, 0x91
  408. Pad+: 0x71, 0x79, 0x0D 0xF1, 0x79, 0x8D
  409. Pad*: 0x71, 0x79, 0x05 0xF1, 0x79, 0x85
  410. Pad/: 0x71, 0x79, 0x1B 0xF1, 0x79, 0x9B
  411. Pad=: 0x71, 0x79, 0x11 0xF1, 0x79, 0x91
  412. RAW CODE:
  413. M0110A
  414. ,---------------------------------------------------------. ,---------------.
  415. | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Bcksp| |Clr| =| /| *|
  416. |---------------------------------------------------------| |---------------|
  417. |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| | | 7| 8| 9| -|
  418. |-----------------------------------------------------' | |---------------|
  419. |CapsLo| A| S| D| F| G| H| J| K| L| ;| '|Return| | 4| 5| 6| +|
  420. |---------------------------------------------------------| |---------------|
  421. |Shift | Z| X| C| V| B| N| M| ,| ,| /|Shft|Up | | 1| 2| 3| |
  422. |---------------------------------------------------------' |-----------|Ent|
  423. |Optio|Mac | Space | \|Lft|Rgt|Dn | | 0| .| |
  424. `---------------------------------------------------------' `---------------'
  425. ,---------------------------------------------------------. ,---------------.
  426. | 65| 25| 27| 29| 2B| 2F| 2D| 35| 39| 33| 3B| 37| 31| 67| |+0F|*11|*1B|*05|
  427. |---------------------------------------------------------| |---------------|
  428. | 61| 19| 1B| 1D| 1F| 23| 21| 41| 45| 3F| 47| 43| 3D| | |+33|+37|+39|+1D|
  429. |-----------------------------------------------------' | |---------------|
  430. | 73| 01| 03| 05| 07| 0B| 09| 4D| 51| 4B| 53| 4F| 49| |+2D|+2F|+31|*0D|
  431. |---------------------------------------------------------| |---------------|
  432. | 71| 0D| 0F| 11| 13| 17| 5B| 5D| 27| 5F| 59| 71|+1B| |+27|+29|+2B| |
  433. |---------------------------------------------------------' |-----------|+19|
  434. | 75| 6F| 63 | 55|+0D|+05|+11| | +25|+03| |
  435. `---------------------------------------------------------' `---------------'
  436. + 0x79, 0xDD / 0xF1, 0xUU
  437. * 0x71, 0x79,DD / 0xF1, 0x79, 0xUU
  438. MODEL NUMBER:
  439. M0110: 0x09 00001001 : model number 4 (100)
  440. M0110A: 0x0B 00001011 : model number 5 (101)
  441. M0110 & M0120: ???
  442. Scan Code
  443. ---------
  444. m0110_recv_key() function returns following scan codes instead of M0110 raw codes.
  445. Scan codes are 1 byte size and MSB(bit7) is set when key is released.
  446. scancode = ((raw&0x80) | ((raw&0x7F)>>1))
  447. M0110 M0120
  448. ,---------------------------------------------------------. ,---------------.
  449. | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backs| |Clr| -|Lft|Rgt|
  450. |---------------------------------------------------------| |---------------|
  451. |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| | 7| 8| 9|Up |
  452. |---------------------------------------------------------| |---------------|
  453. |CapsLo| A| S| D| F| G| H| J| K| L| ;| '|Return| | 4| 5| 6|Dn |
  454. |---------------------------------------------------------| |---------------|
  455. |Shift | Z| X| C| V| B| N| M| ,| ,| /| | | 1| 2| 3| |
  456. `---------------------------------------------------------' |-----------|Ent|
  457. |Opt|Mac | Space |Enter|Opt| | 0| .| |
  458. `------------------------------------------------' `---------------'
  459. ,---------------------------------------------------------. ,---------------.
  460. | 32| 12| 13| 14| 15| 17| 16| 1A| 1C| 19| 1D| 1B| 18| 33| | 47| 4E| 46| 42|
  461. |---------------------------------------------------------| |---------------|
  462. | 30| 0C| 0D| 0E| 0F| 10| 11| 20| 22| 1F| 23| 21| 1E| 2A| | 59| 5B| 5C| 4D|
  463. |---------------------------------------------------------| |---------------|
  464. | 39| 00| 01| 02| 03| 05| 04| 26| 28| 25| 29| 27| 24| | 56| 57| 58| 48|
  465. |---------------------------------------------------------| |---------------|
  466. | 38| 06| 07| 08| 09| 0B| 2D| 2E| 2B| 2F| 2C| 38| | 53| 54| 55| |
  467. `---------------------------------------------------------' |-----------| 4C|
  468. | 3A| 37| 31 | 34| 3A| | 52| 41| |
  469. `------------------------------------------------' `---------------'
  470. International keyboard(See page 22 of "Technical Info for 128K/512K")
  471. ,---------------------------------------------------------.
  472. | 32| 12| 13| 14| 15| 17| 16| 1A| 1C| 19| 1D| 1B| 18| 33|
  473. |---------------------------------------------------------|
  474. | 30| 0C| 0D| 0E| 0F| 10| 11| 20| 22| 1F| 23| 21| 1E| 2A|
  475. |------------------------------------------------------ |
  476. | 39| 00| 01| 02| 03| 05| 04| 26| 28| 25| 29| 27| 24| |
  477. |---------------------------------------------------------|
  478. | 38| 06| 07| 08| 09| 0B| 2D| 2E| 2B| 2F| 2C| 0A| 38|
  479. `---------------------------------------------------------'
  480. | 3A| 37| 34 | 31| 3A|
  481. `------------------------------------------------'
  482. M0110A
  483. ,---------------------------------------------------------. ,---------------.
  484. | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Bcksp| |Clr| =| /| *|
  485. |---------------------------------------------------------| |---------------|
  486. |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| | | 7| 8| 9| -|
  487. |-----------------------------------------------------' | |---------------|
  488. |CapsLo| A| S| D| F| G| H| J| K| L| ;| '|Return| | 4| 5| 6| +|
  489. |---------------------------------------------------------| |---------------|
  490. |Shift | Z| X| C| V| B| N| M| ,| ,| /|Shft|Up | | 1| 2| 3| |
  491. |---------------------------------------------------------' |-----------|Ent|
  492. |Optio|Mac | Space | \|Lft|Rgt|Dn | | 0| .| |
  493. `---------------------------------------------------------' `---------------'
  494. ,---------------------------------------------------------. ,---------------.
  495. | 32| 12| 13| 14| 15| 17| 16| 1A| 1C| 19| 1D| 1B| 18| 33| | 47| 68| 6D| 62|
  496. |---------------------------------------------------------| |---------------|
  497. | 30| 0C| 0D| 0E| 0F| 10| 11| 20| 22| 1F| 23| 21| 1E| | | 59| 5B| 5C| 4E|
  498. |-----------------------------------------------------' | |---------------|
  499. | 39| 00| 01| 02| 03| 05| 04| 26| 28| 25| 29| 27| 24| | 56| 57| 58| 66|
  500. |---------------------------------------------------------| |---------------|
  501. | 38| 06| 07| 08| 09| 0B| 2D| 2E| 2B| 2F| 2C| 38| 4D| | 53| 54| 55| |
  502. |---------------------------------------------------------' |-----------| 4C|
  503. | 3A| 37| 31 | 2A| 46| 42| 48| | 52| 41| |
  504. `---------------------------------------------------------' `---------------'
  505. References
  506. ----------
  507. Technical Info for 128K/512K and Plus
  508. ftp://ftp.apple.asimov.net/pub/apple_II/documentation/macintosh/Mac%20Hardware%20Info%20-%20Mac%20128K.pdf
  509. ftp://ftp.apple.asimov.net/pub/apple_II/documentation/macintosh/Mac%20Hardware%20Info%20-%20Mac%20Plus.pdf
  510. Protocol:
  511. Page 20 of Tech Info for 128K/512K
  512. http://www.mac.linux-m68k.org/devel/plushw.php
  513. Connector:
  514. Page 20 of Tech Info for 128K/512K
  515. http://www.kbdbabel.org/conn/kbd_connector_macplus.png
  516. Signaling:
  517. http://www.kbdbabel.org/signaling/kbd_signaling_mac.png
  518. http://typematic.blog.shinobi.jp/Entry/14/
  519. M0110 raw scan codes:
  520. Page 22 of Tech Info for 128K/512K
  521. Page 07 of Tech Info for Plus
  522. http://m0115.web.fc2.com/m0110.jpg
  523. http://m0115.web.fc2.com/m0110a.jpg
  524. */