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.

layer_switch.h 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. #ifndef LAYER_SWITCH_H
  15. #define LAYER_SWITCH_H
  16. #include <stdint.h>
  17. #include "keyboard.h"
  18. #include "action.h"
  19. /* overlays are asigned at layer 16-31 */
  20. #define OVERLAY_BIT 0x10
  21. #define OVERLAY_MASK 0x0F
  22. /*
  23. * Default Layer
  24. */
  25. /* base layer to fall back */
  26. extern uint8_t default_layer;
  27. void default_layer_set(uint8_t layer);
  28. /*
  29. * Keymap Layer
  30. */
  31. extern uint16_t keymap_stat;
  32. /* return current active layer */
  33. uint8_t keymap_get_layer(void);
  34. void keymap_clear(void);
  35. void keymap_set(uint16_t stat);
  36. void keymap_move(uint8_t layer);
  37. void keymap_on(uint8_t layer);
  38. void keymap_off(uint8_t layer);
  39. void keymap_invert(uint8_t layer);
  40. /* bitwise operation */
  41. void keymap_or(uint16_t stat);
  42. void keymap_and(uint16_t stat);
  43. void keymap_xor(uint16_t stat);
  44. void keymap_debug(void);
  45. /*
  46. * Overlay Layer
  47. */
  48. #ifndef NO_ACTION_OVERLAY
  49. extern uint16_t overlay_stat;
  50. /* return current active layer */
  51. uint8_t overlay_get_layer(void);
  52. void overlay_clear(void);
  53. void overlay_set(uint16_t stat);
  54. void overlay_move(uint8_t layer);
  55. void overlay_on(uint8_t layer);
  56. void overlay_off(uint8_t layer);
  57. void overlay_invert(uint8_t layer);
  58. /* bitwise operation */
  59. void overlay_or(uint16_t stat);
  60. void overlay_and(uint16_t stat);
  61. void overlay_xor(uint16_t stat);
  62. void overlay_debug(void);
  63. #else
  64. #define overlay_stat 0
  65. #define overlay_get_layer()
  66. #define overlay_clear()
  67. #define overlay_set(stat)
  68. #define overlay_move(layer)
  69. #define overlay_on(layer)
  70. #define overlay_off(layer)
  71. #define overlay_invert(layer)
  72. #define overlay_or(stat)
  73. #define overlay_and(stat)
  74. #define overlay_xor(stat)
  75. #define overlay_debug()
  76. #endif
  77. /* return action depending on current layer status */
  78. action_t layer_switch_get_action(key_t key);
  79. #endif