logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

rev3_4rows.c (3741B)


  1. /* Copyright 2020 yushakobo
  2. *
  3. * This program is free software: you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation, either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include "rev3_4rows.h"
  17. bool is_mac_mode(void) {
  18. return keymap_config.swap_lalt_lgui == false;
  19. }
  20. void set_mac_mode(bool macmode) {
  21. /* The result is the same as pressing the AG_NORM(=MAGIC_UNSWAP_ALT_GUI)/AG_SWAP(=MAGIC_SWAP_ALT_GUI) keys.
  22. * see
  23. * https://github.com/qmk/qmk_firmware/blob/fb4a6ad30ea7a648acd59793ed4a30c3a8d8dc32/quantum/process_keycode/process_magic.c#L123-L124
  24. * https://github.com/qmk/qmk_firmware/blob/fb4a6ad30ea7a648acd59793ed4a30c3a8d8dc32/quantum/process_keycode/process_magic.c#L80-L81
  25. */
  26. keymap_config.swap_lalt_lgui = keymap_config.swap_ralt_rgui = !macmode;
  27. eeconfig_update_keymap(&keymap_config);
  28. }
  29. #ifdef DIP_SWITCH_ENABLE
  30. bool dip_switch_update_kb(uint8_t index, bool active) {
  31. switch (index) {
  32. case 0:
  33. if(active) { // Left no.1 Helix rev3 common
  34. set_mac_mode(false);
  35. } else {
  36. set_mac_mode(true);
  37. }
  38. break;
  39. default: // Left no.2 or Right no.1 or Right no.2 for user/keymap
  40. dip_switch_update_user(index, active);
  41. break;
  42. }
  43. return true;
  44. }
  45. #endif
  46. #ifdef OLED_ENABLE
  47. static char *sprint_decimal(char *buf, int data) {
  48. if (data > 9) {
  49. buf = sprint_decimal(buf, data/10);
  50. }
  51. *buf++ = "0123456789"[data%10];
  52. *buf = '\0';
  53. return buf;
  54. }
  55. char *sprints(char *buf, char *src) {
  56. while (*src) {
  57. *buf++ = *src++;
  58. }
  59. *buf = '\0';
  60. return buf;
  61. }
  62. char *sprintd(char *buf, char *leadstr, int data) {
  63. buf = sprints(buf, leadstr);
  64. buf = sprint_decimal(buf, data);
  65. return buf;
  66. }
  67. char *sprint2d(char *buf, char *leadstr, int data) {
  68. buf = sprints(buf, leadstr);
  69. if (data > 99) {
  70. return sprint_decimal(buf, data);
  71. }
  72. if (data < 10) {
  73. *buf++ = ' ';
  74. }
  75. return sprint_decimal(buf, data);
  76. }
  77. bool oled_task_kb(void) {
  78. if (!oled_task_user()) { return false; }
  79. static const char PROGMEM helix_logo[] = {
  80. 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92, 0x93, 0x94,
  81. 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3, 0xB4,
  82. 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4,
  83. 0x0
  84. };
  85. static const char os_logo[][2][3] PROGMEM ={{{0x95,0x96,0},{0xb5,0xb6,0}},{{0x97,0x98,0},{0xb7,0xb8,0}}};
  86. if (is_keyboard_master()) {
  87. if (is_mac_mode()) {
  88. oled_write_P(os_logo[0][0], false);
  89. oled_write_P(PSTR("\n"), false);
  90. oled_write_P(os_logo[0][1], false);
  91. }else{
  92. oled_write_P(os_logo[1][0], false);
  93. oled_write_P(PSTR("\n"), false);
  94. oled_write_P(os_logo[1][1], false);
  95. }
  96. char buf[20];
  97. sprint2d(buf, " Layer: ", get_highest_layer(layer_state));
  98. oled_write(buf, false);
  99. } else {
  100. oled_write_P(helix_logo, false);
  101. }
  102. return false;
  103. }
  104. #endif