Keyboard firmwares for Atmel AVR and Cortex-M
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

keymap.c 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. * Keymap for ADB keyboard
  3. */
  4. #include <stdint.h>
  5. #include <stdbool.h>
  6. #include <avr/pgmspace.h>
  7. #include "usb_keyboard.h"
  8. #include "usb_keycodes.h"
  9. #include "print.h"
  10. #include "debug.h"
  11. #include "util.h"
  12. #include "keymap_skel.h"
  13. // Convert physical keyboard layout to matrix array.
  14. // This is a macro to define keymap easily in keyboard layout form.
  15. // TODO: ADB to USB default keymap
  16. // TODO: keymap macro template for m0116/m0115
  17. /* Apple Keyboard m0116
  18. K7F, \
  19. K35, K12, K13, K14, K15, K17, K16, K1A, K1C, K19, K1D, K1B, K18, K33, K47, K51, K4B, K43, \
  20. K30, K0C, K0D, K0E, K0F, K10, K11, K20, K22, K1F, K23, K21, K1E, K59, K5B, K5C, K4E, \
  21. K36, K00, K01, K02, K03, K05, K04, K26, K28, K25, K29, K27, K24, K56, K57, K58, K45, \
  22. K38, K06, K07, K08, K09, K0B, K2D, K2E, K2B, K2F, K2C, K7B, K53, K54, K55, \
  23. K39, K3A, K37, K32, K31, K2A, K3B, K3C, K3D, K3E, K52, K41, K4C \
  24. */
  25. /* no tenkey
  26. K7F, \
  27. K35, K12, K13, K14, K15, K17, K16, K1A, K1C, K19, K1D, K1B, K18, K33, \
  28. K30, K0C, K0D, K0E, K0F, K10, K11, K20, K22, K1F, K23, K21, K1E, \
  29. K36, K00, K01, K02, K03, K05, K04, K26, K28, K25, K29, K27, K24, \
  30. K38, K06, K07, K08, K09, K0B, K2D, K2E, K2B, K2F, K2C, K7B, \
  31. K39, K3A, K37, K32, K31, K2A, K3B, K3C, K3D, K3E \
  32. */
  33. #define KEYMAP( \
  34. K7F, \
  35. K35, K12, K13, K14, K15, K17, K16, K1A, K1C, K19, K1D, K1B, K18, K33, \
  36. K30, K0C, K0D, K0E, K0F, K10, K11, K20, K22, K1F, K23, K21, K1E, \
  37. K36, K00, K01, K02, K03, K05, K04, K26, K28, K25, K29, K27, K24, \
  38. K38, K06, K07, K08, K09, K0B, K2D, K2E, K2B, K2F, K2C, K7B, \
  39. K39, K3A, K37, K32, K31, K2A, K3B, K3C, K3D, K3E \
  40. ) { \
  41. { K00, K01, K02, K03, K04, K05, K06, K07 }, \
  42. { K08, K09, 000, K0B, K0C, K0D, K0E, K0F }, \
  43. { K10, K11, K12, K13, K14, K15, K16, K17 }, \
  44. { K18, K19, K1A, K1B, K1C, K1D, K1E, K1F }, \
  45. { K20, K21, K22, K23, K24, K25, K26, K27 }, \
  46. { K28, K29, K2A, K2B, K2C, K2D, K2E, K2F }, \
  47. { K30, K31, K32, K33, 000, K35, K36, K37 }, \
  48. { K38, K39, K3A, K3B, K3C, K3D, K3E, 000 }, \
  49. { 000, 000, 000, 000, 000, 000, 000, 000 }, \
  50. { 000, 000, 000, 000, 000, 000, 000, 000 }, \
  51. { 000, 000, 000, 000, 000, 000, 000, 000 }, \
  52. { 000, 000, 000, 000, 000, 000, 000, 000 }, \
  53. { 000, 000, 000, 000, 000, 000, 000, 000 }, \
  54. { 000, 000, 000, 000, 000, 000, 000, 000 }, \
  55. { 000, 000, 000, 000, 000, 000, 000, 000 }, \
  56. { 000, 000, 000, K7B, 000, 000, 000, K7F }, \
  57. }
  58. #define KEYCODE(layer, row, col) (pgm_read_byte(&keymaps[(layer)][(row)][(col)]))
  59. // Assign Fn key(0-7) to a layer to which switch with the Fn key pressed.
  60. static const uint8_t PROGMEM fn_layer[] = {
  61. 0, // FN_0
  62. 0, // FN_1
  63. 0, // FN_2
  64. 0, // FN_3
  65. 0, // FN_4
  66. 0, // FN_5
  67. 0, // FN_6
  68. 0 // FN_7
  69. };
  70. // Assign Fn key(0-7) to a keycode sent when release Fn key without use of the layer.
  71. // See layer.c for details.
  72. static const uint8_t PROGMEM fn_keycode[] = {
  73. KB_NO, // FN_0
  74. KB_NO, // FN_1
  75. KB_NO, // FN_2
  76. KB_NO, // FN_3
  77. KB_NO, // FN_4
  78. KB_NO, // FN_5
  79. KB_NO, // FN_6
  80. KB_NO // FN_7
  81. };
  82. static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  83. /* Layer 0: Default Layer
  84. * ,---------------------------------------------------------.
  85. * |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backs|
  86. * |---------------------------------------------------------|
  87. * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| |
  88. * |-----------------------------------------------------' |
  89. * |Contro| A| S| D| F| G| H| J| K| L|Fn3| '|Return|
  90. * |---------------------------------------------------------|
  91. * |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift |
  92. * |---------------------------------------------------------|
  93. * |Shi|Alt|Gui l `| | \|Lef|Rig|Dow|Up |
  94. * `---------------------------------------------------------'
  95. */
  96. KEYMAP(KB_PWR, \
  97. KB_ESC, KB_1, KB_2, KB_3, KB_4, KB_5, KB_6, KB_7, KB_8, KB_9, KB_0, KB_MINS,KB_EQL, KB_BSPC, \
  98. KB_TAB, KB_Q, KB_W, KB_E, KB_R, KB_T, KB_Y, KB_U, KB_I, KB_O, KB_P, KB_LBRC,KB_RBRC, \
  99. KB_LCTL,KB_A, KB_S, KB_D, KB_F, KB_G, KB_H, KB_J, KB_K, KB_L, KB_SCLN,KB_QUOT,KB_ENT, \
  100. KB_LSFT,KB_Z, KB_X, KB_C, KB_V, KB_B, KB_N, KB_M, KB_COMM,KB_DOT, KB_SLSH,KB_RSFT, \
  101. KB_LSFT,KB_LALT,KB_LGUI,KB_GRV, KB_SPC, KB_BSLS,KB_LEFT,KB_RGHT,KB_DOWN,KB_UP),
  102. };
  103. uint8_t keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t col)
  104. {
  105. return KEYCODE(layer, row, col);
  106. }
  107. uint8_t keymap_fn_layer(uint8_t fn_bits)
  108. {
  109. return pgm_read_byte(&fn_layer[biton(fn_bits)]);
  110. }
  111. uint8_t keymap_fn_keycode(uint8_t fn_bits)
  112. {
  113. return pgm_read_byte(&fn_keycode[(biton(fn_bits))]);
  114. }
  115. // define a condition to enter special function mode
  116. bool keymap_is_special_mode(uint8_t fn_bits)
  117. {
  118. //return (usb_keyboard_mods == (BIT_LCTRL | BIT_LSHIFT | BIT_LALT | BIT_LGUI));
  119. return (usb_keyboard_mods == (BIT_RSHIFT));
  120. }