Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Keymap] Add vitoni keymap for GMMK Pro (ISO) #15006

Merged
merged 12 commits into from
Dec 27, 2021
20 changes: 20 additions & 0 deletions keyboards/gmmk/pro/iso/keymaps/vitoni/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright 2021 Victor Toni (@vitoni)
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#if defined(RGB_MATRIX_ENABLE)
#define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_SOLID_COLOR
// number of milliseconds to wait until turning off RGB automatically
#define RGB_DISABLE_TIMEOUT 300000 // 300 seconds / 5 min
// start fading out before getting disabled
// fading out is timed (depending on the rgb_matrix_config.speed) to have finished before reaching RGB_DISABLE_TIMEOUT
#define RGB_DISABLE_WITH_FADE_OUT
#define RGB_DISABLE_WHEN_USB_SUSPENDED
// number of milliseconds to wait until activating RGB idle effects
#define RGB_IDLE_TIMEOUT 4500 // 4.5 seconds
// activate breathe effect when idle
#define RGB_IDLE_BREATHE
// fade in when we have been suspended
#define RGB_FADE_IN
#endif
148 changes: 148 additions & 0 deletions keyboards/gmmk/pro/iso/keymaps/vitoni/keymap.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
// Copyright 2021 Glorious, LLC <salman@pcgamingrace.com>,
// Copyright 2021 Victor Toni (@vitoni)
// SPDX-License-Identifier: GPL-2.0-or-later

#include QMK_KEYBOARD_H

#include "vitoni.h"

enum layer_names {
_BASE,
_MOV,
_RGB
};

// 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 Prt 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 End
// Ct_L Win_L Alt_L SPACE Alt_R FN Ct_R Left Down Right


//
// 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 CAPS+N to toggle between 6KRO and NKRO. This setting is persisted to the EEPROM and thus persists between restarts.
[_BASE] = LAYOUT(
KC_ESC, 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_PSCR, 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_PGUP,
MO(_MOV), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_NUHS, KC_ENT, KC_PGDN,
KC_LSFT, KC_NUBS, 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_END,
KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, TG(_RGB),KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT
),

[_MOV] = LAYOUT(
RESET, KC_MYCM, KC_WHOM, KC_CALC, KC_MSEL, KC_MPRV, KC_MPLY, KC_MSTP, KC_MNXT, KC_MUTE, KC_VOLD, KC_VOLU, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_INS,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, NK_TOGG, _______, _______, _______, _______, _______, KC_PGUP, _______,
_______, _______, _______, _______, _______, _______, _______, KC_HOME, KC_PGDN, KC_END
),

[_RGB] = LAYOUT(
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RESET, RGB_MOD,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_RMOD,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_TOG, RGB_SPI,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_SAI, RGB_SPD,
_______, _______, _______, _______, _______, _______, _______, RGB_HUD, RGB_SAD, RGB_HUI
),

};
// clang-format on

#if defined(ENCODER_ENABLE)
bool encoder_update_user(uint8_t index, bool clockwise) {
switch (get_highest_layer(layer_state)) {
case _MOV:
if (clockwise) {
tap_code16(C(KC_TAB));
} else {
tap_code16(S(C(KC_TAB)));
}
break;
#if defined(RGB_MATRIX_ENABLE)
case _RGB:
if (clockwise) {
rgb_matrix_increase_val_noeeprom();
} else {
rgb_matrix_decrease_val_noeeprom();
}
break;
#endif // RGB_MATRIX_ENABLE
default:
if (clockwise) {
tap_code(KC_VOLU);
} else {
tap_code(KC_VOLD);
}
break;
}
return true;
}
#endif // ENCODER_ENABLE

#if defined(RGB_MATRIX_ENABLE)
/*
* Set up default RGB color.
*/
void rgb_matrix_set_default_color(void) {
rgb_matrix_sethsv_noeeprom_user(HSV_CHARTREUSE);
}

/*
* Set up RGB defaults.
*/
void rgb_matrix_configure_default_settings(void) {
rgb_matrix_set_default_color();
}

void keyboard_post_init_user(void) {
rgb_matrix_enable_noeeprom();
rgb_matrix_configure_default_settings();
}

/*
* Use RGB underglow to indicate specific layers.
*/
layer_state_t layer_state_set_user(layer_state_t state) {
switch (get_highest_layer(state)) {
case _MOV:
rgb_matrix_sethsv_noeeprom_user(HSV_SPRINGGREEN);
break;
case _RGB:
rgb_matrix_sethsv_noeeprom_user(HSV_GREEN);
break;
default: // for any other layer
rgb_matrix_set_default_color();
break;
}
return state;
}

void matrix_scan_user(void) {
matrix_scan_user_rgb();
}

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if (!process_record_user_rgb(keycode, record)) {
return false;
}

