minor cleanup

master
Stefan Dorn 2016-02-04 04:38:18 +00:00
parent e71b8fbeb0
commit 2159af0050
1 changed files with 117 additions and 121 deletions

View File

@ -1,4 +1,3 @@
// vim: ts=4 sw=4 sts=4
/* ----------------------------------------------------------------------------
* main()
* ----------------------------------------------------------------------------
@ -20,7 +19,8 @@
// ----------------------------------------------------------------------------
#define MAX_ACTIVE_LAYERS 20
// TODO remove this; for now we'll just limit it to the number of layers
#define MAX_ACTIVE_LAYERS KB_LAYERS
// ----------------------------------------------------------------------------
@ -34,9 +34,6 @@ static bool main_kb_was_transparent[KB_ROWS][KB_COLUMNS];
uint8_t main_layers_pressed[KB_ROWS][KB_COLUMNS];
uint8_t main_loop_row;
uint8_t main_loop_col;
uint8_t main_arg_layer;
uint8_t main_arg_layer_offset;
uint8_t main_arg_row;
@ -80,8 +77,8 @@ int main(void) {
// - see the keyboard layout file ("keyboard/ergodox/layout/*.c") for
// which key is assigned which function (per layer)
// - see "lib/key-functions/public/*.c" for the function definitions
for (int row=0; row<KB_ROWS; row++) {
for (int col=0; col<KB_COLUMNS; col++) {
for (uint8_t row=0; row<KB_ROWS; row++) {
for (uint8_t col=0; col<KB_COLUMNS; col++) {
main_arg_is_pressed = (*main_kb_is_pressed)[row][col];
main_arg_was_pressed = (*main_kb_was_pressed)[row][col];
@ -111,16 +108,11 @@ int main(void) {
_delay_ms(MAKEFILE_DEBOUNCE_TIME);
// update LEDs
if (keyboard_leds & (1<<0)) { kb_led_num_on(); }
else { kb_led_num_off(); }
if (keyboard_leds & (1<<1)) { kb_led_caps_on(); }
else { kb_led_caps_off(); }
if (keyboard_leds & (1<<2)) { kb_led_scroll_on(); }
else { kb_led_scroll_off(); }
if (keyboard_leds & (1<<3)) { kb_led_compose_on(); }
else { kb_led_compose_off(); }
if (keyboard_leds & (1<<4)) { kb_led_kana_on(); }
else { kb_led_kana_off(); }
if (keyboard_leds & (1<<0)) { kb_led_num_on(); } else { kb_led_num_off(); }
if (keyboard_leds & (1<<1)) { kb_led_caps_on(); } else { kb_led_caps_off(); }
if (keyboard_leds & (1<<2)) { kb_led_scroll_on(); } else { kb_led_scroll_off(); }
if (keyboard_leds & (1<<3)) { kb_led_compose_on(); } else { kb_led_compose_off(); }
if (keyboard_leds & (1<<4)) { kb_led_kana_on(); } else { kb_led_kana_off(); }
}
return 0;
@ -183,15 +175,17 @@ void main_exec_key(void) {
* - failure: 0 (default) (out of bounds)
*/
uint8_t main_layers_peek(uint8_t offset) {
if (offset <= layers_head)
if (offset <= layers_head) {
return layers[layers_head - offset].layer;
}
return 0; // default, or error
}
uint8_t main_layers_peek_sticky(uint8_t offset) {
if (offset <= layers_head)
if (offset <= layers_head) {
return layers[layers_head - offset].sticky;
}
return 0; // default, or error
}
@ -231,7 +225,7 @@ uint8_t main_layers_push(uint8_t layer, uint8_t sticky) {
*/
void main_layers_pop_id(uint8_t id) {
// look for the element with the id we want to pop
for (uint8_t element=1; element<=layers_head; element++)
for (uint8_t element=1; element<=layers_head; element++) {
// if we find it
if (layers[element].id == id) {
// move all layers above it down one
@ -247,6 +241,7 @@ void main_layers_pop_id(uint8_t id) {
layers_head--;
}
}
}
/*
* get_offset_id()
@ -261,13 +256,14 @@ void main_layers_pop_id(uint8_t id) {
*/
uint8_t main_layers_get_offset_id(uint8_t id) {
// look for the element with the id we want to get the offset of
for (uint8_t element=1; element<=layers_head; element++)
for (uint8_t element=1; element<=layers_head; element++) {
// if we find it
if (layers[element].id == id)
if (layers[element].id == id) {
return (layers_head - element);
}
}
return 0; // default, or error
}
/* ----------------------------------------------------------------------------