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.

keymap.c 7.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /*
  2. Copyright 2011 Jun Wako <[email protected]>
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. /*
  15. * Keymap for Macway mod
  16. */
  17. #include <stdint.h>
  18. #include <stdbool.h>
  19. #include <avr/pgmspace.h>
  20. #include "keycode.h"
  21. #include "print.h"
  22. #include "debug.h"
  23. #include "util.h"
  24. #include "keymap.h"
  25. // Convert physical keyboard layout to matrix array.
  26. // This is a macro to define keymap easily in keyboard layout form.
  27. /*
  28. * Tenkeyless keyboard:
  29. * ,---. ,---------------. ,---------------. ,---------------. ,-----------.
  30. * |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau|
  31. * `---' `---------------' `---------------' `---------------' `-----------'
  32. * ,-----------------------------------------------------------. ,-----------.
  33. * |~ | 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | |Ins|Hom|PgU|
  34. * |-----------------------------------------------------------| |-----------|
  35. * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|End|PgD|
  36. * |-----------------------------------------------------------| `-----------'
  37. * |Caps | A| S| D| F| G| H| J| K| L| ;| '|Return |
  38. * |-----------------------------------------------------------| ,---.
  39. * |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift | |Up |
  40. * |-----------------------------------------------------------| ,-----------.
  41. * |Ctl|Gui|Alt| Space |Alt|Gui|App|Ctl| |Lef|Dow|Rig|
  42. * `-----------------------------------------------------------' `-----------'
  43. *
  44. * TODO: You should define follwing macro properly. It won't be compiled until done.
  45. *
  46. * Keymap array sapce has 18*8 slot, row is designated with A-Q and col with 0-7.
  47. * In this macro KA0 means key at row:A/col:0, KR7 means key at rowR/col7.
  48. * Empty slot of keymap should has KC_NO.For example row:B/col:0 has no key
  49. * so you must define KC_NO in this slot.(from hid_liber/ansi_iso_jis.c)
  50. * Esc key locates at row:A/col:1 so fist argument of macro should say KA1.
  51. * Right arrow key locates at row:Q/col:2 so last argument of macro should say KQ2.
  52. *
  53. * NOTE: Except above examples, the rest of macro definition is garbage just for place holder.
  54. */
  55. #define KEYMAP( \
  56. KA1,K05,K06,K04,K0C,K03,K0B,K83,K0A,K01,K09,K78,K07, KFC,K7E,KFE, \
  57. K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K66, KF0,KEC,KFD, \
  58. K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B,K5D, KF1,KE9,KFA, \
  59. K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52, K5A, \
  60. K12,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A, K59, KF5, \
  61. K14,K9F,K11, K29, K91,KA7,KAF,K94, KEB,KF2,KQ2 \
  62. ) { \
  63. { KC_##KA0, KC_##KA1, KC_##KA2, KC_##KA3, KC_##KA4, KC_##KA5, KC_##KA6, KC_##KA7 }, \
  64. { KC_NO, KC_##KB1, KC_##KB2, KC_##KB3, KC_##KB4, KC_##KB5, KC_##KB6, KC_##KB7 }, \
  65. { KC_##KC0, KC_##KC1, KC_##KC2, KC_##KC3, KC_##KC4, KC_##KC5, KC_##KC6, KC_##KC7 }, \
  66. { KC_##KD0, KC_##KD1, KC_##KD2, KC_##KD3, KC_##KD4, KC_##KD5, KC_##KD6, KC_##KD7 }, \
  67. { KC_##KE0, KC_##KE1, KC_##KE2, KC_##KE3, KC_##KE4, KC_##KE5, KC_##KE6, KC_##KE7 }, \
  68. { KC_##KF0, KC_##KF1, KC_##KF2, KC_##KF3, KC_##KF4, KC_##KF5, KC_##KF6, KC_##KF7 }, \
  69. { KC_##KG0, KC_##KG1, KC_##KG2, KC_##KG3, KC_##KG4, KC_##KG5, KC_##KG6, KC_##KG7 }, \
  70. { KC_##KH0, KC_##KH1, KC_##KH2, KC_##KH3, KC_##KH4, KC_##KH5, KC_##KH6, KC_##KH7 }, \
  71. { KC_##KI0, KC_##KI1, KC_##KI2, KC_##KI3, KC_##KI4, KC_##KI5, KC_##KI6, KC_##KI7 }, \
  72. { KC_##KJ0, KC_##KJ1, KC_##KJ2, KC_##KJ3, KC_##KJ4, KC_##KJ5, KC_##KJ6, KC_##KJ7 }, \
  73. { KC_##KK0, KC_##KK1, KC_##KK2, KC_##KK3, KC_##KK4, KC_##KK5, KC_##KK6, KC_##KK7 }, \
  74. { KC_##KL0, KC_##KL1, KC_##KL2, KC_##KL3, KC_##KL4, KC_##KL5, KC_##KL6, KC_##KL7 }, \
  75. { KC_##KM0, KC_##KM1, KC_##KM2, KC_##KM3, KC_##KM4, KC_##KM5, KC_##KM6, KC_##KM7 }, \
  76. { KC_##KN0, KC_##KN1, KC_##KN2, KC_##KN3, KC_##KN4, KC_##KN5, KC_##KN6, KC_##KN7 }, \
  77. { KC_##KO0, KC_##KO1, KC_##KO2, KC_##KO3, KC_##KO4, KC_##KO5, KC_##KO6, KC_##KO7 }, \
  78. { KC_##KP0, KC_##KP1, KC_##KP2, KC_##KP3, KC_##KP4, KC_##KP5, KC_##KP6, KC_##KP7 }, \
  79. { KC_##KQ0, KC_##KQ1, KC_##KQ2, KC_##KQ3, KC_##KQ4, KC_##KQ5, KC_##KQ6, KC_##KQ7 }, \
  80. { KC_##KR0, KC_##KR1, KC_##KR2, KC_##KR3, KC_##KR4, KC_##KR5, KC_##KR6, KC_##KR7 } \
  81. }
  82. #define KEYCODE(layer, row, col) (pgm_read_byte(&keymaps[(layer)][(row)][(col)]))
  83. // Assign Fn key(0-7) to a layer to which switch with the Fn key pressed.
  84. static const uint8_t PROGMEM fn_layer[] = {
  85. 0, // Fn0
  86. 0, // Fn1
  87. 0, // Fn2
  88. 0, // Fn3
  89. 0, // Fn4
  90. 0, // Fn5
  91. 0, // Fn6
  92. 0 // Fn7
  93. };
  94. // Assign Fn key(0-7) to a keycode sent when release Fn key without use of the layer.
  95. // See layer.c for details.
  96. static const uint8_t PROGMEM fn_keycode[] = {
  97. KC_NO, // Fn0
  98. KC_NO, // Fn1
  99. KC_NO, // Fn2
  100. KC_NO, // Fn3
  101. KC_NO, // Fn4
  102. KC_NO, // Fn5
  103. KC_NO, // Fn6
  104. KC_NO // Fn7
  105. };
  106. /* See common/keycode.h for short name of key symbol. */
  107. static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  108. /* Layer 0: Default Layer
  109. * ,---. ,---------------. ,---------------. ,---------------. ,-----------.
  110. * |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau|
  111. * `---' `---------------' `---------------' `---------------' `-----------'
  112. * ,-----------------------------------------------------------. ,-----------.
  113. * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backspa| |Ins|Hom|PgU|
  114. * |-----------------------------------------------------------| |-----------|
  115. * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|End|PgD|
  116. * |-----------------------------------------------------------| `-----------'
  117. * |CapsLo| A| S| D| F| G| H| J| K| L| ;| '|Return |
  118. * |-----------------------------------------------------------| ,---.
  119. * |Shift | Z| X| C| V| B| N| M| ,| ,| /|Shift | |Up |
  120. * |-----------------------------------------------------------| ,-----------.
  121. * |Ctrl |Gui |Alt | Space |Alt |Gui |Menu|Ctrl| |Lef|Dow|Rig|
  122. * `-----------------------------------------------------------' `-----------'
  123. */
  124. KEYMAP(
  125. ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK,
  126. GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP,
  127. TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, DEL, END, PGDN,
  128. CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT,
  129. LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, UP,
  130. LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT
  131. ),
  132. };
  133. uint8_t keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t col)
  134. {
  135. return KEYCODE(layer, row, col);
  136. }
  137. uint8_t keymap_fn_layer(uint8_t index)
  138. {
  139. return pgm_read_byte(&fn_layer[index]);
  140. }
  141. uint8_t keymap_fn_keycode(uint8_t index)
  142. {
  143. return pgm_read_byte(&fn_keycode[index]);
  144. }