Keyboard firmwares for Atmel AVR and Cortex-M
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

11 лет назад
11 лет назад
11 лет назад
11 лет назад
11 лет назад
11 лет назад
11 лет назад
11 лет назад
11 лет назад
11 лет назад
11 лет назад
11 лет назад
11 лет назад
11 лет назад
11 лет назад
11 лет назад
11 лет назад
11 лет назад
11 лет назад
11 лет назад
11 лет назад
11 лет назад
11 лет назад
11 лет назад
11 лет назад
11 лет назад
11 лет назад
11 лет назад
11 лет назад
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. Copyright 2013 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. #include "keymap.h"
  15. #include "report.h"
  16. #include "keycode.h"
  17. #include "action.h"
  18. action_t keymap_keycode_to_action(uint8_t keycode)
  19. {
  20. action_t action;
  21. switch (keycode) {
  22. case KC_A ... KC_EXSEL:
  23. action.code = ACTION_KEY(keycode);
  24. break;
  25. case KC_LCTRL ... KC_LGUI:
  26. action.code = ACTION_LMOD(keycode);
  27. break;
  28. case KC_RCTRL ... KC_RGUI:
  29. action.code = ACTION_RMOD(keycode);
  30. break;
  31. case KC_SYSTEM_POWER ... KC_SYSTEM_WAKE:
  32. action.code = ACTION_USAGE_SYSTEM(KEYCODE2SYSTEM(keycode));
  33. break;
  34. case KC_AUDIO_MUTE ... KC_WWW_FAVORITES:
  35. action.code = ACTION_USAGE_CONSUMER(KEYCODE2CONSUMER(keycode));
  36. break;
  37. case KC_MS_UP ... KC_MS_ACCEL2:
  38. action.code = ACTION_MOUSEKEY(keycode);
  39. break;
  40. case KC_TRNS:
  41. action.code = ACTION_TRANSPARENT;
  42. break;
  43. default:
  44. action.code = ACTION_NO;
  45. break;
  46. }
  47. return action;
  48. }
  49. #ifndef NO_LEGACY_KEYMAP_SUPPORT
  50. /* legacy support with weak reference */
  51. __attribute__ ((weak))
  52. action_t action_for_key(uint8_t layer, key_t key)
  53. {
  54. /* convert from legacy keycode to action */
  55. uint8_t keycode = keymap_get_keycode(layer, key.pos.row, key.pos.col);
  56. action_t action;
  57. switch (keycode) {
  58. case KC_FN0 ... KC_FN31:
  59. {
  60. uint8_t layer = keymap_fn_layer(FN_INDEX(keycode));
  61. uint8_t key = keymap_fn_keycode(FN_INDEX(keycode));
  62. if (key) {
  63. action.code = ACTION_LAYER_SET_TAP_KEY(layer, key);
  64. } else {
  65. action.code = ACTION_LAYER_SET_MOMENTARY(layer);
  66. }
  67. }
  68. return action;
  69. default:
  70. return keymap_keycode_to_action(keycode);
  71. }
  72. }
  73. #endif
  74. __attribute__ ((weak))
  75. void action_function(keyrecord_t *event, uint8_t id, uint8_t opt)
  76. {
  77. }