Get hook functionality running and DIP switch cleanup

This commit is contained in:
Dave 2020-05-05 15:05:54 -05:00
parent 4d8bc2a9be
commit 5baf20a16b
9 changed files with 84 additions and 76 deletions

View File

@ -348,6 +348,8 @@
// Default keyboard output
#define ASDF_ARCH_DEFAULT_OUTPUT asdf_arch_send_code
// DIP switch is on row 8
#define ASDF_ARCH_DIPSWITCH_ROW 8
// PROCEDURE: asdf_arch_null_output
// INPUTS: (uint8_t) value - ignored

View File

@ -255,6 +255,9 @@
// Default keyboard output
#define ASDF_ARCH_DEFAULT_OUTPUT asdf_arch_send_code
// DIP switch is on row 8
#define ASDF_ARCH_DIPSWITCH_ROW 8
// PROCEDURE: asdf_arch_null_output
// INPUTS: (uint8_t) value - ignored
// OUTPUTS: none

View File

@ -42,7 +42,7 @@
// Edit the number of rows and columns used in this map. If the number is less
// than the maxium, the unused elements will be initialized to 0.
#define ASDF_APPLE2_NUM_ROWS 16 // DIP switches are row 15.
#define ASDF_APPLE2_NUM_ROWS 9 // DIP switches are row 8 (zero-based)
#define ASDF_APPLE2_NUM_COLS 8
#define APPLE_ACTION_RESET ACTION_VOUT1
@ -70,9 +70,7 @@
// the power button LED.
#define ASDF_APPLE2_PLAIN_KEYMAP_INITIALIZER \
{ \
{ .virtual_device = VCAPS_LED, \
.physical_device = APPLE_POWER_LED, \
.initial_value = 0 }, \
{ .virtual_device = VCAPS_LED, .physical_device = APPLE_POWER_LED, .initial_value = 0 }, \
{ .virtual_device = APPLE_VIRTUAL_DISABLED_LED, \
.physical_device = APPLE_DISABLED_LED, \
.initial_value = 0 }, \
@ -80,10 +78,10 @@
.physical_device = APPLE_RESET_OUTPUT, \
.function = V_PULSE_SHORT, \
.initial_value = !APPLE_RESET_ACTIVE_VALUE }, \
{ .virtual_device = APPLE_VIRTUAL_CLR_SCR, \
.physical_device = APPLE_CLR_SCR_OUTPUT, \
.function = V_PULSE_LONG, \
.initial_value = !APPLE_CLR_SCR_ACTIVE_VALUE } \
{ \
.virtual_device = APPLE_VIRTUAL_CLR_SCR, .physical_device = APPLE_CLR_SCR_OUTPUT, \
.function = V_PULSE_LONG, .initial_value = !APPLE_CLR_SCR_ACTIVE_VALUE \
} \
}
// The ALL CAPS map is the classic Apple II/II+ map. There is no CAPS LED, since
@ -100,21 +98,26 @@
.physical_device = APPLE_RESET_OUTPUT, \
.function = V_PULSE_SHORT, \
.initial_value = !APPLE_RESET_ACTIVE_VALUE }, \
{ .virtual_device = APPLE_VIRTUAL_CLR_SCR, \
.physical_device = APPLE_CLR_SCR_OUTPUT, \
.function = V_PULSE_LONG, \
.initial_value = !APPLE_CLR_SCR_ACTIVE_VALUE } \
{ \
.virtual_device = APPLE_VIRTUAL_CLR_SCR, .physical_device = APPLE_CLR_SCR_OUTPUT, \
.function = V_PULSE_LONG, .initial_value = !APPLE_CLR_SCR_ACTIVE_VALUE \
} \
}
#define ASDF_APPLE2_KEYMAP_INITIALIZER ASDF_APPLE2_PLAIN_KEYMAP_INITIALIZER, ASDF_APPLE2_CAPS_KEYMAP_INITIALIZER
#define ASDF_APPLE2_KEYMAP_INITIALIZER \
ASDF_APPLE2_PLAIN_KEYMAP_INITIALIZER, ASDF_APPLE2_CAPS_KEYMAP_INITIALIZER
// Structure to initialize hooks. No hook functions are needed for APPLE2 keyboard.
#define ASDF_APPLE2_KEYMAP_HOOK_INITIALIZER_LENGTH 0
#define ASDF_APPLE2_PLAIN_KEYMAP_HOOK_INITIALIZER {}
#define ASDF_APPLE2_CAPS_KEYMAP_HOOK_INITIALIZER {}
#define ASDF_APPLE2_KEYMAP_HOOK_INITIALIZER ASDF_APPLE2_PLAIN_KEYMAP_HOOK_INITIALIZER, ASDF_APPLE2_CAPS_KEYMAP_HOOK_INITIALIZER
#define ASDF_APPLE2_PLAIN_KEYMAP_HOOK_INITIALIZER \
{ \
}
#define ASDF_APPLE2_CAPS_KEYMAP_HOOK_INITIALIZER \
{ \
}
#define ASDF_APPLE2_KEYMAP_HOOK_INITIALIZER \
ASDF_APPLE2_PLAIN_KEYMAP_HOOK_INITIALIZER, ASDF_APPLE2_CAPS_KEYMAP_HOOK_INITIALIZER
// Key Matrix for combination of ASCII controller and Classic ASCII matrix
@ -148,11 +151,13 @@
// definitions in positions 0-3 ensures consistent map selection among all
// keymaps.
#define ASDF_APPLE2_DIP_SWITCHES [ASDF_NUM_ROWS - 1] = { ACTION_MAPSEL_0, ACTION_MAPSEL_1, ACTION_MAPSEL_2, ACTION_MAPSEL_3 }
#define ASDF_APPLE2_DIP_SWITCHES \
[ASDF_ARCH_DIPSWITCH_ROW] = { ACTION_MAPSEL_0, ACTION_MAPSEL_1, ACTION_MAPSEL_2, ACTION_MAPSEL_3 }
#define APPLE_LEFT_ARROW ASCII_CTRL_H
#define APPLE_RIGHT_ARROW ASCII_CTRL_U
// clang-format off
#define ASDF_APPLE2_PLAIN_MAP \
{ \
[0] = { ACTION_CAPS, ACTION_SHIFT, ACTION_SHIFT, ACTION_NOTHING, \
@ -232,6 +237,7 @@
ACTION_FN_4, ACTION_FN_3, ACTION_FN_2, ACTION_FN_1 }, \
ASDF_APPLE2_DIP_SWITCHES \
}
// clang-format on
#define ASDF_APPLE2_MAP_DECLARATIONS \
static const FLASH keycode_matrix_t apple2_plain_matrix = ASDF_APPLE2_PLAIN_MAP; \
@ -254,18 +260,14 @@
#define ASDF_APPLE2_PLAIN_MAP_DEFS \
{ \
[MOD_PLAIN_MAP] = &apple2_plain_matrix, \
[MOD_SHIFT_MAP] = &apple2_shift_matrix, \
[MOD_CAPS_MAP] = &apple2_caps_matrix, \
[MOD_CTRL_MAP] = &apple2_ctrl_matrix \
[MOD_PLAIN_MAP] = &apple2_plain_matrix, [MOD_SHIFT_MAP] = &apple2_shift_matrix, \
[MOD_CAPS_MAP] = &apple2_caps_matrix, [MOD_CTRL_MAP] = &apple2_ctrl_matrix \
}
#define ASDF_APPLE2_CAPS_MAP_DEFS \
{ \
[MOD_PLAIN_MAP] = &apple2_caps_matrix, \
[MOD_SHIFT_MAP] = &apple2_caps_shift_matrix, \
[MOD_CAPS_MAP] = &apple2_caps_matrix, \
[MOD_CTRL_MAP] = &apple2_ctrl_matrix \
[MOD_PLAIN_MAP] = &apple2_caps_matrix, [MOD_SHIFT_MAP] = &apple2_caps_shift_matrix, \
[MOD_CAPS_MAP] = &apple2_caps_matrix, [MOD_CTRL_MAP] = &apple2_ctrl_matrix \
}
#define ASDF_APPLE2_ALL_MAPS ASDF_APPLE2_PLAIN_MAP_DEFS, ASDF_APPLE2_CAPS_MAP_DEFS
@ -282,12 +284,14 @@
#define ASDF_NUM_COLS ASDF_APPLE2_NUM_COLS
#endif
#if !defined(ASDF_KEYMAP_INITIALIZER_LENGTH) || (ASDF_KEYMAP_INITIALIZER_LENGTH < ASDF_APPLE2_KEYMAP_INITIALIZER_LENGTH)
#if !defined(ASDF_KEYMAP_INITIALIZER_LENGTH) \
|| (ASDF_KEYMAP_INITIALIZER_LENGTH < ASDF_APPLE2_KEYMAP_INITIALIZER_LENGTH)
#undef ASDF_KEYMAP_INITIALIZER_LENGTH
#define ASDF_KEYMAP_INITIALIZER_LENGTH ASDF_APPLE2_KEYMAP_INITIALIZER_LENGTH
#endif
#if !defined(ASDF_KEYMAP_HOOK_INITIALIZER_LENGTH) || (ASDF_KEYMAP_HOOK_INITIALIZER_LENGTH < ASDF_APPLE2_KEYMAP_HOOK_INITIALIZER_LENGTH)
#if !defined(ASDF_KEYMAP_HOOK_INITIALIZER_LENGTH) \
|| (ASDF_KEYMAP_HOOK_INITIALIZER_LENGTH < ASDF_APPLE2_KEYMAP_HOOK_INITIALIZER_LENGTH)
#undef ASDF_KEYMAP_HOOK_INITIALIZER_LENGTH
#define ASDF_KEYMAP_HOOK_INITIALIZER_LENGTH ASDF_APPLE2_KEYMAP_HOOK_INITIALIZER_LENGTH
#endif
@ -296,4 +300,3 @@
//-------|---------|---------+---------+---------+---------+---------+---------+
// Above line is 80 columns, and should display completely in the editor.

View File

@ -34,7 +34,7 @@
// Edit the number of rows and columns used in this map. If the number is less
// than the maxium, the unused elements will be initialized to 0.
#define ASDF_ASCII_NUM_ROWS 16 // DIP switches are row 15.
#define ASDF_ASCII_NUM_ROWS 9 // DIP switches are row 8 (zero based)
#define ASDF_ASCII_NUM_COLS 8
#define ASCII_ACTION_BREAK ACTION_NOTHING
@ -141,8 +141,10 @@
// keymaps.
#define ASDF_ASCII_DIP_SWITCHES [ASDF_NUM_ROWS - 1] = { ACTION_MAPSEL_0, ACTION_MAPSEL_1, ACTION_MAPSEL_2, ACTION_MAPSEL_3 }
#define ASDF_ASCII_DIP_SWITCHES \
[ASDF_ARCH_DIPSWITCH_ROW] = { ACTION_MAPSEL_0, ACTION_MAPSEL_1, ACTION_MAPSEL_2, ACTION_MAPSEL_3 }
// clang-format off
#define ASDF_ASCII_PLAIN_MAP \
{ \
[0] = { ACTION_NOTHING, ACTION_SHIFT, ACTION_SHIFT, ACTION_NOTHING, \
@ -206,6 +208,7 @@
ACTION_FN_4, ACTION_FN_3, ACTION_FN_2, ACTION_FN_1 }, \
ASDF_ASCII_DIP_SWITCHES \
}
// clang-format on
#define ASDF_ASCII_MAP_DECLARATIONS \
static const FLASH keycode_matrix_t ascii_plain_matrix = ASDF_ASCII_PLAIN_MAP; \

