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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

keymap_common.c 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. Copyright 2014 Kai Ryu <[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 <avr/pgmspace.h>
  15. #include "keymap.h"
  16. #include "keymap_in_eeprom.h"
  17. #include "keymap_common.h"
  18. /* translates key to keycode */
  19. uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
  20. {
  21. /* xprintf("Layer: %d, Row: %d, Col: %d, ", layer, key.row, key.col); */
  22. #ifndef KEYMAP_IN_EEPROM_ENABLE
  23. return pgm_read_byte(&keymaps[(layer)][(key.row) * matrix_cols() + (key.col)]);
  24. #else
  25. return eeconfig_read_keymap_key(layer, key.row, key.col);
  26. #endif
  27. }
  28. /* translates Fn keycode to action */
  29. action_t keymap_fn_to_action(uint8_t keycode)
  30. {
  31. return (action_t) {
  32. #ifndef KEYMAP_IN_EEPROM_ENABLE
  33. .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)])
  34. #else
  35. .code = eeconfig_read_keymap_fn_action(FN_INDEX(keycode))
  36. #endif
  37. };
  38. }
  39. #ifdef KEYMAP_IN_EEPROM_ENABLE
  40. const uint8_t* keymaps_pointer(void) {
  41. return (const uint8_t*)keymaps;
  42. }
  43. const uint16_t* fn_actions_pointer(void) {
  44. return fn_actions;
  45. }
  46. #endif