static void layer_pop(uint8_t local_id) {
	uint8_t id = layer_ids[local_id];
	if (id != 0) {
		main_layers_pop_id(id);
		layer_ids[local_id] = 0;
	}
}
static void layer_push(uint8_t local_id) {
	uint8_t keycode = kb_layout_get(LAYER, ROW, COL);
	layer_pop(local_id);
	// Only the topmost layer on the stack should be in sticky once state, pop
	//  the top layer if it is in sticky once state
	uint8_t topSticky = main_layers_peek_sticky(0);
	if (topSticky == eStickyOnceDown || topSticky == eStickyOnceUp) {
		main_layers_pop_id(main_layers_peek(0));
	}
	layer_ids[local_id] = main_layers_push(keycode, eStickyNone);
}
Exemple #3
0
/*
 * Exec key
 * - Execute the keypress or keyrelease function (if it exists) of the key at
 *   the current possition.
 */
void main_exec_key(void) {
	void (*key_function)(void) =
		( (is_pressed)
		  ? kb_layout_press_get(layer, row, col)
		  : kb_layout_release_get(layer, row, col) );

	if (key_function)
		(*key_function)();

	// If the current layer is in the sticky once up state and a key defined
	//  for this layer (a non-transparent key) was pressed, pop the layer
	if (layers[layers_head].sticky == eStickyOnceUp && main_arg_any_non_trans_key_pressed)
		main_layers_pop_id(layers_head);
}
Exemple #4
0
/*
 * [name]
 *   Numpad off
 *
 * [description]
 *   Set the numpad to off (pop the layer element created by "numpad on" out of
 *   the stack) and toggle numlock (regardless of whether or not numlock is
 *   currently on)
 *
 * [note]
 *   Meant to be assigned (along with "numpad on") instead of a normal numlock
 *   key
 */
void kbfun_layer_pop_numpad(void) {
	main_layers_pop_id(numpad_layer_id);
	numpad_layer_id = 0;
	numpad_toggle_numlock();
}
Exemple #5
0
/*
 * [name]
 *   Numpad on
 *
 * [description]
 *   Set the numpad to on (put the numpad layer, specified in the keymap, in an
 *   element at the top of the layer stack, and record that element's id) and
 *   toggle numlock (regardless of whether or not numlock is currently on)
 *
 * [note]
 *   Meant to be assigned (along with "numpad off") instead of a normal numlock
 *   key
 */
void kbfun_layer_push_numpad(void) {
	uint8_t keycode = kb_layout_get(LAYER, ROW, COL);
	main_layers_pop_id(numpad_layer_id);
	numpad_layer_id = main_layers_push(keycode, eStickyNone);
	numpad_toggle_numlock();
}