Refactor some led_set_kb instances (#19179)
* Refactor some led_set_kb instances * Apply suggestions from code review Co-authored-by: Ryan <fauxpark@gmail.com> Co-authored-by: Ryan <fauxpark@gmail.com>
This commit is contained in:
		
							parent
							
								
									ba6ee29040
								
							
						
					
					
						commit
						99cd0b13e1
					
				
					 18 changed files with 165 additions and 202 deletions
				
			
		| 
						 | 
				
			
			@ -95,22 +95,25 @@ void backlight_update_state()
 | 
			
		|||
  show();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void led_set_kb(uint8_t usb_led)
 | 
			
		||||
{
 | 
			
		||||
  if(usb_led & (1<<USB_LED_CAPS_LOCK)) {
 | 
			
		||||
    backlight_state_led |=   1<<STATE_LED_CAPS_LOCK;
 | 
			
		||||
  } else {
 | 
			
		||||
    backlight_state_led &= ~(1<<STATE_LED_CAPS_LOCK);
 | 
			
		||||
  }
 | 
			
		||||
  if(usb_led & (1<<USB_LED_SCROLL_LOCK)) {
 | 
			
		||||
    backlight_state_led |=   1<<STATE_LED_SCROLL_LOCK;
 | 
			
		||||
  } else {
 | 
			
		||||
    backlight_state_led &= ~(1<<STATE_LED_SCROLL_LOCK);
 | 
			
		||||
  }
 | 
			
		||||
  if(usb_led & (1<<USB_LED_NUM_LOCK)) {
 | 
			
		||||
    backlight_state_led |=   1<<STATE_LED_NUM_LOCK;
 | 
			
		||||
  } else {
 | 
			
		||||
    backlight_state_led &= ~(1<<STATE_LED_NUM_LOCK);
 | 
			
		||||
  }
 | 
			
		||||
  backlight_update_state();
 | 
			
		||||
bool led_update_kb(led_t led_state) {
 | 
			
		||||
    bool res = led_update_user(led_state);
 | 
			
		||||
    if(res) {
 | 
			
		||||
      if(led_state.caps_lock) {
 | 
			
		||||
        backlight_state_led |=   1<<STATE_LED_CAPS_LOCK;
 | 
			
		||||
      } else {
 | 
			
		||||
        backlight_state_led &= ~(1<<STATE_LED_CAPS_LOCK);
 | 
			
		||||
      }
 | 
			
		||||
      if(led_state.scroll_lock) {
 | 
			
		||||
        backlight_state_led |=   1<<STATE_LED_SCROLL_LOCK;
 | 
			
		||||
      } else {
 | 
			
		||||
        backlight_state_led &= ~(1<<STATE_LED_SCROLL_LOCK);
 | 
			
		||||
      }
 | 
			
		||||
      if(led_state.num_lock) {
 | 
			
		||||
        backlight_state_led |=   1<<STATE_LED_NUM_LOCK;
 | 
			
		||||
      } else {
 | 
			
		||||
        backlight_state_led &= ~(1<<STATE_LED_NUM_LOCK);
 | 
			
		||||
      }
 | 
			
		||||
      backlight_update_state();
 | 
			
		||||
    }
 | 
			
		||||
    return res;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue