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

Updating the noodlepad_micro keymaps with custom keycodes #23003

Open
wants to merge 18 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion keyboards/themadnoodle/noodlepad_micro/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

#pragma once

#define RGBLIGHT_DEFAULT_MODE RGBLIGHT_MODE_RAINBOW_SWIRL + 5
#define RGBLIGHT_DEFAULT_MODE RGBLIGHT_MODE_RAINBOW_SWIRL + 5
jessel92 marked this conversation as resolved.
Show resolved Hide resolved
11 changes: 9 additions & 2 deletions keyboards/themadnoodle/noodlepad_micro/keyboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"mousekey": true,
"nkro": true,
"rgblight": true,
"encoder": true
"encoder": true,
"unicode": true
},
"rgblight": {
"hue_steps": 10,
Expand All @@ -30,7 +31,13 @@
"rgb_test": true,
"alternating": true,
"twinkle": true
}
},
"layers": {
"enabled": true,
"blink": true,
"max": 8,
"override_rgb": false
}
},
"matrix_pins": {
"cols": ["GP6", "GP7", "GP0"],
Expand Down
163 changes: 162 additions & 1 deletion keyboards/themadnoodle/noodlepad_micro/keymaps/default/keymap.c
jessel92 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@

#include QMK_KEYBOARD_H

enum custom_keycodes {
L_IND = QK_USER, // Toggle the Layer Indicators Modes
L_CYC // Cycle through the layers
};

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {

/* LAYER 0
Expand Down Expand Up @@ -53,6 +58,22 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS
),

/* LAYER 3 (ENCODER)
* ,--ENC2-- --ENC1--.
* | | | |
* |-------+-------+-------|
* | | | |
* |-------+-------+-------|
* | | | |
* `-----------------------'
*/

[3] = LAYOUT(
KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, L_IND, KC_TRNS
)
};

Expand All @@ -63,6 +84,146 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = {
[0] = { ENCODER_CCW_CW(KC_LEFT, KC_RGHT), ENCODER_CCW_CW(KC_VOLD, KC_VOLU) },
[1] = { ENCODER_CCW_CW(RGB_HUD, RGB_HUI), ENCODER_CCW_CW(RGB_SAD, RGB_SAI) },
[2] = { ENCODER_CCW_CW(RGB_VAD, RGB_VAI), ENCODER_CCW_CW(RGB_SPD, RGB_SPI) }
[2] = { ENCODER_CCW_CW(RGB_VAD, RGB_VAI), ENCODER_CCW_CW(RGB_SPD, RGB_SPI) },
[3] = { ENCODER_CCW_CW(KC_LEFT, KC_RGHT), ENCODER_CCW_CW(KC_DOWN, KC_UP) }
};
#endif

/*Custom Keycodes*/
const rgblight_segment_t PROGMEM layer_zero_all[] = RGBLIGHT_LAYER_SEGMENTS({0, 4, HSV_WHITE});
const rgblight_segment_t PROGMEM layer_one_all[] = RGBLIGHT_LAYER_SEGMENTS({0, 4, HSV_RED});
const rgblight_segment_t PROGMEM layer_two_all[] = RGBLIGHT_LAYER_SEGMENTS({0, 4, HSV_GREEN});
const rgblight_segment_t PROGMEM layer_three_all[] = RGBLIGHT_LAYER_SEGMENTS({0, 4, HSV_BLUE});

const rgblight_segment_t PROGMEM layer_zero[] = RGBLIGHT_LAYER_SEGMENTS({0, 1, HSV_WHITE});
const rgblight_segment_t PROGMEM layer_one[] = RGBLIGHT_LAYER_SEGMENTS({1, 1, HSV_WHITE});
const rgblight_segment_t PROGMEM layer_two[] = RGBLIGHT_LAYER_SEGMENTS({2, 1, HSV_WHITE});
const rgblight_segment_t PROGMEM layer_three[] = RGBLIGHT_LAYER_SEGMENTS({3, 1, HSV_WHITE});

const rgblight_segment_t *const PROGMEM my_rgb_layers[] = RGBLIGHT_LAYERS_LIST(

layer_zero_all, // 0
layer_one_all, // 1
layer_two_all, // 2
layer_three_all, // 3
layer_zero, // 4
layer_one, // 5
layer_two, // 6
layer_three // 7

);

void keyboard_post_init_user(void) {
// Enable the LED layers
rgblight_layers = my_rgb_layers;
}

#define LAYER_CYCLE_START 0 // 1st layer on the cycle
#define LAYER_CYCLE_END 3 // Last layer on the cycle

bool led_mode; // false for Blinking Mode, true for Static Mode

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case L_IND:
if (record->event.pressed) {
// Code to toggle between the two Layer Indicators
led_mode = !led_mode; // Toggle the mode

// Updateing lighting layer when key is pressed
if (led_mode) {
if (layer_state_is(0)) {
rgblight_set_layer_state(4, true);
}
if (layer_state_is(1)) {
rgblight_set_layer_state(5, true);
}
if (layer_state_is(2)) {
rgblight_set_layer_state(6, true);
}
if (layer_state_is(3)) {
rgblight_set_layer_state(7, true);
}
} else {
rgblight_set_layer_state(4, false);
rgblight_set_layer_state(5, false);
rgblight_set_layer_state(6, false);
rgblight_set_layer_state(7, false);

if (layer_state_is(0)) {
rgblight_blink_layer(0, 1000);
}
if (layer_state_is(1)) {
rgblight_blink_layer(1, 1000);
}
if (layer_state_is(2)) {
rgblight_blink_layer(2, 1000);
}
if (layer_state_is(3)) {
rgblight_blink_layer(3, 1000);
}
}
} else {
}
return false; // Skip all further processing of this key

case L_CYC:
// Our logic will happen on presses, nothing is done on releases
if (!record->event.pressed) {
// We've already handled the keycode (doing nothing), let QMK know so no further code is run unnecessarily
return false;
}

uint8_t current_layer = get_highest_layer(layer_state);

// Check if we are within the range, if not quit
if (current_layer > LAYER_CYCLE_END || current_layer < LAYER_CYCLE_START) {
return false;
}

uint8_t next_layer = current_layer + 1;
if (next_layer > LAYER_CYCLE_END) {
next_layer = LAYER_CYCLE_START;
}
layer_move(next_layer);
return false;

default:
return true; // Process all other keycodes normally
}
}

layer_state_t layer_state_set_user(layer_state_t state) {
if (led_mode) {
// Code for Static Layer Indicators

rgblight_set_layer_state(4, layer_state_cmp(state, 0));
rgblight_set_layer_state(5, layer_state_cmp(state, 1));
rgblight_set_layer_state(6, layer_state_cmp(state, 2));
rgblight_set_layer_state(7, layer_state_cmp(state, 3));

} else {
// Code for Blinking Layer Indicators

uint8_t layer = get_highest_layer(state);

switch (layer) {
case 0:
rgblight_blink_layer(0, 500);
break;
case 1:
rgblight_blink_layer(1, 500);
break;
case 2:
rgblight_blink_layer(2, 500);
break;
case 3:
rgblight_blink_layer(3, 500);
break;

default:
rgblight_blink_layer(0, 500);
}
}
return state;
}
Loading
Loading