From caeb213400e7f612598af10354306fd4d3ee0adf Mon Sep 17 00:00:00 2001 From: Hansol Kim Date: Thu, 10 Mar 2022 07:04:41 +0900 Subject: Add macOS-friendly keymap for GMMK Pro (ANSI) (#14333) * Add macOS keymap for GMMK Pro (ANSI) * Change macOS keymap directory name to lowercase * Add toggleable layer with alternative keymap for function row * Update readme --- keyboards/gmmk/pro/ansi/keymaps/macos/config.h | 80 +++++ keyboards/gmmk/pro/ansi/keymaps/macos/keymap.c | 448 ++++++++++++++++++++++++ keyboards/gmmk/pro/ansi/keymaps/macos/readme.md | 85 +++++ keyboards/gmmk/pro/ansi/keymaps/macos/rules.mk | 4 + 4 files changed, 617 insertions(+) create mode 100644 keyboards/gmmk/pro/ansi/keymaps/macos/config.h create mode 100644 keyboards/gmmk/pro/ansi/keymaps/macos/keymap.c create mode 100644 keyboards/gmmk/pro/ansi/keymaps/macos/readme.md create mode 100644 keyboards/gmmk/pro/ansi/keymaps/macos/rules.mk diff --git a/keyboards/gmmk/pro/ansi/keymaps/macos/config.h b/keyboards/gmmk/pro/ansi/keymaps/macos/config.h new file mode 100644 index 0000000000..799c5d9593 --- /dev/null +++ b/keyboards/gmmk/pro/ansi/keymaps/macos/config.h @@ -0,0 +1,80 @@ +/* Copyright 2021 zvuc + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once + +// At the time of this, there are 41 effects! That may be a bit too many to cycle through - keeping what I believe is the best. +#ifdef RGB_MATRIX_ENABLE + #define RGB_DISABLE_TIMEOUT 1200000 // 20 minutes (20 * 60 * 1000ms) + +// #define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_SOLID_COLOR + +// Below added per: https://beta.docs.qmk.fm/using-qmk/hardware-features/lighting/feature_rgb_matrix#suspended-state-id-suspended-state + #define RGB_DISABLE_WHEN_USB_SUSPENDED + +// Effects + #define RGB_MATRIX_FRAMEBUFFER_EFFECTS // Heatmap, Rain + #define RGB_MATRIX_KEYPRESSES // REACTIVE, SPLASH modes + + // Disable effects you don't like. + // Soon, you'll have to explicitly enable effects you want: https://github.com/qmk/qmk_firmware/pull/13758 + // #define DISABLE_RGB_MATRIX_SOLID_COLOR, // Static single hue, no speed support + // #define DISABLE_RGB_MATRIX_ALPHAS_MODS, // Static dual hue, speed is hue for secondary hue + // #define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN, // Static gradient top to bottom, speed controls how much gradient changes + // #define DISABLE_RGB_MATRIX_GRADIENT_LEFT_RIGHT, // Static gradient left to right, speed controls how much gradient changes + // #define DISABLE_RGB_MATRIX_BREATHING, // Single hue brightness cycling animation + // #define DISABLE_RGB_MATRIX_BAND_SAT, // Single hue band fading saturation scrolling left to right + // #define DISABLE_RGB_MATRIX_BAND_VAL, // Single hue band fading brightness scrolling left to right + // #define DISABLE_RGB_MATRIX_BAND_PINWHEEL_SAT, // Single hue 3 blade spinning pinwheel fades saturation + // #define DISABLE_RGB_MATRIX_BAND_PINWHEEL_VAL, // Single hue 3 blade spinning pinwheel fades brightness + // #define DISABLE_RGB_MATRIX_BAND_SPIRAL_SAT, // Single hue spinning spiral fades saturation + // #define DISABLE_RGB_MATRIX_BAND_SPIRAL_VAL, // Single hue spinning spiral fades brightness + // #define DISABLE_RGB_MATRIX_CYCLE_ALL, // Full keyboard solid hue cycling through full gradient + // #define DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT, // Full gradient scrolling left to right + // #define DISABLE_RGB_MATRIX_CYCLE_UP_DOWN, // Full gradient scrolling top to bottom + // #define DISABLE_RGB_MATRIX_CYCLE_OUT_IN, // Full gradient scrolling out to in + // #define DISABLE_RGB_MATRIX_CYCLE_OUT_IN_DUAL, // Full dual gradients scrolling out to in + // #define DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON, // Full gradent Chevron shapped scrolling left to right + // #define DISABLE_RGB_MATRIX_CYCLE_PINWHEEL, // Full gradient spinning pinwheel around center of keyboard + // #define DISABLE_RGB_MATRIX_CYCLE_SPIRAL, // Full gradient spinning spiral around center of keyboard + // #define DISABLE_RGB_MATRIX_DUAL_BEACON, // Full gradient spinning around center of keyboard + // #define DISABLE_RGB_MATRIX_RAINBOW_BEACON, // Full tighter gradient spinning around center of keyboard + // #define DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS, // Full dual gradients spinning two halfs of keyboard + // #define DISABLE_RGB_MATRIX_RAINDROPS, // Randomly changes a single key's hue + // #define DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS, // Randomly changes a single key's hue and saturation + // #define DISABLE_RGB_MATRIX_HUE_BREATHING, // Hue shifts up a slight ammount at the same time, then shifts back + // #define DISABLE_RGB_MATRIX_HUE_PENDULUM, // Hue shifts up a slight ammount in a wave to the right, then back to the left + // #define DISABLE_RGB_MATRIX_HUE_WAVE, // Hue shifts up a slight ammount and then back down in a wave to the right + + // Framebuffer effects + // #define DISABLE_RGB_MATRIX_TYPING_HEATMAP, // How hot is your WPM! + // #define DISABLE_RGB_MATRIX_DIGITAL_RAIN, // That famous computer simulation + + // Reactive effects + // #define DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE, // Pulses keys hit to hue & value then fades value out + // #define DISABLE_RGB_MATRIX_SOLID_REACTIVE, // Static single hue, pulses keys hit to shifted hue then fades to current hue + // #define DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE // Hue & value pulse near a single key hit then fades value out + // #define DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE // Hue & value pulse near multiple key hits then fades value out + // #define DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS // Hue & value pulse the same column and row of a single key hit then fades value out + // #define DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS // Hue & value pulse the same column and row of multiple key hits then fades value out + // #define DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS // Hue & value pulse away on the same column and row of a single key hit then fades value out + // #define DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS // Hue & value pulse away on the same column and row of multiple key hits then fades value out + // #define DISABLE_RGB_MATRIX_SPLASH, // Full gradient & value pulse away from a single key hit then fades value out + // #define DISABLE_RGB_MATRIX_MULTISPLASH, // Full gradient & value pulse away from multiple key hits then fades value out + // #define DISABLE_RGB_MATRIX_SOLID_SPLASH, // Hue & value pulse away from a single key hit then fades value out + // #define DISABLE_RGB_MATRIX_SOLID_MULTISPLASH, // Hue & value pulse away from multiple key hits then fades value out + +#endif diff --git a/keyboards/gmmk/pro/ansi/keymaps/macos/keymap.c b/keyboards/gmmk/pro/ansi/keymaps/macos/keymap.c new file mode 100644 index 0000000000..1f8c47306a --- /dev/null +++ b/keyboards/gmmk/pro/ansi/keymaps/macos/keymap.c @@ -0,0 +1,448 @@ +/* Copyright 2021 Glorious, LLC + + GMMK Pro Standard keymap for macOS + by zvuc + + with code snippets from + Andre Brait , stickandgum + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include QMK_KEYBOARD_H + +enum my_keycodes { + KC_MSCTRL = SAFE_RANGE, + KC_LNPD, + LED_TLDE, + LED_1, + LED_2, + LED_3, + LED_4, + LED_5, + LED_6, + LED_7, + LED_8, + LED_9, + LED_0, + LED_MINS, + LED_EQL +}; + +#ifdef RGB_MATRIX_ENABLE + #ifndef RGB_CONFIRMATION_BLINKING_TIME + #define RGB_CONFIRMATION_BLINKING_TIME 2000 // 2 seconds + #endif +#endif // RGB_MATRIX_ENABLE + +// clang-format off +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + +// ESC F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 Eject Rotary(Mute) +// ~ 1 2 3 4 5 6 7 8 9 0 - (=) BackSpc Del +// Tab Q W E R T Y U I O P [ ] \ PgUp +// Caps A S D F G H J K L ; " Enter PgDn +// Sh_L Z X C V B N M , . ? Sh_R Up F13 +// Ct_L Opt_L Cmd_L SPACE Cmd_R Opt_R FN Left Down Right + + + // The FN key by default maps to a momentary toggle to layer 1 to provide access to the RESET key (to put the board into bootloader mode). Without + // this mapping, you have to open the case to hit the button on the bottom of the PCB (near the USB cable attachment) while plugging in the USB + // cable to get the board into bootloader mode - definitely not fun when you're working on your QMK builds. Remove this and put it back to KC_RGUI + // if that's your preference. + // + // To put the keyboard in bootloader mode, use FN+backslash. If you accidentally put it into bootloader, you can just unplug the USB cable and + // it'll be back to normal when you plug it back in. + // + // This keyboard defaults to 6KRO instead of NKRO for compatibility reasons (some KVMs and BIOSes are incompatible with NKRO). + // Since this is, among other things, a "gaming" keyboard, a key combination to enable NKRO on the fly is provided for convenience. + // Press Fn+N to toggle between 6KRO and NKRO. This setting is persisted to the EEPROM and thus persists between restarts. + [0] = LAYOUT( + KC_ESC, KC_BRID, KC_BRIU, KC_MSCTRL, KC_LNPD, RGB_VAD, RGB_VAI, KC_F7, KC_F8, KC_MRWD, KC_MPLY, KC_MFFD, KC_F12, KC_EJCT, KC_MUTE, + KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_DEL, + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_PGUP, + KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_PGDN, + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_F13, + KC_LCTL, KC_LOPT, KC_LCMD, KC_SPC, KC_RCMD, KC_ROPT, MO(1), KC_LEFT, KC_DOWN, KC_RGHT + ), + + [1] = LAYOUT( + _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, RGB_TOG, + LED_TLDE, LED_1, LED_2, LED_3, LED_4, LED_5, LED_6, LED_7, LED_8, LED_9, LED_0, LED_MINS, LED_EQL, _______, KC_PSCR, + _______, RGB_HUI, RGB_VAI, RGB_SAI, _______, _______, _______, _______, _______, _______, _______, _______, _______, RESET, _______, + _______, RGB_HUD, RGB_VAD, RGB_SAD, TG(2), _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, NK_TOGG, _______, _______, _______, _______, _______, RGB_MOD, RGB_TOG, + _______, _______, _______, _______, _______, _______, _______, RGB_SPD, RGB_RMOD, RGB_SPI + ), + + // This is an alternative togglable layer to change default function row to standard F keys + [2] = LAYOUT( + _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_F24, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ + ), + + +}; +// clang-format on + +#ifdef ENCODER_ENABLE + bool encoder_update_user(uint8_t index, bool clockwise) { + // https://beta.docs.qmk.fm/using-qmk/simple-keycodes/feature_advanced_keycodes#alt-escape-for-alt-tab-id-alt-escape-for-alt-tab + if (get_mods() & MOD_MASK_CTRL) { // If CTRL is held + uint8_t mod_state = get_mods(); // Store all modifiers that are held + unregister_mods(MOD_MASK_CTRL); // Immediately unregister the CRTL key (don't send CTRL-PgDn) - del_mods doesn't work here (not immediate) + if (clockwise) { + rgblight_increase_hue(); + } else { + rgblight_decrease_hue(); + } + set_mods(mod_state); // Add back in the CTRL key - so ctrl-key will work if ctrl was never released after paging. + } else if (get_mods() & MOD_MASK_ALT) { + uint8_t mod_state = get_mods(); + unregister_mods(MOD_MASK_ALT); + if (clockwise) { + rgblight_increase_sat(); + } else { + rgblight_decrease_sat(); + } + set_mods(mod_state); + } else if (get_mods() & MOD_MASK_GUI) { + uint8_t mod_state = get_mods(); + unregister_mods(MOD_MASK_GUI); + if (clockwise) { + rgblight_increase_val(); + } else { + rgblight_decrease_val(); + } + set_mods(mod_state); + } else if (get_mods() & MOD_MASK_SHIFT) { + uint8_t mod_state = get_mods(); + unregister_mods(MOD_MASK_SHIFT); + if (clockwise) { + rgblight_increase_speed(); + } else { + rgblight_decrease_speed(); + } + set_mods(mod_state); + } else if (clockwise) { // All else volume. + tap_code(KC_VOLU); + } else { + tap_code(KC_VOLD); + } + return true; + } +#endif //ENCODER_ENABLE + +#ifdef RGB_MATRIX_ENABLE + + // Called on powerup and is the last _init that is run. + void keyboard_post_init_user(void) { + + int mods[35] = {0,2,3,4,5,11,17,33,49,55,65,95,97,79,94,85,93,96,90,69,92,67,76,80,91,75,86,68,77,81,92,28,34,39,44}; + int j; + + /* output each array element's value */ + for (j = 0; j < 35; j++ ) { + g_led_config.flags[mods[j]] = LED_FLAG_MODIFIER; + } + + if (!rgb_matrix_is_enabled()) { + rgb_matrix_enable(); + #ifdef CONSOLE_ENABLE + uprintf("ERROR! RGB Matrix Enabled and wrote to EEPROM! -How was the RGB Matrix Disabled?"); + #endif + } + } + + /* Renaming those to make the purpose on this keymap clearer */ + #define LED_FLAG_CAPS LED_FLAG_NONE + #define LED_FLAG_EFFECTS LED_FLAG_INDICATOR + + static void set_rgb_caps_leds(void); + + #if RGB_CONFIRMATION_BLINKING_TIME > 0 + static uint16_t effect_started_time = 0; + static uint8_t r_effect = 0x0, g_effect = 0x0, b_effect = 0x0; + static void start_effects(void); + + /* The higher this is, the slower the blinking will be */ + #ifndef TIME_SELECTED_BIT + #define TIME_SELECTED_BIT 8 + #endif + #if TIME_SELECTED_BIT < 0 || TIME_SELECTED_BIT >= 16 + #error "TIME_SELECTED_BIT must be a positive integer smaller than 16" + #endif + #define effect_red() r_effect = 0xFF, g_effect = 0x0, b_effect = 0x0 + #define effect_green() r_effect = 0x0, g_effect = 0xFF, b_effect = 0x0 + #endif // RGB_CONFIRMATION_BLINKING_TIME > 0 + + bool led_update_user(led_t led_state) { + if (led_state.caps_lock) { + if (!rgb_matrix_is_enabled()) { + /* Turn ON the RGB Matrix for CAPS LOCK */ + rgb_matrix_set_flags(LED_FLAG_CAPS); + rgb_matrix_enable(); + } + } else if (rgb_matrix_get_flags() == LED_FLAG_CAPS) { + /* RGB Matrix was only ON because of CAPS LOCK. Turn it OFF. */ + rgb_matrix_set_flags(LED_FLAG_ALL); + rgb_matrix_disable(); + } + return true; + } + + bool process_record_user(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + // https://github.com/qmk/qmk_firmware/issues/10111 + case KC_MSCTRL: + if (record->event.pressed) { + host_consumer_send(0x29F); + } else { + host_consumer_send(0); + } + return false; /* Skip all further processing of this key */ + + case KC_LNPD: + if (record->event.pressed) { + host_consumer_send(0x2A0); + } else { + host_consumer_send(0); + } + return false; /* Skip all further processing of this key */ + + #ifdef NKRO_ENABLE + #if RGB_CONFIRMATION_BLINKING_TIME > 0 + case NK_TOGG: + if (record->event.pressed) { + if (keymap_config.nkro) { + /* Turning NKRO OFF */ + effect_red(); + } else { + /* Turning NKRO ON */ + effect_green(); + } + start_effects(); + } + break; + #endif // RGB_CONFIRMATION_BLINKING_TIME > 0 + #endif // NKRO_ENABLE + + #if RGB_CONFIRMATION_BLINKING_TIME > 0 + case TG(2): + if (record->event.pressed) { + if (IS_LAYER_OFF(2)) { + effect_red(); + } else { + effect_green(); + } + start_effects(); + } + break; + #endif // RGB_CONFIRMATION_BLINKING_TIME > 0 + + /* LED quick preset keys assignments */ + case LED_TLDE: + rgb_matrix_mode(RGB_MATRIX_SOLID_COLOR); // Can use RGB_M_P built-in keycode instead. + break; + case LED_1: + rgb_matrix_mode(RGB_MATRIX_ALPHAS_MODS); + break; + case LED_2: + rgb_matrix_mode(RGB_MATRIX_GRADIENT_UP_DOWN); + break; + case LED_3: + rgb_matrix_mode(RGB_MATRIX_JELLYBEAN_RAINDROPS); + break; + case LED_4: + rgb_matrix_mode(RGB_MATRIX_BAND_SAT); + break; + case LED_5: + rgb_matrix_mode(RGB_MATRIX_BAND_VAL); + break; + case LED_6: + rgb_matrix_mode(RGB_MATRIX_BAND_SPIRAL_VAL); + break; + case LED_7: + rgb_matrix_mode(RGB_MATRIX_CYCLE_LEFT_RIGHT); // Can use RGB_M_R built-in keycode instead. + break; + case LED_8: + rgb_matrix_mode(RGB_MATRIX_CYCLE_PINWHEEL); // Can use RGB_M_SW built-in keycode instead. + break; + case LED_9: + rgb_matrix_mode(RGB_MATRIX_BREATHING); // Can use RGB_M_B built-in keycode instead. + break; + + #ifdef RGB_MATRIX_KEYPRESSES // Reactive effects require RGB_MATRIX_KEYPRESSES in config.h + case LED_0: + rgb_matrix_mode(RGB_MATRIX_SOLID_REACTIVE_WIDE); + break; + #endif //RGB_MATRIX_KEYPRESSES + + #ifdef RGB_MATRIX_FRAMEBUFFER_EFFECTS // Heatmap and Rain require #define RGB_MATRIX_FRAMEBUFFER_EFFECTS in config.h + case LED_MINS: + rgb_matrix_mode(RGB_MATRIX_DIGITAL_RAIN); + break; + case LED_EQL: + rgb_matrix_mode(RGB_MATRIX_TYPING_HEATMAP); + break; + #endif //RGB_MATRIX_FRAMEBUFFER_EFFECTS + + + // case RGB_MOD: + // case RGB_RMOD: + // case RGB_HUI: + // case RGB_HUD: + // case RGB_SAI: + // case RGB_SAD: + // case RGB_VAI: + // case RGB_VAD: + // case RGB_SPI: + case RGB_SPD: + if (record->event.pressed) { + if (rgb_matrix_get_flags() != LED_FLAG_ALL) { + /* Ignore changes to RGB settings while only it's supposed to be OFF */ + return false; + } + } + break; + + case RGB_TOG: + // if (record->event.pressed) { + // if (rgb_matrix_get_flags() == LED_FLAG_ALL) { + // rgb_matrix_set_flags(LED_FLAG_NONE); + // rgb_matrix_set_color_all(0, 0, 0); + // } else { + // rgb_matrix_set_flags(LED_FLAG_ALL); + // } + // } + // return false; + if (record->event.pressed) { + if (rgb_matrix_is_enabled()) { + switch (rgb_matrix_get_flags()) { + #if RGB_CONFIRMATION_BLINKING_TIME > 0 + case LED_FLAG_EFFECTS: + #endif + case LED_FLAG_CAPS: + /* Turned ON because of EFFECTS or CAPS, is actually OFF */ + /* Change to LED_FLAG_ALL to signal it's really ON */ + rgb_matrix_set_flags(LED_FLAG_ALL); + /* Will be re-enabled by the processing of the toggle */ + rgb_matrix_disable_noeeprom(); + break; + case LED_FLAG_ALL: + /* Is actually ON */ + #if RGB_CONFIRMATION_BLINKING_TIME > 0 + if (effect_started_time > 0) { + /* Signal EFFECTS */ + rgb_matrix_set_flags(LED_FLAG_EFFECTS); + /* Will be re-enabled by the processing of the toggle */ + rgb_matrix_disable_noeeprom(); + } else + #endif + if (host_keyboard_led_state().caps_lock) { + /* Signal CAPS */ + rgb_matrix_set_flags(LED_FLAG_CAPS); + /* Will be re-enabled by the processing of the toggle */ + rgb_matrix_disable_noeeprom(); + } + break; + } + } + } + break; + + } + return true; + } + + + void rgb_matrix_indicators_user() { + #if RGB_CONFIRMATION_BLINKING_TIME > 0 + if (effect_started_time > 0) { + /* Render blinking EFFECTS */ + uint16_t deltaTime = sync_timer_elapsed(effect_started_time); + if (deltaTime <= RGB_CONFIRMATION_BLINKING_TIME) { + uint8_t led_state = ((~deltaTime) >> TIME_SELECTED_BIT) & 0x01; + uint8_t val_r = led_state * r_effect; + uint8_t val_g = led_state * g_effect; + uint8_t val_b = led_state * b_effect; + rgb_matrix_set_color_all(val_r, val_g, val_b); + if (host_keyboard_led_state().caps_lock) { + set_rgb_caps_leds(); + } + return; + } else { + /* EFFECTS duration is finished */ + effect_started_time = 0; + if (rgb_matrix_get_flags() == LED_FLAG_EFFECTS) { + /* It was turned ON because of EFFECTS */ + if (host_keyboard_led_state().caps_lock) { + /* CAPS is still ON. Demote to CAPS */ + rgb_matrix_set_flags(LED_FLAG_CAPS); + } else { + /* There is nothing else keeping RGB enabled. Reset flags and turn if off. */ + rgb_matrix_set_flags(LED_FLAG_ALL); + rgb_matrix_disable_noeeprom(); + } + } + } + } + #endif // RGB_CONFIRMATION_BLINKING_TIME > 0 + if (rgb_matrix_get_flags() == LED_FLAG_CAPS) { + rgb_matrix_set_color_all(0x0, 0x0, 0x0); + } + if (host_keyboard_led_state().caps_lock) { + set_rgb_caps_leds(); + } + } + + #if RGB_CONFIRMATION_BLINKING_TIME > 0 + static void start_effects() { + effect_started_time = sync_timer_read(); + if (!rgb_matrix_is_enabled()) { + /* Turn it ON, signal the cause (EFFECTS) */ + rgb_matrix_set_flags(LED_FLAG_EFFECTS); + rgb_matrix_enable_noeeprom(); + } else if (rgb_matrix_get_flags() == LED_FLAG_CAPS) { + /* It's already ON, promote the cause from CAPS to EFFECTS */ + rgb_matrix_set_flags(LED_FLAG_EFFECTS); + } + } + #endif // RGB_CONFIRMATION_BLINKING_TIME > 0 + + static void set_rgb_caps_leds() { + rgb_matrix_set_color(67, 0xFF, 0x0, 0x0); // Left side LED 1 + rgb_matrix_set_color(68, 0xFF, 0x0, 0x0); // Right side LED 1 + rgb_matrix_set_color(70, 0xFF, 0x0, 0x0); // Left side LED 2 + rgb_matrix_set_color(71, 0xFF, 0x0, 0x0); // Right side LED 2 + rgb_matrix_set_color(73, 0xFF, 0x0, 0x0); // Left side LED 3 + rgb_matrix_set_color(74, 0xFF, 0x0, 0x0); // Right side LED 3 + rgb_matrix_set_color(76, 0xFF, 0x0, 0x0); // Left side LED 4 + rgb_matrix_set_color(77, 0xFF, 0x0, 0x0); // Right side LED 4 + rgb_matrix_set_color(80, 0xFF, 0x0, 0x0); // Left side LED 5 + rgb_matrix_set_color(81, 0xFF, 0x0, 0x0); // Right side LED 5 + rgb_matrix_set_color(83, 0xFF, 0x0, 0x0); // Left side LED 6 + rgb_matrix_set_color(84, 0xFF, 0x0, 0x0); // Right side LED 6 + rgb_matrix_set_color(87, 0xFF, 0x0, 0x0); // Left side LED 7 + rgb_matrix_set_color(88, 0xFF, 0x0, 0x0); // Right side LED 7 + rgb_matrix_set_color(91, 0xFF, 0x0, 0x0); // Left side LED 8 + rgb_matrix_set_color(92, 0xFF, 0x0, 0x0); // Right side LED 8 + rgb_matrix_set_color(3, 0xFF, 0x0, 0x0); // CAPS LED + } + +#endif // RGB_MATRIX_ENABLE diff --git a/keyboards/gmmk/pro/ansi/keymaps/macos/readme.md b/keyboards/gmmk/pro/ansi/keymaps/macos/readme.md new file mode 100644 index 0000000000..8024e77cc1 --- /dev/null +++ b/keyboards/gmmk/pro/ansi/keymaps/macos/readme.md @@ -0,0 +1,85 @@ +# GMMK Pro Standard Layout for macOS by zvuc + +As you may know, Glorious does not (yet) provide their Glorious Core software for macOS; so with stock firmware, there aren't any ways to customize layouts on the hardware level unless you turn to software-based override solutions such as [Karabiner Elements](https://karabiner-elements.pqrs.org/). This is my attempt to try to create the most macOS-like experience on the GMMK Pro, taking close notes from Apple's Magic Keyboard, also referencing code from other community keymaps. + +## Keymap +Layer 0 +Layer0 + +Layer 1 (Hold Fn) +Layer1 + +Layer 2 (Togglable alternative function row layout by pressing Fn+F) +Layer2 + + +## Notable differences from stock key layout for Windows: +- Delete key placed right next to backspace (under rotary encoder) +- F13 key for the bottommost row (Assign it to a shortcut you like in macOS preferences! [For example: "Emoji & Symbols" to bring up the emoji input popup instantly](https://user-images.githubusercontent.com/2870726/132237211-7e13c156-96a8-4a91-b215-28d310228feb.png)) +- Eject key for the last key in function row: Needed for macOS native global "Sleep" hotkey (Eject) + +## Notable Features +- VIA support +- Rotary Encoder support (Defaults to stock behavior Volume Up/Down) +- Standard order for macOS modifier keys: + * Left: ⌃ Control⌥ Option⌘ Command + * Right: ⌘ Command⌥ OptionFn +- Apple Magic Keyboard-like Function Row Mode (Toggle with Fn+F) + * F1: Decrease display brightness + * F2: Increase display brightness + * F3: Mission Control + * F4: Launchpad + * F5: Decrease keyboard backlight brightness + * F6: Increase keyboard backlight brightness + * F7: (none) + * F8: (none) + * F9: Media Rewind + * F10: Media Play/Pause + * F11: Media Fast Forward + * F12: (none) + +> #### NOTE +> - Media key mappings follow Apple Magic Keyboard except F8 thru F12, where keys have been shifted by one to the right. It's because I wanted to get over the awkward gap between F8 and F9 that the GMMK Pro has—and also because we don't need dedicated keys for volume control when we have the more convenient rotary knob. +> - To access standard F1 - F12 keys, press the Function keys while holding Fn. +> - If you're planning to use Karabiner Elements, use the standard Function row mode (F1 - F12) because Karabiner Elements always overrides function keys even if you want to just use simple or complex modifications, and it doesn't catch custom keys like Mission Control, Launchpad or Eject. (Eject is mapped as F24 so you can replace it with 'Eject' within Karabiner.) + +## RGB Lighting +- Retains Glorious stock firmware key mappings for control + * FnUp / FnDown: Cycle presets + * FnLeft / FnRight: Adjust speed + * FnW / FnS: Adjust brightness +- Quickly switch to popular presets: + * Fn` : Solid color (no animation) + * Fn1 : Solid duotone (no animation) - ShiftKnob to change secondary color. + * Fn2 : Vertical gradient - ShiftKnob to change secondary color. + * Fn3 : "Jellybean Raindrops" + * Fn4 : Horizontal wipe with white backlight + * Fn5 : Horizontal wipe + * Fn6 : Single color pinwheel + * Fn7 : Horizontal rainbow + * Fn8 : Rainbow pinwheel + * Fn9 : Breathing + * Fn0 : Reactive (light up on keypress) + * Fn- : "Digital Rain" + * Fn= : "Heatmap" +- RGB turns off after 20 minutes of inactivity +- RGB turns off when USB is suspended / enters sleep +- Caps Lock toggle indicator (Caps Lock key and side lights will turn red) +- Easy RGB control using Rotary Encoder + - Control+Rotate Knob: Adjust hue + - Option+Rotate Knob: Adjust saturation + - Command+Rotate Knob: Adjust brightness + +> All latest QMK effects [(41 as of now)](https://beta.docs.qmk.fm/using-qmk/hardware-features/lighting/feature_rgb_matrix#rgb-matrix-effects-id-rgb-matrix-effects) are enabled by default and will apply in order when cycling through using FnUp / FnDown. You can disable specific effects by uncommenting (remove the `//` at the beginning of line) respective lines (ex: `#define DISABLE_RGB_MATRIX_BREATHING`) in `qmk_firmware/keyboards/gmmk/pro/ansi/keymaps/zvuc/config.h` then recompiling the firmware. + +## Other Features +- 1000hz polling rate +- Short DEBOUNCE time (5 ms) +- Per-key debounce algorithm (`sym_defer_pk`) +- NKRO toggle (Fn+N) + +## Warning regarding VIA support +When observing this keyboard firmware in VIA, some custom-implemented keys such as Mission Control/Launchpad and RGB preset shortcuts appear as keycodes such as `0x5d62`. **These must not be modified!** There is no way to get their default functionality back unless you re-flash the firmware through QMK Toolbox. + +## Download pre-compiled firmware binary file +[Download BIN file from here](https://github.com/zvuc/qmk_firmware/releases/tag/zvuc-1.0.1) diff --git a/keyboards/gmmk/pro/ansi/keymaps/macos/rules.mk b/keyboards/gmmk/pro/ansi/keymaps/macos/rules.mk new file mode 100644 index 0000000000..e9073d44a0 --- /dev/null +++ b/keyboards/gmmk/pro/ansi/keymaps/macos/rules.mk @@ -0,0 +1,4 @@ +# Enable additional features. + +DEBOUNCE_TYPE = sym_defer_pk +VIA_ENABLE = yes -- cgit v1.2.1