forked from mirrors/qmk_userspace
		
	helper to compare current layer_state to user layer
Performs the same bit comparison that the layer_move functions perform
This commit is contained in:
		
					parent
					
						
							
								fc54d62111
							
						
					
				
			
			
				commit
				
					
						1620d78e73
					
				
			
		
					 2 changed files with 12 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -88,6 +88,16 @@ void layer_clear(void)
 | 
			
		|||
    layer_state_set(0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool layer_state_is(uint8_t layer)
 | 
			
		||||
{
 | 
			
		||||
    return layer_state_cmp(layer_state, layer);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool layer_state_cmp(uint32_t cmp_layer_state, uint8_t layer) {
 | 
			
		||||
    if (layer == 0) { return cmp_layer_state == 0; }
 | 
			
		||||
    return (cmp_layer_state & (1UL<<layer)) > 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void layer_move(uint8_t layer)
 | 
			
		||||
{
 | 
			
		||||
    layer_state_set(1UL<<layer);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -51,6 +51,8 @@ void default_layer_xor(uint32_t state);
 | 
			
		|||
extern uint32_t layer_state;
 | 
			
		||||
void layer_debug(void);
 | 
			
		||||
void layer_clear(void);
 | 
			
		||||
bool layer_state_is(uint8_t layer);
 | 
			
		||||
bool layer_state_cmp(uint32_t layer1, uint8_t layer2);
 | 
			
		||||
void layer_move(uint8_t layer);
 | 
			
		||||
void layer_on(uint8_t layer);
 | 
			
		||||
void layer_off(uint8_t layer);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue