Skip to content

Commit

Permalink
Get rid of USB_LED_SCROLL_LOCK (#21405)
Browse files Browse the repository at this point in the history
  • Loading branch information
fauxpark authored Jul 2, 2023
1 parent 9dbad1f commit 7ff80a5
Show file tree
Hide file tree
Showing 62 changed files with 399 additions and 479 deletions.
21 changes: 0 additions & 21 deletions keyboards/bpiphany/kitten_paw/keymaps/ickerwx/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

#define MEDAPP LT(MEDIA, KC_APP)

uint8_t current_layer_global = 255;

enum layers {
DEFAULT,
PROG1,
Expand Down Expand Up @@ -87,25 +85,6 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
_______,_______,_______, LT(MISC, KC_SPC), _______,_______,_______,_______, _______,_______,_______, _______,_______),
};

void matrix_scan_user(void) {
uint8_t layer;
layer = get_highest_layer(layer_state);

if (current_layer_global != layer) {
current_layer_global = layer;

// unset CAPSLOCK and SCROLL LOCK LEDs
led_set(host_keyboard_leds() & ~(1<<USB_LED_CAPS_LOCK));
led_set(host_keyboard_leds() & ~(1<<USB_LED_SCROLL_LOCK));
// set SCROLL LOCK LED when the mouse layer is active, CAPS LOCK when PROG layer is active
if (layer == MOUSE1 || layer == MOUSE2) {
led_set(host_keyboard_leds() | (1<<USB_LED_SCROLL_LOCK));
} else if (layer == PROG1 || layer == PROG2) {
led_set(host_keyboard_leds() | (1<<USB_LED_CAPS_LOCK));
}
}
}

