now releasing keys on the same layer they were pressed

lol - i'd forgotten to do this before
partial-rewrite
Ben Blazak 2013-04-19 16:46:42 -07:00
parent 81e7e32dbe
commit a210660b24
1 changed files with 28 additions and 10 deletions

View File

@ -25,19 +25,39 @@
// ----------------------------------------------------------------------------
void kb__layout__exec_key(bool pressed, uint8_t row, uint8_t column) {
void (*function)(void);
uint8_t offset = 0;
do {
function = _layout[ layer_stack__peek(offset) ]
[ row ]
[ column ]
[ (pressed) ? 0 : 1 ];
// keep track of the layer the key was pressed on, so we can release it on
// the same layer
// - if the release is transparent, search through the layer stack for a
// non-transparent release in the same position, as normal
// - don't need to initialize, since we'll only read from positions that
// we've previously set
static uint8_t pressed_layer[OPT__KB__ROWS][OPT__KB__COLUMNS];
void (*function)(void);
uint8_t layer;
for(uint8_t i = 0; i < layer_stack__size()+1+1; i++) { // i = offset+1
if (i == 0)
if (!pressed)
layer = pressed_layer[row][column];
else
continue;
else
layer = layer_stack__peek(i-1);
function = _layout[ layer ]
[ row ]
[ column ]
[ (pressed) ? 0 : 1 ];
if (function == &KF(transp))
function = NULL;
if (function) {
if (pressed)
pressed_layer[row][column] = layer;
(*function)();
if (pressed && _sticky_key) {
@ -47,9 +67,7 @@ void kb__layout__exec_key(bool pressed, uint8_t row, uint8_t column) {
return;
}
offset++;
} while (offset < layer_stack__size());
}
// if we get here, there was a transparent key in layer 0; do nothing
}