View File

@ -34,7 +34,7 @@
// Edit the number of rows and columns used in this map. If the number is less
// than the maxium, the unused elements will be initialized to 0.
#define ASDF_SOL_NUM_ROWS 16 // DIP switches are row 9
#define ASDF_SOL_NUM_ROWS 13 // DIP switches are row 9
#define ASDF_SOL_NUM_COLS 8
@ -148,11 +148,8 @@
}, \
}
#define DIP_SWITCH_ROW 15
#define ASDF_SOL_DIP_SWITCHES \
[DIP_SWITCH_ROW] = { ACTION_MAPSEL_0, ACTION_MAPSEL_1, ACTION_MAPSEL_2, ACTION_MAPSEL_3 }
[ASDF_ARCH_DIPSWITCH_ROW] = { ACTION_MAPSEL_0, ACTION_MAPSEL_1, ACTION_MAPSEL_2, ACTION_MAPSEL_3 }
// clang-format off
#define ASDF_SOL_PLAIN_MAP \

View File

@ -496,11 +496,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_hook_get(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 (*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

@ -76,7 +76,7 @@ void asdf_hook_null_func(void) {}
//
static uint8_t asdf_hook_valid_id(asdf_hook_id_t id)
{
return (id < ASDF_NUM_HOOKS);
return (id > ASDF_HOOK_NULL && id < ASDF_NUM_HOOKS);
}
// PROCEDURE: asdf_hook_do
@ -166,8 +166,7 @@ static void asdf_hook_assign(asdf_hook_id_t hook_id, asdf_hook_function_t func)
//
void asdf_hook_init(asdf_hook_initializer_t *const initializer_list)
{
// initialize hooks to NULL
// initialize hooks to null function
for (uint8_t i = 0; i < ASDF_NUM_HOOKS; i++) {
hook_map[i] = asdf_hook_null_func;
}

View File

@ -28,6 +28,7 @@
// These are "hooks" output identifiers that can be mapped to the real outputs using
// keymap initializer commands.
typedef enum {
ASDF_HOOK_NULL,
ASDF_HOOK_SCANNER,
ASDF_HOOK_OUTPUT,
ASDF_HOOK_EACH_SCAN,

View File

@ -93,8 +93,8 @@ void asdf_keymaps_select_keymap(uint8_t index)
if (index < ASDF_NUM_KEYMAPS) {
keymap_index = index;
asdf_virtual_init((asdf_virtual_initializer_t *const) keymap_initializer_list[keymap_index]);
asdf_hook_init((asdf_hook_initializer_t *const) keymap_hook_initializer_list[keymap_index]);
asdf_modifiers_init();
asdf_hook_init((asdf_hook_initializer_t *const) keymap_hook_initializer_list[keymap_index]);
}
}