logo

qmk_firmware

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

ziyoulang_k3_mod.c (3585B)


  1. // Copyright 2023 Coom (@coomstoolbox)
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #include "quantum.h"
  4. #include <stdio.h>
  5. void keyboard_post_init_kb(void) {
  6. #ifdef CONSOLE_ENABLE
  7. debug_enable=true;
  8. debug_matrix=true;
  9. #endif
  10. keyboard_post_init_user();
  11. }
  12. static uint16_t last_keycode = KC_NO;
  13. static keypos_t last_key = {0, 0};
  14. bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
  15. if (!process_record_user(keycode, record)) {
  16. return false;
  17. }
  18. // コンソールが有効化されている場合、マトリックス上の位置とキー押下状態を出力します
  19. #ifdef CONSOLE_ENABLE
  20. uprintf("KL: kc: %u, col: %u, row: %u, pressed: %u\n", keycode, record->event.key.col, record->event.key.row, record->event.pressed);
  21. #endif
  22. if (record->event.pressed) {
  23. if (last_keycode != keycode) {
  24. last_keycode = keycode;
  25. last_key = record->event.key;
  26. }
  27. }
  28. return true;
  29. }
  30. #ifdef OLED_ENABLE
  31. oled_rotation_t oled_init_kb(oled_rotation_t rotation) {
  32. return OLED_ROTATION_180;
  33. }
  34. static void render_logo(void) {
  35. static const char PROGMEM qmk_logo[] = {
  36. 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92, 0x93, 0x94,
  37. 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3, 0xB4,
  38. 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0x00
  39. };
  40. oled_write_P(qmk_logo, false);
  41. #ifdef CONSOLE_ENABLE
  42. uprintf("Ziyoulang K3 Mod\n");
  43. oled_set_cursor(3, 0);
  44. oled_write_P(PSTR("Ziyoulang K3 Mod"), false);
  45. #endif
  46. }
  47. bool oled_task_kb(void) {
  48. if (!oled_task_user()) {
  49. return false;
  50. }
  51. int uptime_seconds = (int)(timer_read32() / 1000);
  52. if (uptime_seconds < 5) {
  53. render_logo();
  54. return false;
  55. }
  56. // Host Keyboard Layer Status
  57. oled_write_P(PSTR("Layer: "), false);
  58. switch (get_highest_layer(layer_state | default_layer_state)) {
  59. case 0:
  60. oled_write_P(PSTR("Default\n"), false);
  61. break;
  62. case 1:
  63. oled_write_P(PSTR("2\n"), false);
  64. break;
  65. case 2:
  66. oled_write_P(PSTR("3\n"), false);
  67. break;
  68. default:
  69. // Or use the write_ln shortcut over adding '\n' to the end of your string
  70. oled_write_ln_P(PSTR("Undefined"), false);
  71. }
  72. // Host Keyboard LED Status
  73. led_t led_state = host_keyboard_led_state();
  74. if (led_state.num_lock) {
  75. oled_write_P(PSTR("NUM"), true);
  76. oled_write_P(PSTR(" "), false);
  77. } else {
  78. oled_write_P(PSTR(" "), false);
  79. }
  80. if (led_state.caps_lock) {
  81. oled_write_P(PSTR("CAP"), true);
  82. oled_write_P(PSTR(" "), false);
  83. } else {
  84. oled_write_P(PSTR(" "), false);
  85. }
  86. if (led_state.scroll_lock) {
  87. oled_write_P(PSTR("SCR"), true);
  88. oled_write_ln_P(PSTR(" "), false);
  89. } else {
  90. oled_write_ln_P(PSTR(" "), false);
  91. }
  92. // Last Key pressed info
  93. oled_write_P(PSTR("kc : "), false);
  94. if (last_keycode > 21000) {
  95. oled_write_ln_P(PSTR(" Fn"), false);
  96. } else {
  97. oled_write_ln_P(get_u16_str(last_keycode, ' '), false);
  98. }
  99. oled_write_P(PSTR("col: "), false);
  100. oled_write_P(get_u8_str(last_key.col, ' '), false);
  101. oled_write_P(PSTR(",row: "), false);
  102. oled_write_P(get_u8_str(last_key.row, ' '), false);
  103. return false;
  104. }
  105. #endif