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.

170 lines
5.5 KiB

adding Hadron v3 keyboard, QWIIC devices support, haptic feedback support (#4462) * add initial support for hadron ver3 * add initial support for hadron ver3 * pull qwiic support for micro_led to be modified for use in hadron's 64x24 ssd1306 oled display * initial work on OLED using qwiic driver * early work to get 128x32 oled working by redefining qwiic micro oled parameters. Currently working, but would affect qwiic's micro oled functionality * moved oled defines to config.h and added ifndef to micro_oled driver * WORKING :D - note, still work in progress to get the start location correct on the 128x32 display. * added equation to automatically calculate display offset based on screen width * adding time-out timer to oled display * changed read lock staus via read_led_state * lock indications fixes * Added scroll lock indication to oled * add support for DRV2605 haptic driver * Improve readabiity of DRV2605 driver. -added typedef for waveform library -added unions for registers * Update keyboards/hadron/ver2/keymaps/default/config.h Co-Authored-By: ishtob <ishtob@gmail.com> * Update keyboards/hadron/ver2/keymaps/default/config.h Co-Authored-By: ishtob <ishtob@gmail.com> * Update keyboards/hadron/ver2/keymaps/default/config.h Co-Authored-By: ishtob <ishtob@gmail.com> * Update keyboards/hadron/ver2/keymaps/default/config.h Co-Authored-By: ishtob <ishtob@gmail.com> * Fixes for PR * PR fixes * fix old persistent layer function to use new set_single_persistent_default_layer * fix issues with changing makefile defines that broken per-key haptic pulse * Comment fixes * Add definable parameter and auto-calibration based on motor choice
5 years ago
8 years ago
  1. /*
  2. Copyright 2013 Jun Wako <wakojun@gmail.com>
  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. #pragma once
  15. #include <stdint.h>
  16. #include "keyboard.h"
  17. #include "action.h"
  18. #include "bitwise.h"
  19. #ifdef DYNAMIC_KEYMAP_ENABLE
  20. # ifndef DYNAMIC_KEYMAP_LAYER_COUNT
  21. # define DYNAMIC_KEYMAP_LAYER_COUNT 4
  22. # endif
  23. # define MAX_LAYER DYNAMIC_KEYMAP_LAYER_COUNT
  24. # if DYNAMIC_KEYMAP_LAYER_COUNT <= 8
  25. # ifndef LAYER_STATE_8BIT
  26. # define LAYER_STATE_8BIT
  27. # endif
  28. # elif DYNAMIC_KEYMAP_LAYER_COUNT <= 16
  29. # ifndef LAYER_STATE_16BIT
  30. # define LAYER_STATE_16BIT
  31. # endif
  32. # else
  33. # ifndef LAYER_STATE_32BIT
  34. # define LAYER_STATE_32BIT
  35. # endif
  36. # endif
  37. #endif
  38. #if !defined(LAYER_STATE_8BIT) && !defined(LAYER_STATE_16BIT) && !defined(LAYER_STATE_32BIT)
  39. # define LAYER_STATE_16BIT
  40. #endif
  41. #if defined(LAYER_STATE_8BIT)
  42. typedef uint8_t layer_state_t;
  43. # define MAX_LAYER_BITS 3
  44. # ifndef MAX_LAYER
  45. # define MAX_LAYER 8
  46. # endif
  47. # define get_highest_layer(state) biton(state)
  48. #elif defined(LAYER_STATE_16BIT)
  49. typedef uint16_t layer_state_t;
  50. # define MAX_LAYER_BITS 4
  51. # ifndef MAX_LAYER
  52. # define MAX_LAYER 16
  53. # endif
  54. # define get_highest_layer(state) biton16(state)
  55. #elif defined(LAYER_STATE_32BIT)
  56. typedef uint32_t layer_state_t;
  57. # define MAX_LAYER_BITS 5
  58. # ifndef MAX_LAYER
  59. # define MAX_LAYER 32
  60. # endif
  61. # define get_highest_layer(state) biton32(state)
  62. #else
  63. # error Layer Mask size not specified. HOW?!
  64. #endif
  65. /*
  66. * Default Layer
  67. */
  68. extern layer_state_t default_layer_state;
  69. void default_layer_debug(void);
  70. void default_layer_set(layer_state_t state);
  71. __attribute__((weak)) layer_state_t default_layer_state_set_kb(layer_state_t state);
  72. __attribute__((weak)) layer_state_t default_layer_state_set_user(layer_state_t state);
  73. #ifndef NO_ACTION_LAYER
  74. /* bitwise operation */
  75. void default_layer_or(layer_state_t state);
  76. void default_layer_and(layer_state_t state);
  77. void default_layer_xor(layer_state_t state);
  78. #else
  79. # define default_layer_or(state)
  80. # define default_layer_and(state)
  81. # define default_layer_xor(state)
  82. #endif
  83. /*
  84. * Keymap Layer
  85. */
  86. #ifndef NO_ACTION_LAYER
  87. extern layer_state_t layer_state;
  88. void layer_state_set(layer_state_t state);
  89. bool layer_state_is(uint8_t layer);
  90. bool layer_state_cmp(layer_state_t layer1, uint8_t layer2);
  91. void layer_debug(void);
  92. void layer_clear(void);
  93. void layer_move(uint8_t layer);
  94. void layer_on(uint8_t layer);
  95. void layer_off(uint8_t layer);
  96. void layer_invert(uint8_t layer);
  97. /* bitwise operation */
  98. void layer_or(layer_state_t state);
  99. void layer_and(layer_state_t state);
  100. void layer_xor(layer_state_t state);
  101. layer_state_t layer_state_set_user(layer_state_t state);
  102. layer_state_t layer_state_set_kb(layer_state_t state);
  103. /**
  104. * @brief Applies the tri layer to global layer state. Not be used in layer_state_set_(kb|user) functions.
  105. *
  106. * @param layer1 First layer to check for tri layer
  107. * @param layer2 Second layer to check for tri layer
  108. * @param layer3 Layer to activate if both other layers are enabled
  109. */
  110. void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3);
  111. /**
  112. * @brief Applies the tri layer behavior to supplied layer bitmask, without using layer functions.
  113. *
  114. * @param state Original layer bitmask to check and modify
  115. * @param layer1 First layer to check for tri layer
  116. * @param layer2 Second layer to check for tri layer
  117. * @param layer3 Layer to activate if both other layers are enabled
  118. * @return layer_state_t returns a modified layer bitmask with tri layer modifications applied
  119. */
  120. layer_state_t update_tri_layer_state(layer_state_t state, uint8_t layer1, uint8_t layer2, uint8_t layer3);
  121. #else
  122. # define layer_state 0
  123. # define layer_state_set(layer)
  124. # define layer_state_is(layer) (layer == 0)
  125. # define layer_state_cmp(state, layer) (state == 0 ? layer == 0 : (state & (layer_state_t)1 << layer) != 0)
  126. # define layer_debug()
  127. # define layer_clear()
  128. # define layer_move(layer) (void)layer
  129. # define layer_on(layer) (void)layer
  130. # define layer_off(layer) (void)layer
  131. # define layer_invert(layer) (void)layer
  132. # define layer_or(state) (void)state
  133. # define layer_and(state) (void)state
  134. # define layer_xor(state) (void)state
  135. # define layer_state_set_kb(state) (void)state
  136. # define layer_state_set_user(state) (void)state
  137. # define update_tri_layer(layer1, layer2, layer3)
  138. # define update_tri_layer_state(state, layer1, layer2, layer3) (void)state
  139. #endif
  140. /* pressed actions cache */
  141. #if !defined(NO_ACTION_LAYER) && !defined(STRICT_LAYER_RELEASE)
  142. void update_source_layers_cache(keypos_t key, uint8_t layer);
  143. uint8_t read_source_layers_cache(keypos_t key);
  144. #endif
  145. action_t store_or_get_action(bool pressed, keypos_t key);
  146. /* return the topmost non-transparent layer currently associated with key */
  147. uint8_t layer_switch_get_layer(keypos_t key);
  148. /* return action depending on current layer status */
  149. action_t layer_switch_get_action(keypos_t key);