Get rid of USB_LED_NUM_LOCK
(#21424)
This commit is contained in:
parent
7ff80a57cb
commit
9ab16e62f7
25 changed files with 91 additions and 133 deletions
|
@ -59,16 +59,17 @@ void keyboard_pre_init_user(void) {
|
||||||
setPinOutput(B0);
|
setPinOutput(B0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void led_set_user(uint8_t usb_led) {
|
bool led_update_user(led_t led_state) {
|
||||||
if (IS_LED_ON(usb_led, USB_LED_NUM_LOCK)) {
|
if (led_state.num_lock) {
|
||||||
writePinLow(D5);
|
writePinLow(D5);
|
||||||
} else {
|
} else {
|
||||||
writePinHigh(D5);
|
writePinHigh(D5);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_LED_ON(usb_led, USB_LED_CAPS_LOCK)) {
|
if (led_state.caps_lock) {
|
||||||
writePinLow(B0);
|
writePinLow(B0);
|
||||||
} else {
|
} else {
|
||||||
writePinHigh(B0);
|
writePinHigh(B0);
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
// Force-enable Numlock
|
||||||
if (!(usb_led & (1<<USB_LED_NUM_LOCK))) {
|
if (!led_state.num_lock) {
|
||||||
register_code(KC_NUM_LOCK);
|
register_code(KC_NUM_LOCK);
|
||||||
unregister_code(KC_NUM_LOCK);
|
unregister_code(KC_NUM_LOCK);
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -266,10 +266,10 @@ void render_status(void) {
|
||||||
|
|
||||||
oled_write_P(PSTR("\n"), false);
|
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(PSTR("Mode:"), false);
|
||||||
oled_write_P(IS_LED_ON(led_usb_state, USB_LED_NUM_LOCK) ? PSTR(" NUM ") : PSTR("\n"), false);
|
oled_write_P(led_state.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.caps_lock ? PSTR(" CAPS") : PSTR("\n"), false);
|
||||||
|
|
||||||
# ifdef RGB_MATRIX_ENABLE
|
# ifdef RGB_MATRIX_ENABLE
|
||||||
oled_write_P(PSTR("\n"), false);
|
oled_write_P(PSTR("\n"), false);
|
||||||
|
|
|
@ -25,7 +25,6 @@ enum dz60rgb_keycodes {
|
||||||
#define _V_V_V_ KC_TRNS
|
#define _V_V_V_ KC_TRNS
|
||||||
#define LT_CAPS LT(_NAV, KC_CAPS)
|
#define LT_CAPS LT(_NAV, KC_CAPS)
|
||||||
#define LT_DEL LT(_RGB, KC_DEL)
|
#define LT_DEL LT(_RGB, KC_DEL)
|
||||||
extern bool autoshift_enabled;
|
|
||||||
#define MT_SLSH RSFT_T(KC_SLSH)
|
#define MT_SLSH RSFT_T(KC_SLSH)
|
||||||
#define MT_APP RALT_T(KC_APP)
|
#define MT_APP RALT_T(KC_APP)
|
||||||
#define LM_LALT LM(_FNM, MOD_LALT)
|
#define LM_LALT LM(_FNM, MOD_LALT)
|
||||||
|
@ -92,12 +91,12 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
bool rgb_matrix_indicators_user(void) {
|
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) {
|
if (!g_suspend_state && rgb_matrix_config.enable) {
|
||||||
switch (get_highest_layer(layer_state)) {
|
switch (get_highest_layer(layer_state)) {
|
||||||
case _NAV:
|
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(13, 0xFF, 0x00, 0x00);
|
||||||
rgb_matrix_set_color(19, 0xFF, 0xFF, 0x00);
|
rgb_matrix_set_color(19, 0xFF, 0xFF, 0x00);
|
||||||
} else {
|
} else {
|
||||||
|
@ -204,17 +203,11 @@ bool rgb_matrix_indicators_user(void) {
|
||||||
rgb_matrix_set_color(41, 0xFF, 0x00, 0x40); // ctrl+delete
|
rgb_matrix_set_color(41, 0xFF, 0x00, 0x40); // ctrl+delete
|
||||||
rgb_matrix_set_color(43, 0xFF, 0x00, 0x40); // ctrl+slash
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this_led & (1 << USB_LED_CAPS_LOCK)) {
|
if (led_state.caps_lock) {
|
||||||
rgb_matrix_set_color(40, 0xFF, 0xFF, 0xFF);
|
rgb_matrix_set_color(40, 0xFF, 0xFF, 0xFF);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -58,7 +58,7 @@ void rgb_matrix_layer_helper (uint8_t red, uint8_t green, uint8_t blue) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool rgb_matrix_indicators_user(void) {
|
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) {
|
if (!g_suspend_state && rgb_matrix_config.enable) {
|
||||||
switch (get_highest_layer(layer_state)) {
|
switch (get_highest_layer(layer_state)) {
|
||||||
|
@ -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);
|
rgb_matrix_set_color(40, 0xFF, 0xFF, 0xFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (get_highest_layer(layer_state)) {
|
switch (get_highest_layer(layer_state)) {
|
||||||
case _LAYER3:
|
case _LAYER3:
|
||||||
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(13, 0xFF, 0x00, 0x00);
|
||||||
} else {
|
} else {
|
||||||
rgb_matrix_set_color(13, 0x00, 0x00, 0x00);
|
rgb_matrix_set_color(13, 0x00, 0x00, 0x00);
|
||||||
|
@ -152,22 +152,3 @@ bool rgb_matrix_indicators_user(void) {
|
||||||
}
|
}
|
||||||
return false;
|
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;
|
|
||||||
}
|
|
||||||
|
|
|
@ -25,7 +25,6 @@ enum dz65rgb_keycodes {
|
||||||
#define TG_NKRO MAGIC_TOGGLE_NKRO
|
#define TG_NKRO MAGIC_TOGGLE_NKRO
|
||||||
#define _V_V_V_ KC_TRNS
|
#define _V_V_V_ KC_TRNS
|
||||||
#define LT_CAPS LT(_NAV, KC_CAPS)
|
#define LT_CAPS LT(_NAV, KC_CAPS)
|
||||||
extern bool autoshift_enabled;
|
|
||||||
#define MT_APP RALT_T(KC_APP)
|
#define MT_APP RALT_T(KC_APP)
|
||||||
#define LM_LALT LM(_FNM, MOD_LALT)
|
#define LM_LALT LM(_FNM, MOD_LALT)
|
||||||
|
|
||||||
|
@ -87,12 +86,12 @@ bool rgb_matrix_indicators_user(void) {
|
||||||
rgb_matrix_set_color(8, 0xFF, 0xFF, 0xFF);
|
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) {
|
if (!g_suspend_state && rgb_matrix_config.enable) {
|
||||||
switch (get_highest_layer(layer_state)) {
|
switch (get_highest_layer(layer_state)) {
|
||||||
case _NAV:
|
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(17, 0xFF, 0x00, 0x00);
|
||||||
rgb_matrix_set_color(26, 0xFF, 0xFF, 0x00);
|
rgb_matrix_set_color(26, 0xFF, 0xFF, 0x00);
|
||||||
} else {
|
} else {
|
||||||
|
@ -171,12 +170,6 @@ bool rgb_matrix_indicators_user(void) {
|
||||||
rgb_matrix_set_color(24, 0xFF, 0x40, 0x00); // KC_MPRV
|
rgb_matrix_set_color(24, 0xFF, 0x40, 0x00); // KC_MPRV
|
||||||
rgb_matrix_set_color(25, 0xFF, 0x40, 0x00);
|
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(6, 0xFF, 0x80, 0x00); //RGB_MOD
|
||||||
rgb_matrix_set_color(48, 0xFF, 0x80, 0x00);
|
rgb_matrix_set_color(48, 0xFF, 0x80, 0x00);
|
||||||
rgb_matrix_set_color(29, 0xFF, 0x80, 0x00); //RGB_MOD
|
rgb_matrix_set_color(29, 0xFF, 0x80, 0x00); //RGB_MOD
|
||||||
|
|
|
@ -96,9 +96,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t * record) {
|
||||||
return true;
|
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
|
// output high
|
||||||
DDRD |= (1<<6);
|
DDRD |= (1<<6);
|
||||||
PORTD |= (1<<6);
|
PORTD |= (1<<6);
|
||||||
|
@ -107,7 +107,7 @@ void led_set_user(uint8_t usb_led)
|
||||||
DDRD &= ~(1<<6);
|
DDRD &= ~(1<<6);
|
||||||
PORTD &= ~(1<<6);
|
PORTD &= ~(1<<6);
|
||||||
}
|
}
|
||||||
if (usb_led & (1<<USB_LED_NUM_LOCK)) {
|
if (led_state.num_lock) {
|
||||||
// output low
|
// output low
|
||||||
DDRC |= (1<<7);
|
DDRC |= (1<<7);
|
||||||
PORTC |= ~(1<<7);
|
PORTC |= ~(1<<7);
|
||||||
|
@ -116,4 +116,5 @@ void led_set_user(uint8_t usb_led)
|
||||||
DDRC &= ~(1<<7);
|
DDRC &= ~(1<<7);
|
||||||
PORTC &= ~(1<<7);
|
PORTC &= ~(1<<7);
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,9 +109,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t * record) {
|
||||||
return true;
|
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
|
// output high
|
||||||
DDRD |= (1<<6);
|
DDRD |= (1<<6);
|
||||||
PORTD |= (1<<6);
|
PORTD |= (1<<6);
|
||||||
|
@ -120,7 +120,7 @@ void led_set_user(uint8_t usb_led)
|
||||||
DDRD &= ~(1<<6);
|
DDRD &= ~(1<<6);
|
||||||
PORTD &= ~(1<<6);
|
PORTD &= ~(1<<6);
|
||||||
}
|
}
|
||||||
if (usb_led & (1<<USB_LED_NUM_LOCK)) {
|
if (led_state.num_lock) {
|
||||||
// output low
|
// output low
|
||||||
DDRC |= (1<<7);
|
DDRC |= (1<<7);
|
||||||
PORTC |= ~(1<<7);
|
PORTC |= ~(1<<7);
|
||||||
|
@ -129,4 +129,5 @@ void led_set_user(uint8_t usb_led)
|
||||||
DDRC &= ~(1<<7);
|
DDRC &= ~(1<<7);
|
||||||
PORTC &= ~(1<<7);
|
PORTC &= ~(1<<7);
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,9 +96,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t * record) {
|
||||||
return true;
|
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
|
// output high
|
||||||
DDRD |= (1<<6);
|
DDRD |= (1<<6);
|
||||||
PORTD |= (1<<6);
|
PORTD |= (1<<6);
|
||||||
|
@ -107,7 +107,7 @@ void led_set_user(uint8_t usb_led)
|
||||||
DDRD &= ~(1<<6);
|
DDRD &= ~(1<<6);
|
||||||
PORTD &= ~(1<<6);
|
PORTD &= ~(1<<6);
|
||||||
}
|
}
|
||||||
if (usb_led & (1<<USB_LED_NUM_LOCK)) {
|
if (led_state.num_lock) {
|
||||||
// output low
|
// output low
|
||||||
DDRC |= (1<<7);
|
DDRC |= (1<<7);
|
||||||
PORTC |= ~(1<<7);
|
PORTC |= ~(1<<7);
|
||||||
|
@ -116,4 +116,5 @@ void led_set_user(uint8_t usb_led)
|
||||||
DDRC &= ~(1<<7);
|
DDRC &= ~(1<<7);
|
||||||
PORTC &= ~(1<<7);
|
PORTC &= ~(1<<7);
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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).
|
* both regular threads and ISRs, unlocked (during resume-from-sleep).
|
||||||
* In particular, I2C functions (interrupt-driven) should NOT be called from here.
|
* In particular, I2C functions (interrupt-driven) should NOT be called from here.
|
||||||
*/
|
*/
|
||||||
void led_set(uint8_t usb_led) {
|
bool led_update_kb(led_t led_state) {
|
||||||
msg_t msg;
|
bool res = led_update_user(led_state);
|
||||||
|
if (res) {
|
||||||
|
msg_t msg;
|
||||||
|
|
||||||
if (usb_led & (1<<USB_LED_NUM_LOCK)) {
|
if (led_state.num_lock) {
|
||||||
chSysUnconditionalLock();
|
chSysUnconditionalLock();
|
||||||
msg=(1 << 8) | TOGGLE_NUM_LOCK;
|
msg=(1 << 8) | TOGGLE_NUM_LOCK;
|
||||||
chMBPostI(&led_mailbox, msg);
|
chMBPostI(&led_mailbox, msg);
|
||||||
chSysUnconditionalUnlock();
|
chSysUnconditionalUnlock();
|
||||||
} else {
|
} else {
|
||||||
chSysUnconditionalLock();
|
chSysUnconditionalLock();
|
||||||
msg=(0 << 8) | TOGGLE_NUM_LOCK;
|
msg=(0 << 8) | TOGGLE_NUM_LOCK;
|
||||||
chMBPostI(&led_mailbox, msg);
|
chMBPostI(&led_mailbox, msg);
|
||||||
chSysUnconditionalUnlock();
|
chSysUnconditionalUnlock();
|
||||||
}
|
}
|
||||||
if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
|
if (led_state.caps_lock) {
|
||||||
chSysUnconditionalLock();
|
chSysUnconditionalLock();
|
||||||
msg=(1 << 8) | TOGGLE_CAPS_LOCK;
|
msg=(1 << 8) | TOGGLE_CAPS_LOCK;
|
||||||
chMBPostI(&led_mailbox, msg);
|
chMBPostI(&led_mailbox, msg);
|
||||||
chSysUnconditionalUnlock();
|
chSysUnconditionalUnlock();
|
||||||
} else {
|
} else {
|
||||||
chSysUnconditionalLock();
|
chSysUnconditionalLock();
|
||||||
msg=(0 << 8) | TOGGLE_CAPS_LOCK;
|
msg=(0 << 8) | TOGGLE_CAPS_LOCK;
|
||||||
chMBPostI(&led_mailbox, msg);
|
chMBPostI(&led_mailbox, msg);
|
||||||
chSysUnconditionalUnlock();
|
chSysUnconditionalUnlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -187,8 +187,9 @@ static THD_FUNCTION(LEDthread, arg) {
|
||||||
// initialize persistent variables
|
// initialize persistent variables
|
||||||
pwm_step_status = 4; //full brightness
|
pwm_step_status = 4; //full brightness
|
||||||
page_status = 0; //start frame 0 (all off/on)
|
page_status = 0; //start frame 0 (all off/on)
|
||||||
numlock_status = (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) ? 1 : 0;
|
led_t led_state = host_keyboard_led_state();
|
||||||
capslock_status = (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) ? 1 : 0;
|
numlock_status = led_state.num_lock ? 1 : 0;
|
||||||
|
capslock_status = led_state.caps_lock ? 1 : 0;
|
||||||
|
|
||||||
while(true) {
|
while(true) {
|
||||||
// wait for a message (asynchronous)
|
// wait for a message (asynchronous)
|
||||||
|
|
|
@ -377,13 +377,7 @@ layer_state_t layer_state_set_user(layer_state_t state) {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
void led_set_user(uint8_t usb_led) {
|
bool led_update_user(led_t led_state) {
|
||||||
|
bnumlock = led_state.num_lock;
|
||||||
if (usb_led & (1 << USB_LED_NUM_LOCK)) {
|
return false;
|
||||||
bnumlock = true;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
bnumlock = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -262,14 +262,11 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
void matrix_init_user(void) {
|
void matrix_init_user(void) {
|
||||||
// eeconfig_init(); // reset keyboard to a standard default state; useful when new releases messup with eeprom values
|
// 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)
|
// 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);
|
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) {
|
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||||
switch (keycode) {
|
switch (keycode) {
|
||||||
case CK_TRIPLEZERO:
|
case CK_TRIPLEZERO:
|
||||||
|
|
|
@ -26,7 +26,6 @@ uint16_t rgb_idle_seconds = 0;
|
||||||
uint16_t rgb_timer;
|
uint16_t rgb_timer;
|
||||||
uint8_t save_layer;
|
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_SHIFT (get_mods() & MOD_MASK_SHIFT)
|
||||||
#define MODS_CTRL (get_mods() & MOD_MASK_CTRL)
|
#define MODS_CTRL (get_mods() & MOD_MASK_CTRL)
|
||||||
|
|
||||||
|
@ -143,7 +142,7 @@ static void set_rgb_layer(int layer) {
|
||||||
void matrix_init_keymap(void) {
|
void matrix_init_keymap(void) {
|
||||||
set_rgb_layer(_QWERTY);
|
set_rgb_layer(_QWERTY);
|
||||||
// force numlock on upon startup
|
// force numlock on upon startup
|
||||||
if (!NUMLOCK_ON) {
|
if (!host_keyboard_led_state().num_lock) {
|
||||||
tap_code(KC_NUM_LOCK);
|
tap_code(KC_NUM_LOCK);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -89,8 +89,8 @@ tap_dance_action_t tap_dance_actions[] = {
|
||||||
[ALT_L1] = ACTION_TAP_DANCE_FN_ADVANCED(NULL,alt_finished, alt_reset)
|
[ALT_L1] = ACTION_TAP_DANCE_FN_ADVANCED(NULL,alt_finished, alt_reset)
|
||||||
};
|
};
|
||||||
|
|
||||||
void led_set_keymap(uint8_t usb_led) {
|
bool led_update_keymap(led_t led_state) {
|
||||||
if (usb_led & (1<<USB_LED_NUM_LOCK)) {
|
if (led_state.num_lock) {
|
||||||
numlock_on = true;
|
numlock_on = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -36,11 +36,12 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void led_set_user(uint8_t usb_led) {
|
bool led_update_user(led_t led_state) {
|
||||||
if (usb_led & (1 << USB_LED_NUM_LOCK)) {
|
if (led_state.num_lock) {
|
||||||
// Illuminate the LED under the Num Lock key
|
// Illuminate the LED under the Num Lock key
|
||||||
rgblight_sethsv_at(0, 0, 127, 1);
|
rgblight_sethsv_at(0, 0, 127, 1);
|
||||||
} else {
|
} else {
|
||||||
rgblight_sethsv_at(0, 0, 0, 1);
|
rgblight_sethsv_at(0, 0, 0, 1);
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,8 +173,8 @@ void render_layer_state(void) {
|
||||||
oled_write_P(PSTR(" Macro "), layer_state_is(_MACRO));
|
oled_write_P(PSTR(" Macro "), layer_state_is(_MACRO));
|
||||||
}
|
}
|
||||||
|
|
||||||
void render_keylock_status(uint8_t led_usb_state) {
|
void render_keylock_status(led_t led_state) {
|
||||||
oled_write_P(PSTR("NumLock"), led_usb_state & (1 << USB_LED_NUM_LOCK));
|
oled_write_P(PSTR("NumLock"), led_state.num_lock);
|
||||||
oled_write_P(PSTR(" "), false);
|
oled_write_P(PSTR(" "), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@ void render_layer_messages(void) {
|
||||||
void render_status(void) {
|
void render_status(void) {
|
||||||
/* Show Keyboard Layout */
|
/* Show Keyboard Layout */
|
||||||
render_layer_messages();
|
render_layer_messages();
|
||||||
render_keylock_status(host_keyboard_leds());
|
render_keylock_status(host_keyboard_led_state());
|
||||||
render_layer_state();
|
render_layer_state();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,23 +51,9 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool led_update_user(led_t led_state) {
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
void led_set_user(uint8_t usb_led) {
|
|
||||||
// Insert custom handling for CAPS_LOCK, NUM_LOCK, SCROLL_LOCK here
|
// Insert custom handling for CAPS_LOCK, NUM_LOCK, SCROLL_LOCK here
|
||||||
if (IS_LED_ON(usb_led, USB_LED_NUM_LOCK)) {
|
if (led_state.num_lock) {
|
||||||
writePinHigh(F4);
|
writePinHigh(F4);
|
||||||
writePinHigh(F1);
|
writePinHigh(F1);
|
||||||
writePinHigh(F5);
|
writePinHigh(F5);
|
||||||
|
@ -76,4 +62,5 @@ void led_set_user(uint8_t usb_led) {
|
||||||
writePinLow(F1);
|
writePinLow(F1);
|
||||||
writePinLow(F5);
|
writePinLow(F5);
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||||
case NUMPAD:
|
case NUMPAD:
|
||||||
if (record->event.pressed) {
|
if (record->event.pressed) {
|
||||||
layer_invert(L_NUMPAD);
|
layer_invert(L_NUMPAD);
|
||||||
bool num_lock = host_keyboard_leds() & 1<<USB_LED_NUM_LOCK;
|
bool num_lock = host_keyboard_led_state().num_lock;
|
||||||
if (num_lock != (bool)IS_LAYER_ON(L_NUMPAD)) {
|
if (num_lock != (bool)IS_LAYER_ON(L_NUMPAD)) {
|
||||||
tap_code(KC_NUM_LOCK); // Toggle Num Lock to match layer state.
|
tap_code(KC_NUM_LOCK); // Toggle Num Lock to match layer state.
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,16 +126,17 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
void matrix_init_user(void) {
|
void matrix_init_user(void) {
|
||||||
if (!(host_keyboard_leds() & (1<<USB_LED_NUM_LOCK))) {
|
if (!host_keyboard_led_state().num_lock) {
|
||||||
register_code(KC_NUM_LOCK);
|
register_code(KC_NUM_LOCK);
|
||||||
unregister_code(KC_NUM_LOCK);
|
unregister_code(KC_NUM_LOCK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
rgblight_mode(18);
|
rgblight_mode(18);
|
||||||
} else {
|
} else {
|
||||||
rgblight_mode(14);
|
rgblight_mode(14);
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -200,8 +200,9 @@ bool oled_task_user(void) {
|
||||||
int rowa = 0;
|
int rowa = 0;
|
||||||
|
|
||||||
//Set Indicator icon
|
//Set Indicator icon
|
||||||
if (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) { rown = 1; } else { rown = 0; }
|
led_t led_state = host_keyboard_led_state();
|
||||||
if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) { rowc = 1; } else { rowc = 0; }
|
if (led_state.num_lock) { rown = 1; } else { rown = 0; }
|
||||||
|
if (led_state.caps_lock) { rowc = 1; } else { rowc = 0; }
|
||||||
if (layer_state == L_LOWER) { rowl = 1; }
|
if (layer_state == L_LOWER) { rowl = 1; }
|
||||||
if (layer_state == L_RAISE) { rowr = 1; }
|
if (layer_state == L_RAISE) { rowr = 1; }
|
||||||
if (layer_state == L_ADJUST) { rowa = 1; }
|
if (layer_state == L_ADJUST) { rowa = 1; }
|
||||||
|
|
|
@ -200,8 +200,9 @@ bool oled_task_user(void) {
|
||||||
int rowa = 0;
|
int rowa = 0;
|
||||||
|
|
||||||
//Set Indicator icon
|
//Set Indicator icon
|
||||||
if (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) { rown = 1; } else { rown = 0; }
|
led_t led_state = host_keyboard_led_state();
|
||||||
if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) { rowc = 1; } else { rowc = 0; }
|
if (led_state.num_lock) { rown = 1; } else { rown = 0; }
|
||||||
|
if (led_state.caps_lock) { rowc = 1; } else { rowc = 0; }
|
||||||
if (layer_state == L_LOWER) { rowl = 1; }
|
if (layer_state == L_LOWER) { rowl = 1; }
|
||||||
if (layer_state == L_RAISE) { rowr = 1; }
|
if (layer_state == L_RAISE) { rowr = 1; }
|
||||||
if (layer_state == L_ADJUST) { rowa = 1; }
|
if (layer_state == L_ADJUST) { rowa = 1; }
|
||||||
|
|
|
@ -35,12 +35,13 @@ void keyboard_post_init_user(void) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void led_set_user(uint8_t usb_led) {
|
bool led_update_user(led_t led_state) {
|
||||||
if (IS_LED_ON(usb_led, USB_LED_NUM_LOCK)) {
|
if (led_state.num_lock) {
|
||||||
rgblight_sethsv_noeeprom(HSV_CYAN);
|
rgblight_sethsv_noeeprom(HSV_CYAN);
|
||||||
} else {
|
} else {
|
||||||
rgblight_sethsv_noeeprom(HSV_MAGENTA);
|
rgblight_sethsv_noeeprom(HSV_MAGENTA);
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void shutdown_user (void) {
|
void shutdown_user (void) {
|
||||||
|
|
|
@ -23,7 +23,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
/* FIXME: Add doxygen comments here. */
|
/* FIXME: Add doxygen comments here. */
|
||||||
|
|
||||||
/* keyboard LEDs */
|
/* keyboard LEDs */
|
||||||
#define USB_LED_NUM_LOCK 0
|
|
||||||
#define USB_LED_CAPS_LOCK 1
|
#define USB_LED_CAPS_LOCK 1
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -389,7 +389,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t* record)
|
||||||
/* KC_KP_1, KC_KP_2, ..., KC_KP_0, KC_KP_DOT */
|
/* KC_KP_1, KC_KP_2, ..., KC_KP_0, KC_KP_DOT */
|
||||||
(keycode >= KC_KP_1 && keycode <= KC_KP_DOT);
|
(keycode >= KC_KP_1 && keycode <= KC_KP_DOT);
|
||||||
|
|
||||||
if(numpadKeyPressed && !(host_keyboard_leds() & (1 << USB_LED_NUM_LOCK)))
|
if(numpadKeyPressed && !host_keyboard_led_state().num_lock)
|
||||||
{
|
{
|
||||||
add_key(KC_NUM_LOCK);
|
add_key(KC_NUM_LOCK);
|
||||||
send_keyboard_report();
|
send_keyboard_report();
|
||||||
|
|
Loading…
Reference in a new issue