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

Align Code to QMK Coding Guidelines for keyboard_post_init_user() #40

Open
wants to merge 3 commits into
base: fl16-v0.2.8-prep
Choose a base branch
from
Open
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
2 changes: 0 additions & 2 deletions keyboards/framework/framework.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
#include "os_detection.h"

void keyboard_post_init_kb(void) {
keyboard_post_init_user();

// Enable debug output
debug_enable = true;
debug_matrix = true;
Expand Down
29 changes: 24 additions & 5 deletions keyboards/framework/macropad/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
#include QMK_KEYBOARD_H
#include "factory.h"

enum _layers {
_NUMLOCK,
_FN,
_FACTORY,
};

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/*
* ┌────┬────┬────┬────┐
Expand Down Expand Up @@ -88,12 +94,16 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
bool led_update_user(led_t led_state) {
// Change layer if numlock state changes, either triggered by OS or
// by numlock key on this keyboard
if (led_state.num_lock) {
layer_off(_FN);
} else {
layer_on(_FN);
static bool last_value = false;
if(last_value != led_state.num_lock) {
last_value = led_state.num_lock;
if (led_state.num_lock) {
layer_off(_FN);
} else {
layer_on(_FN);
}
}
return true;
return true;
}

void enable_factory_mode(bool enable) {
Expand All @@ -102,3 +112,12 @@ void enable_factory_mode(bool enable) {
else
layer_off(_FACTORY);
}

void keyboard_post_init_user(void) {
// Sync initial numlock state from the host
if (host_keyboard_led_state().num_lock) {
layer_on(_NUMLOCK);
} else {
layer_off(_FN);
}
}
11 changes: 1 addition & 10 deletions keyboards/framework/macropad/macropad.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,4 @@ led_config_t g_led_config = { {
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4
} };
#endif

void keyboard_post_init_user(void) {
// Sync initial numlock state from the host
if (host_keyboard_led_state().num_lock) {
layer_on(_NUMLOCK);
} else {
layer_off(_FN);
}
}
#endif
6 changes: 0 additions & 6 deletions keyboards/framework/macropad/macropad.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,3 @@
{ K108, H1, H2, KC_NO, H4, K107, K109, K110 }, \
{ KC_NO, KC_NO, KC_NO, KC_NO, H3, KC_NO, KC_NO, KC_NO }, \
}

enum _layers {
_NUMLOCK,
_FN,
_FACTORY,
};
14 changes: 14 additions & 0 deletions keyboards/framework/numpad/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@

#include QMK_KEYBOARD_H

enum _layers {
_NUMLOCK,
_FN
};

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/*
* ┌────┬────┬────┬────┐
Expand Down Expand Up @@ -69,3 +74,12 @@ bool led_update_user(led_t led_state) {
}
return true;
}

void keyboard_post_init_user(void) {
// Sync initial numlock state from the host
if (host_keyboard_led_state().num_lock) {
layer_on(_NUMLOCK);
} else {
layer_off(_FN);
}
}
9 changes: 0 additions & 9 deletions keyboards/framework/numpad/numpad.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,3 @@

#include "quantum.h"
#include "numpad.h"

void keyboard_post_init_user(void) {
// Sync initial numlock state from the host
if (host_keyboard_led_state().num_lock) {
layer_on(_NUMLOCK);
} else {
layer_off(_FN);
}
}
4 changes: 0 additions & 4 deletions keyboards/framework/numpad/numpad.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,3 @@
{ KC_NO, KC_NO, KC_NO, KC_NO, H3, KC_NO, KC_NO, KC_NO }, \
}

enum _layers {
_NUMLOCK,
_FN
};