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.

MEMO.txt 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  1. TODO
  2. test on remote site
  3. tmk.github.io/tmk_editor/hhkb/?
  4. github pages
  5. https://help.github.com/articles/user-organization-and-project-pages
  6. save file button
  7. https://developer.mozilla.org/en-US/docs/Web/API/Blob
  8. var typedArray = GetTheTypedArraySomehow();
  9. var blob = new Blob([typedArray], {type: "application/octet-binary"}); // pass a useful mime type here
  10. "application/octet-stream"
  11. var url = URL.createObjectURL(blob);
  12. TrueErgonomic
  13. var a = document.getElementById("download-link");
  14. a.href = window.URL.createObjectURL(blob);
  15. a.download = 'TrulyErgonomic_v3_3.hex';
  16. // a.textContent = 'Download file.';
  17. a.className = 'TE_link';
  18. a.click()
  19. keyboard key text css
  20. align of wrapped text
  21. edit action for FN key
  22. load/save JSON
  23. load/save hex(binary)
  24. binary file format
  25. meta info:
  26. date/time
  27. keyboard id
  28. keymap/actionmap
  29. firmware
  30. load binary
  31. Mass Storage or HID comm
  32. fixed address for keymaps
  33. action map support
  34. Hex file format
  35. http://en.wikipedia.org/wiki/Intel_HEX
  36. 1.Start code: ':'
  37. 2.Byte Count: 2 hex(0-255)
  38. 3.Address: 4 hex(0-2^16)
  39. 4.Record Type: 2 hex(00-05)
  40. 00: Data record. which contains 16bit address and data.
  41. 01: End of File record. It must appear in the last line.(usually :00000001FF)
  42. 02: Extended Segment Address Record.
  43. 03: Start Segment Address Record.
  44. 04: Extended Linear Address Record. Upper two bytes of 32 bit address.
  45. 05: Start Linear Address Record.
  46. 5.Data: byte_count * hex(a sequence of bytes)
  47. 6.Checksum: 2 hex LSB of 2's complement of the sum of fields: 'Byte Count', 'Address', 'Record Type' and 'Data'.
  48. checksum = ~(the sum of bytes)&0xff + 1 = (the sum)&0xff^0xff + 1
  49. TMK keymapping mode
  50. keymap 8bit code
  51. Special 8bit code Fn0-32 can be assigned for action code.
  52. actions[] -> ---------------
  53. | action x 32 |
  54. keymaps[] -> ---------------
  55. | keymap 0 |
  56. ---------------
  57. | keymap 1 |
  58. ---------------
  59. | keymap 2 |
  60. ---------------
  61. | keymap 3 |
  62. ---------------
  63. Interface: uint8_t keymap_key_to_keycode(uint8_t layer, key_t key) in keymap.h
  64. action_t keymap_fn_to_action(uint8_t keycode) in keymap.h
  65. static const uint16_t PROGMEM fn_actions[] = {
  66. [0] = ACTION_LAYER_MOMENTARY(0),
  67. [1] = ACTION_LAYER_MOMENTARY(1),
  68. [2] = ACTION_LAYER_MOMENTARY(2),
  69. [3] = ACTION_LAYER_MOMENTARY(3),
  70. [4] = ACTION_LAYER_TOGGLE(0),
  71. [5] = ACTION_LAYER_TOGGLE(1),
  72. [6] = ACTION_LAYER_TOGGLE(2),
  73. [7] = ACTION_LAYER_TOGGLE(3),
  74. [8] = ACTION_LAYER_TAP_TOGGLE(0),
  75. [9] = ACTION_LAYER_TAP_TOGGLE(1),
  76. [10] = ACTION_LAYER_TAP_TOGGLE(2),
  77. [11] = ACTION_LAYER_TAP_TOGGLE(3),
  78. };
  79. actionmap 16bit code
  80. All key action can be defined in 16bit code.
  81. Memory usage will be about doubled size compared to keymap 8bit code.
  82. Map Structure:
  83. actionmaps[] -> ---------------
  84. | actionmap 0 |
  85. ---------------
  86. | actionmap 1 |
  87. ---------------
  88. | actionmap 2 |
  89. ---------------
  90. | actionmap 3 |
  91. ---------------
  92. Interface: action_t action_for_key(uint8_t layer, key_t key) in action.h
  93. Flash usage cosidaration
  94. ATmega32U4
  95. 32KB Firmware -24KB(with full option)
  96. Keymapping 4KB-
  97. Bootloader 4KB(Atmel stock) or 512B(Teensy)
  98. ATmega16U4
  99. 16KB Firmware -10KB
  100. Keymapping 2KB-
  101. Bootloader 4KB(Atmel stock) or 512B(Teensy)
  102. PS/2 and ADB have 256 keys in map, so use 512B each layer.
  103. 8layers will be available for ATMega32U4 and 4layers for 16U4. This seems like enough in most case.
  104. HTML
  105. Keyboard key element ID
  106. a) ID indicates place of look. needs Converter Table.
  107. b) ID indicates matrix position.
  108. x c) ID indicates defalut key name like: q, w, ... lshift...
  109. Not good. no consistency of name length.
  110. Javascript
  111. Keymap Array
  112. includes matrix postions of the key.
  113. keymap[LAYER][8][8] = {
  114. { { }, { } }
  115. Keycode table
  116. keyname => keycode(16bit)
  117. keycode => keyname
  118. Keymap
  119. 16bit keymap at first
  120. 8bit keymap support depends on future request
  121. Fn key configure
  122. Macro editor
  123. Where it converts key postion into matrix position at?
  124. Convert table? UI can use position of elemen placing.
  125. UI uses matrix posiotn for ID of element.
  126. HHKB key matrix
  127. COL 0 1 2 3 4 5 6 7
  128. ROW ---------------------------------------------------------------
  129. 0| 2 q w s a z x c
  130. 1| 3 4 r e d f v b
  131. 2| 5 6 y t g h n _NONE_
  132. 3| 1 Esc Tab Control LShift LAlt LMeta Space
  133. 4| 7 8 u i k j m _NONE_
  134. 5| \ ` Delete Return Fn RShift RAlt RMeta
  135. 6| 9 0 o p ; l , _NONE_
  136. 7| - + ] [ ' / . _NONE_
  137. Key to matrix Table
  138. /* Qwerty
  139. * ,-----------------------------------------------------------.
  140. * |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| \| `|
  141. * |-----------------------------------------------------------|
  142. * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]|Backs|
  143. * |-----------------------------------------------------------|
  144. * |Contro| A| S| D| F| G| H| J| K| L| ;| '|Enter |
  145. * |-----------------------------------------------------------|
  146. * |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift |Fn |
  147. * `-----------------------------------------------------------'
  148. * |Gui|Alt | Space |Alt |Gui|
  149. * `-------------------------------------------'
  150. */
  151. [
  152. 0x31, 0x30, 0x00, 0x10, 0x11, 0x20, 0x21, 0x40, 0x41, 0x60, 0x61, 0x70, 0x71, 0x50, 0x51,
  153. 0x32, 0x01, 0x02, 0x13, 0x12, 0x23, 0x22, 0x42, 0x43, 0x62, 0x63, 0x73, 0x72, 0x52,
  154. 0x33, 0x04, 0x03, 0x14, 0x15, 0x24, 0x25, 0x45, 0x44, 0x65, 0x64, 0x66, 0x53,
  155. 0x34, 0x05, 0x06, 0x07, 0x16, 0x17, 0x26, 0x46, 0x66, 0x76, 0x75, 0x55, 0x54,
  156. 0x35, 0x36, 0x37, 0x57, 0x56,
  157. ]
  158. KC_NO = 0x00,
  159. KC_ROLL_OVER,
  160. KC_POST_FAIL,
  161. KC_UNDEFINED,
  162. KC_A,
  163. KC_B,
  164. KC_C,
  165. KC_D,
  166. KC_E,
  167. KC_F,
  168. KC_G,
  169. KC_H,
  170. KC_I,
  171. KC_J,
  172. KC_K,
  173. KC_L,
  174. KC_M, /* 0x10 */
  175. KC_N,
  176. KC_O,
  177. KC_P,
  178. KC_Q,
  179. KC_R,
  180. KC_S,
  181. KC_T,
  182. KC_U,
  183. KC_V,
  184. KC_W,
  185. KC_X,
  186. KC_Y,
  187. KC_Z,
  188. KC_1,
  189. KC_2,
  190. KC_3, /* 0x20 */
  191. KC_4,
  192. KC_5,
  193. KC_6,
  194. KC_7,
  195. KC_8,
  196. KC_9,
  197. KC_0,
  198. KC_ENTER,
  199. KC_ESCAPE,
  200. KC_BSPACE,
  201. KC_TAB,
  202. KC_SPACE,
  203. KC_MINUS,
  204. KC_EQUAL,
  205. KC_LBRACKET,
  206. KC_RBRACKET, /* 0x30 */
  207. KC_BSLASH, /* \ (and |) */
  208. KC_NONUS_HASH, /* Non-US # and ~ */
  209. KC_SCOLON, /* ; (and :) */
  210. KC_QUOTE, /* ' and " */
  211. KC_GRAVE, /* Grave accent and tilde */
  212. KC_COMMA, /* , and < */
  213. KC_DOT, /* . and > */
  214. KC_SLASH, /* / and ? */
  215. KC_CAPSLOCK,
  216. KC_F1,
  217. KC_F2,
  218. KC_F3,
  219. KC_F4,
  220. KC_F5,
  221. KC_F6,
  222. KC_F7, /* 0x40 */
  223. KC_F8,
  224. KC_F9,
  225. KC_F10,
  226. KC_F11,
  227. KC_F12,
  228. KC_PSCREEN,
  229. KC_SCROLLLOCK,
  230. KC_PAUSE,
  231. KC_INSERT,
  232. KC_HOME,
  233. KC_PGUP,
  234. KC_DELETE,
  235. KC_END,
  236. KC_PGDOWN,
  237. KC_RIGHT,
  238. KC_LEFT, /* 0x50 */
  239. KC_DOWN,
  240. KC_UP,
  241. KC_NUMLOCK,
  242. KC_KP_SLASH,
  243. KC_KP_ASTERISK,
  244. KC_KP_MINUS,
  245. KC_KP_PLUS,
  246. KC_KP_ENTER,
  247. KC_KP_1,
  248. KC_KP_2,
  249. KC_KP_3,
  250. KC_KP_4,
  251. KC_KP_5,
  252. KC_KP_6,
  253. KC_KP_7,
  254. KC_KP_8, /* 0x60 */
  255. KC_KP_9,
  256. KC_KP_0,
  257. KC_KP_DOT,
  258. KC_NONUS_BSLASH, /* Non-US \ and | */
  259. KC_APPLICATION,
  260. KC_POWER,
  261. KC_KP_EQUAL,
  262. KC_F13,
  263. KC_F14,
  264. KC_F15,
  265. KC_F16,
  266. KC_F17,
  267. KC_F18,
  268. KC_F19,
  269. KC_F20,
  270. KC_F21, /* 0x70 */
  271. KC_F22,
  272. KC_F23,
  273. KC_F24,
  274. KC_EXECUTE,
  275. KC_HELP,
  276. KC_MENU,
  277. KC_SELECT,
  278. KC_STOP,
  279. KC_AGAIN,
  280. KC_UNDO,
  281. KC_CUT,
  282. KC_COPY,
  283. KC_PASTE,
  284. KC_FIND,
  285. KC__MUTE,
  286. KC__VOLUP, /* 0x80 */
  287. KC__VOLDOWN,
  288. KC_LOCKING_CAPS, /* locking Caps Lock */
  289. KC_LOCKING_NUM, /* locking Num Lock */
  290. KC_LOCKING_SCROLL, /* locking Scroll Lock */
  291. KC_KP_COMMA,
  292. KC_KP_EQUAL_AS400, /* equal sign on AS/400 */
  293. KC_INT1,
  294. KC_INT2,
  295. KC_INT3,
  296. KC_INT4,
  297. KC_INT5,
  298. KC_INT6,
  299. KC_INT7,
  300. KC_INT8,
  301. KC_INT9,
  302. KC_LANG1, /* 0x90 */
  303. KC_LANG2,
  304. KC_LANG3,
  305. KC_LANG4,
  306. KC_LANG5,
  307. KC_LANG6,
  308. KC_LANG7,
  309. KC_LANG8,
  310. KC_LANG9,
  311. KC_ALT_ERASE,
  312. KC_SYSREQ,
  313. KC_CANCEL,
  314. KC_CLEAR,
  315. KC_PRIOR,
  316. KC_RETURN,
  317. KC_SEPARATOR,
  318. KC_OUT, /* 0xA0 */
  319. KC_OPER,
  320. KC_CLEAR_AGAIN,
  321. KC_CRSEL,
  322. KC_EXSEL, /* 0xA4 */
  323. /* NOTE: Following codes(0xB0-DD) are not used. Leave them for reference. */
  324. KC_KP_00 = 0xB0,
  325. KC_KP_000,
  326. KC_THOUSANDS_SEPARATOR,
  327. KC_DECIMAL_SEPARATOR,
  328. KC_CURRENCY_UNIT,
  329. KC_CURRENCY_SUB_UNIT,
  330. KC_KP_LPAREN,
  331. KC_KP_RPAREN,
  332. KC_KP_LCBRACKET, /* { */
  333. KC_KP_RCBRACKET, /* } */
  334. KC_KP_TAB,
  335. KC_KP_BSPACE,
  336. KC_KP_A,
  337. KC_KP_B,
  338. KC_KP_C,
  339. KC_KP_D,
  340. KC_KP_E, /* 0xC0 */
  341. KC_KP_F,
  342. KC_KP_XOR,
  343. KC_KP_HAT,
  344. KC_KP_PERC,
  345. KC_KP_LT,
  346. KC_KP_GT,
  347. KC_KP_AND,
  348. KC_KP_LAZYAND,
  349. KC_KP_OR,
  350. KC_KP_LAZYOR,
  351. KC_KP_COLON,
  352. KC_KP_HASH,
  353. KC_KP_SPACE,
  354. KC_KP_ATMARK,
  355. KC_KP_EXCLAMATION,
  356. KC_KP_MEM_STORE, /* 0xD0 */
  357. KC_KP_MEM_RECALL,
  358. KC_KP_MEM_CLEAR,
  359. KC_KP_MEM_ADD,
  360. KC_KP_MEM_SUB,
  361. KC_KP_MEM_MUL,
  362. KC_KP_MEM_DIV,
  363. KC_KP_PLUS_MINUS,
  364. KC_KP_CLEAR,
  365. KC_KP_CLEAR_ENTRY,
  366. KC_KP_BINARY,
  367. KC_KP_OCTAL,
  368. KC_KP_DECIMAL,
  369. KC_KP_HEXADECIMAL, /* 0xDD */
  370. /* Modifiers */
  371. KC_LCTRL = 0xE0,
  372. KC_LSHIFT,
  373. KC_LALT,
  374. KC_LGUI,
  375. KC_RCTRL,
  376. KC_RSHIFT,
  377. KC_RALT,
  378. KC_RGUI,