keymap.c 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108
  1. /*
  2. * algernon's ErgoDox EZ layout, please see the readme.md file!
  3. */
  4. #include <stdarg.h>
  5. #include "ergodox.h"
  6. #include "led.h"
  7. #include "debug.h"
  8. #include "action_layer.h"
  9. #include "action_util.h"
  10. #include "timer.h"
  11. #include "keymap_plover.h"
  12. #include "eeconfig.h"
  13. #include "wait.h"
  14. #include "version.h"
  15. /* Layers */
  16. enum {
  17. BASE = 0,
  18. ADORE,
  19. ARRW,
  20. APPSEL,
  21. HUN,
  22. NMDIA,
  23. PLVR,
  24. };
  25. /* Macros */
  26. enum {
  27. NONE = 0,
  28. // Buttons that do extra stuff
  29. A_GUI,
  30. A_PLVR,
  31. A_MPN,
  32. // Application select keys
  33. APP_SLK, // Slack
  34. APP_EMCS, // Emacs
  35. APP_TERM, // Terminal
  36. APP_CHRM, // Chrome
  37. APP_MSIC, // Music
  38. // Hungarian layer keys
  39. HU_AA, // Á
  40. HU_OO, // Ó
  41. HU_EE, // É
  42. HU_UU, // Ú
  43. HU_II, // Í
  44. HU_OE, // Ö
  45. HU_UE, // Ü
  46. HU_OEE, // Ő
  47. HU_UEE, // Ű
  48. // number/symbol keys
  49. A_1, // 1
  50. A_2, // 2
  51. A_3, // ...
  52. A_4,
  53. A_5,
  54. A_6,
  55. A_7,
  56. A_8,
  57. A_9,
  58. A_0,
  59. // Fx
  60. Fx,
  61. };
  62. /* Fn keys */
  63. enum {
  64. F_BSE = 0,
  65. F_HUN,
  66. F_GUI,
  67. F_SFT,
  68. F_ALT,
  69. F_CTRL
  70. };
  71. /* Custom keycodes */
  72. enum {
  73. CT_CLN = 0,
  74. CT_TA,
  75. CT_LBP,
  76. CT_RBP,
  77. CT_TMUX,
  78. CT_TPS,
  79. CT_SR,
  80. };
  81. /* States & timers */
  82. uint16_t gui_timer = 0;
  83. uint16_t kf_timers[12];
  84. #if KEYLOGGER_ENABLE
  85. # ifdef AUTOLOG_ENABLE
  86. bool log_enable = true;
  87. # else
  88. bool log_enable = false;
  89. # endif
  90. #endif
  91. bool time_travel = false;
  92. bool skip_leds = false;
  93. static uint8_t is_adore = 0;
  94. /* The Keymap */
  95. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  96. /* Keymap 0: Base Layer
  97. *
  98. * ,-----------------------------------------------------. ,-----------------------------------------------------.
  99. * | Next/Prev | 9 | 7 @ | 5 * | 3 ^ | 1 $ | F11 | | Fx | 0 % | 2 ! | 4 # | 6 & | 8 | Plover |
  100. * |-----------+------+------+------+------+-------------| |------+------+------+------+------+------+-----------|
  101. * | ~ | ' | , | . | P | Y | ( | | ) | F | G | C | R | L | \ |
  102. * |-----------+------+------+------+------+------| [ | | ] |------+------+------+------+------+-----------|
  103. * | Tab/ARROW | A | O | E | U | I |------| |------| D | H | T | N | S | = / Arrow |
  104. * |-----------+------+------+------+------+------| tmux | | tmux |------+------+------+------+------+-----------|
  105. * | Play/Pause| / | Q | J | K | X | | | Pane | B | M | W | V | Z | Stop/Reset|
  106. * `-----------+------+------+------+------+-------------' `-------------+------+------+------+------+-----------'
  107. * | | | | | : | | - | | | | |
  108. * `-----------------------------------' `-----------------------------------'
  109. * ,-------------. ,-------------.
  110. * | LAlt | GUI | | MDIA | Del |
  111. * ,------|------|------| |------+------+------.
  112. * | | | Ctrl | | LEAD | | |
  113. * |Backsp|LShift|------| |------| Enter| Space|
  114. * | | | ESC | | HUN | | |
  115. * `--------------------' `--------------------'
  116. */
  117. [BASE] = KEYMAP(
  118. // left hand
  119. M(A_MPN) ,M(A_9) ,M(A_7) ,M(A_5) ,M(A_3) ,M(A_1) ,KC_F11
  120. ,KC_GRV ,KC_QUOT ,KC_COMM ,KC_DOT ,KC_P ,KC_Y ,TD(CT_LBP)
  121. ,TD(CT_TA) ,KC_A ,KC_O ,KC_E ,KC_U ,KC_I
  122. ,KC_MPLY ,KC_SLSH ,KC_Q ,KC_J ,KC_K ,KC_X ,TD(CT_TMUX)
  123. ,KC_NO ,KC_NO ,KC_NO ,KC_NO ,TD(CT_CLN)
  124. ,F(F_ALT),F(F_GUI)
  125. ,F(F_CTRL)
  126. ,KC_BSPC,F(F_SFT),KC_ESC
  127. // right hand
  128. ,M(Fx) ,M(A_0) ,M(A_2) ,M(A_4) ,M(A_6) ,M(A_8) ,M(A_PLVR)
  129. ,TD(CT_RBP),KC_F ,KC_G ,KC_C ,KC_R ,KC_L ,KC_BSLS
  130. ,KC_D ,KC_H ,KC_T ,KC_N ,KC_S ,KC_EQL
  131. ,TD(CT_TPS),KC_B ,KC_M ,KC_W ,KC_V ,KC_Z ,TD(CT_SR)
  132. ,KC_MINS ,KC_NO ,KC_NO ,KC_NO ,KC_NO
  133. ,OSL(NMDIA),KC_DEL
  134. ,KC_LEAD
  135. ,F(F_HUN) ,KC_ENT ,KC_SPC
  136. ),
  137. /* Keymap 1: Adore layer
  138. *
  139. * ,-----------------------------------------------------. ,-----------------------------------------------------.
  140. * | Play/Pause| 9 | 7 @ | 5 * | 3 ^ | 1 $ | F11 | | Fx | 0 % | 2 ! | 4 # | 6 & | 8 | Plover |
  141. * |-----------+------+------+------+------+-------------| |------+------+------+------+------+------+-----------|
  142. * | \ | X | W | C | H | F | ( | | ) | M | G | L | P | / | `~ |
  143. * |-----------+------+------+------+------+------| [ | | ] |------+------+------+------+------+-----------|
  144. * | Tab/Arrow | A | O | E | I | U |------| |------| D | R | T | N | S | = |
  145. * |-----------+------+------+------+------+------| tmux | | tmux |------+------+------+------+------+-----------|
  146. * | | Z | Q | ' | , | . | | | pane | B | K | V | Y | J | |
  147. * `-----------+------+------+------+------+-------------' `-------------+------+------+------+------+-----------'
  148. * | | | | | : | | - | | | | |
  149. * `-----------------------------------' `-----------------------------------'
  150. * ,-------------. ,-------------.
  151. * | LAlt | GUI | | MDIA | Del |
  152. * ,------|------|------| |------+------+------.
  153. * | | | Ctrl | | HUN | | |
  154. * |Backsp|LShift|------| |------| Enter| Space|
  155. * | | | ESC | | LEAD | | |
  156. * `--------------------' `--------------------'
  157. */
  158. [ADORE] = KEYMAP(
  159. // left hand
  160. KC_MPLY ,M(A_9) ,M(A_7) ,M(A_5) ,M(A_3) ,M(A_1) ,KC_F11
  161. ,KC_BSLS ,KC_X ,KC_W ,KC_C ,KC_H ,KC_F ,TD(CT_LBP)
  162. ,TD(CT_TA) ,KC_A ,KC_O ,KC_E ,KC_I ,KC_U
  163. ,KC_NO ,KC_Z ,KC_Q ,KC_QUOT ,KC_COMM ,KC_DOT ,TD(CT_TMUX)
  164. ,KC_NO ,KC_NO ,KC_NO ,KC_NO ,TD(CT_CLN)
  165. ,F(F_ALT),F(F_GUI)
  166. ,F(F_CTRL)
  167. ,KC_BSPC,F(F_SFT),KC_ESC
  168. // right hand
  169. ,M(Fx) ,M(A_0) ,M(A_2) ,M(A_4) ,M(A_6) ,M(A_8) ,M(A_PLVR)
  170. ,TD(CT_RBP),KC_M ,KC_G ,KC_L ,KC_P ,KC_SLSH ,KC_GRV
  171. ,KC_D ,KC_R ,KC_T ,KC_N ,KC_S ,KC_EQL
  172. ,TD(CT_TPS),KC_B ,KC_K ,KC_V ,KC_Y ,KC_J ,KC_NO
  173. ,KC_MINS ,KC_NO ,KC_NO ,KC_NO ,KC_NO
  174. ,OSL(NMDIA),KC_DEL
  175. ,F(F_HUN)
  176. ,KC_LEAD ,KC_ENT ,KC_SPC
  177. ),
  178. /* Keymap 2: Arrow layer
  179. *
  180. * ,-----------------------------------------------------. ,-----------------------------------------------------.
  181. * | | | | | | | | | | | | | | | |
  182. * |-----------+------+------+------+------+-------------| |------+------+------+------+------+------+-----------|
  183. * | | | | | | | | | | | Home | Up | End | | |
  184. * |-----------+------+------+------+------+------| | | |------+------+------+------+------+-----------|
  185. * | | | | | | |------| |------| | Left | Down | Rght | | |
  186. * |-----------+------+------+------+------+------| | | |------+------+------+------+------+-----------|
  187. * | | | | | | | | | | | | | | | |
  188. * `-----------+------+------+------+------+-------------' `-------------+------+------+------+------+-----------'
  189. * | | | | | | | | | | | |
  190. * `----------------------------------' `----------------------------------'
  191. * ,-------------. ,-------------.
  192. * | | | | | |
  193. * ,------|------|------| |------+------+------.
  194. * | | | | | | | |
  195. * | Enter| |------| |------| PgUp | PgDn |
  196. * | | | | | | | |
  197. * `--------------------' `--------------------'
  198. */
  199. [ARRW] = KEYMAP(
  200. // left hand
  201. KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS
  202. ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS
  203. ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS
  204. ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS
  205. ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS
  206. ,KC_TRNS ,KC_TRNS
  207. ,KC_TRNS
  208. ,KC_ENT ,KC_TRNS ,KC_TRNS
  209. // right hand
  210. ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS
  211. ,KC_TRNS ,KC_TRNS ,KC_HOME ,KC_UP ,KC_END ,KC_TRNS ,KC_TRNS
  212. ,KC_TRNS ,KC_LEFT ,KC_DOWN ,KC_RGHT ,KC_TRNS ,KC_TRNS
  213. ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS
  214. ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS
  215. ,KC_TRNS ,KC_TRNS
  216. ,KC_TRNS
  217. ,KC_TRNS ,KC_PGUP ,KC_PGDN
  218. ),
  219. /* Keymap 3: Application select layer
  220. *
  221. * ,-----------------------------------------------------. ,-----------------------------------------------------.
  222. * | |Music |Slack |Emacs |Term |Chrome| | | | | | | | | |
  223. * |-----------+------+------+------+------+-------------| |------+------+------+------+------+------+-----------|
  224. * | | | | | | | | | | | | | | | |
  225. * |-----------+------+------+------+------+------| | | |------+------+------+------+------+-----------|
  226. * | | | | | | |------| |------| | | | | | |
  227. * |-----------+------+------+------+------+------| | | |------+------+------+------+------+-----------|
  228. * | | | | | | | | | | | | | | | |
  229. * `-----------+------+------+------+------+-------------' `-------------+------+------+------+------+-----------'
  230. * | | | | | | | | | | | |
  231. * `----------------------------------' `----------------------------------'
  232. * ,-------------. ,-------------.
  233. * | | | | | |
  234. * ,------|------|------| |------+------+------.
  235. * | | | | | | | |
  236. * | | |------| |------| | |
  237. * | | | | | | | |
  238. * `--------------------' `--------------------'
  239. */
  240. [APPSEL] = KEYMAP(
  241. // left hand
  242. KC_TRNS ,M(APP_MSIC),M(APP_SLK),M(APP_EMCS),M(APP_TERM),M(APP_CHRM),KC_TRNS
  243. ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS
  244. ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS
  245. ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS
  246. ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS
  247. ,KC_TRNS ,KC_TRNS
  248. ,KC_TRNS
  249. ,KC_TRNS ,KC_TRNS ,KC_TRNS
  250. // right hand
  251. ,KC_TRNS ,KC_NO ,KC_NO ,KC_NO ,KC_NO ,KC_NO ,KC_TRNS
  252. ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS
  253. ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS
  254. ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS
  255. ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS
  256. ,KC_TRNS ,KC_TRNS
  257. ,KC_TRNS
  258. ,KC_TRNS ,KC_TRNS ,KC_TRNS
  259. ),
  260. /* Keymap 4: Hungarian Layer
  261. *
  262. * ,-----------------------------------------------------. ,-----------------------------------------------------.
  263. * | | | | | | | | | | | | | | | |
  264. * |-----------+------+------+------+------+-------------| |------+------+------+------+------+------+-----------|
  265. * | | | Ő | | Ű | | | | | | | | | | |
  266. * |-----------+------+------+------+------+------| | | |------+------+------+------+------+-----------|
  267. * | | Á | Ó | É | Ú | Í |------| |------| | | | | | |
  268. * |-----------+------+------+------+------+------| | | |------+------+------+------+------+-----------|
  269. * | | | Ö | | Ü | | | | | | | | | | |
  270. * `-----------+------+------+------+------+-------------' `-------------+------+------+------+------+-----------'
  271. * | | | | | | | | | | | |
  272. * `----------------------------------' `----------------------------------'
  273. * ,-------------. ,-------------.
  274. * | | | | | |
  275. * ,------|------|------| |------+------+------.
  276. * | | | | | | | |
  277. * | | |------| |------| | |
  278. * | | | | | BASE | | |
  279. * `--------------------' `--------------------'
  280. */
  281. [HUN] = KEYMAP(
  282. // left hand
  283. KC_NO ,KC_NO ,KC_NO ,KC_NO ,KC_NO ,KC_NO ,KC_NO
  284. ,KC_NO ,KC_NO ,M(HU_OEE),KC_NO ,M(HU_UEE),KC_NO ,KC_NO
  285. ,KC_NO ,M(HU_AA),M(HU_OO) ,M(HU_EE),M(HU_UU) ,M(HU_II)
  286. ,KC_NO ,KC_NO ,M(HU_OE) ,KC_NO ,M(HU_UE) ,KC_NO ,KC_NO
  287. ,KC_NO ,KC_NO ,KC_NO ,KC_NO ,KC_NO
  288. ,KC_NO ,KC_NO
  289. ,KC_NO
  290. ,KC_NO ,KC_TRNS ,KC_TRNS
  291. // right hand
  292. ,KC_TRNS ,KC_NO ,KC_NO ,KC_NO ,KC_NO ,KC_NO ,KC_NO
  293. ,KC_NO ,KC_NO ,KC_NO ,KC_NO ,KC_NO ,KC_NO ,KC_NO
  294. ,KC_NO ,KC_NO ,KC_NO ,KC_NO ,KC_NO ,KC_NO
  295. ,KC_NO ,KC_NO ,KC_NO ,KC_NO ,KC_NO ,KC_NO ,KC_NO
  296. ,KC_NO ,KC_NO ,KC_NO ,KC_NO ,KC_NO
  297. ,KC_NO ,KC_NO
  298. ,KC_NO
  299. ,F(F_BSE),KC_TRNS ,KC_TRNS
  300. ),
  301. /* Keymap 5: Navigation & Media layer
  302. *
  303. * ,-----------------------------------------------------. ,-----------------------------------------------------.
  304. * | | F9 | F7 | F5 | F3 | F1 |ScrLCK| | | F10 | F2 | F4 | F6 | F8 | |
  305. * |-----------+------+------+------+------+-------------| |------+------+------+------+------+------+-----------|
  306. * | | | | | | | | | | | | | | | |
  307. * |-----------+------+------+------+------+------| | | |------+------+------+------+------+-----------|
  308. * | | | | | | |------| |------| | | | | | |
  309. * |-----------+------+------+------+------+------| | | |------+------+------+------+------+-----------|
  310. * | | | | | | | | | | | | | | | |
  311. * `-----------+------+------+------+------+-------------' `-------------+------+------+------+------+-----------'
  312. * | | | | | | | | | | | |
  313. * `----------------------------------' `----------------------------------'
  314. * ,-------------. ,-------------.
  315. * | Mute | VlUp | | BASE | |
  316. * ,------|------|------| |------+------+------.
  317. * | | | VlDn | | | | |
  318. * | | |------| |------| | |
  319. * | | | | | | | |
  320. * `--------------------' `--------------------'
  321. */
  322. [NMDIA] = KEYMAP(
  323. // left hand
  324. KC_NO ,KC_F9 ,KC_F7 ,KC_F5 ,KC_F3 ,KC_F1 ,LGUI(KC_L)
  325. ,KC_NO ,KC_NO ,KC_NO ,KC_NO ,KC_NO ,KC_NO ,KC_NO
  326. ,KC_NO ,KC_NO ,KC_NO ,KC_NO ,KC_NO ,KC_NO
  327. ,KC_NO ,KC_NO ,KC_NO ,KC_NO ,KC_NO ,KC_NO ,KC_NO
  328. ,KC_NO ,KC_NO ,KC_NO ,KC_NO ,KC_NO
  329. ,KC_MUTE ,KC_VOLU
  330. ,KC_VOLD
  331. ,KC_NO ,KC_NO ,KC_TRNS
  332. // right hand
  333. ,KC_TRNS ,KC_F10 ,KC_F2 ,KC_F4 ,KC_F6 ,KC_F8 ,KC_NO
  334. ,KC_NO ,KC_NO ,KC_NO ,KC_NO ,KC_NO ,KC_NO ,KC_NO
  335. ,KC_NO ,KC_NO ,KC_NO ,KC_NO ,KC_NO ,KC_NO
  336. ,KC_NO ,KC_NO ,KC_NO ,KC_NO ,KC_NO ,KC_NO ,KC_NO
  337. ,KC_NO ,KC_NO ,KC_NO ,KC_NO ,KC_NO
  338. ,KC_TRNS ,KC_NO
  339. ,KC_NO
  340. ,KC_NO ,KC_NO ,KC_NO
  341. ),
  342. /* Keymap 6: Steno for Plover
  343. *
  344. * ,--------------------------------------------------. ,--------------------------------------------------.
  345. * | | | | | | | | | | | | | | | BASE |
  346. * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
  347. * | | # | # | # | # | # | # | | # | # | # | # | # | # | # |
  348. * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  349. * | | | T | P | H | |------| |------| | F | P | L | T | D |
  350. * |--------+ S +------+------+------+ * | * | | * | * +------+------+------+------+--------|
  351. * | | | K | W | R | | | | | | R | B | G | S | Z |
  352. * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
  353. * | | | | | | | | | | | |
  354. * `----------------------------------' `----------------------------------'
  355. * ,-------------. ,-------------.
  356. * | | | | | |
  357. * ,------|------|------| |------+------+------.
  358. * | | | | | | | |
  359. * | A | O |------| |------| E | U |
  360. * | | | | | | | |
  361. * `--------------------' `--------------------'
  362. */
  363. [PLVR] = KEYMAP(
  364. // left hand
  365. KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO,
  366. KC_NO, PV_NUM, PV_NUM, PV_NUM, PV_NUM, PV_NUM, PV_NUM,
  367. KC_NO, PV_LS, PV_LT, PV_LP, PV_LH, PV_STAR,
  368. KC_NO, PV_LS, PV_LK, PV_LW, PV_LR, PV_STAR, PV_STAR,
  369. KC_NO, KC_NO, KC_NO, KC_NO, KC_NO,
  370. KC_NO, KC_NO,
  371. KC_NO,
  372. PV_A, PV_O, KC_NO,
  373. // right hand
  374. KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, M(A_PLVR),
  375. PV_NUM, PV_NUM, PV_NUM, PV_NUM, PV_NUM, PV_NUM, PV_NUM,
  376. PV_STAR, PV_RF, PV_RP, PV_RL, PV_RT, PV_RD,
  377. PV_STAR, PV_STAR, PV_RR, PV_RB, PV_RG, PV_RS, PV_RZ,
  378. KC_NO, KC_NO, KC_NO, KC_NO, KC_NO,
  379. KC_NO, KC_NO,
  380. KC_NO,
  381. KC_NO,PV_E, PV_U
  382. ),
  383. };
  384. const uint16_t PROGMEM fn_actions[] = {
  385. [F_BSE] = ACTION_LAYER_CLEAR(ON_PRESS)
  386. ,[F_HUN] = ACTION_LAYER_INVERT(HUN, ON_PRESS)
  387. ,[F_GUI] = ACTION_MACRO_TAP(A_GUI)
  388. ,[F_SFT] = ACTION_MODS_ONESHOT (MOD_LSFT)
  389. ,[F_ALT] = ACTION_MODS_ONESHOT (MOD_LALT)
  390. ,[F_CTRL] = ACTION_MODS_ONESHOT (MOD_LCTL)
  391. };
  392. static void toggle_steno(int pressed)
  393. {
  394. uint8_t layer = biton32(layer_state);
  395. if (pressed) {
  396. if (layer != PLVR) layer_on(PLVR); else layer_off(PLVR);
  397. register_code(PV_LP);
  398. register_code(PV_LH);
  399. register_code(PV_LR);
  400. register_code(PV_O);
  401. register_code(PV_RL);
  402. register_code(PV_RG);
  403. } else {
  404. unregister_code(PV_LP);
  405. unregister_code(PV_LH);
  406. unregister_code(PV_LR);
  407. unregister_code(PV_O);
  408. unregister_code(PV_RL);
  409. unregister_code(PV_RG);
  410. }
  411. }
  412. static macro_t *ang_do_hun (keyrecord_t *record, uint16_t accent, uint16_t hun_char)
  413. {
  414. uint8_t need_shift = 0;
  415. uint8_t hold_shift = 0;
  416. if (!record->event.pressed)
  417. return MACRO_NONE;
  418. layer_off (HUN);
  419. if (keyboard_report->mods & MOD_BIT (KC_LSFT)) {
  420. hold_shift = 1;
  421. need_shift = 1;
  422. unregister_code (KC_LSFT);
  423. }
  424. if ((get_oneshot_mods () & MOD_BIT(KC_LSFT)) && !has_oneshot_mods_timed_out ()) {
  425. need_shift = 1;
  426. hold_shift = 0;
  427. unregister_code (KC_LSFT);
  428. }
  429. clear_oneshot_mods ();
  430. register_code (KC_RALT);
  431. unregister_code (KC_RALT);
  432. if (accent == (KC_DQT)) {
  433. register_code (KC_RSFT);
  434. }
  435. register_code (accent);
  436. unregister_code (accent);
  437. if (need_shift && accent != (KC_DQT)) {
  438. register_code (KC_RSFT);
  439. } else if (accent == (KC_DQT) && !need_shift) {
  440. unregister_code (KC_RSFT);
  441. }
  442. register_code (hun_char);
  443. unregister_code (hun_char);
  444. if (need_shift || accent == (KC_DQT))
  445. unregister_code (KC_RSFT);
  446. if (hold_shift)
  447. register_code (KC_LSFT);
  448. return MACRO_NONE;
  449. }
  450. static void ang_handle_num_row(uint8_t id, keyrecord_t *record) {
  451. uint8_t idx = id - A_1;
  452. uint8_t kc;
  453. static bool shifted[10];
  454. if (keyboard_report->mods & MOD_BIT(KC_LSFT) ||
  455. ((get_oneshot_mods() & MOD_BIT(KC_LSFT)) && !has_oneshot_mods_timed_out())) {
  456. if (record->event.pressed)
  457. shifted[idx] = true;
  458. }
  459. if (!shifted[idx]) {
  460. kc = idx + KC_1;
  461. } else {
  462. switch (id) {
  463. case A_8:
  464. case A_9:
  465. shifted[idx] = false;
  466. return;
  467. case A_7:
  468. kc = KC_2;
  469. break;
  470. case A_5:
  471. kc = KC_8;
  472. break;
  473. case A_3:
  474. kc = KC_6;
  475. break;
  476. case A_1:
  477. kc = KC_4;
  478. break;
  479. case A_0:
  480. kc = KC_5;
  481. break;
  482. case A_2:
  483. kc = KC_1;
  484. break;
  485. case A_4:
  486. kc = KC_3;
  487. break;
  488. case A_6:
  489. kc = KC_7;
  490. break;
  491. }
  492. }
  493. if (record->event.pressed) {
  494. register_code (kc);
  495. } else {
  496. unregister_code (kc);
  497. shifted[idx] = false;
  498. }
  499. }
  500. const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
  501. {
  502. switch(id) {
  503. case A_MPN:
  504. if (record->event.pressed) {
  505. if (keyboard_report->mods & MOD_BIT(KC_LSFT) ||
  506. ((get_oneshot_mods() & MOD_BIT(KC_LSFT)) && !has_oneshot_mods_timed_out())) {
  507. int oneshot = ((get_oneshot_mods() & MOD_BIT(KC_LSFT)) && !has_oneshot_mods_timed_out());
  508. if (oneshot)
  509. clear_oneshot_mods ();
  510. unregister_code (KC_LSFT);
  511. register_code (KC_MPRV);
  512. unregister_code (KC_MPRV);
  513. if (!oneshot)
  514. register_code (KC_LSFT);
  515. } else {
  516. return MACRO (T(MNXT), END);
  517. }
  518. }
  519. break;
  520. /* Hungarian layer */
  521. case HU_AA:
  522. return ang_do_hun (record, KC_QUOT, KC_A);
  523. case HU_OO:
  524. return ang_do_hun (record, KC_QUOT, KC_O);
  525. case HU_EE:
  526. return ang_do_hun (record, KC_QUOT, KC_E);
  527. case HU_UU:
  528. return ang_do_hun (record, KC_QUOT, KC_U);
  529. case HU_II:
  530. return ang_do_hun (record, KC_QUOT, KC_I);
  531. case HU_OE:
  532. return ang_do_hun (record, KC_DQT, KC_O);
  533. case HU_UE:
  534. return ang_do_hun (record, KC_DQT, KC_U);
  535. case HU_OEE:
  536. return ang_do_hun (record, KC_EQL, KC_O);
  537. case HU_UEE:
  538. return ang_do_hun (record, KC_EQL, KC_U);
  539. /* Plover base */
  540. case A_PLVR:
  541. toggle_steno(record->event.pressed);
  542. break;
  543. /* Fx */
  544. case Fx:
  545. if (record->event.pressed) {
  546. set_oneshot_mods (MOD_LALT);
  547. layer_on (NMDIA);
  548. set_oneshot_layer (NMDIA, ONESHOT_START);
  549. } else {
  550. clear_oneshot_layer_state (ONESHOT_PRESSED);
  551. }
  552. break;
  553. /* GUI & AppSel */
  554. case A_GUI:
  555. if (record->event.pressed) {
  556. register_code (KC_LGUI);
  557. if (record->tap.count && !record->tap.interrupted) {
  558. if (record->tap.count >= 2) {
  559. uprintf("CMD:appsel_start\n");
  560. layer_on (APPSEL);
  561. set_oneshot_layer (APPSEL, ONESHOT_START);
  562. }
  563. } else {
  564. record->tap.count = 0;
  565. }
  566. gui_timer = 0;
  567. } else {
  568. if (record->tap.count >= 2)
  569. {
  570. clear_oneshot_layer_state (ONESHOT_PRESSED);
  571. }
  572. gui_timer = timer_read ();
  573. }
  574. break;
  575. case APP_SLK:
  576. if (record->event.pressed)
  577. uprintf("CMD:appsel_slack\n");
  578. break;
  579. case APP_EMCS:
  580. if (record->event.pressed)
  581. uprintf("CMD:appsel_emacs\n");
  582. break;
  583. case APP_TERM:
  584. if (record->event.pressed)
  585. uprintf("CMD:appsel_term\n");
  586. break;
  587. case APP_CHRM:
  588. if (record->event.pressed)
  589. uprintf("CMD:appsel_chrome\n");
  590. break;
  591. case APP_MSIC:
  592. if (record->event.pressed)
  593. uprintf("CMD:appsel_music\n");
  594. break;
  595. // number row and symbols
  596. case A_1 ... A_0:
  597. ang_handle_num_row(id, record);
  598. break;
  599. }
  600. return MACRO_NONE;
  601. };
  602. // Runs just one time when the keyboard initializes.
  603. void matrix_init_user(void) {
  604. uint8_t dl;
  605. set_unicode_input_mode(UC_LNX);
  606. ergodox_led_all_on();
  607. for (int i = LED_BRIGHTNESS_HI; i > LED_BRIGHTNESS_LO; i--) {
  608. ergodox_led_all_set (i);
  609. wait_ms (5);
  610. }
  611. wait_ms(1000);
  612. for (int i = LED_BRIGHTNESS_LO; i > 0; i--) {
  613. ergodox_led_all_set (i);
  614. wait_ms (10);
  615. }
  616. ergodox_led_all_off();
  617. if (!eeconfig_is_enabled())
  618. eeconfig_init();
  619. dl = eeconfig_read_default_layer ();
  620. if (dl == (1UL << ADORE)) {
  621. is_adore = 1;
  622. }
  623. };
  624. LEADER_EXTERNS();
  625. static void ang_tap (uint16_t code, ...) {
  626. uint16_t kc = code;
  627. va_list ap;
  628. va_start(ap, code);
  629. do {
  630. register_code16(kc);
  631. unregister_code16(kc);
  632. wait_ms(50);
  633. kc = va_arg(ap, int);
  634. } while (kc != 0);
  635. va_end(ap);
  636. }
  637. #define TAP_ONCE(code) \
  638. register_code (code); \
  639. unregister_code (code)
  640. typedef struct {
  641. bool layer_toggle;
  642. bool sticky;
  643. } td_ta_state_t;
  644. static void ang_tap_dance_ta_finished (qk_tap_dance_state_t *state, void *user_data) {
  645. td_ta_state_t *td_ta = (td_ta_state_t *) user_data;
  646. if (td_ta->sticky) {
  647. td_ta->sticky = false;
  648. td_ta->layer_toggle = false;
  649. layer_off (ARRW);
  650. return;
  651. }
  652. if (state->count == 1 && !state->pressed) {
  653. register_code (KC_TAB);
  654. td_ta->sticky = false;
  655. td_ta->layer_toggle = false;
  656. } else {
  657. td_ta->layer_toggle = true;
  658. layer_on (ARRW);
  659. td_ta->sticky = (state->count == 2);
  660. }
  661. }
  662. static void ang_tap_dance_ta_reset (qk_tap_dance_state_t *state, void *user_data) {
  663. td_ta_state_t *td_ta = (td_ta_state_t *) user_data;
  664. if (!td_ta->layer_toggle)
  665. unregister_code (KC_TAB);
  666. if (!td_ta->sticky)
  667. layer_off (ARRW);
  668. }
  669. static void ang_tap_dance_tmux_finished (qk_tap_dance_state_t *state, void *user_data) {
  670. if (state->count == 1) {
  671. register_code(KC_LALT);
  672. register_code(KC_SPC);
  673. unregister_code(KC_SPC);
  674. unregister_code(KC_LALT);
  675. } else {
  676. register_code(KC_LCTL);
  677. register_code(KC_A);
  678. unregister_code(KC_A);
  679. unregister_code(KC_LCTL);
  680. }
  681. }
  682. static void ang_tap_dance_tmux_pane_select (qk_tap_dance_state_t *state, void *user_data) {
  683. uint8_t kc = KC_P;
  684. if (state->count >= 2) {
  685. kc = KC_Z;
  686. }
  687. register_code(KC_LALT);
  688. register_code(KC_SPC);
  689. unregister_code(KC_SPC);
  690. unregister_code(KC_LALT);
  691. register_code(kc);
  692. unregister_code(kc);
  693. }
  694. static void
  695. _td_sr_each (qk_tap_dance_state_t *state, void *user_data) {
  696. skip_leds = true;
  697. switch (state->count) {
  698. case 1:
  699. ergodox_right_led_3_on ();
  700. break;
  701. case 2:
  702. ergodox_right_led_2_on ();
  703. break;
  704. case 3:
  705. ergodox_right_led_1_on ();
  706. break;
  707. case 4:
  708. ergodox_right_led_3_off ();
  709. wait_ms (50);
  710. ergodox_right_led_2_off ();
  711. wait_ms (50);
  712. ergodox_right_led_1_off ();
  713. break;
  714. }
  715. }
  716. static void
  717. _td_sr_finished (qk_tap_dance_state_t *state, void *user_data) {
  718. if (state->count == 1) {
  719. register_code (KC_MSTP);
  720. }
  721. if (state->count >= 4) {
  722. uprintf("CMD:reflash\n");
  723. wait_ms (1000);
  724. reset_keyboard ();
  725. reset_tap_dance (state);
  726. }
  727. }
  728. static void
  729. _td_sr_reset (qk_tap_dance_state_t *state, void *user_data) {
  730. ergodox_right_led_1_off ();
  731. wait_ms (50);
  732. ergodox_right_led_2_off ();
  733. wait_ms (50);
  734. ergodox_right_led_3_off ();
  735. if (state->count == 1) {
  736. unregister_code (KC_MSTP);
  737. }
  738. }
  739. qk_tap_dance_action_t tap_dance_actions[] = {
  740. [CT_CLN] = ACTION_TAP_DANCE_DOUBLE (KC_COLN, KC_SCLN)
  741. ,[CT_TA] = {
  742. .fn = { NULL, ang_tap_dance_ta_finished, ang_tap_dance_ta_reset },
  743. .user_data = (void *)&((td_ta_state_t) { false, false })
  744. }
  745. ,[CT_LBP] = ACTION_TAP_DANCE_DOUBLE (KC_LBRC, KC_LPRN)
  746. ,[CT_RBP] = ACTION_TAP_DANCE_DOUBLE (KC_RBRC, KC_RPRN)
  747. ,[CT_TMUX]= ACTION_TAP_DANCE_FN (ang_tap_dance_tmux_finished)
  748. ,[CT_TPS] = ACTION_TAP_DANCE_FN (ang_tap_dance_tmux_pane_select)
  749. ,[CT_SR] = ACTION_TAP_DANCE_FN_ADVANCED (_td_sr_each, _td_sr_finished, _td_sr_reset)
  750. };
  751. // Runs constantly in the background, in a loop.
  752. void matrix_scan_user(void) {
  753. uint8_t layer = biton32(layer_state);
  754. bool is_arrow = false;
  755. if (gui_timer && timer_elapsed (gui_timer) > TAPPING_TERM)
  756. unregister_code (KC_LGUI);
  757. if (!skip_leds) {
  758. if (layer == HUN) {
  759. ergodox_right_led_2_on();
  760. ergodox_right_led_3_on();
  761. } else if (layer == NMDIA) {
  762. ergodox_right_led_1_on();
  763. ergodox_right_led_2_on();
  764. } else if (layer == PLVR) {
  765. ergodox_right_led_1_on ();
  766. ergodox_right_led_2_on ();
  767. ergodox_right_led_3_on ();
  768. } else if (layer == ADORE) {
  769. ergodox_right_led_1_on ();
  770. ergodox_right_led_2_on ();
  771. ergodox_right_led_3_on ();
  772. ergodox_right_led_2_set (LED_BRIGHTNESS_HI);
  773. }
  774. }
  775. if (layer_state & (1UL << ARRW)) {
  776. if (!skip_leds) {
  777. ergodox_right_led_1_on ();
  778. ergodox_right_led_3_on ();
  779. }
  780. is_arrow = true;
  781. }
  782. if (!skip_leds) {
  783. if (keyboard_report->mods & MOD_BIT(KC_LSFT) ||
  784. ((get_oneshot_mods() & MOD_BIT(KC_LSFT)) && !has_oneshot_mods_timed_out())) {
  785. ergodox_right_led_1_set (LED_BRIGHTNESS_HI);
  786. ergodox_right_led_1_on ();
  787. } else {
  788. ergodox_right_led_1_set (LED_BRIGHTNESS_LO);
  789. if (layer != NMDIA && layer != PLVR && layer != ADORE && !is_arrow)
  790. ergodox_right_led_1_off ();
  791. }
  792. if (keyboard_report->mods & MOD_BIT(KC_LALT) ||
  793. ((get_oneshot_mods() & MOD_BIT(KC_LALT)) && !has_oneshot_mods_timed_out())) {
  794. ergodox_right_led_2_set (LED_BRIGHTNESS_HI);
  795. ergodox_right_led_2_on ();
  796. } else {
  797. ergodox_right_led_2_set (LED_BRIGHTNESS_LO);
  798. if (layer != HUN && layer != NMDIA && layer != PLVR && layer != ADORE)
  799. ergodox_right_led_2_off ();
  800. }
  801. if (keyboard_report->mods & MOD_BIT(KC_LCTRL) ||
  802. ((get_oneshot_mods() & MOD_BIT(KC_LCTRL)) && !has_oneshot_mods_timed_out())) {
  803. ergodox_right_led_3_set (LED_BRIGHTNESS_HI);
  804. ergodox_right_led_3_on ();
  805. } else {
  806. ergodox_right_led_3_set (LED_BRIGHTNESS_LO);
  807. if (layer != HUN && layer != PLVR && layer != ADORE && !is_arrow)
  808. ergodox_right_led_3_off ();
  809. }
  810. }
  811. LEADER_DICTIONARY() {
  812. leading = false;
  813. leader_end ();
  814. SEQ_ONE_KEY (KC_C) {
  815. ang_tap (LSFT(KC_C), KC_S, KC_I, KC_L, KC_L, KC_RALT, KC_QUOT, KC_A, KC_M, KC_A, KC_S,
  816. KC_S, KC_Z, KC_O, KC_N, KC_Y, KC_K, KC_RALT, KC_QUOT, KC_A, KC_M, 0);
  817. }
  818. SEQ_ONE_KEY (KC_G) {
  819. ang_tap (LSFT(KC_G), KC_E, KC_J, KC_G, KC_RALT, KC_EQL, KC_O,
  820. KC_RALT, KC_EQL, KC_O,
  821. KC_RALT, KC_EQL, KC_O, 0);
  822. }
  823. #if KEYLOGGER_ENABLE
  824. SEQ_ONE_KEY (KC_D) {
  825. ergodox_led_all_on();
  826. wait_ms(100);
  827. ergodox_led_all_off();
  828. log_enable = !log_enable;
  829. }
  830. #endif
  831. SEQ_ONE_KEY (KC_T) {
  832. time_travel = !time_travel;
  833. }
  834. SEQ_ONE_KEY (KC_U) {
  835. qk_ucis_start();
  836. }
  837. SEQ_ONE_KEY (KC_V) {
  838. SEND_STRING (QMK_KEYBOARD "/" QMK_KEYMAP " @ (" QMK_VERSION "/" KEYMAP_VERSION ")");
  839. }
  840. SEQ_ONE_KEY (KC_L) {
  841. /* λ */
  842. unicode_input_start();
  843. register_hex(0x03bb);
  844. unicode_input_finish();
  845. }
  846. SEQ_ONE_KEY (KC_Y) {
  847. ang_tap (KC_BSLS, KC_O, KC_SLSH, 0);
  848. }
  849. SEQ_ONE_KEY (KC_S) {
  850. unicode_input_start(); register_hex(0xaf); unicode_input_finish();
  851. TAP_ONCE (KC_BSLS);
  852. register_code (KC_RSFT); TAP_ONCE (KC_MINS); TAP_ONCE (KC_9); unregister_code (KC_RSFT);
  853. unicode_input_start (); register_hex(0x30c4); unicode_input_finish();
  854. register_code (KC_RSFT); TAP_ONCE (KC_0); TAP_ONCE (KC_MINS); unregister_code (KC_RSFT);
  855. TAP_ONCE (KC_SLSH);
  856. unicode_input_start (); register_hex(0xaf); unicode_input_finish();
  857. }
  858. SEQ_TWO_KEYS (KC_W, KC_M) {
  859. uprintf("CMD:wm\n");
  860. }
  861. SEQ_ONE_KEY (KC_A) {
  862. if (is_adore == 0) {
  863. default_layer_and (0);
  864. default_layer_or ((1UL << ADORE));
  865. eeconfig_update_default_layer ((1UL << ADORE));
  866. is_adore = 1;
  867. ergodox_led_all_off ();
  868. ergodox_right_led_3_on ();
  869. wait_ms (100);
  870. ergodox_right_led_2_on ();
  871. wait_ms (100);
  872. ergodox_right_led_3_off ();
  873. ergodox_right_led_1_on ();
  874. wait_ms (100);
  875. ergodox_right_led_2_off ();
  876. wait_ms (100);
  877. ergodox_right_led_1_off ();
  878. } else {
  879. is_adore = 0;
  880. default_layer_and (0);
  881. default_layer_or (1UL << BASE);
  882. eeconfig_update_default_layer ((1UL << BASE));
  883. ergodox_led_all_off ();
  884. ergodox_right_led_1_on ();
  885. wait_ms (100);
  886. ergodox_right_led_2_on ();
  887. wait_ms (100);
  888. ergodox_right_led_1_off ();
  889. ergodox_right_led_3_on ();
  890. wait_ms (100);
  891. ergodox_right_led_2_off ();
  892. wait_ms (100);
  893. ergodox_right_led_3_off ();
  894. }
  895. }
  896. }
  897. }
  898. static uint16_t last4[4];
  899. const qk_ucis_symbol_t ucis_symbol_table[] = UCIS_TABLE
  900. (
  901. UCIS_SYM("poop", 0x1f4a9),
  902. UCIS_SYM("rofl", 0x1f923),
  903. UCIS_SYM("kiss", 0x1f619),
  904. UCIS_SYM("snowman", 0x2603),
  905. UCIS_SYM("coffee", 0x2615),
  906. UCIS_SYM("heart", 0x2764),
  907. UCIS_SYM("bolt", 0x26a1),
  908. UCIS_SYM("pi", 0x03c0),
  909. UCIS_SYM("mouse", 0x1f401)
  910. );
  911. bool process_record_user (uint16_t keycode, keyrecord_t *record) {
  912. #if KEYLOGGER_ENABLE
  913. if (log_enable) {
  914. uint8_t layer = biton32(layer_state);
  915. if ((layer == ADORE) || (layer == BASE))
  916. uprintf ("KL: col=%02d, row=%02d, pressed=%d, layer=%s\n", record->event.key.col,
  917. record->event.key.row, record->event.pressed, (is_adore) ? "ADORE" : "Dvorak");
  918. }
  919. #endif
  920. if (keycode == KC_ESC && record->event.pressed) {
  921. bool queue = true;
  922. if ((get_oneshot_mods ()) && !has_oneshot_mods_timed_out ()) {
  923. clear_oneshot_mods ();
  924. queue = false;
  925. }
  926. if (layer_state & (1UL<<HUN)) {
  927. layer_off (HUN);
  928. queue = false;
  929. }
  930. return queue;
  931. }
  932. if (time_travel && !record->event.pressed) {
  933. uint8_t p;
  934. // shift cache one to the left
  935. for (p = 0; p < 3; p++) {
  936. last4[p] = last4[p + 1];
  937. }
  938. last4[3] = keycode;
  939. if (last4[0] == KC_D && last4[1] == KC_A && last4[2] == KC_T && last4[3] == KC_E) {
  940. ang_tap (KC_E, KC_SPC, KC_MINS, KC_D, KC_SPC, KC_QUOT, 0);
  941. register_code (KC_RSFT);
  942. register_code (KC_EQL);
  943. unregister_code (KC_EQL);
  944. unregister_code (KC_RSFT);
  945. ang_tap (KC_4, KC_SPC, KC_D, KC_A, KC_Y, KC_S, KC_QUOT, 0);
  946. return false;
  947. }
  948. }
  949. return true;
  950. }
  951. void qk_ucis_symbol_fallback (void) {
  952. for (uint8_t i = 0; i < qk_ucis_state.count - 1; i++) {
  953. uint8_t code;
  954. if ((qk_ucis_state.codes[i] >= M(A_1)) && (qk_ucis_state.codes[i] <= M(A_0)))
  955. code = qk_ucis_state.codes[i] - M(A_1) + KC_1;
  956. else
  957. code = qk_ucis_state.codes[i];
  958. register_code(code);
  959. unregister_code(code);
  960. wait_ms (10);
  961. }
  962. }