logo

qmk_firmware

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

keymap.c (8726B)


  1. /* Copyright 2019 niltea
  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 QMK_KEYBOARD_H
  17. #ifdef OLED_ENABLE
  18. #include <string.h>
  19. #include "lib/oled_helper.h"
  20. #endif
  21. enum layerID {
  22. MAC_CS_1 = 0,
  23. MAC_CS_2,
  24. MAC_PS_1,
  25. MAC_PS_2,
  26. WIN_CS_1,
  27. WIN_CS_2,
  28. WIN_PS_1,
  29. WIN_PS_2,
  30. IOS_CS_1,
  31. IOS_CS_2,
  32. SETTING,
  33. };
  34. #define Mac_CS PDF(MAC_CS_1)
  35. #define Mac_PS PDF(MAC_PS_1)
  36. #define Win_CS PDF(WIN_CS_1)
  37. #define Win_PS PDF(WIN_PS_1)
  38. #define IOS_CS PDF(IOS_CS_1)
  39. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  40. // Mac
  41. // Clip Studio
  42. [MAC_CS_1] = LAYOUT(
  43. KC_TAB, LGUI(KC_A), KC_E, KC_P, LGUI(KC_0),
  44. MO(MAC_CS_2), KC_M, KC_BSPC, KC_B, KC_HYPR,
  45. KC_LSFT, KC_LGUI, LGUI(KC_Z), KC_SPC
  46. ),
  47. [MAC_CS_2] = LAYOUT(
  48. MO(SETTING), KC_ESC, KC_G, KC_R, LGUI(KC_GRV),
  49. _______, LGUI(KC_D), KC_K, KC_F, LGUI(KC_S),
  50. KC_LALT, KC_I, SGUI(KC_Z), KC_H
  51. ),
  52. // Photoshop
  53. [MAC_PS_1] = LAYOUT(
  54. KC_TAB, LGUI(KC_A), KC_E, KC_B, LGUI(KC_1),
  55. MO(MAC_PS_2), KC_L, LGUI(KC_DEL), LGUI(KC_QUOT), KC_MEH,
  56. KC_LSFT, KC_LGUI, LGUI(KC_Z), KC_SPC
  57. ),
  58. [MAC_PS_2] = LAYOUT(
  59. MO(SETTING), KC_ESC, KC_G, KC_R, KC_ESC,
  60. _______, LGUI(KC_D), KC_V, LGUI(KC_T), LGUI(KC_S),
  61. KC_LALT, KC_I, SGUI(KC_Z), KC_H
  62. ),
  63. // Windows
  64. // Clip Studio
  65. [WIN_CS_1] = LAYOUT(
  66. KC_TAB, LCTL(KC_A), KC_E, KC_P, LCTL(KC_0),
  67. MO(WIN_CS_2), KC_M, KC_BSPC, KC_B, KC_HYPR,
  68. KC_LSFT, KC_LCTL, LCTL(KC_Z), KC_SPC
  69. ),
  70. [WIN_CS_2] = LAYOUT(
  71. MO(SETTING), KC_ESC, KC_G, KC_R, LCTL(KC_GRV),
  72. _______, LCTL(KC_D), KC_K, KC_F, LCTL(KC_S),
  73. KC_LALT, KC_I, C(S(KC_Z)), KC_H
  74. ),
  75. // Photoshop
  76. [WIN_PS_1] = LAYOUT(
  77. KC_TAB, LCTL(KC_A), KC_E, KC_B, LCTL(KC_1),
  78. MO(WIN_PS_2), KC_L, LCTL(KC_DEL), LCTL(KC_QUOT), KC_MEH,
  79. KC_LSFT, KC_LCTL, LCTL(KC_Z), KC_SPC
  80. ),
  81. [WIN_PS_2] = LAYOUT(
  82. MO(SETTING), KC_ESC, KC_G, KC_R, KC_ESC,
  83. _______, LCTL(KC_D), KC_V, LCTL(KC_T), LCTL(KC_S),
  84. KC_LALT, KC_I, C(S(KC_Z)), KC_H
  85. ),
  86. // iOS
  87. // Clip Studio
  88. [IOS_CS_1] = LAYOUT(
  89. KC_TAB, LGUI(KC_A), KC_E, KC_P, LGUI(KC_0),
  90. MO(IOS_CS_2), KC_M, KC_BSPC, KC_B, LGUI(KC_LALT),
  91. KC_LSFT, KC_LGUI, LGUI(KC_Z), KC_SPC
  92. ),
  93. [IOS_CS_2] = LAYOUT(
  94. MO(SETTING), KC_ESC, KC_G, KC_R, LGUI(KC_EQL),
  95. _______, LGUI(KC_D), KC_K, KC_F, LGUI(KC_S),
  96. KC_LALT, KC_I, SGUI(KC_Z), KC_H
  97. ),
  98. [SETTING] = LAYOUT(
  99. _______, IOS_CS, Win_CS, Mac_CS, KC_NO,
  100. _______, KC_NO, Win_PS, Mac_PS, KC_NO,
  101. KC_NO, KC_NO, KC_NO, KC_NO
  102. ),
  103. };
  104. bool encoder_update_user(uint8_t index, bool clockwise) {
  105. uint8_t currentDefault = get_highest_layer(default_layer_state);
  106. uint8_t currentLayer = get_highest_layer(layer_state);
  107. if (index == 0) { /* the upper encoder */
  108. switch (currentDefault) {
  109. case MAC_CS_1:
  110. if (currentLayer % 2 == 0) {
  111. // default layer
  112. // Zoom
  113. tap_code16(!clockwise ? G(KC_MINS) : G(KC_EQL));
  114. } else {
  115. // Fn Layer
  116. // rotate canvas
  117. tap_code(!clockwise ? KC_MINS : KC_QUOT);
  118. }
  119. break;
  120. case MAC_PS_1:
  121. if (currentLayer % 2 == 0) {
  122. // default layer
  123. // Zoom
  124. tap_code16(!clockwise ? G(KC_MINS) : G(KC_EQL));
  125. } else {
  126. // Fn Layer
  127. // undo / redo
  128. tap_code16(!clockwise ? G(KC_Z) : S(G(KC_Z)));
  129. }
  130. break;
  131. case WIN_CS_1:
  132. if (currentLayer % 2 == 0) {
  133. // default layer
  134. // Zoom
  135. tap_code16(!clockwise ? C(KC_MINS) : C(KC_EQL));
  136. } else {
  137. // Fn Layer
  138. // rotate canvas
  139. tap_code(!clockwise ? KC_MINS : KC_QUOT);
  140. }
  141. break;
  142. case WIN_PS_1:
  143. if (currentLayer % 2 == 0) {
  144. // default layer
  145. // Zoom
  146. tap_code16(!clockwise ? C(KC_MINS) : C(KC_SCLN));
  147. } else {
  148. // Fn Layer
  149. // undo / redo
  150. tap_code16(!clockwise ? C(KC_Z) : C(S(KC_Z)));
  151. }
  152. break;
  153. case IOS_CS_1:
  154. if (currentLayer % 2 == 0) {
  155. // default layer
  156. // Zoom
  157. tap_code16(!clockwise ? G(KC_MINS) : G(KC_SCLN));
  158. } else {
  159. // Fn Layer
  160. // rotate canvas
  161. tap_code(!clockwise ? KC_MINS : KC_EQL);
  162. }
  163. break;
  164. default:
  165. break;
  166. }
  167. } else if (index == 1) { /* the lower encoder */
  168. switch (currentDefault) {
  169. case MAC_CS_1:
  170. if (currentLayer % 2 == 0) {
  171. // default layer
  172. // size of brush
  173. tap_code(!clockwise ? KC_LBRC : KC_RBRC);
  174. } else {
  175. // Fn Layer
  176. // opacity of brush
  177. tap_code16(!clockwise ? G(KC_LBRC) : G(KC_RBRC));
  178. }
  179. break;
  180. case MAC_PS_1:
  181. if (currentLayer % 2 == 0) {
  182. // default layer
  183. // size of brush
  184. tap_code(!clockwise ? KC_LBRC : KC_RBRC);
  185. } else {
  186. // Fn Layer
  187. // opacity of brush
  188. tap_code16(!clockwise ? KC_LCBR : KC_RCBR);
  189. }
  190. break;
  191. case WIN_CS_1:
  192. if (currentLayer % 2 == 0) {
  193. // default layer
  194. // rotate canvas
  195. tap_code(!clockwise ? KC_LBRC : KC_RBRC);
  196. } else {
  197. // Fn Layer
  198. // opacity of brush
  199. tap_code16(!clockwise ? C(KC_LBRC) : C(KC_RBRC));
  200. }
  201. break;
  202. case WIN_PS_1:
  203. if (currentLayer % 2 == 0) {
  204. // default layer
  205. // rotate canvas
  206. tap_code(!clockwise ? KC_LBRC : KC_RBRC);
  207. } else {
  208. // Fn Layer
  209. // opacity of brush
  210. tap_code16(!clockwise ? KC_LCBR : KC_RCBR);
  211. }
  212. break;
  213. case IOS_CS_1:
  214. if (currentLayer % 2 == 0) {
  215. // default layer
  216. // size of brush
  217. tap_code(!clockwise ? KC_RBRC : KC_BSLS);
  218. } else {
  219. // Fn Layer
  220. // opacity of brush
  221. tap_code16(!clockwise ? G(KC_RBRC) : G(KC_BSLS));
  222. }
  223. break;
  224. default:
  225. break;
  226. }
  227. }
  228. return true;
  229. }
  230. // OLED Display
  231. #ifdef OLED_ENABLE
  232. bool oled_task_user(void) {
  233. // get layer Number
  234. uint8_t currentDefault = get_highest_layer(default_layer_state);
  235. uint8_t currentLayer = get_highest_layer(layer_state);
  236. // write OS mode / 1st line of the logo
  237. switch (currentDefault) {
  238. case MAC_CS_1:
  239. case MAC_PS_1:
  240. render_row(0, "Mac ");
  241. break;
  242. case WIN_CS_1:
  243. case WIN_PS_1:
  244. render_row(0, "Win ");
  245. break;
  246. case IOS_CS_1:
  247. render_row(0, "iOS ");
  248. break;
  249. default:
  250. render_row(0, " ");
  251. }
  252. // write Application mode / 2nd line of the logo
  253. switch (currentDefault) {
  254. case MAC_CS_1:
  255. case WIN_CS_1:
  256. case IOS_CS_1:
  257. render_row(1, "A:CS");
  258. break;
  259. case MAC_PS_1:
  260. case WIN_PS_1:
  261. render_row(1, "A:Ps");
  262. break;
  263. default:
  264. render_row(1, " ");
  265. }
  266. if (currentLayer == SETTING) {
  267. // 3rd & 4th line of the logo
  268. render_row(2, "****");
  269. render_row(3, "LSEL");
  270. } else {
  271. // Layer Status / 3rd line of the logo
  272. if (currentLayer % 2 == 0) {
  273. // default layer
  274. render_row(2, "L:DF");
  275. } else {
  276. // Fn Layer
  277. render_row(2, "L:Fn");
  278. }
  279. // pressed key / 4th line of the logo
  280. render_row(3, " ");
  281. }
  282. return false;
  283. }
  284. #endif // #ifdef OLED_ENABLE