minor hook cleanups

- Rename asdf_hook_do() to asdf_hook_execute()
- asdf.c: Call asdf_hook_execute() for ASDF_HOOK_EACH_SCAN hook call in the scan
  routine, instead of getting then calling the function via hook_get()
- asdf.c: move the fetch of scan function hook outside the scan loop.
This commit is contained in:
Dave 2020-05-19 17:58:58 -05:00
parent b3b2a93cdb
commit 25d0693eda
3 changed files with 8 additions and 6 deletions

View File

@ -512,9 +512,11 @@ static void asdf_handle_key_held_pressed(uint8_t row, uint8_t col)
//
void asdf_keyscan(void)
{
asdf_hook_get(ASDF_HOOK_EACH_SCAN)();
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);
for (uint8_t row = 0; row < ASDF_NUM_ROWS; row++) {
asdf_cols_t (*row_reader)(uint8_t) = (asdf_cols_t(*)(uint8_t)) asdf_hook_get(ASDF_HOOK_SCANNER);
asdf_cols_t row_key_state = (*row_reader)(row);
asdf_cols_t changed = row_key_state ^ last_stable_key_state[row];

View File

@ -77,7 +77,7 @@ static uint8_t asdf_hook_valid_id(asdf_hook_id_t id)
return (id > ASDF_HOOK_NULL && id < ASDF_NUM_HOOKS);
}
// PROCEDURE: asdf_hook_do
// PROCEDURE: asdf_hook_execute
// INPUTS: (asdf_hook_id_t) hook_id: The hook for which to execute the attached
// function.
//
@ -93,7 +93,7 @@ static uint8_t asdf_hook_valid_id(asdf_hook_id_t id)
//
// COMPLEXITY: 2
//
void asdf_hook_do(asdf_hook_id_t hook_id)
void asdf_hook_execute(asdf_hook_id_t hook_id)
{
if (asdf_hook_valid_id(hook_id)) {
hook_map[hook_id]();

View File

@ -48,12 +48,12 @@ typedef struct {
} asdf_hook_initializer_t;
// PROCEDURE: asdf_hook_do
// PROCEDURE: asdf_hook_execute
// INPUTS: (asdf_hook_id_t) hook_id: The hook for which to execute attache functions.
// OUTPUTS: none
// DESCRIPTION: if the hook ID is valid, then execute the function attached to the hook.
// SIDE EFFECTS: variable depending on the hooks.
void asdf_hook_do(asdf_hook_id_t hook_id);
void asdf_hook_execute(asdf_hook_id_t hook_id);
// PROCEDURE: asdf_hook_get
// INPUTS: (asdf_hook_id_t) hook_id: The hook for which to retrieve the attached