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.

147 lines
4.4 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. #ifdef DYNAMIC_KEYMAP_ENABLE
  19. # ifndef DYNAMIC_KEYMAP_LAYER_COUNT
  20. # define DYNAMIC_KEYMAP_LAYER_COUNT 4
  21. # endif
  22. # if DYNAMIC_KEYMAP_LAYER_COUNT <= 8
  23. # ifndef LAYER_STATE_8BIT
  24. # define LAYER_STATE_8BIT
  25. # endif
  26. # elif DYNAMIC_KEYMAP_LAYER_COUNT <= 16
  27. # ifndef LAYER_STATE_16BIT
  28. # define LAYER_STATE_16BIT
  29. # endif
  30. # else
  31. # ifndef LAYER_STATE_32BIT
  32. # define LAYER_STATE_32BIT
  33. # endif
  34. # endif
  35. #endif
  36. #if !defined(LAYER_STATE_8BIT) && !defined(LAYER_STATE_16BIT) && !defined(LAYER_STATE_32BIT)
  37. # define LAYER_STATE_32BIT
  38. #endif
  39. #if defined(LAYER_STATE_8BIT)
  40. typedef uint8_t layer_state_t;
  41. # define MAX_LAYER_BITS 3
  42. # ifndef MAX_LAYER
  43. # define MAX_LAYER 8
  44. # endif
  45. # define get_highest_layer(state) biton(state)
  46. #elif defined(LAYER_STATE_16BIT)
  47. typedef uint16_t layer_state_t;
  48. # define MAX_LAYER_BITS 4
  49. # ifndef MAX_LAYER
  50. # define MAX_LAYER 16
  51. # endif
  52. # define get_highest_layer(state) biton16(state)
  53. #elif defined(LAYER_STATE_32BIT)
  54. typedef uint32_t layer_state_t;
  55. # define MAX_LAYER_BITS 5
  56. # ifndef MAX_LAYER
  57. # define MAX_LAYER 32
  58. # endif
  59. # define get_highest_layer(state) biton32(state)
  60. #else
  61. # error Layer Mask size not specified. HOW?!
  62. #endif
  63. /*
  64. * Default Layer
  65. */
  66. extern layer_state_t default_layer_state;
  67. void default_layer_debug(void);
  68. void default_layer_set(layer_state_t state);
  69. __attribute__((weak)) layer_state_t default_layer_state_set_kb(layer_state_t state);
  70. __attribute__((weak)) layer_state_t default_layer_state_set_user(layer_state_t state);
  71. #ifndef NO_ACTION_LAYER
  72. /* bitwise operation */
  73. void default_layer_or(layer_state_t state);
  74. void default_layer_and(layer_state_t state);
  75. void default_layer_xor(layer_state_t state);
  76. #else
  77. # define default_layer_or(state)
  78. # define default_layer_and(state)
  79. # define default_layer_xor(state)
  80. #endif
  81. /*
  82. * Keymap Layer
  83. */
  84. #ifndef NO_ACTION_LAYER
  85. extern layer_state_t layer_state;
  86. void layer_state_set(layer_state_t state);
  87. bool layer_state_is(uint8_t layer);
  88. bool layer_state_cmp(layer_state_t layer1, uint8_t layer2);
  89. void layer_debug(void);
  90. void layer_clear(void);
  91. void layer_move(uint8_t layer);
  92. void layer_on(uint8_t layer);
  93. void layer_off(uint8_t layer);
  94. void layer_invert(uint8_t layer);
  95. /* bitwise operation */
  96. void layer_or(layer_state_t state);
  97. void layer_and(layer_state_t state);
  98. void layer_xor(layer_state_t state);
  99. layer_state_t layer_state_set_user(layer_state_t state);
  100. layer_state_t layer_state_set_kb(layer_state_t state);
  101. #else
  102. # define layer_state 0
  103. # define layer_state_set(layer)
  104. # define layer_state_is(layer) (layer == 0)
  105. # define layer_state_cmp(state, layer) (state == 0 ? layer == 0 : (state & (layer_state_t)1 << layer) != 0)
  106. # define layer_debug()
  107. # define layer_clear()
  108. # define layer_move(layer) (void)layer
  109. # define layer_on(layer) (void)layer
  110. # define layer_off(layer) (void)layer
  111. # define layer_invert(layer) (void)layer
  112. # define layer_or(state) (void)state
  113. # define layer_and(state) (void)state
  114. # define layer_xor(state) (void)state
  115. # define layer_state_set_kb(state) (void)state
  116. # define layer_state_set_user(state) (void)state
  117. #endif
  118. /* pressed actions cache */
  119. #if !defined(NO_ACTION_LAYER) && !defined(STRICT_LAYER_RELEASE)
  120. void update_source_layers_cache(keypos_t key, uint8_t layer);
  121. uint8_t read_source_layers_cache(keypos_t key);
  122. #endif
  123. action_t store_or_get_action(bool pressed, keypos_t key);
  124. /* return the topmost non-transparent layer currently associated with key */
  125. uint8_t layer_switch_get_layer(keypos_t key);
  126. /* return action depending on current layer status */
  127. action_t layer_switch_get_action(keypos_t key);