diff options
author | Wojciech Siewierski <wojciech.siewierski@onet.pl> | 2016-04-02 18:00:28 +0200 |
---|---|---|
committer | Wojciech Siewierski <wojciech.siewierski@onet.pl> | 2016-04-02 19:29:01 +0200 |
commit | 4dce7258d1b31be0d91f6de0693a10917f514dd8 (patch) | |
tree | 073d8e67974e0a1bbf66022f219a151fc7a752b0 /tmk_core/common | |
parent | 97cc44e063f4c4ea18a8ad3f3bb2519f1117c93a (diff) |
Cleanup after merge
- remove a superfluous parenthesis
- wrap lines longer than 80 characters
- add const specifiers where appropriate
- remove unnecessary casts
Diffstat (limited to 'tmk_core/common')
-rw-r--r-- | tmk_core/common/action.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c index bf609f5e7b..78596a69cf 100644 --- a/tmk_core/common/action.c +++ b/tmk_core/common/action.c @@ -82,20 +82,26 @@ action_t store_or_get_action(bool pressed, keypos_t key) if (disable_action_cache) { return layer_switch_get_action(key); } - uint8_t key_number = key.col + (key.row * MATRIX_COLS); - uint8_t storage_row = key_number / 8; - uint8_t storage_bit = key_number % 8; + const uint8_t key_number = key.col + (key.row * MATRIX_COLS); + const uint8_t storage_row = key_number / 8; + const uint8_t storage_bit = key_number % 8; uint8_t layer; if (pressed) { layer = layer_switch_get_layer(key); - for (uint8_t bit_number = 0; bit_number <= 4; bit_number++) { - source_layers_cache[bit_number][storage_row] ^= (-(bool)((layer & (1U << bit_number)) != 0) ^ source_layers_cache[bit_number][storage_row])) & (1U << storage_bit); + for (uint8_t bit_number = 0; bit_number < 5; bit_number++) { + source_layers_cache[bit_number][storage_row] ^= + (-((layer & (1U << bit_number)) != 0) + ^ source_layers_cache[bit_number][storage_row]) + & (1U << storage_bit); } } else { layer = 0; - for (uint8_t bit_number = 0; bit_number <= 4; bit_number++) { - layer |= (uint8_t)((source_layers_cache[bit_number][storage_row] & (1U << storage_bit)) != 0) << bit_number; + for (uint8_t bit_number = 0; bit_number < 5; bit_number++) { + layer |= + ((source_layers_cache[bit_number][storage_row] + & (1U << storage_bit)) != 0) + << bit_number; } } return action_for_key(layer, key); |