2020-05-01 21:39:21 +00:00
|
|
|
// -*- mode: C; tab-width: 4 ; indent-tabs-mode: nil -*-
|
|
|
|
//
|
|
|
|
// Unfified Keyboard Project
|
|
|
|
// ASDF keyboard firmware
|
|
|
|
//
|
|
|
|
// asdf_hook.h
|
|
|
|
//
|
|
|
|
// Definitions and prototypes for configurable function hooks
|
|
|
|
//
|
|
|
|
// Copyright 2019 David Fenyes
|
|
|
|
// This program is free software: you can redistribute it and/or modify it under
|
|
|
|
// the terms of the GNU General Public License as published by the Free Software
|
|
|
|
// Foundation, either version 3 of the License, or (at your option) any later
|
|
|
|
// version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
|
|
// details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License along with
|
|
|
|
// this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
//
|
|
|
|
|
|
|
|
#if !defined(ASDF_HOOKS_H)
|
|
|
|
#define ASDF_HOOKS_H
|
|
|
|
|
|
|
|
// These are "hooks" output identifiers that can be mapped to the real outputs using
|
|
|
|
// keymap initializer commands.
|
|
|
|
typedef enum {
|
2020-05-05 20:05:54 +00:00
|
|
|
ASDF_HOOK_NULL,
|
2020-05-01 21:39:21 +00:00
|
|
|
ASDF_HOOK_SCANNER,
|
|
|
|
ASDF_HOOK_OUTPUT,
|
|
|
|
ASDF_HOOK_EACH_SCAN,
|
2021-12-05 05:10:33 +00:00
|
|
|
ASDF_HOOK_USER_1,
|
|
|
|
ASDF_HOOK_USER_2,
|
|
|
|
ASDF_HOOK_USER_3,
|
|
|
|
ASDF_HOOK_USER_4,
|
|
|
|
ASDF_HOOK_USER_5,
|
|
|
|
ASDF_HOOK_USER_6,
|
|
|
|
ASDF_HOOK_USER_7,
|
|
|
|
ASDF_HOOK_USER_8,
|
|
|
|
ASDF_HOOK_USER_9,
|
|
|
|
ASDF_HOOK_USER_10,
|
2020-05-01 21:39:21 +00:00
|
|
|
ASDF_NUM_HOOKS,
|
|
|
|
} asdf_hook_id_t;
|
|
|
|
|
|
|
|
#define ASDF_HOOK_KEYMAP_SETUP ASDF_NUM_HOOKS
|
|
|
|
|
|
|
|
// Each keymap specifies an array of initializer structs to configure function hooks,
|
|
|
|
// specifying the hook ID and mapped function.
|
|
|
|
|
|
|
|
typedef void (*asdf_hook_function_t)(void);
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
asdf_hook_id_t hook_id;
|
|
|
|
asdf_hook_function_t hook_func;
|
2021-02-19 20:10:25 +00:00
|
|
|
} asdf_hook_initializer_t;
|
2020-05-01 21:39:21 +00:00
|
|
|
|
|
|
|
|
2020-05-19 22:58:58 +00:00
|
|
|
// PROCEDURE: asdf_hook_execute
|
2020-05-01 21:39:21 +00:00
|
|
|
// 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.
|
2020-05-19 22:58:58 +00:00
|
|
|
void asdf_hook_execute(asdf_hook_id_t hook_id);
|
2020-05-01 21:39:21 +00:00
|
|
|
|
|
|
|
// PROCEDURE: asdf_hook_get
|
|
|
|
// INPUTS: (asdf_hook_id_t) hook_id: The hook for which to retrieve the attached
|
|
|
|
// function.
|
|
|
|
// OUTPUTS: none
|
|
|
|
// DESCRIPTION: if the hook ID is valid, then retrieve the function attached to the hook.
|
|
|
|
// SIDE EFFECTS: none
|
|
|
|
asdf_hook_function_t asdf_hook_get(asdf_hook_id_t hook_id);
|
|
|
|
|
|
|
|
// PROCEDURE: asdf_hook_init
|
2021-02-19 20:10:25 +00:00
|
|
|
// INPUTS: none
|
2020-05-01 21:39:21 +00:00
|
|
|
// OUTPUTS: none
|
|
|
|
// DESCRIPTION: Initializes function hooks for the selected keymap. If a
|
|
|
|
// function is assigned to the "KEYMAP_SETUP" hook, then execute the function.
|
|
|
|
// There is no actual slot where KEYMAP_SETUP functions are stored.
|
2021-02-19 20:10:25 +00:00
|
|
|
void asdf_hook_init(void);
|
|
|
|
|
|
|
|
// PROCEDURE: asdf_hook_assign
|
|
|
|
// INPUTS: (asdf_hook_id_t) hook_id: The hook for which to execute attache functions.
|
|
|
|
// (asdf_hook_function_t) func: function to be attached to the hook.
|
|
|
|
// OUTPUTS: none
|
|
|
|
// DESCRIPTION: If the hook ID is valid, map the function to the hook ID.
|
|
|
|
// Ignore if not valid.
|
|
|
|
void asdf_hook_assign(asdf_hook_id_t hook_id, asdf_hook_function_t func);
|
|
|
|
|
2020-05-01 21:39:21 +00:00
|
|
|
|
|
|
|
#endif /* !defined (ASDF_HOOKS_H) */
|
|
|
|
|
|
|
|
//-------|---------|---------+---------+---------+---------+---------+---------+
|
|
|
|
// Above line is 80 columns, and should display completely in the editor.
|