void tap_helper(keyrecord_t *record, uint16_t orig_mod, uint16_t macro_mod, uint16_t macro_kc ) {
if (record->event.pressed) {
if (record->tap.count > 0 && !record->tap.interrupted) {
Expand Down
8 changes: 4 additions & 4 deletions keyboards/cannonkeys/satisfaction75/satisfaction75.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,22 +243,22 @@ void via_custom_value_command(uint8_t *data, uint8_t length) {


void read_host_led_state(void) {
uint8_t leds = host_keyboard_leds();
if (leds & (1 << USB_LED_NUM_LOCK)) {
led_t led_state = host_keyboard_led_state();
if (led_state.num_lock) {
if (led_numlock == false){
led_numlock = true;}
} else {
if (led_numlock == true){
led_numlock = false;}
}
if (leds & (1 << USB_LED_CAPS_LOCK)) {
if (led_state.caps_lock) {
if (led_capslock == false){
led_capslock = true;}
} else {
if (led_capslock == true){
led_capslock = false;}
}
if (leds & (1 << USB_LED_SCROLL_LOCK)) {
if (led_state.scroll_lock) {
if (led_scrolllock == false){
led_scrolllock = true;}
} else {
Expand Down
8 changes: 4 additions & 4 deletions keyboards/ckeys/washington/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ bool oled_task_user(void) {
}

// Host Keyboard LED Status
uint8_t usb_led = host_keyboard_leds();
oled_write_P(IS_LED_ON(usb_led, USB_LED_NUM_LOCK) ? PSTR("NUMLCK ") : PSTR(" "), false);
oled_write_P(IS_LED_ON(usb_led, USB_LED_CAPS_LOCK) ? PSTR("CAPLCK ") : PSTR(" "), false);
oled_write_P(IS_LED_ON(usb_led, USB_LED_SCROLL_LOCK) ? PSTR("SCRLCK ") : PSTR(" "), false);
led_t led_state = host_keyboard_led_state();
oled_write_P(led_state.num_lock ? PSTR("NUMLCK ") : PSTR(" "), false);
oled_write_P(led_state.caps_lock ? PSTR("CAPLCK ") : PSTR(" "), false);
oled_write_P(led_state.scroll_lock ? PSTR("SCRLCK ") : PSTR(" "), false);
return false;
}
#endif
9 changes: 5 additions & 4 deletions keyboards/converter/ibm_terminal/led.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "led.h"


void led_set(uint8_t usb_led)
bool led_update_kb(led_t led_state)
{
uint8_t ps2_led = 0;
if (usb_led & (1<<USB_LED_SCROLL_LOCK))
if (led_state.scroll_lock)
ps2_led |= (1<<PS2_LED_SCROLL_LOCK);
if (usb_led & (1<<USB_LED_NUM_LOCK))
if (led_state.num_lock)
ps2_led |= (1<<PS2_LED_NUM_LOCK);
if (usb_led & (1<<USB_LED_CAPS_LOCK))
if (led_state.caps_lock)
ps2_led |= (1<<PS2_LED_CAPS_LOCK);
ps2_host_set_led(ps2_led);
return false;
}
10 changes: 5 additions & 5 deletions keyboards/crkbd/keymaps/oled_sample/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,12 @@ void render_layer_state(void) {
oled_write_P(PSTR("Raise"), layer_state_is(_RAISE));
}

void render_keylock_status(uint8_t led_usb_state) {
void render_keylock_status(led_t led_state) {
oled_write_P(PSTR("Lock:"), false);
oled_write_P(PSTR(" "), false);
oled_write_P(PSTR("N"), led_usb_state & (1 << USB_LED_NUM_LOCK));
oled_write_P(PSTR("C"), led_usb_state & (1 << USB_LED_CAPS_LOCK));
oled_write_ln_P(PSTR("S"), led_usb_state & (1 << USB_LED_SCROLL_LOCK));
oled_write_P(PSTR("N"), led_state.num_lock);
oled_write_P(PSTR("C"), led_state.caps_lock);
oled_write_ln_P(PSTR("S"), led_state.scroll_lock);
}

void render_mod_status(uint8_t modifiers) {
Expand Down Expand Up @@ -183,7 +183,7 @@ void render_bootmagic_status(void) {
void render_status_main(void) {
/* Show Keyboard Layout */
render_default_layer_state();
render_keylock_status(host_keyboard_leds());
render_keylock_status(host_keyboard_led_state());
render_mod_status(get_mods());
render_bootmagic_status();

Expand Down
8 changes: 4 additions & 4 deletions keyboards/crkbd/lib/host_led_state_reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ char host_led_state_str[24];

const char *read_host_led_state(void)
{
uint8_t leds = host_keyboard_leds();
led_t led_state = host_keyboard_led_state();
snprintf(host_led_state_str, sizeof(host_led_state_str), "NL:%s CL:%s SL:%s",
(leds & (1 << USB_LED_NUM_LOCK)) ? "on" : "- ",
(leds & (1 << USB_LED_CAPS_LOCK)) ? "on" : "- ",
(leds & (1 << USB_LED_SCROLL_LOCK)) ? "on" : "- ");
(led_state.num_lock) ? "on" : "- ",
(led_state.caps_lock) ? "on" : "- ",
(led_state.scroll_lock) ? "on" : "- ");

return host_led_state_str;
}
4 changes: 2 additions & 2 deletions keyboards/duck/octagon/v1/v1.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ void backlight_set(uint8_t level) {
bool led_update_kb(led_t led_state) {
bool res = led_update_user(led_state);
if(res) {
backlight_os_state & (1<<USB_LED_CAPS_LOCK) ? (PORTB &= ~0b00000001) : (PORTB |= 0b00000001);
backlight_os_state & (1<<USB_LED_SCROLL_LOCK) ? (PORTB &= ~0b00010000) : (PORTB |= 0b00010000);
backlight_os_state & 2 ? (PORTB &= ~0b00000001) : (PORTB |= 0b00000001);
backlight_os_state & 4 ? (PORTB &= ~0b00010000) : (PORTB |= 0b00010000);
}
return res;
}
10 changes: 5 additions & 5 deletions keyboards/duck/octagon/v2/v2.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,17 @@ bool led_update_kb(led_t led_state) {
bool res = led_update_user(led_state);
if(res) {
bool status[7] = {
backlight_os_state & (1<<USB_LED_CAPS_LOCK),
backlight_os_state & (1<<USB_LED_SCROLL_LOCK),
backlight_os_state & (1<<USB_LED_NUM_LOCK),
backlight_os_state & 2,
backlight_os_state & 4,
backlight_os_state & 1,
backlight_layer_state & (1<<1),
backlight_layer_state & (1<<2),
backlight_layer_state & (1<<3),
backlight_layer_state & (1<<4)
};
indicator_leds_set(status);
backlight_os_state & (1<<USB_LED_CAPS_LOCK) ? (PORTB &= ~0b00000001) : (PORTB |= 0b00000001);
backlight_os_state & (1<<USB_LED_SCROLL_LOCK) ? (PORTB &= ~0b00010000) : (PORTB |= 0b00010000);
backlight_os_state & 2 ? (PORTB &= ~0b00000001) : (PORTB |= 0b00000001);
backlight_os_state & 4 ? (PORTB &= ~0b00010000) : (PORTB |= 0b00010000);
}
return res;
}
83 changes: 0 additions & 83 deletions keyboards/duck/tcv3/tcv3.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,69 +24,6 @@ enum BACKLIGHT_AREAS {
BACKLIGHT_SWITCH = 0b0001111
};

// uint8_t backlight_rgb_r = 255;
// uint8_t backlight_rgb_g = 0;
// uint8_t backlight_rgb_b = 0;
// uint8_t backlight_os_state = 0;
// uint32_t backlight_layer_state = 0;

// void backlight_toggle_rgb(bool enabled)
// {
// if(enabled) {
// uint8_t rgb[17][3] = {
// {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b},
// {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b},
// {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b},
// {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b},
// {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b},
// {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b},
// {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b},
// {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b},
// {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b},
// {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b},
// {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b},
// {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b},
// {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b},
// {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b},
// {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b},
// {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b},
// {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b}
// };
// backlight_set_rgb(rgb);
// } else {
// uint8_t rgb[17][3] = {
// {0, 0, 0},
// {0, 0, 0},
// {0, 0, 0},
// {0, 0, 0},
// {0, 0, 0},
// {0, 0, 0},
// {0, 0, 0},
// {0, 0, 0},
// {0, 0, 0},
// {0, 0, 0},
// {0, 0, 0},
// {0, 0, 0},
// {0, 0, 0},
// {0, 0, 0},
// {0, 0, 0},
// {0, 0, 0},
// {0, 0, 0}
// };
// backlight_set_rgb(rgb);
// }
// }

// void backlight_set_rgb(uint8_t cfg[17][3])
// {
// cli();
// for(uint8_t i = 0; i < 17; ++i) {
// send_color(cfg[i][0], cfg[i][1], cfg[i][2], Device_PCBRGB);
// }
// sei();
// show();
// }

// Q5, Q6, Q7 is connected to B1 - alphas
// Q8, Q9 is connected to B2 - frow
// Q1, Q2, Q3 is connected to B3 - mods
Expand All @@ -99,26 +36,6 @@ void backlight_set(uint8_t level) {
level & BACKLIGHT_MACRO ? (PORTE |= 0b01000000) : (PORTE &= ~0b01000000);
}

// // Port from backlight_update_state
// bool led_update_kb(led_t led_state) {
// bool res = led_update_user(led_state);
// if(res) {
// bool status[7] = {
// backlight_os_state & (1<<USB_LED_CAPS_LOCK),
// backlight_os_state & (1<<USB_LED_SCROLL_LOCK),
// backlight_os_state & (1<<USB_LED_NUM_LOCK),
// backlight_layer_state & (1<<1),
// backlight_layer_state & (1<<2),
// backlight_layer_state & (1<<3),
// backlight_layer_state & (1<<4)
// };
// indicator_leds_set(status);
// backlight_os_state & (1<<USB_LED_CAPS_LOCK) ? (PORTB &= ~0b00000001) : (PORTB |= 0b00000001);
// backlight_os_state & (1<<USB_LED_SCROLL_LOCK) ? (PORTB &= ~0b00010000) : (PORTB |= 0b00010000);
// }
// return res;
// }

// U5 Pin 1, 2, 3 connected to top left LEDs

// U6 Pin 1, 2, 3 connected to bottom right leds col of 3
Expand Down
20 changes: 8 additions & 12 deletions keyboards/ergodox_ez/keymaps/bepo_tm_style/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,12 +253,7 @@ void matrix_scan_user(void) {
};

// The state of the LEDs requested by the system, as a bitmask.
static uint8_t sys_led_state = 0;

// Use these masks to read the system LEDs state.
static const uint8_t sys_led_mask_num_lock = 1 << USB_LED_NUM_LOCK;
static const uint8_t sys_led_mask_caps_lock = 1 << USB_LED_CAPS_LOCK;
static const uint8_t sys_led_mask_scroll_lock = 1 << USB_LED_SCROLL_LOCK;
static led_t sys_led_state = {0};

// Value to use to switch LEDs on. The default value of 255 is far too bright.
static const uint8_t max_led_value = 20;
Expand Down Expand Up @@ -294,25 +289,26 @@ void led_3_off(void) {
}

// Called when the computer wants to change the state of the keyboard LEDs.
void led_set_user(uint8_t usb_led) {
sys_led_state = usb_led;
bool led_update_user(led_t led_state) {
sys_led_state = led_state;
if (LAYER_ON(SYSLEDS)) {
if (sys_led_state & sys_led_mask_caps_lock) {
if (sys_led_state.caps_lock) {
led_1_on();
} else {
led_1_off();
}
if (sys_led_state & sys_led_mask_num_lock) {
if (sys_led_state.num_lock) {
led_2_on();
} else {
led_2_off();
}
if (sys_led_state & sys_led_mask_scroll_lock) {
if (sys_led_state.scroll_lock) {
led_3_on();
} else {
led_3_off();
}
}
return false;
}

layer_state_t layer_state_set_user(layer_state_t state) {
Expand All @@ -327,7 +323,7 @@ layer_state_t layer_state_set_user(layer_state_t state) {
}

if (LAYER_ON(SYSLEDS)) {
led_set_user(sys_led_state);
led_update_user(sys_led_state);
return state;
}

Expand Down
28 changes: 17 additions & 11 deletions keyboards/gh80_3000/keymaps/ansi_std/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,29 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
)
};

void led_set_user(uint8_t usb_led) {

if (usb_led & (1 << USB_LED_NUM_LOCK)) {
DDRB |= (1 << 5); PORTB &= ~(1 << 5);
bool led_update_user(led_t led_state) {
if (led_state.num_lock) {
DDRB |= (1 << 5);
PORTB &= ~(1 << 5);
} else {
DDRB &= ~(1 << 5); PORTB &= ~(1 << 5);
DDRB &= ~(1 << 5);
PORTB &= ~(1 << 5);
}

if (usb_led & (1 << USB_LED_CAPS_LOCK)) {
DDRB |= (1 << 6); PORTB &= ~(1 << 6);
if (led_state.caps_lock) {
DDRB |= (1 << 6);
PORTB &= ~(1 << 6);
} else {
DDRB &= ~(1 << 6); PORTB &= ~(1 << 6);
DDRB &= ~(1 << 6);
PORTB &= ~(1 << 6);
}

if (usb_led & (1 << USB_LED_SCROLL_LOCK)) {
DDRB |= (1 << 7); PORTB &= ~(1 << 7);
if (led_state.scroll_lock) {
DDRB |= (1 << 7);
PORTB &= ~(1 << 7);
} else {
DDRB &= ~(1 << 7); PORTB &= ~(1 << 7);
DDRB &= ~(1 << 7);
PORTB &= ~(1 << 7);
}
return false;
}
Loading

0 comments on commit 7ff80a5

Please sign in to comment.