Notation fixes for pointers to functions

This commit is contained in:
Dave 2020-08-06 15:17:28 -05:00
parent c13672b408
commit 2a02f74171
3 changed files with 6 additions and 7 deletions

View File

@ -363,11 +363,10 @@ static void asdf_activate_key(asdf_keycode_t keycode)
//
static void asdf_deactivate_key(asdf_keycode_t keycode)
{
if (keycode & ASDF_ACTION) {
if (keycode > ASDF_ACTION) {
asdf_deactivate_action((action_t) keycode);
}
else {
// deactivate a released keypress
if (last_key == keycode) {
last_key = ACTION_NOTHING;
@ -449,7 +448,6 @@ static void asdf_handle_key_press_or_release(uint8_t row, uint8_t col, uint8_t k
}
else {
// key was released
last_stable_key_state[row] &= ~(1 << col);
asdf_deactivate_key(asdf_lookup_keycode(row, col));
}
@ -512,6 +510,7 @@ static void asdf_handle_key_held_pressed(uint8_t row, uint8_t col)
//
void asdf_keyscan(void)
{
asdf_cols_t (*row_reader)(uint8_t) = (asdf_cols_t(*)(uint8_t)) asdf_hook_get(ASDF_HOOK_SCANNER);
asdf_hook_execute(ASDF_HOOK_EACH_SCAN);
@ -522,7 +521,7 @@ void asdf_keyscan(void)
asdf_cols_t changed = row_key_state ^ last_stable_key_state[row];
// loop over the bits until all changed or pressed keys in the row are handled.
for (uint8_t col = 0; (changed | row_key_state) && col < ASDF_NUM_COLS; col++) {
for (uint8_t col = 0; (changed || row_key_state) && col < ASDF_NUM_COLS; col++) {
if (changed & 1) {
// key state is different from last stable state
asdf_handle_key_press_or_release(row, col, row_key_state & 1);

View File

@ -166,7 +166,7 @@ void asdf_hook_init(asdf_hook_initializer_t *const initializer_list)
{
// initialize hooks to null function
for (uint8_t i = 0; i < ASDF_NUM_HOOKS; i++) {
hook_map[i] = asdf_hook_null_func;
hook_map[i] = &asdf_hook_null_func;
}
hook_map[ASDF_HOOK_SCANNER] = (asdf_hook_function_t) ASDF_ARCH_DEFAULT_SCANNER;

View File

@ -72,8 +72,8 @@ int main(void)
asdf_keycode_t code = asdf_next_code();
if (code != ASDF_INVALID_CODE) {
void (*output_function)(asdf_keycode_t) =
(void (*)(asdf_keycode_t)) asdf_hook_get(ASDF_HOOK_OUTPUT);
void (*output_function)(asdf_keycode_t) =
(void (*)(asdf_keycode_t)) asdf_hook_get(ASDF_HOOK_OUTPUT);
(*output_function)(code);
}
asdf_keyscan();