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

Get rid of USB_LED_NUM_LOCK #21424

Merged
merged 2 commits into from
Jul 2, 2023
Merged
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
7 changes: 4 additions & 3 deletions keyboards/40percentclub/gherkin/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,17 @@ void keyboard_pre_init_user(void) {
setPinOutput(B0);
}

void led_set_user(uint8_t usb_led) {
if (IS_LED_ON(usb_led, USB_LED_NUM_LOCK)) {
bool led_update_user(led_t led_state) {
if (led_state.num_lock) {
writePinLow(D5);
} else {
writePinHigh(D5);
}

if (IS_LED_ON(usb_led, USB_LED_CAPS_LOCK)) {
if (led_state.caps_lock) {
writePinLow(B0);
} else {
writePinHigh(B0);
}
return false;
}
5 changes: 3 additions & 2 deletions keyboards/contra/keymaps/maxr1998/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,11 @@ void update_tri_layer_user(void) {
}
}

void led_set_user(uint8_t usb_led) {
bool led_update_user(led_t led_state) {
// Force-enable Numlock
if (!(usb_led & (1<<USB_LED_NUM_LOCK))) {
if (!led_state.num_lock) {
register_code(KC_NUM_LOCK);
unregister_code(KC_NUM_LOCK);
}
return false;
}
6 changes: 3 additions & 3 deletions keyboards/crkbd/keymaps/rpbaptist/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,10 @@ void render_status(void) {

oled_write_P(PSTR("\n"), false);

uint8_t led_usb_state = host_keyboard_leds();
led_t led_state = host_keyboard_led_state();
oled_write_P(PSTR("Mode:"), false);
oled_write_P(IS_LED_ON(led_usb_state, USB_LED_NUM_LOCK) ? PSTR(" NUM ") : PSTR("\n"), false);
oled_write_P(IS_LED_ON(led_usb_state, USB_LED_CAPS_LOCK) ? PSTR(" CAPS") : PSTR("\n"), false);
oled_write_P(led_state.num_lock ? PSTR(" NUM ") : PSTR("\n"), false);
oled_write_P(led_state.caps_lock ? PSTR(" CAPS") : PSTR("\n"), false);

# ifdef RGB_MATRIX_ENABLE
oled_write_P(PSTR("\n"), false);
Expand Down
13 changes: 3 additions & 10 deletions keyboards/dztech/dz60rgb/keymaps/matthewrobo/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ enum dz60rgb_keycodes {
#define _V_V_V_ KC_TRNS
#define LT_CAPS LT(_NAV, KC_CAPS)
#define LT_DEL LT(_RGB, KC_DEL)
extern bool autoshift_enabled;
#define MT_SLSH RSFT_T(KC_SLSH)
#define MT_APP RALT_T(KC_APP)
#define LM_LALT LM(_FNM, MOD_LALT)
Expand Down Expand Up @@ -92,12 +91,12 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
};

bool rgb_matrix_indicators_user(void) {
uint8_t this_led = host_keyboard_leds();
led_t led_state = host_keyboard_led_state();

if (!g_suspend_state && rgb_matrix_config.enable) {
switch (get_highest_layer(layer_state)) {
case _NAV:
if (this_led & (1 << USB_LED_NUM_LOCK)) {
if (led_state.num_lock) {
rgb_matrix_set_color(13, 0xFF, 0x00, 0x00);
rgb_matrix_set_color(19, 0xFF, 0xFF, 0x00);
} else {
Expand Down Expand Up @@ -204,17 +203,11 @@ bool rgb_matrix_indicators_user(void) {
rgb_matrix_set_color(41, 0xFF, 0x00, 0x40); // ctrl+delete
rgb_matrix_set_color(43, 0xFF, 0x00, 0x40); // ctrl+slash

if (this_led & (1 << !autoshift_enabled)) {
rgb_matrix_set_color(0, 0xFF, 0x00, 0x00); // AS_TOGG
} else {
rgb_matrix_set_color(0, 0xFF, 0xFF, 0x00);
}

break;
}
}

if (this_led & (1 << USB_LED_CAPS_LOCK)) {
if (led_state.caps_lock) {
rgb_matrix_set_color(40, 0xFF, 0xFF, 0xFF);
}
return false;
Expand Down
25 changes: 3 additions & 22 deletions keyboards/dztech/dz60rgb/keymaps/mekanist/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void rgb_matrix_layer_helper (uint8_t red, uint8_t green, uint8_t blue) {
}

bool rgb_matrix_indicators_user(void) {
uint8_t this_led = host_keyboard_leds();
led_t led_state = host_keyboard_led_state();

if (!g_suspend_state && rgb_matrix_config.enable) {
switch (get_highest_layer(layer_state)) {
Expand All @@ -73,13 +73,13 @@ bool rgb_matrix_indicators_user(void) {
}
}

if (this_led & (1 << USB_LED_CAPS_LOCK)) {
if (led_state.caps_lock) {
rgb_matrix_set_color(40, 0xFF, 0xFF, 0xFF);
}

switch (get_highest_layer(layer_state)) {
case _LAYER3:
if (this_led & (1 << USB_LED_NUM_LOCK)) {
if (led_state.num_lock) {
rgb_matrix_set_color(13, 0xFF, 0x00, 0x00);
} else {
rgb_matrix_set_color(13, 0x00, 0x00, 0x00);
Expand Down Expand Up @@ -152,22 +152,3 @@ bool rgb_matrix_indicators_user(void) {
}
return false;
}





void matrix_init_user(void)
{
//user initialization
}

void matrix_scan_user(void)
{
//user matrix
}

bool process_record_user(uint16_t keycode, keyrecord_t* record)
{
return true;
}
11 changes: 2 additions & 9 deletions keyboards/dztech/dz65rgb/keymaps/matthewrobo/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ enum dz65rgb_keycodes {
#define TG_NKRO MAGIC_TOGGLE_NKRO
#define _V_V_V_ KC_TRNS
#define LT_CAPS LT(_NAV, KC_CAPS)
extern bool autoshift_enabled;
#define MT_APP RALT_T(KC_APP)
#define LM_LALT LM(_FNM, MOD_LALT)

Expand Down Expand Up @@ -87,12 +86,12 @@ bool rgb_matrix_indicators_user(void) {
rgb_matrix_set_color(8, 0xFF, 0xFF, 0xFF);
}

uint8_t this_led = host_keyboard_leds();
led_t led_state = host_keyboard_led_state();

if (!g_suspend_state && rgb_matrix_config.enable) {
switch (get_highest_layer(layer_state)) {
case _NAV:
if (IS_LED_ON(this_led, USB_LED_NUM_LOCK)) {
if (led_state.num_lock) {
rgb_matrix_set_color(17, 0xFF, 0x00, 0x00);
rgb_matrix_set_color(26, 0xFF, 0xFF, 0x00);
} else {
Expand Down Expand Up @@ -171,12 +170,6 @@ bool rgb_matrix_indicators_user(void) {
rgb_matrix_set_color(24, 0xFF, 0x40, 0x00); // KC_MPRV
rgb_matrix_set_color(25, 0xFF, 0x40, 0x00);

if (this_led & (1 << !autoshift_enabled)) {
rgb_matrix_set_color(15, 0xFF, 0x00, 0x00); // AS_TOGG
} else {
rgb_matrix_set_color(15, 0xFF, 0xFF, 0x00);
}

rgb_matrix_set_color(6, 0xFF, 0x80, 0x00); //RGB_MOD
rgb_matrix_set_color(48, 0xFF, 0x80, 0x00);
rgb_matrix_set_color(29, 0xFF, 0x80, 0x00); //RGB_MOD
Expand Down
7 changes: 4 additions & 3 deletions keyboards/handwired/arrow_pad/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t * record) {
return true;
}

void led_set_user(uint8_t usb_led)
bool led_update_user(led_t led_state)
{
if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
if (led_state.caps_lock) {
// output high
DDRD |= (1<<6);
PORTD |= (1<<6);
Expand All @@ -107,7 +107,7 @@ void led_set_user(uint8_t usb_led)
DDRD &= ~(1<<6);
PORTD &= ~(1<<6);
}
if (usb_led & (1<<USB_LED_NUM_LOCK)) {
if (led_state.num_lock) {
// output low
DDRC |= (1<<7);
PORTC |= ~(1<<7);
Expand All @@ -116,4 +116,5 @@ void led_set_user(uint8_t usb_led)
DDRC &= ~(1<<7);
PORTC &= ~(1<<7);
}
return false;
}
7 changes: 4 additions & 3 deletions keyboards/handwired/arrow_pad/keymaps/pad_21/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t * record) {
return true;
}

void led_set_user(uint8_t usb_led)
bool led_update_user(led_t led_state)
{
if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
if (led_state.caps_lock) {
// output high
DDRD |= (1<<6);
PORTD |= (1<<6);
Expand All @@ -120,7 +120,7 @@ void led_set_user(uint8_t usb_led)
DDRD &= ~(1<<6);
PORTD &= ~(1<<6);
}
if (usb_led & (1<<USB_LED_NUM_LOCK)) {
if (led_state.num_lock) {
// output low
DDRC |= (1<<7);
PORTC |= ~(1<<7);
Expand All @@ -129,4 +129,5 @@ void led_set_user(uint8_t usb_led)
DDRC &= ~(1<<7);
PORTC &= ~(1<<7);
}
return false;
}
7 changes: 4 additions & 3 deletions keyboards/handwired/arrow_pad/keymaps/pad_24/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t * record) {
return true;
}

void led_set_user(uint8_t usb_led)
bool led_update_user(led_t led_state)
{
if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
if (led_state.caps_lock) {
// output high
DDRD |= (1<<6);
PORTD |= (1<<6);
Expand All @@ -107,7 +107,7 @@ void led_set_user(uint8_t usb_led)
DDRD &= ~(1<<6);
PORTD &= ~(1<<6);
}
if (usb_led & (1<<USB_LED_NUM_LOCK)) {
if (led_state.num_lock) {
// output low
DDRC |= (1<<7);
PORTC |= ~(1<<7);
Expand All @@ -116,4 +116,5 @@ void led_set_user(uint8_t usb_led)
DDRC &= ~(1<<7);
PORTC &= ~(1<<7);
}
return false;
}
52 changes: 28 additions & 24 deletions keyboards/input_club/infinity60/led.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,33 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
* both regular threads and ISRs, unlocked (during resume-from-sleep).
* In particular, I2C functions (interrupt-driven) should NOT be called from here.
*/
void led_set(uint8_t usb_led) {
msg_t msg;

if (usb_led & (1<<USB_LED_NUM_LOCK)) {
chSysUnconditionalLock();
msg=(1 << 8) | TOGGLE_NUM_LOCK;
chMBPostI(&led_mailbox, msg);
chSysUnconditionalUnlock();
} else {
chSysUnconditionalLock();
msg=(0 << 8) | TOGGLE_NUM_LOCK;
chMBPostI(&led_mailbox, msg);
chSysUnconditionalUnlock();
}
if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
chSysUnconditionalLock();
msg=(1 << 8) | TOGGLE_CAPS_LOCK;
chMBPostI(&led_mailbox, msg);
chSysUnconditionalUnlock();
} else {
chSysUnconditionalLock();
msg=(0 << 8) | TOGGLE_CAPS_LOCK;
chMBPostI(&led_mailbox, msg);
chSysUnconditionalUnlock();
bool led_update_kb(led_t led_state) {
bool res = led_update_user(led_state);
if (res) {
msg_t msg;

if (led_state.num_lock) {
chSysUnconditionalLock();
msg=(1 << 8) | TOGGLE_NUM_LOCK;
chMBPostI(&led_mailbox, msg);
chSysUnconditionalUnlock();
} else {
chSysUnconditionalLock();
msg=(0 << 8) | TOGGLE_NUM_LOCK;
chMBPostI(&led_mailbox, msg);
chSysUnconditionalUnlock();
}
if (led_state.caps_lock) {
chSysUnconditionalLock();
msg=(1 << 8) | TOGGLE_CAPS_LOCK;
chMBPostI(&led_mailbox, msg);
chSysUnconditionalUnlock();
} else {
chSysUnconditionalLock();
msg=(0 << 8) | TOGGLE_CAPS_LOCK;
chMBPostI(&led_mailbox, msg);
chSysUnconditionalUnlock();
}
}
return false;
}
5 changes: 3 additions & 2 deletions keyboards/input_club/infinity60/led_controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,9 @@ static THD_FUNCTION(LEDthread, arg) {
// initialize persistent variables
pwm_step_status = 4; //full brightness
page_status = 0; //start frame 0 (all off/on)
numlock_status = (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) ? 1 : 0;
capslock_status = (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) ? 1 : 0;
led_t led_state = host_keyboard_led_state();
numlock_status = led_state.num_lock ? 1 : 0;
capslock_status = led_state.caps_lock ? 1 : 0;

while(true) {
// wait for a message (asynchronous)
Expand Down
12 changes: 3 additions & 9 deletions keyboards/kbdfans/niu_mini/keymaps/tobias/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,13 +377,7 @@ layer_state_t layer_state_set_user(layer_state_t state) {
*/


void led_set_user(uint8_t usb_led) {

if (usb_led & (1 << USB_LED_NUM_LOCK)) {
bnumlock = true;

} else {
bnumlock = false;
}

bool led_update_user(led_t led_state) {
bnumlock = led_state.num_lock;
return false;
}
5 changes: 1 addition & 4 deletions keyboards/kprepublic/jj40/keymaps/stevexyz/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,14 +262,11 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
void matrix_init_user(void) {
// eeconfig_init(); // reset keyboard to a standard default state; useful when new releases messup with eeprom values
// set num lock on at start (for numonly layer to work)
if (!(host_keyboard_leds() & (1<<USB_LED_NUM_LOCK))) {
if (!host_keyboard_led_state().num_lock) {
SEND_STRING(SS_TAP(X_NUM_LOCK)); //register_code(KC_NUM_LOCK); unregister_code(KC_NUM_LOCK);
}
}

void matrix_scan_user(void) {
}

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case CK_TRIPLEZERO:
Expand Down
3 changes: 1 addition & 2 deletions keyboards/massdrop/alt/keymaps/jdelkins_ss/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ uint16_t rgb_idle_seconds = 0;
uint16_t rgb_timer;
uint8_t save_layer;

#define NUMLOCK_ON (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK))
#define MODS_SHIFT (get_mods() & MOD_MASK_SHIFT)
#define MODS_CTRL (get_mods() & MOD_MASK_CTRL)

Expand Down Expand Up @@ -143,7 +142,7 @@ static void set_rgb_layer(int layer) {
void matrix_init_keymap(void) {
set_rgb_layer(_QWERTY);
// force numlock on upon startup
if (!NUMLOCK_ON) {
if (!host_keyboard_led_state().num_lock) {
tap_code(KC_NUM_LOCK);
}
};
Expand Down
4 changes: 2 additions & 2 deletions keyboards/mt/mt980/keymaps/walker/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ tap_dance_action_t tap_dance_actions[] = {
[ALT_L1] = ACTION_TAP_DANCE_FN_ADVANCED(NULL,alt_finished, alt_reset)
};

void led_set_keymap(uint8_t usb_led) {
if (usb_led & (1<<USB_LED_NUM_LOCK)) {
bool led_update_keymap(led_t led_state) {
if (led_state.num_lock) {
numlock_on = true;
}
else {
Expand Down
Loading