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

update mlego/m48 to data driven #20223

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
21 changes: 0 additions & 21 deletions keyboards/mlego/m48/config.h

This file was deleted.

67 changes: 0 additions & 67 deletions keyboards/mlego/m48/info.json

This file was deleted.

19 changes: 2 additions & 17 deletions keyboards/mlego/m48/keymaps/default/config.h
Original file line number Diff line number Diff line change
@@ -1,21 +1,6 @@
/*
Copyright 2021-2022 Alin M Elena <[email protected]>

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 <http://www.gnu.org/licenses/>.
*/
// Copyright 2021-2022 alin m elena (@alinelena)
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#define TAPPING_TOGGLE 2
#define UNICODE_SELECTED_MODES UNICODE_MODE_LINUX, UNICODE_MODE_MACOS, UNICODE_MODE_WINCOMPOSE
96 changes: 22 additions & 74 deletions keyboards/mlego/m48/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
@@ -1,37 +1,16 @@
/*
Copyright 2021-2022 Alin M Elena <[email protected]>

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 <http://www.gnu.org/licenses/>.
*/
// Copyright 2021-2022 alin m elena (@alinelena)
// SPDX-License-Identifier: GPL-2.0-or-later

#include QMK_KEYBOARD_H

enum layer_names {
_QW = 0,
_LWR,
_RSE,
_ADJ
};

#ifdef RGBLIGHT_ENABLE

const rgblight_segment_t PROGMEM my_qwerty_layer[] = RGBLIGHT_LAYER_SEGMENTS({0, RGBLED_NUM, HSV_PURPLE});
const rgblight_segment_t PROGMEM my_lwr_layer[] = RGBLIGHT_LAYER_SEGMENTS({0, RGBLED_NUM, HSV_CYAN});
const rgblight_segment_t PROGMEM my_rse_layer[] = RGBLIGHT_LAYER_SEGMENTS({0, RGBLED_NUM, HSV_RED});
const rgblight_segment_t PROGMEM my_adj_layer[] = RGBLIGHT_LAYER_SEGMENTS({0, RGBLED_NUM, HSV_GREEN});

const rgblight_segment_t* const PROGMEM my_rgb_layers[] = RGBLIGHT_LAYERS_LIST(my_qwerty_layer, my_lwr_layer, my_rse_layer, my_adj_layer);
const rgblight_segment_t* const PROGMEM my_rgb[] = RGBLIGHT_LAYERS_LIST(my_qwerty_layer, my_lwr_layer, my_rse_layer, my_adj_layer);
#endif

#define LOWER TT(_LWR)
Expand Down Expand Up @@ -115,24 +94,27 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
};
// clang-format on

#if defined(ENCODER_MAP_ENABLE)
const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][2] = {
[_QW] = {ENCODER_CCW_CW(KC_VOLD, KC_VOLU)},
# ifdef RGBLIGHT_ENABLE
[_LWR] = {ENCODER_CCW_CW(RGB_HUD, RGB_HUI)},
[_RSE] = {ENCODER_CCW_CW(RGB_VAD, RGB_VAI)},
[_ADJ] = {ENCODER_CCW_CW(RGB_RMOD, RGB_MOD)},
# else
[_LWR] = {ENCODER_CCW_CW(KC_MNXT, KC_MPRV)},
[_RSE] = {ENCODER_CCW_CW(KC_MFFD, KC_MRWD)},
[_ADJ] = {ENCODER_CCW_CW(KC_PGDN, KC_PGUP)},
# endif
};
#endif

// let us assume we start with both layers off
bool toggle_lwr = false;
bool toggle_rse = false;

bool led_update_user(led_t led_state) {
// Disable the default LED update code, so that lock LEDs could be reused to show layer status.
return false;
}

void matrix_scan_user(void) {
led_lwr(toggle_lwr);
led_rse(toggle_rse);
led_t led_state = host_keyboard_led_state();
led_caps(led_state.caps_lock);
if (layer_state_is(_ADJ)) {
led_lwr(true);
led_rse(true);
}
toggle_leds(toggle_lwr, toggle_rse);
}

bool process_record_user(uint16_t keycode, keyrecord_t* record) {
Expand Down Expand Up @@ -173,44 +155,10 @@ layer_state_t default_layer_state_set_user(layer_state_t state) {
rgblight_set_layer_state(0, layer_state_cmp(state, _QW));
return state;
}
#endif

void keyboard_post_init_user(void) {
// Enable the LED layers
rgblight_layers = my_rgb_layers;
}
#ifdef RGBLIGHT_ENABLE
rgblight_layers = my_rgb;
#endif

#ifdef ENCODER_ENABLE

# define MEDIA_KEY_DELAY 10

static inline void my_encoders(const uint8_t index, const bool clockwise) {
if (index == 0) { /* First encoder */
if (IS_LAYER_ON(_LWR)) {
if (clockwise) {
rgblight_decrease_val_noeeprom();
} else {
rgblight_increase_val_noeeprom();
}
} else if (IS_LAYER_ON(_RSE)) {
if (clockwise) {
rgblight_decrease_hue_noeeprom();
} else {
rgblight_increase_hue_noeeprom();
}

} else {
if (clockwise) {
tap_code_delay(KC_VOLD, MEDIA_KEY_DELAY);
} else {
tap_code_delay(KC_VOLU, MEDIA_KEY_DELAY);
}
}
}
}

bool encoder_update_user(uint8_t index, bool clockwise) {
my_encoders(index, clockwise);
return true;
}
#endif
1 change: 1 addition & 0 deletions keyboards/mlego/m48/keymaps/default/rules.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ENCODER_MAP_ENABLE = yes
20 changes: 0 additions & 20 deletions keyboards/mlego/m48/keymaps/via/config.h

This file was deleted.

Loading