keymap.c 58 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418
  1. #include QMK_KEYBOARD_H
  2. #define CHORD_TIMEOUT 100
  3. #define DANCE_TIMEOUT 200
  4. #define LEADER_TIMEOUT 750
  5. #define TAP_TIMEOUT 50
  6. #define LONG_PRESS_MULTIPLIER 3
  7. #define DYNAMIC_MACRO_MAX_LENGTH 20
  8. #define COMMAND_MAX_LENGTH 5
  9. #define LEADER_MAX_LENGTH 5
  10. #define HASH_TYPE uint32_t
  11. #define NUMBER_OF_KEYS 20
  12. #define DEFAULT_PSEUDOLAYER QWERTY
  13. #define H_TOP1 ((HASH_TYPE) 1 << 0)
  14. #define H_TOP2 ((HASH_TYPE) 1 << 1)
  15. #define H_TOP3 ((HASH_TYPE) 1 << 2)
  16. #define H_TOP4 ((HASH_TYPE) 1 << 3)
  17. #define H_TOP5 ((HASH_TYPE) 1 << 4)
  18. #define H_TOP6 ((HASH_TYPE) 1 << 5)
  19. #define H_TOP7 ((HASH_TYPE) 1 << 6)
  20. #define H_TOP8 ((HASH_TYPE) 1 << 7)
  21. #define H_TOP9 ((HASH_TYPE) 1 << 8)
  22. #define H_TOP0 ((HASH_TYPE) 1 << 9)
  23. #define H_BOT1 ((HASH_TYPE) 1 << 10)
  24. #define H_BOT2 ((HASH_TYPE) 1 << 11)
  25. #define H_BOT3 ((HASH_TYPE) 1 << 12)
  26. #define H_BOT4 ((HASH_TYPE) 1 << 13)
  27. #define H_BOT5 ((HASH_TYPE) 1 << 14)
  28. #define H_BOT6 ((HASH_TYPE) 1 << 15)
  29. #define H_BOT7 ((HASH_TYPE) 1 << 16)
  30. #define H_BOT8 ((HASH_TYPE) 1 << 17)
  31. #define H_BOT9 ((HASH_TYPE) 1 << 18)
  32. #define H_BOT0 ((HASH_TYPE) 1 << 19)
  33. enum internal_keycodes {
  34. TOP1 = SAFE_RANGE,
  35. TOP2, TOP3, TOP4, TOP5, TOP6, TOP7, TOP8, TOP9, TOP0, BOT1, BOT2, BOT3, BOT4, BOT5, BOT6, BOT7, BOT8, BOT9, BOT0,
  36. FIRST_INTERNAL_KEYCODE = TOP1,
  37. LAST_INTERNAL_KEYCODE = BOT0
  38. };
  39. enum pseudolayers {
  40. ALWAYS_ON, QWERTY, NUM, MOV, MOUSE, ASETNIOP, ASETNIOP_123, ASETNIOP_FN
  41. };
  42. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  43. [0] = LAYOUT_butter(TOP1, TOP2, TOP3, TOP4, TOP5, TOP6, TOP7, TOP8, TOP9, TOP0, BOT1, BOT2, BOT3, BOT4, BOT5, BOT6, BOT7, BOT8, BOT9, BOT0),
  44. };
  45. size_t keymapsCount = 1;
  46. uint8_t keycodes_buffer_array[] = {
  47. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  48. };
  49. uint8_t command_buffer[] = {
  50. 0, 0, 0, 0, 0
  51. };
  52. uint16_t leader_buffer[] = {
  53. 0, 0, 0, 0, 0
  54. };
  55. uint8_t dynamic_macro_buffer[] = {
  56. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  57. };
  58. enum chord_states {
  59. IDLE,
  60. READY,
  61. ACTIVATED,
  62. DEACTIVATED,
  63. PRESS_FROM_ACTIVE,
  64. FINISHED_FROM_ACTIVE,
  65. IDLE_IN_DANCE,
  66. READY_IN_DANCE,
  67. FINISHED,
  68. LOCKED,
  69. READY_LOCKED,
  70. RESTART,
  71. IN_ONE_SHOT
  72. };
  73. struct Chord {
  74. uint32_t keycodes_hash;
  75. uint8_t pseudolayer;
  76. uint8_t* state;
  77. uint8_t* counter;
  78. uint16_t value1;
  79. uint8_t value2;
  80. void (*function) (const struct Chord*);
  81. };
  82. uint8_t current_pseudolayer = DEFAULT_PSEUDOLAYER;
  83. bool lock_next = false;
  84. uint16_t chord_timer = 0;
  85. uint16_t dance_timer = 0;
  86. bool autoshift_mode = true;
  87. uint8_t keycode_index = 0;
  88. uint8_t command_mode = 0;
  89. uint8_t command_ind = 0;
  90. bool in_leader_mode = false;
  91. uint8_t leader_ind = 0;
  92. uint16_t leader_timer = 0;
  93. uint8_t dynamic_macro_mode = false;
  94. uint8_t dynamic_macro_ind = 0;
  95. bool a_key_went_through = false;
  96. struct Chord* last_chord = NULL;
  97. bool handle_US_ANSI_shifted_keys(int16_t keycode, bool in) {
  98. bool is_US_ANSI_shifted = true;
  99. int16_t regular_keycode = KC_NO;
  100. switch (keycode) {
  101. case KC_TILDE:
  102. regular_keycode = KC_GRAVE;
  103. break;
  104. case KC_EXCLAIM:
  105. regular_keycode = KC_1;
  106. break;
  107. case KC_AT:
  108. regular_keycode = KC_2;
  109. break;
  110. case KC_HASH:
  111. regular_keycode = KC_3;
  112. break;
  113. case KC_DOLLAR:
  114. regular_keycode = KC_4;
  115. break;
  116. case KC_PERCENT:
  117. regular_keycode = KC_5;
  118. break;
  119. case KC_CIRCUMFLEX:
  120. regular_keycode = KC_6;
  121. break;
  122. case KC_AMPERSAND:
  123. regular_keycode = KC_7;
  124. break;
  125. case KC_ASTERISK:
  126. regular_keycode = KC_8;
  127. break;
  128. case KC_LEFT_PAREN:
  129. regular_keycode = KC_9;
  130. break;
  131. case KC_RIGHT_PAREN:
  132. regular_keycode = KC_0;
  133. break;
  134. case KC_UNDERSCORE:
  135. regular_keycode = KC_MINUS;
  136. break;
  137. case KC_PLUS:
  138. regular_keycode = KC_EQUAL;
  139. break;
  140. case KC_LEFT_CURLY_BRACE:
  141. regular_keycode = KC_LBRACKET;
  142. break;
  143. case KC_RIGHT_CURLY_BRACE:
  144. regular_keycode = KC_RBRACKET;
  145. break;
  146. case KC_PIPE:
  147. regular_keycode = KC_BSLASH;
  148. break;
  149. case KC_COLON:
  150. regular_keycode = KC_SCOLON;
  151. break;
  152. case KC_DOUBLE_QUOTE:
  153. regular_keycode = KC_QUOTE;
  154. break;
  155. case KC_LEFT_ANGLE_BRACKET:
  156. regular_keycode = KC_COMMA;
  157. break;
  158. case KC_RIGHT_ANGLE_BRACKET:
  159. regular_keycode = KC_DOT;
  160. break;
  161. case KC_QUESTION:
  162. regular_keycode = KC_SLASH;
  163. break;
  164. default:
  165. is_US_ANSI_shifted = false;
  166. }
  167. if (is_US_ANSI_shifted) {
  168. if (in) {
  169. register_code(KC_LSFT);
  170. register_code(regular_keycode);
  171. } else {
  172. unregister_code(regular_keycode);
  173. unregister_code(KC_LSFT);
  174. }
  175. }
  176. return is_US_ANSI_shifted;
  177. }
  178. void key_in(int16_t keycode) {
  179. if (command_mode == 1 && command_ind < COMMAND_MAX_LENGTH) {
  180. command_buffer[command_ind] = keycode;
  181. command_ind++;
  182. a_key_went_through = true;
  183. } else if (in_leader_mode && leader_ind < LEADER_MAX_LENGTH) {
  184. leader_buffer[leader_ind] = keycode;
  185. leader_ind++;
  186. a_key_went_through = true;
  187. } else if (dynamic_macro_mode && dynamic_macro_ind < DYNAMIC_MACRO_MAX_LENGTH) {
  188. dynamic_macro_buffer[dynamic_macro_ind] = keycode;
  189. dynamic_macro_ind++;
  190. a_key_went_through = true;
  191. } else {
  192. if (!handle_US_ANSI_shifted_keys(keycode, true)) {
  193. register_code(keycode);
  194. }
  195. send_keyboard_report();
  196. a_key_went_through = true;
  197. }
  198. }
  199. void key_out(int16_t keycode) {
  200. if (command_mode == 0) {
  201. if (!handle_US_ANSI_shifted_keys(keycode, false)) {
  202. if (command_mode == 0 && in_leader_mode == false && dynamic_macro_mode == false) {
  203. unregister_code(keycode);
  204. }
  205. }
  206. send_keyboard_report();
  207. }
  208. }
  209. void tap_key(int16_t keycode) {
  210. key_in(keycode);
  211. wait_ms(TAP_TIMEOUT);
  212. key_out(keycode);
  213. }
  214. void single_dance(const struct Chord* self) {
  215. switch (*self->state) {
  216. case ACTIVATED:
  217. key_in(self->value1);
  218. break;
  219. case DEACTIVATED:
  220. key_out(self->value1);
  221. *self->state = IDLE;
  222. break;
  223. case RESTART:
  224. key_out(self->value1);
  225. break;
  226. default:
  227. break;
  228. }
  229. }
  230. void key_layer_dance(const struct Chord* self) {
  231. switch (*self->state) {
  232. case ACTIVATED:
  233. current_pseudolayer = self->value2;
  234. a_key_went_through = false;
  235. break;
  236. case DEACTIVATED:
  237. case RESTART:
  238. if (!a_key_went_through) {
  239. tap_key(self->value1);
  240. }
  241. current_pseudolayer = self->pseudolayer;
  242. *self->state = IDLE; // does not have effect if the state was RESTART
  243. break;
  244. default:
  245. break;
  246. }
  247. }
  248. void key_mod_dance(const struct Chord* self) {
  249. switch (*self->state) {
  250. case ACTIVATED:
  251. key_in(self->value2);
  252. a_key_went_through = false;
  253. break;
  254. case DEACTIVATED:
  255. case RESTART:
  256. key_out(self->value2);
  257. if (!a_key_went_through) {
  258. tap_key(self->value1);
  259. }
  260. *self->state = IDLE; // does not have effect if the state was RESTART
  261. break;
  262. default:
  263. break;
  264. }
  265. }
  266. void key_key_dance(const struct Chord* self) {
  267. switch (*self->state) {
  268. case ACTIVATED:
  269. break;
  270. case DEACTIVATED:
  271. tap_key(self->value1);
  272. *self->state = IDLE;
  273. break;
  274. case FINISHED:
  275. case PRESS_FROM_ACTIVE:
  276. key_in(self->value2);
  277. break;
  278. case RESTART:
  279. key_out(self->value2);
  280. break;
  281. default:
  282. break;
  283. }
  284. }
  285. void autoshift_dance_impl(const struct Chord* self) {
  286. switch (*self->state) {
  287. case ACTIVATED:
  288. *self->counter = 0;
  289. break;
  290. case DEACTIVATED:
  291. case RESTART:
  292. tap_key(self->value1);
  293. *self->state = IDLE;
  294. break;
  295. case FINISHED_FROM_ACTIVE:
  296. if (*self->counter == (LONG_PRESS_MULTIPLIER - 2)) {
  297. key_in(KC_LSFT);
  298. tap_key(self->value1);
  299. key_out(KC_LSFT);
  300. *self->state = IDLE;
  301. // the skip to IDLE is usually just a lag optimization,
  302. // in this case it has a logic function, on a short
  303. // press (still longer than a tap) the key does not get shifted
  304. } else {
  305. *self->counter += 1;
  306. *self->state = PRESS_FROM_ACTIVE;
  307. dance_timer = timer_read();
  308. }
  309. break;
  310. default:
  311. break;
  312. }
  313. }
  314. void autoshift_dance(const struct Chord* self) {
  315. if (autoshift_mode) {
  316. autoshift_dance_impl(self);
  317. } else {
  318. single_dance(self);
  319. }
  320. }
  321. void autoshift_toggle(const struct Chord* self){
  322. if (*self->state == ACTIVATED) {
  323. autoshift_mode = !autoshift_mode;
  324. *self->state = IDLE;
  325. }
  326. }
  327. void temp_pseudolayer(const struct Chord* self) {
  328. switch (*self->state) {
  329. case ACTIVATED:
  330. current_pseudolayer = self->value1;
  331. break;
  332. case DEACTIVATED:
  333. current_pseudolayer = self->pseudolayer;
  334. *self->state = IDLE;
  335. break;
  336. case RESTART:
  337. current_pseudolayer = self->pseudolayer;
  338. break;
  339. default:
  340. break;
  341. }
  342. }
  343. void perm_pseudolayer(const struct Chord* self) {
  344. if (*self->state == ACTIVATED) {
  345. current_pseudolayer = self->value1;
  346. *self->state = IDLE;
  347. }
  348. }
  349. void switch_layer(const struct Chord* self) {
  350. if (*self->state == ACTIVATED) {
  351. layer_move(self->value1);
  352. *self->state = IDLE;
  353. }
  354. }
  355. void lock(const struct Chord* self) {
  356. if (*self->state == ACTIVATED) {
  357. lock_next = true;
  358. *self->state = IDLE;
  359. }
  360. }
  361. void one_shot_key(const struct Chord* self) {
  362. switch (*self->state) {
  363. case ACTIVATED:
  364. break;
  365. case DEACTIVATED:
  366. key_in(self->value1);
  367. *self->state = IN_ONE_SHOT;
  368. break;
  369. case FINISHED:
  370. case PRESS_FROM_ACTIVE:
  371. key_in(self->value1);
  372. a_key_went_through = false;
  373. break;
  374. case RESTART:
  375. if (a_key_went_through) {
  376. key_out(self->value1);
  377. } else {
  378. *self->state = IN_ONE_SHOT;
  379. }
  380. default:
  381. break;
  382. }
  383. }
  384. void one_shot_layer(const struct Chord* self) {
  385. switch (*self->state) {
  386. case ACTIVATED:
  387. break;
  388. case DEACTIVATED:
  389. current_pseudolayer = self->value1;
  390. *self->state = IN_ONE_SHOT;
  391. break;
  392. case FINISHED:
  393. case PRESS_FROM_ACTIVE:
  394. current_pseudolayer = self->value1;
  395. a_key_went_through = false;
  396. break;
  397. case RESTART:
  398. if (a_key_went_through) {
  399. current_pseudolayer = self->pseudolayer;
  400. } else {
  401. *self->state = IN_ONE_SHOT;
  402. }
  403. default:
  404. break;
  405. }
  406. }
  407. void command(const struct Chord* self) {
  408. if (*self->state == ACTIVATED) {
  409. command_mode++;
  410. *self->state = IDLE;
  411. }
  412. }
  413. bool identical(uint16_t* buffer1, uint16_t* buffer2) {
  414. bool same = true;
  415. for (int i = 0; i < LEADER_MAX_LENGTH; i++) {
  416. same = same && (buffer1[i] == buffer2[i]);
  417. }
  418. return same;
  419. }
  420. void leader(const struct Chord* self) {
  421. if (*self->state == ACTIVATED) {
  422. in_leader_mode = true;
  423. *self->state = IDLE;
  424. }
  425. }
  426. void dynamic_macro_record(const struct Chord* self) {
  427. if (*self->state == ACTIVATED) {
  428. for (int i = 0; i < DYNAMIC_MACRO_MAX_LENGTH; i++) {
  429. dynamic_macro_buffer[i] = 0;
  430. }
  431. dynamic_macro_mode = true;
  432. *self->state = IDLE;
  433. }
  434. }
  435. void dynamic_macro_next(const struct Chord* self) {
  436. if (*self->state == ACTIVATED) {
  437. if (dynamic_macro_mode && dynamic_macro_ind < DYNAMIC_MACRO_MAX_LENGTH) {
  438. dynamic_macro_buffer[dynamic_macro_ind] = 0;
  439. dynamic_macro_ind++;
  440. }
  441. *self->state = IDLE;
  442. }
  443. }
  444. void dynamic_macro_end(const struct Chord* self) {
  445. if (*self->state == ACTIVATED) {
  446. if (dynamic_macro_mode) {
  447. dynamic_macro_mode = false;
  448. }
  449. *self->state = IDLE;
  450. }
  451. }
  452. void dynamic_macro_play(const struct Chord* self) {
  453. if (*self->state == ACTIVATED) {
  454. int ind_start = 0;
  455. while (ind_start < DYNAMIC_MACRO_MAX_LENGTH) {
  456. for (int i = ind_start; i < DYNAMIC_MACRO_MAX_LENGTH; i++) {
  457. if (dynamic_macro_buffer[i] == 0) {
  458. break;
  459. }
  460. register_code(dynamic_macro_buffer[i]);
  461. }
  462. send_keyboard_report();
  463. wait_ms(TAP_TIMEOUT);
  464. for (int i = ind_start; i < DYNAMIC_MACRO_MAX_LENGTH; i++) {
  465. if (dynamic_macro_buffer[i] == 0) {
  466. ind_start = i + 1;
  467. break;
  468. }
  469. unregister_code(dynamic_macro_buffer[i]);
  470. }
  471. send_keyboard_report();
  472. }
  473. *self->state = IDLE;
  474. }
  475. }
  476. void clear(const struct Chord* self);
  477. void reset_keyboard_kb(void){
  478. #ifdef WATCHDOG_ENABLE
  479. MCUSR = 0;
  480. wdt_disable();
  481. wdt_reset();
  482. #endif
  483. reset_keyboard();
  484. }
  485. void reset(const struct Chord* self) {
  486. if (*self->state == ACTIVATED) {
  487. reset_keyboard_kb();
  488. }
  489. }
  490. uint8_t state_0 = IDLE;
  491. const struct Chord chord_0 PROGMEM = {H_TOP1 + H_TOP2 + H_BOT1 + H_BOT2, ALWAYS_ON, &state_0, NULL, 0, 0, lock};
  492. uint8_t state_1 = IDLE;
  493. const struct Chord chord_1 PROGMEM = {H_TOP2 + H_TOP3 + H_BOT2 + H_BOT3, ALWAYS_ON, &state_1, NULL, 0, 0, autoshift_toggle};
  494. uint8_t state_2 = IDLE;
  495. const struct Chord chord_2 PROGMEM = {H_TOP5 + H_TOP6 + H_BOT5 + H_BOT6, ALWAYS_ON, &state_2, NULL, 0, 0, command};
  496. uint8_t state_3 = IDLE;
  497. const struct Chord chord_3 PROGMEM = {H_TOP1 + H_TOP2 + H_TOP9 + H_TOP0 + H_BOT1 + H_BOT2 + H_BOT9 + H_BOT0, ALWAYS_ON, &state_3, NULL, 0, 0, clear};
  498. uint8_t state_4 = IDLE;
  499. uint8_t counter_4 = 0;
  500. const struct Chord chord_4 PROGMEM = {H_TOP1, QWERTY, &state_4, &counter_4, KC_Q, 0, autoshift_dance};
  501. uint8_t state_5 = IDLE;
  502. uint8_t counter_5 = 0;
  503. const struct Chord chord_5 PROGMEM = {H_TOP2, QWERTY, &state_5, &counter_5, KC_W, 0, autoshift_dance};
  504. uint8_t state_6 = IDLE;
  505. uint8_t counter_6 = 0;
  506. const struct Chord chord_6 PROGMEM = {H_TOP3, QWERTY, &state_6, &counter_6, KC_E, 0, autoshift_dance};
  507. uint8_t state_7 = IDLE;
  508. uint8_t counter_7 = 0;
  509. const struct Chord chord_7 PROGMEM = {H_TOP4, QWERTY, &state_7, &counter_7, KC_R, 0, autoshift_dance};
  510. uint8_t state_8 = IDLE;
  511. uint8_t counter_8 = 0;
  512. const struct Chord chord_8 PROGMEM = {H_TOP5, QWERTY, &state_8, &counter_8, KC_T, 0, autoshift_dance};
  513. uint8_t state_9 = IDLE;
  514. uint8_t counter_9 = 0;
  515. const struct Chord chord_9 PROGMEM = {H_TOP6, QWERTY, &state_9, &counter_9, KC_Y, 0, autoshift_dance};
  516. uint8_t state_10 = IDLE;
  517. uint8_t counter_10 = 0;
  518. const struct Chord chord_10 PROGMEM = {H_TOP7, QWERTY, &state_10, &counter_10, KC_U, 0, autoshift_dance};
  519. uint8_t state_11 = IDLE;
  520. uint8_t counter_11 = 0;
  521. const struct Chord chord_11 PROGMEM = {H_TOP8, QWERTY, &state_11, &counter_11, KC_I, 0, autoshift_dance};
  522. uint8_t state_12 = IDLE;
  523. uint8_t counter_12 = 0;
  524. const struct Chord chord_12 PROGMEM = {H_TOP9, QWERTY, &state_12, &counter_12, KC_O, 0, autoshift_dance};
  525. uint8_t state_13 = IDLE;
  526. uint8_t counter_13 = 0;
  527. const struct Chord chord_13 PROGMEM = {H_TOP0, QWERTY, &state_13, &counter_13, KC_P, 0, autoshift_dance};
  528. uint8_t state_14 = IDLE;
  529. uint8_t counter_14 = 0;
  530. const struct Chord chord_14 PROGMEM = {H_TOP1 + H_BOT1, QWERTY, &state_14, &counter_14, KC_A, 0, autoshift_dance};
  531. uint8_t state_15 = IDLE;
  532. uint8_t counter_15 = 0;
  533. const struct Chord chord_15 PROGMEM = {H_TOP2 + H_BOT2, QWERTY, &state_15, &counter_15, KC_S, 0, autoshift_dance};
  534. uint8_t state_16 = IDLE;
  535. uint8_t counter_16 = 0;
  536. const struct Chord chord_16 PROGMEM = {H_TOP3 + H_BOT3, QWERTY, &state_16, &counter_16, KC_D, 0, autoshift_dance};
  537. uint8_t state_17 = IDLE;
  538. uint8_t counter_17 = 0;
  539. const struct Chord chord_17 PROGMEM = {H_TOP4 + H_BOT4, QWERTY, &state_17, &counter_17, KC_F, 0, autoshift_dance};
  540. uint8_t state_18 = IDLE;
  541. uint8_t counter_18 = 0;
  542. const struct Chord chord_18 PROGMEM = {H_TOP5 + H_BOT5, QWERTY, &state_18, &counter_18, KC_G, 0, autoshift_dance};
  543. uint8_t state_19 = IDLE;
  544. uint8_t counter_19 = 0;
  545. const struct Chord chord_19 PROGMEM = {H_TOP6 + H_BOT6, QWERTY, &state_19, &counter_19, KC_H, 0, autoshift_dance};
  546. uint8_t state_20 = IDLE;
  547. uint8_t counter_20 = 0;
  548. const struct Chord chord_20 PROGMEM = {H_TOP7 + H_BOT7, QWERTY, &state_20, &counter_20, KC_J, 0, autoshift_dance};
  549. uint8_t state_21 = IDLE;
  550. uint8_t counter_21 = 0;
  551. const struct Chord chord_21 PROGMEM = {H_TOP8 + H_BOT8, QWERTY, &state_21, &counter_21, KC_K, 0, autoshift_dance};
  552. uint8_t state_22 = IDLE;
  553. uint8_t counter_22 = 0;
  554. const struct Chord chord_22 PROGMEM = {H_TOP9 + H_BOT9, QWERTY, &state_22, &counter_22, KC_L, 0, autoshift_dance};
  555. uint8_t state_23 = IDLE;
  556. uint8_t counter_23 = 0;
  557. const struct Chord chord_23 PROGMEM = {H_TOP0 + H_BOT0, QWERTY, &state_23, &counter_23, KC_SCOLON, 0, autoshift_dance};
  558. uint8_t state_24 = IDLE;
  559. uint8_t counter_24 = 0;
  560. const struct Chord chord_24 PROGMEM = {H_BOT1, QWERTY, &state_24, &counter_24, KC_Z, 0, autoshift_dance};
  561. uint8_t state_25 = IDLE;
  562. uint8_t counter_25 = 0;
  563. const struct Chord chord_25 PROGMEM = {H_BOT2, QWERTY, &state_25, &counter_25, KC_X, 0, autoshift_dance};
  564. uint8_t state_26 = IDLE;
  565. uint8_t counter_26 = 0;
  566. const struct Chord chord_26 PROGMEM = {H_BOT3, QWERTY, &state_26, &counter_26, KC_C, 0, autoshift_dance};
  567. uint8_t state_27 = IDLE;
  568. uint8_t counter_27 = 0;
  569. const struct Chord chord_27 PROGMEM = {H_BOT4, QWERTY, &state_27, &counter_27, KC_V, 0, autoshift_dance};
  570. uint8_t state_28 = IDLE;
  571. uint8_t counter_28 = 0;
  572. const struct Chord chord_28 PROGMEM = {H_BOT5, QWERTY, &state_28, &counter_28, KC_B, 0, autoshift_dance};
  573. uint8_t state_29 = IDLE;
  574. uint8_t counter_29 = 0;
  575. const struct Chord chord_29 PROGMEM = {H_BOT6, QWERTY, &state_29, &counter_29, KC_N, 0, autoshift_dance};
  576. uint8_t state_30 = IDLE;
  577. uint8_t counter_30 = 0;
  578. const struct Chord chord_30 PROGMEM = {H_BOT7, QWERTY, &state_30, &counter_30, KC_M, 0, autoshift_dance};
  579. uint8_t state_31 = IDLE;
  580. uint8_t counter_31 = 0;
  581. const struct Chord chord_31 PROGMEM = {H_BOT8, QWERTY, &state_31, &counter_31, KC_COMMA, 0, autoshift_dance};
  582. uint8_t state_32 = IDLE;
  583. uint8_t counter_32 = 0;
  584. const struct Chord chord_32 PROGMEM = {H_BOT9, QWERTY, &state_32, &counter_32, KC_DOT, 0, autoshift_dance};
  585. uint8_t state_33 = IDLE;
  586. uint8_t counter_33 = 0;
  587. const struct Chord chord_33 PROGMEM = {H_BOT0, QWERTY, &state_33, &counter_33, KC_SLASH, 0, autoshift_dance};
  588. uint8_t state_34 = IDLE;
  589. const struct Chord chord_34 PROGMEM = {H_TOP1 + H_TOP2, QWERTY, &state_34, NULL, KC_ESC, 0, single_dance};
  590. uint8_t state_35 = IDLE;
  591. const struct Chord chord_35 PROGMEM = {H_TOP2 + H_TOP3, QWERTY, &state_35, NULL, MOV, 0, temp_pseudolayer};
  592. uint8_t state_36 = IDLE;
  593. const struct Chord chord_36 PROGMEM = {H_TOP3 + H_TOP4, QWERTY, &state_36, NULL, KC_TAB, 0, single_dance};
  594. uint8_t state_37 = IDLE;
  595. const struct Chord chord_37 PROGMEM = {H_TOP5 + H_TOP6, QWERTY, &state_37, NULL, KC_RGUI, 0, one_shot_key};
  596. uint8_t state_38 = IDLE;
  597. const struct Chord chord_38 PROGMEM = {H_TOP7 + H_TOP8, QWERTY, &state_38, NULL, KC_INS, 0, single_dance};
  598. uint8_t state_39 = IDLE;
  599. const struct Chord chord_39 PROGMEM = {H_TOP8 + H_TOP9, QWERTY, &state_39, NULL, KC_DEL, 0, single_dance};
  600. uint8_t state_40 = IDLE;
  601. const struct Chord chord_40 PROGMEM = {H_TOP9 + H_TOP0, QWERTY, &state_40, NULL, KC_BSPC, 0, single_dance};
  602. uint8_t state_41 = IDLE;
  603. const struct Chord chord_41 PROGMEM = {H_TOP9 + H_TOP0 + H_BOT9 + H_BOT0, QWERTY, &state_41, NULL, KC_ENTER, 0, single_dance};
  604. uint8_t state_42 = IDLE;
  605. const struct Chord chord_42 PROGMEM = {H_BOT1 + H_BOT2, QWERTY, &state_42, NULL, KC_LSFT, 0, one_shot_key};
  606. uint8_t state_43 = IDLE;
  607. const struct Chord chord_43 PROGMEM = {H_BOT2 + H_BOT3, QWERTY, &state_43, NULL, KC_LCTL, 0, one_shot_key};
  608. uint8_t state_44 = IDLE;
  609. const struct Chord chord_44 PROGMEM = {H_BOT3 + H_BOT4, QWERTY, &state_44, NULL, KC_LALT, 0, one_shot_key};
  610. uint8_t state_45 = IDLE;
  611. const struct Chord chord_45 PROGMEM = {H_BOT4 + H_BOT5, QWERTY, &state_45, NULL, NUM, 0, one_shot_layer};
  612. uint8_t state_46 = IDLE;
  613. const struct Chord chord_46 PROGMEM = {H_BOT5 + H_BOT6, QWERTY, &state_46, NULL, KC_LGUI, 0, one_shot_key};
  614. uint8_t state_47 = IDLE;
  615. const struct Chord chord_47 PROGMEM = {H_BOT6 + H_BOT7, QWERTY, &state_47, NULL, NUM, 0, one_shot_layer};
  616. uint8_t state_48 = IDLE;
  617. const struct Chord chord_48 PROGMEM = {H_BOT7 + H_BOT8, QWERTY, &state_48, NULL, KC_RALT, 0, one_shot_key};
  618. uint8_t state_49 = IDLE;
  619. const struct Chord chord_49 PROGMEM = {H_BOT8 + H_BOT9, QWERTY, &state_49, NULL, KC_RCTL, 0, one_shot_key};
  620. uint8_t state_50 = IDLE;
  621. const struct Chord chord_50 PROGMEM = {H_BOT9 + H_BOT0, QWERTY, &state_50, NULL, KC_RSFT, 0, one_shot_key};
  622. uint8_t state_51 = IDLE;
  623. const struct Chord chord_51 PROGMEM = {H_BOT1 + H_BOT0, QWERTY, &state_51, NULL, KC_SPACE, 0, single_dance};
  624. uint8_t state_52 = IDLE;
  625. const struct Chord chord_52 PROGMEM = {H_TOP1 + H_TOP2 + H_TOP3 + H_TOP4, QWERTY, &state_52, NULL, MOUSE, 0, temp_pseudolayer};
  626. uint8_t state_53 = IDLE;
  627. const struct Chord chord_53 PROGMEM = {H_TOP1 + H_TOP2 + H_TOP3 + H_TOP4, QWERTY, &state_53, NULL, ASETNIOP, 0, perm_pseudolayer};
  628. uint8_t state_54 = IDLE;
  629. uint8_t counter_54 = 0;
  630. const struct Chord chord_54 PROGMEM = {H_TOP1, NUM, &state_54, &counter_54, KC_1, 0, autoshift_dance};
  631. uint8_t state_55 = IDLE;
  632. uint8_t counter_55 = 0;
  633. const struct Chord chord_55 PROGMEM = {H_TOP2, NUM, &state_55, &counter_55, KC_2, 0, autoshift_dance};
  634. uint8_t state_56 = IDLE;
  635. uint8_t counter_56 = 0;
  636. const struct Chord chord_56 PROGMEM = {H_TOP3, NUM, &state_56, &counter_56, KC_3, 0, autoshift_dance};
  637. uint8_t state_57 = IDLE;
  638. uint8_t counter_57 = 0;
  639. const struct Chord chord_57 PROGMEM = {H_TOP4, NUM, &state_57, &counter_57, KC_4, 0, autoshift_dance};
  640. uint8_t state_58 = IDLE;
  641. uint8_t counter_58 = 0;
  642. const struct Chord chord_58 PROGMEM = {H_TOP5, NUM, &state_58, &counter_58, KC_5, 0, autoshift_dance};
  643. uint8_t state_59 = IDLE;
  644. uint8_t counter_59 = 0;
  645. const struct Chord chord_59 PROGMEM = {H_TOP6, NUM, &state_59, &counter_59, KC_6, 0, autoshift_dance};
  646. uint8_t state_60 = IDLE;
  647. uint8_t counter_60 = 0;
  648. const struct Chord chord_60 PROGMEM = {H_TOP7, NUM, &state_60, &counter_60, KC_7, 0, autoshift_dance};
  649. uint8_t state_61 = IDLE;
  650. uint8_t counter_61 = 0;
  651. const struct Chord chord_61 PROGMEM = {H_TOP8, NUM, &state_61, &counter_61, KC_8, 0, autoshift_dance};
  652. uint8_t state_62 = IDLE;
  653. uint8_t counter_62 = 0;
  654. const struct Chord chord_62 PROGMEM = {H_TOP9, NUM, &state_62, &counter_62, KC_9, 0, autoshift_dance};
  655. uint8_t state_63 = IDLE;
  656. uint8_t counter_63 = 0;
  657. const struct Chord chord_63 PROGMEM = {H_TOP0, NUM, &state_63, &counter_63, KC_0, 0, autoshift_dance};
  658. uint8_t state_64 = IDLE;
  659. const struct Chord chord_64 PROGMEM = {H_TOP1 + H_BOT1, NUM, &state_64, NULL, KC_F1, 0, single_dance};
  660. uint8_t state_65 = IDLE;
  661. const struct Chord chord_65 PROGMEM = {H_TOP2 + H_BOT2, NUM, &state_65, NULL, KC_F2, 0, single_dance};
  662. uint8_t state_66 = IDLE;
  663. const struct Chord chord_66 PROGMEM = {H_TOP3 + H_BOT3, NUM, &state_66, NULL, KC_F3, 0, single_dance};
  664. uint8_t state_67 = IDLE;
  665. const struct Chord chord_67 PROGMEM = {H_TOP4 + H_BOT4, NUM, &state_67, NULL, KC_F4, 0, single_dance};
  666. uint8_t state_68 = IDLE;
  667. const struct Chord chord_68 PROGMEM = {H_TOP5 + H_BOT5, NUM, &state_68, NULL, KC_F5, 0, single_dance};
  668. uint8_t state_69 = IDLE;
  669. const struct Chord chord_69 PROGMEM = {H_TOP6 + H_BOT6, NUM, &state_69, NULL, KC_F6, 0, single_dance};
  670. uint8_t state_70 = IDLE;
  671. const struct Chord chord_70 PROGMEM = {H_TOP7 + H_BOT7, NUM, &state_70, NULL, KC_F7, 0, single_dance};
  672. uint8_t state_71 = IDLE;
  673. const struct Chord chord_71 PROGMEM = {H_TOP8 + H_BOT8, NUM, &state_71, NULL, KC_F8, 0, single_dance};
  674. uint8_t state_72 = IDLE;
  675. const struct Chord chord_72 PROGMEM = {H_TOP9 + H_BOT9, NUM, &state_72, NULL, KC_F9, 0, single_dance};
  676. uint8_t state_73 = IDLE;
  677. const struct Chord chord_73 PROGMEM = {H_TOP0 + H_BOT0, NUM, &state_73, NULL, KC_F10, 0, single_dance};
  678. uint8_t state_74 = IDLE;
  679. uint8_t counter_74 = 0;
  680. const struct Chord chord_74 PROGMEM = {H_BOT1, NUM, &state_74, &counter_74, KC_GRAVE, 0, autoshift_dance};
  681. uint8_t state_75 = IDLE;
  682. uint8_t counter_75 = 0;
  683. const struct Chord chord_75 PROGMEM = {H_BOT2, NUM, &state_75, &counter_75, KC_MINUS, 0, autoshift_dance};
  684. uint8_t state_76 = IDLE;
  685. uint8_t counter_76 = 0;
  686. const struct Chord chord_76 PROGMEM = {H_BOT3, NUM, &state_76, &counter_76, KC_EQUAL, 0, autoshift_dance};
  687. uint8_t state_77 = IDLE;
  688. uint8_t counter_77 = 0;
  689. const struct Chord chord_77 PROGMEM = {H_BOT4, NUM, &state_77, &counter_77, KC_LBRACKET, 0, autoshift_dance};
  690. uint8_t state_78 = IDLE;
  691. uint8_t counter_78 = 0;
  692. const struct Chord chord_78 PROGMEM = {H_BOT5, NUM, &state_78, &counter_78, KC_RBRACKET, 0, autoshift_dance};
  693. uint8_t state_79 = IDLE;
  694. uint8_t counter_79 = 0;
  695. const struct Chord chord_79 PROGMEM = {H_BOT6, NUM, &state_79, &counter_79, KC_BSLASH, 0, autoshift_dance};
  696. uint8_t state_80 = IDLE;
  697. uint8_t counter_80 = 0;
  698. const struct Chord chord_80 PROGMEM = {H_BOT7, NUM, &state_80, &counter_80, KC_QUOTE, 0, autoshift_dance};
  699. uint8_t state_81 = IDLE;
  700. const struct Chord chord_81 PROGMEM = {H_BOT9, NUM, &state_81, NULL, KC_F11, 0, single_dance};
  701. uint8_t state_82 = IDLE;
  702. const struct Chord chord_82 PROGMEM = {H_BOT0, NUM, &state_82, NULL, KC_F12, 0, single_dance};
  703. uint8_t state_83 = IDLE;
  704. const struct Chord chord_83 PROGMEM = {H_TOP1 + H_TOP2, NUM, &state_83, NULL, KC_ESC, 0, single_dance};
  705. uint8_t state_84 = IDLE;
  706. const struct Chord chord_84 PROGMEM = {H_TOP3 + H_TOP4, NUM, &state_84, NULL, KC_TAB, 0, single_dance};
  707. uint8_t state_85 = IDLE;
  708. const struct Chord chord_85 PROGMEM = {H_TOP5 + H_TOP6, NUM, &state_85, NULL, KC_RGUI, 0, one_shot_key};
  709. uint8_t state_86 = IDLE;
  710. const struct Chord chord_86 PROGMEM = {H_TOP7 + H_TOP8, NUM, &state_86, NULL, KC_INS, 0, single_dance};
  711. uint8_t state_87 = IDLE;
  712. const struct Chord chord_87 PROGMEM = {H_TOP8 + H_TOP9, NUM, &state_87, NULL, KC_DEL, 0, single_dance};
  713. uint8_t state_88 = IDLE;
  714. const struct Chord chord_88 PROGMEM = {H_TOP9 + H_TOP0, NUM, &state_88, NULL, KC_BSPC, 0, single_dance};
  715. uint8_t state_89 = IDLE;
  716. const struct Chord chord_89 PROGMEM = {H_TOP9 + H_TOP0 + H_BOT9 + H_BOT0, NUM, &state_89, NULL, KC_ENTER, 0, single_dance};
  717. uint8_t state_90 = IDLE;
  718. const struct Chord chord_90 PROGMEM = {H_BOT1 + H_BOT2, NUM, &state_90, NULL, KC_LSFT, 0, one_shot_key};
  719. uint8_t state_91 = IDLE;
  720. const struct Chord chord_91 PROGMEM = {H_BOT2 + H_BOT3, NUM, &state_91, NULL, KC_LCTL, 0, one_shot_key};
  721. uint8_t state_92 = IDLE;
  722. const struct Chord chord_92 PROGMEM = {H_BOT3 + H_BOT4, NUM, &state_92, NULL, KC_LALT, 0, one_shot_key};
  723. uint8_t state_93 = IDLE;
  724. const struct Chord chord_93 PROGMEM = {H_BOT5 + H_BOT6, NUM, &state_93, NULL, KC_LGUI, 0, one_shot_key};
  725. uint8_t state_94 = IDLE;
  726. const struct Chord chord_94 PROGMEM = {H_BOT7 + H_BOT8, NUM, &state_94, NULL, KC_RALT, 0, one_shot_key};
  727. uint8_t state_95 = IDLE;
  728. const struct Chord chord_95 PROGMEM = {H_BOT8 + H_BOT9, NUM, &state_95, NULL, KC_RCTL, 0, one_shot_key};
  729. uint8_t state_96 = IDLE;
  730. const struct Chord chord_96 PROGMEM = {H_BOT9 + H_BOT0, NUM, &state_96, NULL, KC_RSFT, 0, one_shot_key};
  731. uint8_t state_97 = IDLE;
  732. const struct Chord chord_97 PROGMEM = {H_BOT1 + H_BOT0, NUM, &state_97, NULL, KC_SPACE, 0, single_dance};
  733. uint8_t state_98 = IDLE;
  734. const struct Chord chord_98 PROGMEM = {H_TOP7, MOV, &state_98, NULL, KC_HOME, 0, single_dance};
  735. uint8_t state_99 = IDLE;
  736. const struct Chord chord_99 PROGMEM = {H_TOP8, MOV, &state_99, NULL, KC_UP, 0, single_dance};
  737. uint8_t state_100 = IDLE;
  738. const struct Chord chord_100 PROGMEM = {H_TOP9, MOV, &state_100, NULL, KC_END, 0, single_dance};
  739. uint8_t state_101 = IDLE;
  740. const struct Chord chord_101 PROGMEM = {H_TOP0, MOV, &state_101, NULL, KC_PGUP, 0, single_dance};
  741. uint8_t state_102 = IDLE;
  742. const struct Chord chord_102 PROGMEM = {H_BOT3, MOV, &state_102, NULL, KC_LSFT, 0, single_dance};
  743. uint8_t state_103 = IDLE;
  744. const struct Chord chord_103 PROGMEM = {H_BOT4, MOV, &state_103, NULL, KC_LCTL, 0, single_dance};
  745. uint8_t state_104 = IDLE;
  746. const struct Chord chord_104 PROGMEM = {H_BOT5, MOV, &state_104, NULL, KC_LALT, 0, single_dance};
  747. uint8_t state_105 = IDLE;
  748. const struct Chord chord_105 PROGMEM = {H_BOT6, MOV, &state_105, NULL, KC_LGUI, 0, single_dance};
  749. uint8_t state_106 = IDLE;
  750. const struct Chord chord_106 PROGMEM = {H_BOT7, MOV, &state_106, NULL, KC_LEFT, 0, single_dance};
  751. uint8_t state_107 = IDLE;
  752. const struct Chord chord_107 PROGMEM = {H_BOT8, MOV, &state_107, NULL, KC_DOWN, 0, single_dance};
  753. uint8_t state_108 = IDLE;
  754. const struct Chord chord_108 PROGMEM = {H_BOT9, MOV, &state_108, NULL, KC_RIGHT, 0, single_dance};
  755. uint8_t state_109 = IDLE;
  756. const struct Chord chord_109 PROGMEM = {H_BOT0, MOV, &state_109, NULL, KC_PGDN, 0, single_dance};
  757. uint8_t state_110 = IDLE;
  758. const struct Chord chord_110 PROGMEM = {H_TOP7, MOUSE, &state_110, NULL, KC_BTN1, 0, single_dance};
  759. uint8_t state_111 = IDLE;
  760. const struct Chord chord_111 PROGMEM = {H_TOP8, MOUSE, &state_111, NULL, KC_MS_U, 0, single_dance};
  761. uint8_t state_112 = IDLE;
  762. const struct Chord chord_112 PROGMEM = {H_TOP9, MOUSE, &state_112, NULL, KC_BTN2, 0, single_dance};
  763. uint8_t state_113 = IDLE;
  764. const struct Chord chord_113 PROGMEM = {H_TOP0, MOUSE, &state_113, NULL, KC_WH_U, 0, single_dance};
  765. uint8_t state_114 = IDLE;
  766. const struct Chord chord_114 PROGMEM = {H_BOT3, MOUSE, &state_114, NULL, KC_LSFT, 0, single_dance};
  767. uint8_t state_115 = IDLE;
  768. const struct Chord chord_115 PROGMEM = {H_BOT4, MOUSE, &state_115, NULL, KC_LCTL, 0, single_dance};
  769. uint8_t state_116 = IDLE;
  770. const struct Chord chord_116 PROGMEM = {H_BOT5, MOUSE, &state_116, NULL, KC_LALT, 0, single_dance};
  771. uint8_t state_117 = IDLE;
  772. const struct Chord chord_117 PROGMEM = {H_BOT6, MOUSE, &state_117, NULL, KC_LGUI, 0, single_dance};
  773. uint8_t state_118 = IDLE;
  774. const struct Chord chord_118 PROGMEM = {H_BOT7, MOUSE, &state_118, NULL, KC_MS_L, 0, single_dance};
  775. uint8_t state_119 = IDLE;
  776. const struct Chord chord_119 PROGMEM = {H_BOT8, MOUSE, &state_119, NULL, KC_MS_D, 0, single_dance};
  777. uint8_t state_120 = IDLE;
  778. const struct Chord chord_120 PROGMEM = {H_BOT9, MOUSE, &state_120, NULL, KC_MS_R, 0, single_dance};
  779. uint8_t state_121 = IDLE;
  780. const struct Chord chord_121 PROGMEM = {H_BOT0, MOUSE, &state_121, NULL, KC_WH_D, 0, single_dance};
  781. uint8_t state_122 = IDLE;
  782. const struct Chord chord_122 PROGMEM = {H_TOP1, ASETNIOP, &state_122, NULL, KC_A, 0, single_dance};
  783. uint8_t state_123 = IDLE;
  784. const struct Chord chord_123 PROGMEM = {H_TOP2, ASETNIOP, &state_123, NULL, KC_S, 0, single_dance};
  785. uint8_t state_124 = IDLE;
  786. const struct Chord chord_124 PROGMEM = {H_TOP3, ASETNIOP, &state_124, NULL, KC_E, 0, single_dance};
  787. uint8_t state_125 = IDLE;
  788. const struct Chord chord_125 PROGMEM = {H_TOP4, ASETNIOP, &state_125, NULL, KC_T, 0, single_dance};
  789. uint8_t state_126 = IDLE;
  790. const struct Chord chord_126 PROGMEM = {H_TOP7, ASETNIOP, &state_126, NULL, KC_N, 0, single_dance};
  791. uint8_t state_127 = IDLE;
  792. const struct Chord chord_127 PROGMEM = {H_TOP8, ASETNIOP, &state_127, NULL, KC_I, 0, single_dance};
  793. uint8_t state_128 = IDLE;
  794. const struct Chord chord_128 PROGMEM = {H_TOP9, ASETNIOP, &state_128, NULL, KC_O, 0, single_dance};
  795. uint8_t state_129 = IDLE;
  796. const struct Chord chord_129 PROGMEM = {H_TOP0, ASETNIOP, &state_129, NULL, KC_P, 0, single_dance};
  797. uint8_t state_130 = IDLE;
  798. const struct Chord chord_130 PROGMEM = {H_TOP1 + H_TOP2, ASETNIOP, &state_130, NULL, KC_W, 0, single_dance};
  799. uint8_t state_131 = IDLE;
  800. const struct Chord chord_131 PROGMEM = {H_TOP2 + H_TOP3, ASETNIOP, &state_131, NULL, KC_D, 0, single_dance};
  801. uint8_t state_132 = IDLE;
  802. const struct Chord chord_132 PROGMEM = {H_TOP3 + H_TOP4, ASETNIOP, &state_132, NULL, KC_R, 0, single_dance};
  803. uint8_t state_133 = IDLE;
  804. const struct Chord chord_133 PROGMEM = {H_TOP4 + H_TOP7, ASETNIOP, &state_133, NULL, KC_B, 0, single_dance};
  805. uint8_t state_134 = IDLE;
  806. const struct Chord chord_134 PROGMEM = {H_TOP7 + H_TOP8, ASETNIOP, &state_134, NULL, KC_H, 0, single_dance};
  807. uint8_t state_135 = IDLE;
  808. const struct Chord chord_135 PROGMEM = {H_TOP8 + H_TOP9, ASETNIOP, &state_135, NULL, KC_L, 0, single_dance};
  809. uint8_t state_136 = IDLE;
  810. const struct Chord chord_136 PROGMEM = {H_TOP9 + H_TOP0, ASETNIOP, &state_136, NULL, KC_SCOLON, 0, single_dance};
  811. uint8_t state_137 = IDLE;
  812. const struct Chord chord_137 PROGMEM = {H_TOP1 + H_TOP3, ASETNIOP, &state_137, NULL, KC_X, 0, single_dance};
  813. uint8_t state_138 = IDLE;
  814. const struct Chord chord_138 PROGMEM = {H_TOP2 + H_TOP4, ASETNIOP, &state_138, NULL, KC_C, 0, single_dance};
  815. uint8_t state_139 = IDLE;
  816. const struct Chord chord_139 PROGMEM = {H_TOP3 + H_TOP7, ASETNIOP, &state_139, NULL, KC_Y, 0, single_dance};
  817. uint8_t state_140 = IDLE;
  818. const struct Chord chord_140 PROGMEM = {H_TOP4 + H_TOP8, ASETNIOP, &state_140, NULL, KC_V, 0, single_dance};
  819. uint8_t state_141 = IDLE;
  820. const struct Chord chord_141 PROGMEM = {H_TOP7 + H_TOP9, ASETNIOP, &state_141, NULL, KC_U, 0, single_dance};
  821. uint8_t state_142 = IDLE;
  822. const struct Chord chord_142 PROGMEM = {H_TOP1 + H_TOP4, ASETNIOP, &state_142, NULL, KC_F, 0, single_dance};
  823. uint8_t state_143 = IDLE;
  824. const struct Chord chord_143 PROGMEM = {H_TOP2 + H_TOP7, ASETNIOP, &state_143, NULL, KC_J, 0, single_dance};
  825. uint8_t state_144 = IDLE;
  826. const struct Chord chord_144 PROGMEM = {H_TOP3 + H_TOP8, ASETNIOP, &state_144, NULL, KC_COMMA, 0, single_dance};
  827. uint8_t state_145 = IDLE;
  828. const struct Chord chord_145 PROGMEM = {H_TOP4 + H_TOP9, ASETNIOP, &state_145, NULL, KC_G, 0, single_dance};
  829. uint8_t state_146 = IDLE;
  830. const struct Chord chord_146 PROGMEM = {H_TOP7 + H_TOP0, ASETNIOP, &state_146, NULL, KC_M, 0, single_dance};
  831. uint8_t state_147 = IDLE;
  832. const struct Chord chord_147 PROGMEM = {H_TOP1 + H_TOP7, ASETNIOP, &state_147, NULL, KC_Q, 0, single_dance};
  833. uint8_t state_148 = IDLE;
  834. const struct Chord chord_148 PROGMEM = {H_TOP2 + H_TOP8, ASETNIOP, &state_148, NULL, KC_K, 0, single_dance};
  835. uint8_t state_149 = IDLE;
  836. const struct Chord chord_149 PROGMEM = {H_TOP3 + H_TOP9, ASETNIOP, &state_149, NULL, KC_MINUS, 0, single_dance};
  837. uint8_t state_150 = IDLE;
  838. const struct Chord chord_150 PROGMEM = {H_TOP4 + H_TOP0, ASETNIOP, &state_150, NULL, KC_BSPC, 0, single_dance};
  839. uint8_t state_151 = IDLE;
  840. const struct Chord chord_151 PROGMEM = {H_TOP1 + H_TOP8, ASETNIOP, &state_151, NULL, KC_Z, 0, single_dance};
  841. uint8_t state_152 = IDLE;
  842. const struct Chord chord_152 PROGMEM = {H_TOP2 + H_TOP9, ASETNIOP, &state_152, NULL, KC_DOT, 0, single_dance};
  843. uint8_t state_153 = IDLE;
  844. const struct Chord chord_153 PROGMEM = {H_TOP3 + H_TOP0, ASETNIOP, &state_153, NULL, KC_QUOTE, 0, single_dance};
  845. uint8_t state_154 = IDLE;
  846. const struct Chord chord_154 PROGMEM = {H_TOP1 + H_TOP9, ASETNIOP, &state_154, NULL, KC_LBRACKET, 0, single_dance};
  847. uint8_t state_155 = IDLE;
  848. const struct Chord chord_155 PROGMEM = {H_TOP2 + H_TOP0, ASETNIOP, &state_155, NULL, KC_RBRACKET, 0, single_dance};
  849. uint8_t state_156 = IDLE;
  850. const struct Chord chord_156 PROGMEM = {H_TOP1 + H_TOP0, ASETNIOP, &state_156, NULL, KC_SLASH, 0, single_dance};
  851. uint8_t state_157 = IDLE;
  852. const struct Chord chord_157 PROGMEM = {H_TOP5, ASETNIOP, &state_157, NULL, KC_ESC, 0, single_dance};
  853. uint8_t state_158 = IDLE;
  854. const struct Chord chord_158 PROGMEM = {H_TOP6, ASETNIOP, &state_158, NULL, KC_DEL, 0, single_dance};
  855. uint8_t state_159 = IDLE;
  856. const struct Chord chord_159 PROGMEM = {H_BOT4, ASETNIOP, &state_159, NULL, KC_LSFT, 0, single_dance};
  857. uint8_t state_160 = IDLE;
  858. const struct Chord chord_160 PROGMEM = {H_BOT5, ASETNIOP, &state_160, NULL, KC_LCTL, 0, single_dance};
  859. uint8_t state_161 = IDLE;
  860. const struct Chord chord_161 PROGMEM = {H_BOT6, ASETNIOP, &state_161, NULL, KC_LALT, 0, single_dance};
  861. uint8_t state_162 = IDLE;
  862. uint8_t counter_162 = 0;
  863. const struct Chord chord_162 PROGMEM = {H_BOT7, ASETNIOP, &state_162, &counter_162, KC_SPACE, ASETNIOP_123, key_layer_dance};
  864. uint8_t state_163 = IDLE;
  865. const struct Chord chord_163 PROGMEM = {H_TOP5 + H_TOP6, ASETNIOP, &state_163, NULL, KC_LGUI, 0, single_dance};
  866. uint8_t state_164 = IDLE;
  867. const struct Chord chord_164 PROGMEM = {H_TOP1 + H_TOP2 + H_TOP3 + H_TOP4, ASETNIOP, &state_164, NULL, QWERTY, 0, perm_pseudolayer};
  868. uint8_t state_165 = IDLE;
  869. const struct Chord chord_165 PROGMEM = {H_BOT4 + H_BOT7, ASETNIOP, &state_165, NULL, ASETNIOP_FN, 0, temp_pseudolayer};
  870. uint8_t state_166 = IDLE;
  871. const struct Chord chord_166 PROGMEM = {H_TOP1, ASETNIOP_123, &state_166, NULL, KC_1, 0, single_dance};
  872. uint8_t state_167 = IDLE;
  873. const struct Chord chord_167 PROGMEM = {H_TOP2, ASETNIOP_123, &state_167, NULL, KC_2, 0, single_dance};
  874. uint8_t state_168 = IDLE;
  875. const struct Chord chord_168 PROGMEM = {H_TOP3, ASETNIOP_123, &state_168, NULL, KC_3, 0, single_dance};
  876. uint8_t state_169 = IDLE;
  877. const struct Chord chord_169 PROGMEM = {H_TOP4, ASETNIOP_123, &state_169, NULL, KC_4, 0, single_dance};
  878. uint8_t state_170 = IDLE;
  879. const struct Chord chord_170 PROGMEM = {H_TOP7, ASETNIOP_123, &state_170, NULL, KC_7, 0, single_dance};
  880. uint8_t state_171 = IDLE;
  881. const struct Chord chord_171 PROGMEM = {H_TOP8, ASETNIOP_123, &state_171, NULL, KC_8, 0, single_dance};
  882. uint8_t state_172 = IDLE;
  883. const struct Chord chord_172 PROGMEM = {H_TOP9, ASETNIOP_123, &state_172, NULL, KC_9, 0, single_dance};
  884. uint8_t state_173 = IDLE;
  885. const struct Chord chord_173 PROGMEM = {H_TOP0, ASETNIOP_123, &state_173, NULL, KC_0, 0, single_dance};
  886. uint8_t state_174 = IDLE;
  887. const struct Chord chord_174 PROGMEM = {H_TOP3 + H_TOP4, ASETNIOP_123, &state_174, NULL, KC_5, 0, single_dance};
  888. uint8_t state_175 = IDLE;
  889. const struct Chord chord_175 PROGMEM = {H_TOP4 + H_TOP7, ASETNIOP_123, &state_175, NULL, KC_EQUAL, 0, single_dance};
  890. uint8_t state_176 = IDLE;
  891. const struct Chord chord_176 PROGMEM = {H_TOP7 + H_TOP8, ASETNIOP_123, &state_176, NULL, KC_6, 0, single_dance};
  892. uint8_t state_177 = IDLE;
  893. const struct Chord chord_177 PROGMEM = {H_TOP8 + H_TOP9, ASETNIOP_123, &state_177, NULL, KC_BSLASH, 0, single_dance};
  894. uint8_t state_178 = IDLE;
  895. const struct Chord chord_178 PROGMEM = {H_TOP9 + H_TOP0, ASETNIOP_123, &state_178, NULL, KC_SCOLON, 0, single_dance};
  896. uint8_t state_179 = IDLE;
  897. const struct Chord chord_179 PROGMEM = {H_TOP4 + H_TOP0, ASETNIOP_123, &state_179, NULL, KC_BSPC, 0, single_dance};
  898. uint8_t state_180 = IDLE;
  899. const struct Chord chord_180 PROGMEM = {H_TOP5, ASETNIOP_123, &state_180, NULL, KC_ESC, 0, single_dance};
  900. uint8_t state_181 = IDLE;
  901. const struct Chord chord_181 PROGMEM = {H_TOP6, ASETNIOP_123, &state_181, NULL, KC_DEL, 0, single_dance};
  902. uint8_t state_182 = IDLE;
  903. const struct Chord chord_182 PROGMEM = {H_BOT4, ASETNIOP_123, &state_182, NULL, KC_LSFT, 0, single_dance};
  904. uint8_t state_183 = IDLE;
  905. const struct Chord chord_183 PROGMEM = {H_BOT5, ASETNIOP_123, &state_183, NULL, KC_LCTL, 0, single_dance};
  906. uint8_t state_184 = IDLE;
  907. const struct Chord chord_184 PROGMEM = {H_BOT6, ASETNIOP_123, &state_184, NULL, KC_LALT, 0, single_dance};
  908. uint8_t state_185 = IDLE;
  909. const struct Chord chord_185 PROGMEM = {H_TOP5 + H_TOP6, ASETNIOP_123, &state_185, NULL, KC_LGUI, 0, single_dance};
  910. uint8_t state_186 = IDLE;
  911. const struct Chord chord_186 PROGMEM = {H_TOP1, ASETNIOP_FN, &state_186, NULL, KC_HOME, 0, single_dance};
  912. uint8_t state_187 = IDLE;
  913. const struct Chord chord_187 PROGMEM = {H_TOP2, ASETNIOP_FN, &state_187, NULL, KC_PGDN, 0, single_dance};
  914. uint8_t state_188 = IDLE;
  915. const struct Chord chord_188 PROGMEM = {H_TOP3, ASETNIOP_FN, &state_188, NULL, KC_PGUP, 0, single_dance};
  916. uint8_t state_189 = IDLE;
  917. const struct Chord chord_189 PROGMEM = {H_TOP4, ASETNIOP_FN, &state_189, NULL, KC_END, 0, single_dance};
  918. uint8_t state_190 = IDLE;
  919. const struct Chord chord_190 PROGMEM = {H_TOP7, ASETNIOP_FN, &state_190, NULL, KC_LEFT, 0, single_dance};
  920. uint8_t state_191 = IDLE;
  921. const struct Chord chord_191 PROGMEM = {H_TOP8, ASETNIOP_FN, &state_191, NULL, KC_DOWN, 0, single_dance};
  922. uint8_t state_192 = IDLE;
  923. const struct Chord chord_192 PROGMEM = {H_TOP9, ASETNIOP_FN, &state_192, NULL, KC_UP, 0, single_dance};
  924. uint8_t state_193 = IDLE;
  925. const struct Chord chord_193 PROGMEM = {H_TOP0, ASETNIOP_FN, &state_193, NULL, KC_RIGHT, 0, single_dance};
  926. uint8_t state_194 = IDLE;
  927. const struct Chord chord_194 PROGMEM = {H_TOP1 + H_TOP2, ASETNIOP_FN, &state_194, NULL, KC_F1, 0, single_dance};
  928. uint8_t state_195 = IDLE;
  929. const struct Chord chord_195 PROGMEM = {H_TOP2 + H_TOP3, ASETNIOP_FN, &state_195, NULL, KC_F2, 0, single_dance};
  930. uint8_t state_196 = IDLE;
  931. const struct Chord chord_196 PROGMEM = {H_TOP3 + H_TOP4, ASETNIOP_FN, &state_196, NULL, KC_F3, 0, single_dance};
  932. uint8_t state_197 = IDLE;
  933. const struct Chord chord_197 PROGMEM = {H_TOP4 + H_TOP7, ASETNIOP_FN, &state_197, NULL, KC_F4, 0, single_dance};
  934. uint8_t state_198 = IDLE;
  935. const struct Chord chord_198 PROGMEM = {H_TOP7 + H_TOP8, ASETNIOP_FN, &state_198, NULL, KC_F5, 0, single_dance};
  936. uint8_t state_199 = IDLE;
  937. const struct Chord chord_199 PROGMEM = {H_TOP8 + H_TOP9, ASETNIOP_FN, &state_199, NULL, KC_F6, 0, single_dance};
  938. uint8_t state_200 = IDLE;
  939. const struct Chord chord_200 PROGMEM = {H_TOP9 + H_TOP0, ASETNIOP_FN, &state_200, NULL, KC_F7, 0, single_dance};
  940. uint8_t state_201 = IDLE;
  941. const struct Chord chord_201 PROGMEM = {H_TOP1 + H_TOP3, ASETNIOP_FN, &state_201, NULL, KC_F10, 0, single_dance};
  942. uint8_t state_202 = IDLE;
  943. const struct Chord chord_202 PROGMEM = {H_TOP8 + H_TOP0, ASETNIOP_FN, &state_202, NULL, KC_F8, 0, single_dance};
  944. uint8_t state_203 = IDLE;
  945. const struct Chord chord_203 PROGMEM = {H_TOP1 + H_TOP4, ASETNIOP_FN, &state_203, NULL, KC_F11, 0, single_dance};
  946. uint8_t state_204 = IDLE;
  947. const struct Chord chord_204 PROGMEM = {H_TOP7 + H_TOP0, ASETNIOP_FN, &state_204, NULL, KC_F9, 0, single_dance};
  948. uint8_t state_205 = IDLE;
  949. const struct Chord chord_205 PROGMEM = {H_TOP1 + H_TOP7, ASETNIOP_FN, &state_205, NULL, KC_F12, 0, single_dance};
  950. uint8_t state_206 = IDLE;
  951. const struct Chord chord_206 PROGMEM = {H_TOP4 + H_TOP0, ASETNIOP_FN, &state_206, NULL, KC_BSPC, 0, single_dance};
  952. uint8_t state_207 = IDLE;
  953. const struct Chord chord_207 PROGMEM = {H_TOP5, ASETNIOP_FN, &state_207, NULL, KC_ESC, 0, single_dance};
  954. uint8_t state_208 = IDLE;
  955. const struct Chord chord_208 PROGMEM = {H_TOP6, ASETNIOP_FN, &state_208, NULL, KC_DEL, 0, single_dance};
  956. uint8_t state_209 = IDLE;
  957. const struct Chord chord_209 PROGMEM = {H_BOT4, ASETNIOP_FN, &state_209, NULL, KC_LSFT, 0, single_dance};
  958. uint8_t state_210 = IDLE;
  959. const struct Chord chord_210 PROGMEM = {H_BOT5, ASETNIOP_FN, &state_210, NULL, KC_LCTL, 0, single_dance};
  960. uint8_t state_211 = IDLE;
  961. const struct Chord chord_211 PROGMEM = {H_BOT6, ASETNIOP_FN, &state_211, NULL, KC_LALT, 0, single_dance};
  962. uint8_t state_212 = IDLE;
  963. const struct Chord chord_212 PROGMEM = {H_TOP5 + H_TOP6, ASETNIOP_FN, &state_212, NULL, KC_LGUI, 0, single_dance};
  964. const struct Chord* const list_of_chords[] PROGMEM = {
  965. &chord_0, &chord_1, &chord_2, &chord_3, &chord_4, &chord_5, &chord_6, &chord_7, &chord_8, &chord_9, &chord_10, &chord_11, &chord_12, &chord_13, &chord_14, &chord_15, &chord_16, &chord_17, &chord_18, &chord_19, &chord_20, &chord_21, &chord_22, &chord_23, &chord_24, &chord_25, &chord_26, &chord_27, &chord_28, &chord_29, &chord_30, &chord_31, &chord_32, &chord_33, &chord_34, &chord_35, &chord_36, &chord_37, &chord_38, &chord_39, &chord_40, &chord_41, &chord_42, &chord_43, &chord_44, &chord_45, &chord_46, &chord_47, &chord_48, &chord_49, &chord_50, &chord_51, &chord_52, &chord_53, &chord_54, &chord_55, &chord_56, &chord_57, &chord_58, &chord_59, &chord_60, &chord_61, &chord_62, &chord_63, &chord_64, &chord_65, &chord_66, &chord_67, &chord_68, &chord_69, &chord_70, &chord_71, &chord_72, &chord_73, &chord_74, &chord_75, &chord_76, &chord_77, &chord_78, &chord_79, &chord_80, &chord_81, &chord_82, &chord_83, &chord_84, &chord_85, &chord_86, &chord_87, &chord_88, &chord_89, &chord_90, &chord_91, &chord_92, &chord_93, &chord_94, &chord_95, &chord_96, &chord_97, &chord_98, &chord_99, &chord_100, &chord_101, &chord_102, &chord_103, &chord_104, &chord_105, &chord_106, &chord_107, &chord_108, &chord_109, &chord_110, &chord_111, &chord_112, &chord_113, &chord_114, &chord_115, &chord_116, &chord_117, &chord_118, &chord_119, &chord_120, &chord_121, &chord_122, &chord_123, &chord_124, &chord_125, &chord_126, &chord_127, &chord_128, &chord_129, &chord_130, &chord_131, &chord_132, &chord_133, &chord_134, &chord_135, &chord_136, &chord_137, &chord_138, &chord_139, &chord_140, &chord_141, &chord_142, &chord_143, &chord_144, &chord_145, &chord_146, &chord_147, &chord_148, &chord_149, &chord_150, &chord_151, &chord_152, &chord_153, &chord_154, &chord_155, &chord_156, &chord_157, &chord_158, &chord_159, &chord_160, &chord_161, &chord_162, &chord_163, &chord_164, &chord_165, &chord_166, &chord_167, &chord_168, &chord_169, &chord_170, &chord_171, &chord_172, &chord_173, &chord_174, &chord_175, &chord_176, &chord_177, &chord_178, &chord_179, &chord_180, &chord_181, &chord_182, &chord_183, &chord_184, &chord_185, &chord_186, &chord_187, &chord_188, &chord_189, &chord_190, &chord_191, &chord_192, &chord_193, &chord_194, &chord_195, &chord_196, &chord_197, &chord_198, &chord_199, &chord_200, &chord_201, &chord_202, &chord_203, &chord_204, &chord_205, &chord_206, &chord_207, &chord_208, &chord_209, &chord_210, &chord_211, &chord_212
  966. };
  967. const uint16_t** const leader_triggers PROGMEM = NULL;
  968. void (*leader_functions[]) (void) = {};
  969. #define NUMBER_OF_CHORDS 213
  970. #define NUMBER_OF_LEADER_COMBOS 0
  971. bool are_hashed_keycodes_in_sound(HASH_TYPE keycodes_hash, HASH_TYPE sound) {
  972. return (keycodes_hash & sound) == keycodes_hash;
  973. }
  974. uint8_t keycode_to_index(uint16_t keycode) {
  975. return keycode - FIRST_INTERNAL_KEYCODE;
  976. }
  977. void sound_keycode_array(uint16_t keycode) {
  978. uint8_t index = keycode_to_index(keycode);
  979. keycode_index++;
  980. keycodes_buffer_array[index] = keycode_index;
  981. }
  982. void silence_keycode_hash_array(HASH_TYPE keycode_hash) {
  983. for (int i = 0; i < NUMBER_OF_KEYS; i++) {
  984. bool index_in_hash = ((HASH_TYPE) 1 << i) & keycode_hash;
  985. if (index_in_hash) {
  986. uint8_t current_val = keycodes_buffer_array[i];
  987. keycodes_buffer_array[i] = 0;
  988. for (int j = 0; j < NUMBER_OF_KEYS; j++) {
  989. if (keycodes_buffer_array[j] > current_val) {
  990. keycodes_buffer_array[j]--;
  991. }
  992. }
  993. keycode_index--;
  994. }
  995. }
  996. }
  997. bool are_hashed_keycodes_in_array(HASH_TYPE keycode_hash) {
  998. for (int i = 0; i < NUMBER_OF_KEYS; i++) {
  999. bool index_in_hash = ((HASH_TYPE) 1 << i) & keycode_hash;
  1000. bool index_in_array = (bool) keycodes_buffer_array[i];
  1001. if (index_in_hash && !index_in_array) {
  1002. return false;
  1003. }
  1004. }
  1005. return true;
  1006. }
  1007. void kill_one_shots(void) {
  1008. struct Chord chord_storage;
  1009. struct Chord* chord_ptr;
  1010. struct Chord* chord;
  1011. for (int i = 0; i < NUMBER_OF_CHORDS; i++) {
  1012. chord_ptr = (struct Chord*) pgm_read_word (&list_of_chords[i]);
  1013. memcpy_P(&chord_storage, chord_ptr, sizeof(struct Chord));
  1014. chord = &chord_storage;
  1015. if (*chord->state == IN_ONE_SHOT) {
  1016. *chord->state = RESTART;
  1017. chord->function(chord);
  1018. if (*chord->state == RESTART) {
  1019. *chord->state = IDLE;
  1020. }
  1021. }
  1022. }
  1023. }
  1024. void process_finished_dances(void) {
  1025. struct Chord chord_storage;
  1026. struct Chord* chord_ptr;
  1027. struct Chord* chord;
  1028. for (int i = 0; i < NUMBER_OF_CHORDS; i++) {
  1029. chord_ptr = (struct Chord*) pgm_read_word (&list_of_chords[i]);
  1030. memcpy_P(&chord_storage, chord_ptr, sizeof(struct Chord));
  1031. chord = &chord_storage;
  1032. if (*chord->state == ACTIVATED) {
  1033. *chord->state = PRESS_FROM_ACTIVE;
  1034. chord->function(chord);
  1035. if (a_key_went_through) {
  1036. kill_one_shots();
  1037. }
  1038. dance_timer = timer_read();
  1039. } else if (*chord->state == IDLE_IN_DANCE) {
  1040. *chord->state = FINISHED;
  1041. chord->function(chord);
  1042. if (*chord->state == FINISHED) {
  1043. *chord->state = RESTART;
  1044. if (*chord->state == RESTART) {
  1045. *chord->state = IDLE;
  1046. }
  1047. }
  1048. } else if (*chord->state == PRESS_FROM_ACTIVE) {
  1049. *chord->state = FINISHED_FROM_ACTIVE;
  1050. chord->function(chord);
  1051. if (a_key_went_through) {
  1052. kill_one_shots();
  1053. }
  1054. dance_timer = timer_read();
  1055. }
  1056. }
  1057. }
  1058. uint8_t keycodes_buffer_array_min(uint8_t* first_keycode_index) {
  1059. for (int i = 0; i < NUMBER_OF_KEYS; i++) {
  1060. if (keycodes_buffer_array[i] == 1) {
  1061. if (first_keycode_index != NULL) {
  1062. *first_keycode_index = (uint8_t) i;
  1063. }
  1064. return 1;
  1065. }
  1066. }
  1067. return 0;
  1068. }
  1069. void remove_subchords(void) {
  1070. struct Chord chord_storage;
  1071. struct Chord* chord_ptr;
  1072. struct Chord* chord;
  1073. for (int i = 0; i < NUMBER_OF_CHORDS; i++) {
  1074. chord_ptr = (struct Chord*) pgm_read_word (&list_of_chords[i]);
  1075. memcpy_P(&chord_storage, chord_ptr, sizeof(struct Chord));
  1076. chord = &chord_storage;
  1077. if (!(*chord->state == READY || *chord->state == READY_IN_DANCE || *chord->state == READY_LOCKED)) {
  1078. continue;
  1079. }
  1080. struct Chord chord_storage_2;
  1081. struct Chord* chord_ptr_2;
  1082. struct Chord* chord_2;
  1083. for (int j = 0; j < NUMBER_OF_CHORDS; j++) {
  1084. if (i == j) {continue;}
  1085. chord_ptr_2 = (struct Chord*) pgm_read_word (&list_of_chords[j]);
  1086. memcpy_P(&chord_storage_2, chord_ptr_2, sizeof(struct Chord));
  1087. chord_2 = &chord_storage_2;
  1088. if (are_hashed_keycodes_in_sound(chord_2->keycodes_hash, chord->keycodes_hash)) {
  1089. if (*chord_2->state == READY) {
  1090. *chord_2->state = IDLE;
  1091. }
  1092. if (*chord_2->state == READY_IN_DANCE) {
  1093. *chord_2->state = IDLE_IN_DANCE;
  1094. }
  1095. if (*chord_2->state == READY_LOCKED) {
  1096. *chord_2->state = LOCKED;
  1097. }
  1098. }
  1099. }
  1100. }
  1101. }
  1102. void process_ready_chords(void) {
  1103. uint8_t first_keycode_index = 0;
  1104. while (keycodes_buffer_array_min(&first_keycode_index)) {
  1105. // find ready chords
  1106. struct Chord chord_storage;
  1107. struct Chord* chord_ptr;
  1108. struct Chord* chord;
  1109. for (int i = 0; i < NUMBER_OF_CHORDS; i++) {
  1110. chord_ptr = (struct Chord*) pgm_read_word (&list_of_chords[i]);
  1111. memcpy_P(&chord_storage, chord_ptr, sizeof(struct Chord));
  1112. chord = &chord_storage;
  1113. // if the chord does not contain the first keycode
  1114. bool contains_first_keycode = ((uint32_t) 1 << first_keycode_index) & chord->keycodes_hash;
  1115. if (!contains_first_keycode) {
  1116. continue;
  1117. }
  1118. if (!are_hashed_keycodes_in_array(chord->keycodes_hash)){
  1119. continue;
  1120. }
  1121. if (*chord->state == LOCKED) {
  1122. *chord->state = READY_LOCKED;
  1123. continue;
  1124. }
  1125. if (!(chord->pseudolayer == current_pseudolayer || chord->pseudolayer == ALWAYS_ON)) {
  1126. continue;
  1127. }
  1128. if (*chord->state == IDLE) {
  1129. *chord->state = READY;
  1130. continue;
  1131. }
  1132. if (*chord->state == IDLE_IN_DANCE) {
  1133. *chord->state = READY_IN_DANCE;
  1134. }
  1135. }
  1136. // remove subchords
  1137. remove_subchords();
  1138. // execute logic
  1139. // this should be only one chord
  1140. for (int i = 0; i < NUMBER_OF_CHORDS; i++) {
  1141. chord_ptr = (struct Chord*) pgm_read_word (&list_of_chords[i]);
  1142. memcpy_P(&chord_storage, chord_ptr, sizeof(struct Chord));
  1143. chord = &chord_storage;
  1144. if (*chord->state == READY_LOCKED) {
  1145. *chord->state = RESTART;
  1146. chord->function(chord);
  1147. if (*chord->state == RESTART) {
  1148. *chord->state = IDLE;
  1149. }
  1150. break;
  1151. }
  1152. if (*chord->state == READY || *chord->state == READY_IN_DANCE) {
  1153. if (last_chord && last_chord != chord) {
  1154. process_finished_dances();
  1155. }
  1156. bool lock_next_prev_state = lock_next;
  1157. *chord->state = ACTIVATED;
  1158. chord->function(chord);
  1159. dance_timer = timer_read();
  1160. if (lock_next && lock_next == lock_next_prev_state) {
  1161. lock_next = false;
  1162. *chord->state = PRESS_FROM_ACTIVE;
  1163. chord->function(chord);
  1164. if (*chord->state == PRESS_FROM_ACTIVE) {
  1165. *chord->state = LOCKED;
  1166. }
  1167. if (a_key_went_through) {
  1168. kill_one_shots();
  1169. }
  1170. }
  1171. break;
  1172. }
  1173. }
  1174. // silence notes
  1175. silence_keycode_hash_array(chord->keycodes_hash);
  1176. }
  1177. }
  1178. void deactivate_active_chords(uint16_t keycode) {
  1179. HASH_TYPE hash = (HASH_TYPE)1 << (keycode - SAFE_RANGE);
  1180. bool broken;
  1181. struct Chord chord_storage;
  1182. struct Chord* chord_ptr;
  1183. struct Chord* chord;
  1184. for (int i = 0; i < NUMBER_OF_CHORDS; i++) {
  1185. chord_ptr = (struct Chord*) pgm_read_word (&list_of_chords[i]);
  1186. memcpy_P(&chord_storage, chord_ptr, sizeof(struct Chord));
  1187. chord = &chord_storage;
  1188. broken = are_hashed_keycodes_in_sound(hash, chord->keycodes_hash);
  1189. if (!broken) {
  1190. continue;
  1191. }
  1192. switch (*chord->state) {
  1193. case ACTIVATED:
  1194. *chord->state = DEACTIVATED;
  1195. chord->function(chord);
  1196. if (*chord->state == DEACTIVATED) {
  1197. dance_timer = timer_read();
  1198. *chord->state = IDLE_IN_DANCE;
  1199. }
  1200. if (*chord->state != IN_ONE_SHOT) {
  1201. kill_one_shots();
  1202. }
  1203. break;
  1204. case PRESS_FROM_ACTIVE:
  1205. case FINISHED_FROM_ACTIVE:
  1206. *chord->state = RESTART;
  1207. chord->function(chord);
  1208. if (*chord->state == RESTART) {
  1209. *chord->state = IDLE;
  1210. }
  1211. kill_one_shots();
  1212. break;
  1213. default:
  1214. break;
  1215. }
  1216. }
  1217. }
  1218. void process_command(void) {
  1219. command_mode = 0;
  1220. for (int i = 0; i < COMMAND_MAX_LENGTH; i++) {
  1221. if (command_buffer[i]) {
  1222. register_code(command_buffer[i]);
  1223. }
  1224. send_keyboard_report();
  1225. }
  1226. wait_ms(TAP_TIMEOUT);
  1227. for (int i = 0; i < COMMAND_MAX_LENGTH; i++) {
  1228. if (command_buffer[i]) {
  1229. unregister_code(command_buffer[i]);
  1230. }
  1231. send_keyboard_report();
  1232. }
  1233. for (int i = 0; i < COMMAND_MAX_LENGTH; i++) {
  1234. command_buffer[i] = 0;
  1235. }
  1236. command_ind = 0;
  1237. }
  1238. void process_leader(void) {
  1239. in_leader_mode = false;
  1240. for (int i = 0; i < NUMBER_OF_LEADER_COMBOS; i++) {
  1241. uint16_t trigger[LEADER_MAX_LENGTH];
  1242. memcpy_P(trigger, leader_triggers[i], LEADER_MAX_LENGTH * sizeof(uint16_t));
  1243. if (identical(leader_buffer, trigger)) {
  1244. (*leader_functions[i])();
  1245. break;
  1246. }
  1247. }
  1248. for (int i = 0; i < LEADER_MAX_LENGTH; i++) {
  1249. leader_buffer[i] = 0;
  1250. }
  1251. }
  1252. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  1253. if (keycode < FIRST_INTERNAL_KEYCODE || keycode > LAST_INTERNAL_KEYCODE) {
  1254. return true;
  1255. }
  1256. if (record->event.pressed) {
  1257. sound_keycode_array(keycode);
  1258. } else {
  1259. process_ready_chords();
  1260. deactivate_active_chords(keycode);
  1261. }
  1262. chord_timer = timer_read();
  1263. leader_timer = timer_read();
  1264. return false;
  1265. }
  1266. void matrix_scan_user(void) {
  1267. bool chord_timer_expired = timer_elapsed(chord_timer) > CHORD_TIMEOUT;
  1268. if (chord_timer_expired && keycodes_buffer_array_min(NULL)) {
  1269. process_ready_chords();
  1270. }
  1271. bool dance_timer_expired = timer_elapsed(dance_timer) > DANCE_TIMEOUT;
  1272. if (dance_timer_expired) { // would love to have && in_dance but not sure how
  1273. process_finished_dances();
  1274. }
  1275. bool in_command_mode = command_mode == 2;
  1276. if (in_command_mode) {
  1277. process_command();
  1278. }
  1279. bool leader_timer_expired = timer_elapsed(leader_timer) > LEADER_TIMEOUT;
  1280. if (leader_timer_expired && in_leader_mode) {
  1281. process_leader();
  1282. }
  1283. }
  1284. void clear(const struct Chord* self) {
  1285. if (*self->state == ACTIVATED) {
  1286. // kill all chords
  1287. struct Chord chord_storage;
  1288. struct Chord* chord_ptr;
  1289. struct Chord* chord;
  1290. for (int i = 0; i < NUMBER_OF_CHORDS; i++) {
  1291. chord_ptr = (struct Chord*) pgm_read_word (&list_of_chords[i]);
  1292. memcpy_P(&chord_storage, chord_ptr, sizeof(struct Chord));
  1293. chord = &chord_storage;
  1294. *chord->state = IDLE;
  1295. if (chord->counter) {
  1296. *chord->counter = 0;
  1297. }
  1298. }
  1299. // clear keyboard
  1300. clear_keyboard();
  1301. send_keyboard_report();
  1302. // switch to default pseudolayer
  1303. current_pseudolayer = DEFAULT_PSEUDOLAYER;
  1304. // clear all keyboard states
  1305. lock_next = false;
  1306. autoshift_mode = true;
  1307. command_mode = 0;
  1308. in_leader_mode = false;
  1309. leader_ind = 0;
  1310. dynamic_macro_mode = false;
  1311. a_key_went_through = false;
  1312. for (int i = 0; i < DYNAMIC_MACRO_MAX_LENGTH; i++) {
  1313. dynamic_macro_buffer[i] = 0;
  1314. }
  1315. }
  1316. }