switch (keycode) {
case RESET: // when activating RESET mode for flashing
if (record->event.pressed) {
rgb_matrix_set_color_all(63, 0, 0);
rgb_matrix_driver.flush();
}
return true;
}
return true; // Process all other keycodes normally
}
#endif // RGB_MATRIX_ENABLE
104 changes: 104 additions & 0 deletions keyboards/gmmk/pro/iso/keymaps/vitoni/readme.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
= ViToni's keymap for GMMK Pro ISO

== Layout
Based on the stock layout but making use of CAPS as FN similar to laptop keyboards.
This frees up the left row for other uses (although not remapped yet).
Since both Delete and Insert are used for coding they are part of the CAPS layer as well.

The differences are as follows:

=== Layer 0 (`_BASE`)
Mostly stock + CAPS goes to layer `_MOV`.
FN toggles the layer `_RGB`.

=== Layer 1 (`_MOV`), accessed by pressing `CAPS` on layer `_BASE`
[%header]
|===
| Key / Action | Mapped to
| ESC | _RESET_
| F1 | KC_MYCM
| F2 | KC_WHOM
| F3 | KC_CALC
| F4 | KC_MSEL
| F5 | KC_MPRV
| F6 | KC_MPLY
| F7 | KC_MSTP
| F8 | KC_MNXT
| F9 | KC_MUTE
| F10 | KC_VOLD
| F11 | KC_VOLU
| N | NK_TOGG
| Delete | Insert
| Left | Home
| Right | End
| Up | PgUp
| Down | PgDn
|===

=== Layer 2 (`_RGB`), accessed by pressing `FN` on layer `_BASE`
Revamped the stock FN layer to focus on RGB only.

[%header]
|===
| Key / Action | Mapped to
| Knob clockwise | Value/Brightness up
| Knob anti-clockwise | Value/Brightness down
| Backspace | _RESET_
| Enter | RGB_TOG
| Del | RGB_MOD
| PgUp | RGB_RMOD
| PgDn | RGB_SPI
| End | RGB_SPD
| Left | RGB_HUD
| Right | RGB_HUI
| Up | RGB_SAI
| Down | RGB_SAD
|===

No other changes have been made.

== RGB light

The code customizing RGB light usage is decribed here:

* link:../../../../../../users/vitoni/readme.adoc[/users/vitoni/readme.adoc]

When using `RGB_DISABLE_TIMEOUT` addtional options are available:

* `RGB_FADE_IN` makes the RGB lights fade in instead of setting the value/brightness to 100% (implicitly due to HSV including the brightness) when resuming after RGB lights have been turned off.
Fade in occurs when the keyboard is initialized and when the RGB brightness has been changed (e.g. suspending, fade out, etc.).
* `RGB_DISABLE_WITH_FADE_OUT` activates fade out before the keyboard is disabled by `RGB_DISABLE_TIMEOUT`.

Parameters used to define the behavior are:
[%header]
|===
|Key | Default | Description

| RGB_MATRIX_MAXIMUM_BRIGHTNESS
| 200 (&lt;= UNIT8_MAX)
| Maximum assumed value for brightness.
Used to calculate lead time for fade out before suspend timeout.

|===

`RGB_IDLE_TIMEOUT` enables fading out after being idle for the defined time and allows
* `RGB_IDLE_BREATHE` also activates a brethe effect while idling.

[%header]
|===
|Key | Default | Description

|RGB_IDLE_TIMEOUT
|4500
|Time in milliseconds without activity before considered to be idle.

|RGB_IDLE_MINIMUM_BRIGHTNESS
|`RGB_MATRIX_MAXIMUM_BRIGHTNESS` / 5
|Brightness value RGB is dimmed to when starting to idle. +
When breathing used as the lower bound of the brightness value.

|RGB_IDLE_MAXIMUM_BRIGHTNESS
|`RGB_MATRIX_MAXIMUM_BRIGHTNESS` * 2/5
|Upper bound of brightness value of the RGB light while breathing.

|===
16 changes: 16 additions & 0 deletions users/vitoni/readme.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
= User functions

Functions are mostly related to changing the RGB lights depending on user interaction and when idling.

== utils.h

Common functions are declared in link:utils.h[]. These function are not directly RGB related but used to modify state and calculate values.

== rgb_matrix_effects.h

Functions in link:rgb_matrix_effects.h[] make use of common function in `utils.h` and are used to create to RGB matrix effects such as fading or breathing.

== vitoni.h

The functions declared in link:vitoni.h[] are used as entry points for usage of RGB effects.
One entry point is `matrix_scan` based for regular task while the other is `process_record` based for user activity tasks.
Loading