Progress toward building new keymap scheme with cmake

- keymap files (c,h) are in src/Keymaps
- keymap files are added to the keymap library in src/Keymaps/CMakeLists.txt
- keymaps for the build are listed, along with positions, in /keymap_lists.cmake
- cmake generates a keymap jump table from the keymap lib and list
- tests mostly passing.  Keymap structure for testing will be used as the model
  for the app keymaps.
This commit is contained in:
Dave 2021-03-07 20:38:40 -06:00
parent 3a854d97f2
commit 8310259cc7
23 changed files with 745 additions and 276 deletions

View File

@ -1,5 +1,7 @@
cmake_minimum_required(VERSION 3.19)
set(KEYMAPFILE keymaps.txt)
# Set up the toolchain and other architecture specific details
if(ARCH MATCHES atmega328p)
@ -30,17 +32,37 @@ project("asdf"
set_property(GLOBAL PROPERTY C_STANDARD 99)
set(ASDF_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
message("SRC Dir is ${ASDF_SRC_DIR}")
set (ASDF_TARGET_NAME asdf-v${PROJECT_VERSION}-${ARCH})
set (ASDF_EXECUTABLE_TARGET_NAME ${ASDF_TARGET_NAME})
macro(temporary_config_file SOURCE_FILE GENERATED_FILE)
configure_file(${SOURCE_FILE} ${GENERATED_FILE}
COPYONLY)
list(APPEND TEMPFILE_LIST ${GENERATED_FILE})
endmacro(temporary_config_file)
function(create_keymap_setups keymaps keymap_table)
list(TRANSFORM keymaps REPLACE "<\(.+\):\(.+\)>" "\n [\\2] = setup_\\1_keymap" OUTPUT_VARIABLE temp_list)
list(APPEND temp_list "")
set(${keymap_table} "${temp_list}" PARENT_SCOPE)
endfunction(create_keymap_setups)
function(create_keymap_report keymaps keymap_report)
list(TRANSFORM keymaps REPLACE "<\(.+\):\(.+\)>" "\nkeymap [\\2]: \\1" OUTPUT_VARIABLE temp_list)
list(APPEND temp_list "")
set(${keymap_report} "${temp_list}" PARENT_SCOPE)
endfunction(create_keymap_report)
include(keymap_list.cmake)
create_keymap_setups("${keymap_list}" keymap_table)
create_keymap_report("${keymap_list}" keymap_report)
# get list length and decrement by one to account for trailing semicolon
list (LENGTH keymap_table num_keymaps)
math(EXPR num_keymaps "${num_keymaps}-1")
message("**********************")
message("Keymap table: ${keymap_report}")
message("**********************\n\n")
if(ARCH MATCHES test)
add_subdirectory(test)

View File

@ -0,0 +1,9 @@
list(APPEND keymap_list
"<classic:0>"
"<classic_caps:1>"
"<apple2:2>"
"<apple2_caps:3>"
"<sol:4>"
)

View File

@ -1,12 +1,9 @@
set (KEYMAP "production")
message("C compiler: ${CMAKE_C_COMPILER}")
temporary_config_file(${ASDF_SRC_DIR}/Arch/asdf_arch_${ARCH}.h ${CMAKE_CURRENT_BINARY_DIR}/asdf_arch.h)
temporary_config_file(${ASDF_SRC_DIR}/Arch/asdf_arch_${ARCH}.c ${CMAKE_CURRENT_BINARY_DIR}/asdf_arch.c)
temporary_config_file(${ASDF_SRC_DIR}/Keymaps/asdf_all_keymap_defs_${KEYMAP}.h ${CMAKE_CURRENT_BINARY_DIR}/asdf_keymap_defs.h)
configure_file(${ASDF_SRC_DIR}/Arch/asdf_arch_${ARCH}.h ${CMAKE_CURRENT_BINARY_DIR}/asdf_arch.h COPYONLY)
configure_file(${ASDF_SRC_DIR}/Arch/asdf_arch_${ARCH}.c ${CMAKE_CURRENT_BINARY_DIR}/asdf_arch.c COPYONLY)
configure_file(${ASDF_SRC_DIR}/asdf_keymap_table.c.in ${CMAKE_CURRENT_BINARY_DIR}/asdf_keymap_table.c)
configure_file(${ASDF_SRC_DIR}/asdf_keymap_table.h.in ${CMAKE_CURRENT_BINARY_DIR}/asdf_keymap_table.h)
list(APPEND C_FLAGS
-std=c99
@ -38,6 +35,7 @@ list (APPEND SOURCES
${CMAKE_CURRENT_BINARY_DIR}/asdf_arch.c
asdf_buffer.c
asdf_hook.c
asdf_keymap_table.c
asdf_keymaps.c
asdf_modifiers.c
asdf_physical.c
@ -46,6 +44,9 @@ list (APPEND SOURCES
main.c
)
# create a library for the keymap modules
add_subdirectory(Keymaps)
# add the executable
if (COMMAND custom_add_executable)
custom_add_executable(${ASDF_TARGET_NAME}
@ -66,6 +67,7 @@ target_compile_options(${ASDF_EXECUTABLE_TARGET_NAME}
${CFLAGS}
)
target_link_libraries(${ASDF_EXECUTABLE_TARGET_NAME}
keymaps
)

View File

@ -0,0 +1,71 @@
// -*- mode: C; tab-width: 2 ; indent-tabs-mode: nil -*-
//
// Unified Keyboard Project
// ASDF keyboard firmware
//
// asdf_keymap_classic.c
//
// Implements the "classic" ADM 3A style keymaps
//
// 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/>.
//
#include "asdf_keymap_classic.h"
#include "asdf_keymap_classic_add_map.h"
// PROCEDURE:
// INPUTS:
// OUTPUTS:
//
// DESCRIPTION:
//
// SIDE EFFECTS:
//
// NOTES:
//
// SCOPE:
//
// COMPLEXITY:
//
void setup_classic_caps_keymap(void)
{
// for the ALL CAPS keymap, the "plain" mode is the same as "all caps" mode:
classic_add_map(classic_caps_map, MOD_PLAIN_MAP);
classic_add_map(classic_caps_map, MOD_CAPS_MAP);
classic_add_map(classic_shift_map, MOD_SHIFT_MAP);
classic_add_map(classic_ctrl_map, MOD_CTRL_MAP);
asdf_virtual_init();
// Assign power LED to virtual power LED, and initialize to ON
asdf_virtual_assign(CLASSIC_VIRTUAL_POWER_LED, CLASSIC_POWER_LED, V_NOFUNC, CLASSIC_POWER_LED_INIT_VALUE);
// Because the virtual power LED never changes, also assign the CAPSLOCK
// physical LED to the virtual Power LED, and intialize to OFF (or can change
// to ON depending on preference)
asdf_virtual_assign(CLASSIC_VIRTUAL_POWER_LED, CLASSIC_CAPS_LED, V_NOFUNC, CLASSIC_CAPS_LED_INIT_VALUE);
// assign RESET output to the virtual RESET output, configure to produce a short pulse when activated
asdf_virtual_assign(CLASSIC_VIRTUAL_RESET, CLASSIC_RESET_OUTPUT, V_PULSE_SHORT, !CLASSIC_RESET_ACTIVE_VALUE);
// assign the CLRSCR output to the virtual CLRSCR output, configure to produce a long pulse when activated
asdf_virtual_assign(CLASSIC_VIRTUAL_CLR_SCR, CLASSIC_CLR_SCR_OUT, V_PULSE_LONG, !CLASSIC_CLR_SCR_ACTIVE_VALUE);
}
//-------|---------|---------+---------+---------+---------+---------+---------+
// Above line is 80 columns, and should display completely in the editor.

View File

@ -0,0 +1,106 @@
// -*- mode: C; tab-width: 2 ; indent-tabs-mode: nil -*-
//
// Unified Keyboard Project
// ASDF keyboard firmware
//
// asdf_keymap_apple2.c
//
// set up keymaps for Apple II keyboards
//
// 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/>.
//
#include "asdf_keymap_apple2.h"
#include "asdf_keymap_defs_dipswitch.h"
// PROCEDURE:
// INPUTS:
// OUTPUTS:
//
// DESCRIPTION:
//
// SIDE EFFECTS:
//
// NOTES:
//
// SCOPE:
//
// COMPLEXITY:
//
// PROCEDURE: apple_add_map
// INPUTS: asdf_keycode_t (*matrix) - a SOL_NUM_ROWS x SOL_NUM_COLS matrix of
// keycodes for each physical row/column pair
// modifier_index_t modifier index - the modifier state corresponding to
// the keycode matrix
//
// OUTPUTS: none
// DESCRIPTION: Passes the keycode matrix and modifier state through to
// asdf_keymaps_add_map(), along with the row/column dimensions.
//
// SIDE EFFECTS: the matrix is added to the keymap
//
// SCOPE: private
//
// COMPLEXITY: 1
//
static void apple_add_map(const asdf_keycode_t (*matrix)[APPLE_NUM_COLS],
modifier_index_t modifier_index)
{
asdf_keymaps_add_map(&matrix[0][0], modifier_index, (uint8_t) APPLE_NUM_ROWS,
(uint8_t) APPLE_NUM_COLS);
}
void setup_classic_keymap(void)
{
apple_add_map(apple_plain_map, MOD_PLAIN_MAP);
apple_add_map(apple_caps_map, MOD_CAPS_MAP);
apple_add_map(apple_shift_map, MOD_SHIFT_MAP);
apple_add_map(apple_ctrl_map, MOD_CTRL_MAP);
asdf_virtual_init();
// Attach the physical POWER LED as the CAPS LED. Assign no triggered
// function, and initialize to initial state of the CAPS logic. The CAPS LED
// will be controlled by the state of the CAPSLOCK logic.
{ .virtual_device = VCAPS_LED, .physical_device = APPLE_POWER_LED, .initial_value = 0 }, \
asdf_virtual_assign(VCAPS_LED, APPLE_POWER_LED, V_NOFUNC, APPLE_POWER_LED_INIT_VALUE);
// Assign CAPS LED to virtual CAPS LED, and initialize to the INIT value, to
// match the initial CAPSLOCK state. The capslock state code will alter the
// virtual LED according to the state.
asdf_virtual_assign(VCAPS_LED, APPLE_CAPS_LED, V_NOFUNC, APPLE_CAPS_LED_INIT_VALUE);
{ .virtual_device = APPLE_VIRTUAL_DISABLED_LED, \
.physical_device = APPLE_DISABLED_LED, \
.initial_value = 0 }, \
// assign RESET output to the virtual RESET output, configure to produce a short pulse when activated
asdf_virtual_assign(APPLE_VIRTUAL_RESET, APPLE_RESET_OUTPUT, V_PULSE_SHORT, !APPLE_RESET_ACTIVE_VALUE);
// assign the CLRSCR output to the virtual CLRSCR output, configure to produce a long pulse when activated
asdf_virtual_assign(APPLE_VIRTUAL_CLR_SCR, APPLE_CLR_SCR_OUTPUT, V_PULSE_LONG, !APPLE_CLR_SCR_ACTIVE_VALUE);
}
//-------|---------|---------+---------+---------+---------+---------+---------+
// Above line is 80 columns, and should display completely in the editor.

View File

@ -24,102 +24,7 @@
//
#include "asdf_keymap_classic.h"
// Key Matrix for combination of ASCII controller and Classic ASCII matrix
//
// Col-> 0 1 2 3 4 5 6 7
// Row 0 POWER R-Shift L-Shift (no key) ESC TAB CTRL \(backslash)
// Row 1 Rubout P ; / SPACEBAR Z A Q
// Row 2 Break ,(comma) M N B V C X
// Row 3 Spare K J H G F D A
// Row 4 Rt arrow I U Y T R E W
// Row 5 LT arrow Repeat CapsLock Return LineFeed O(alpha) L .(period)
// Row 6 ~(tilde) ] [ -(dash) :(colon) 0(numeral) 9 8
// Row 7 @(at) 7 6 5 4 3 2 1
//
// Row 15 DIP switches 0-7
//
// Notes:
//
// 1) The keys above correspond to the silk screen on the PCB. For the OSI and
// Apple layouts, the keys may not all match the silk screen. When creating a
// layout different from the silk screen, look up the row and column for the
// silk screen label at the desired position, and then place the desired
// function in the keymap definition at the desired row and column. For
// example, the Apple 2 keymap places the "RESET" key at the "[" silk-screen
// position, Row 6, Col 2. The keymap places ACTION_RESET at Row 6, Col 2 in
// the "ASDF_APPLE2_CTRL_MAP" to map the RESET function to the CTRL-RESET key
// combination.
//
// 2) To ensure consistent DIP switch operation within the keymap, a
// ASDF_ASCII_DIP_SWITCHES macro is defined. Keeping the ACTION_MAPSEL0-3
// definitions in positions 0-3 ensures consistent map selection among all
// keymaps.
#define ASDF_CLASSIC_DIP_SWITCHES ASDF_KEYMAP_DIP_SWITCHES
static const FLASH keycode_matrix_t ascii_plain_matrix = {
[0] = { ACTION_NOTHING, ACTION_SHIFT, ACTION_SHIFT, ACTION_NOTHING, CLASSIC_ESC, ASCII_TAB,
ACTION_CTRL, ASCII_BACKSLASH },
[1] = { ASCII_DEL, 'p', ';', '/', ASCII_SPACE, 'z', 'a', 'q' },
[2] = { ASCII_ACTION_BREAK, ASCII_COMMA, 'm', 'n', 'b', 'v', 'c', 'x' },
[3] = { ACTION_NOTHING, 'k', 'j', 'h', 'g', 'f', 'd', 's' },
[4] = { ACTION_NOTHING, 'i', 'u', 'y', 't', 'r', 'e', 'w' },
[5] = { ACTION_NOTHING, ACTION_REPEAT, ACTION_CAPS, ASCII_CR, ASCII_LF, 'o', 'l', ASCII_PERIOD },
[6] = { ASCII_TILDE, ASCII_RT_SQUARE_BRACE, ASCII_LT_SQUARE_BRACE, '-', ':', ASCII_ZERO, '9',
'8' },
[7] = { ASCII_AT, '7', '6', '5', '4', '3', '2', '1' },
ASDF_CLASSIC_DIP_SWITCHES
};
static const FLASH keycode_matrix_t ascii_shift_matrix = {
[0] = { ACTION_NOTHING, ACTION_SHIFT, ACTION_SHIFT, ACTION_NOTHING, ASCII_ESC, ASCII_TAB,
ACTION_CTRL, ASCII_VERT_BAR },
[1] = { ASCII_DEL, 'P', '+', '?', ASCII_SPACE, 'Z', 'A', 'Q' },
[2] = { ASCII_ACTION_CLEAR, '<', 'M', 'N', 'B', 'V', 'C', 'X' },
[3] = { ACTION_NOTHING, 'K', 'J', 'H', 'G', 'F', 'D', 'S' },
[4] = { ACTION_NOTHING, 'I', 'U', 'Y', 'T', 'R', 'E', 'W' },
[5] = { ACTION_NOTHING, ACTION_REPEAT, ACTION_CAPS, ASCII_CR, ASCII_LF, 'O', 'L', '>' },
[6] = { ASCII_TILDE, ASCII_RT_CURLY_BRACE, ASCII_LT_CURLY_BRACE, '=', '*', ASCII_ZERO,
ASCII_RT_PAREN, ASCII_LT_PAREN },
[7] = { ASCII_GRAVE_ACCENT, ASCII_SINGLE_QUOTE, '&', '%', '$', '#', ASCII_DOUBLE_QUOTE, '!' },
ASDF_CLASSIC_DIP_SWITCHES
};
static const FLASH keycode_matrix_t ascii_caps_matrix = {
[0] = { ACTION_NOTHING, ACTION_SHIFT, ACTION_SHIFT, ACTION_NOTHING, ASCII_ESC, ASCII_TAB,
ACTION_CTRL, ASCII_BACKSLASH },
[1] = { ASCII_DEL, 'P', ';', '/', ASCII_SPACE, 'Z', 'A', 'Q' },
[2] = { ASCII_ACTION_BREAK, ASCII_COMMA, 'M', 'N', 'B', 'V', 'C', 'X' },
[3] = { ACTION_NOTHING, 'K', 'J', 'H', 'G', 'F', 'D', 'S' },
[4] = { ACTION_NOTHING, 'I', 'U', 'Y', 'T', 'R', 'E', 'W' },
[5] = { ACTION_NOTHING, ACTION_REPEAT, ACTION_CAPS, ASCII_CR, ASCII_LF, 'O', 'L', ASCII_PERIOD },
[6] = { ASCII_TILDE, ASCII_RT_SQUARE_BRACE, ASCII_LT_SQUARE_BRACE, '-', ':', ASCII_ZERO, '9',
'8' },
[7] = { ASCII_AT, '7', '6', '5', '4', '3', '2', '1' },
ASDF_CLASSIC_DIP_SWITCHES
};
static const FLASH keycode_matrix_t ascii_ctrl_matrix = {
[0] = { ACTION_NOTHING, ACTION_SHIFT, ACTION_SHIFT, ACTION_NOTHING, ASCII_ESC, ASCII_TAB,
ACTION_CTRL, 0x1c },
[1] = { ACTION_NOTHING, ASCII_CTRL_P, ACTION_NOTHING, ACTION_NOTHING, ASCII_SPACE, ASCII_CTRL_Z,
ASCII_CTRL_A, ASCII_CTRL_Q },
[2] = { ASCII_ACTION_RESET, ASCII_COMMA, ASCII_CTRL_M, ASCII_CTRL_N, ASCII_CTRL_B, ASCII_CTRL_V,
ASCII_CTRL_C, ASCII_CTRL_X },
[3] = { ACTION_NOTHING, ASCII_CTRL_K, ASCII_CTRL_J, ASCII_CTRL_H, ASCII_CTRL_G, ASCII_CTRL_F,
ASCII_CTRL_D, ASCII_CTRL_S },
[4] = { ACTION_NOTHING, ASCII_CTRL_I, ASCII_CTRL_U, ASCII_CTRL_Y, ASCII_CTRL_T, ASCII_CTRL_R,
ASCII_CTRL_E, ASCII_CTRL_W },
[5] = { ACTION_NOTHING, ACTION_REPEAT, ACTION_CAPS, ASCII_CR, ASCII_LF, ASCII_CTRL_O,
ASCII_CTRL_L, ACTION_NOTHING },
[6] = { ACTION_NOTHING, 0x1d, ASCII_ESC, ACTION_NOTHING, ACTION_NOTHING, ACTION_FN_10,
ACTION_FN_9, ACTION_FN_8 },
[7] = { ASCII_NULL, ACTION_FN_7, ACTION_FN_6, ACTION_FN_5, ACTION_FN_4, ACTION_FN_3, ACTION_FN_2,
ACTION_FN_1 },
ASDF_CLASSIC_DIP_SWITCHES
};
#include "asdf_keymap_classic_add_map.h"
// PROCEDURE:
// INPUTS:
@ -136,33 +41,12 @@ static const FLASH keycode_matrix_t ascii_ctrl_matrix = {
// COMPLEXITY:
//
// PROCEDURE: classic_add_map
// INPUTS: asdf_keycode_t (*matrix) - a SOL_NUM_ROWS x SOL_NUM_COLS matrix of keycodes for each physical row/column pair
// modifier_index_t modifier index - the modifier state corresponding to the keycode matrix
// OUTPUTS: none
// DESCRIPTION: Passes the keycode matrix and modifier state through to
// asdf_keymaps_add_map(), along with the row/column dimensions.
//
// SIDE EFFECTS: the matrix is added to the keymap
//
// SCOPE: private
//
// COMPLEXITY: 1
//
static void classic_add_map(const asdf_keycode_t (*matrix)[CLASSIC_NUM_COLS],
modifier_index_t modifier_index)
{
asdf_keymaps_add_map(&matrix[0][0], modifier_index, (uint8_t) CLASSIC_NUM_ROWS,
(uint8_t) CLASSIC_NUM_COLS);
}
void setup_classic_keymap(void)
{
classic_add_map(classic_plain_map, MOD_PLAIN_MAP);
classic_add_map(classic_caps_map, MOD_CAPS_MAP);
classic_add_map(classic_shift_map, MOD_SHIFT_MAP);
classic_add_map(classic_ctrl_map, MOD_CTRL_MAP);
classic_add_map(CLASSIC_PLAIN_MAP, MOD_PLAIN_MAP);
classic_add_map(CLASSIC_CAPS_MAP, MOD_CAPS_MAP);
classic_add_map(CLASSIC_SHIFT_MAP, MOD_SHIFT_MAP);
classic_add_map(CLASSIC_CTRL_MAP, MOD_CTRL_MAP);
asdf_virtual_init();

View File

@ -59,41 +59,7 @@
#define CLASSIC_CAPS_LED PHYSICAL_LED3
#define CLASSIC_CAPS_LED_INIT_VALUE 0
// Key Matrix for combination of ASCII controller and Classic ASCII matrix
//
// Col-> 0 1 2 3 4 5 6 7
// Row 0 POWER R-Shift L-Shift (no key) ESC TAB CTRL \(backslash)
// Row 1 Rubout P ; / SPACEBAR Z A Q
// Row 2 Break ,(comma) M N B V C X
// Row 3 Spare K J H G F D A
// Row 4 Rt arrow I U Y T R E W
// Row 5 LT arrow Repeat CapsLock Return LineFeed O(alpha) L .(period)
// Row 6 ~(tilde) ] [ -(dash) :(colon) 0(numeral) 9 8
// Row 7 @(at) 7 6 5 4 3 2 1
//
// Row 15 DIP switches 0-7
//
// Notes:
//
// 1) The keys above correspond to the silk screen on the PCB. For the OSI and
// Apple layouts, the keys may not all match the silk screen. When creating a
// layout different from the silk screen, look up the row and column for the
// silk screen label at the desired position, and then place the desired
// function in the keymap definition at the desired row and column. For
// example, the Apple 2 keymap places the "RESET" key at the "[" silk-screen
// position, Row 6, Col 2. The keymap places ACTION_RESET at Row 6, Col 2 in
// the "ASDF_APPLE2_CTRL_MAP" to map the RESET function to the CTRL-RESET key
// combination.
//
// 2) To ensure consistent DIP switch operation within the keymap, a
// ASDF_ASCII_DIP_SWITCHES macro is defined. Keeping the ACTION_MAPSEL0-3
// definitions in positions 0-3 ensures consistent map selection among all
// keymaps.
#define ASDF_CLASSIC_DIP_SWITCHES ASDF_KEYMAP_DIP_SWITCHES
void classic_add_map(const asdf_keycode_t (*matrix)[CLASSIC_NUM_COLS],modifier_index_t);
#endif /* !defined (ASDF_KEYMAP_DEFS_ASCII_H) */

View File

@ -0,0 +1,146 @@
// -*- mode: C; tab-width: 2 ; indent-tabs-mode: nil -*-
//
// Unified Keyboard Project
// ASDF keyboard firmware
//
// asdf_keymap_classic.c
//
// defines the keymap matrices used by the "classic" ADM 3A style keymap variants
//
// 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/>.
//
#include "asdf_keymap_classic.h"
// Key Matrix for combination of ASCII controller and Classic ASCII matrix
//
// Col-> 0 1 2 3 4 5 6 7
// Row 0 POWER R-Shift L-Shift (no key) ESC TAB CTRL \(backslash)
// Row 1 Rubout P ; / SPACEBAR Z A Q
// Row 2 Break ,(comma) M N B V C X
// Row 3 Spare K J H G F D A
// Row 4 Rt arrow I U Y T R E W
// Row 5 LT arrow Repeat CapsLock Return LineFeed O(alpha) L .(period)
// Row 6 ~(tilde) ] [ -(dash) :(colon) 0(numeral) 9 8
// Row 7 @(at) 7 6 5 4 3 2 1
//
// Row 15 DIP switches 0-7
//
// Notes:
//
// 1) The keys above correspond to the silk screen on the PCB. For the OSI and
// Apple layouts, the keys may not all match the silk screen. When creating a
// layout different from the silk screen, look up the row and column for the
// silk screen label at the desired position, and then place the desired
// function in the keymap definition at the desired row and column. For
// example, the Apple 2 keymap places the "RESET" key at the "[" silk-screen
// position, Row 6, Col 2. The keymap places ACTION_RESET at Row 6, Col 2 in
// the "ASDF_APPLE2_CTRL_MAP" to map the RESET function to the CTRL-RESET key
// combination.
//
// 2) To ensure consistent DIP switch operation within the keymap, a
// ASDF_ASCII_DIP_SWITCHES macro is defined. Keeping the ACTION_MAPSEL0-3
// definitions in positions 0-3 ensures consistent map selection among all
// keymaps.
#define ASDF_CLASSIC_DIP_SWITCHES ASDF_KEYMAP_DIP_SWITCHES
const FLASH keycode_matrix_t ascii_plain_matrix = {
[0] = { ACTION_NOTHING, ACTION_SHIFT, ACTION_SHIFT, ACTION_NOTHING, CLASSIC_ESC, ASCII_TAB,
ACTION_CTRL, ASCII_BACKSLASH },
[1] = { ASCII_DEL, 'p', ';', '/', ASCII_SPACE, 'z', 'a', 'q' },
[2] = { ASCII_ACTION_BREAK, ASCII_COMMA, 'm', 'n', 'b', 'v', 'c', 'x' },
[3] = { ACTION_NOTHING, 'k', 'j', 'h', 'g', 'f', 'd', 's' },
[4] = { ACTION_NOTHING, 'i', 'u', 'y', 't', 'r', 'e', 'w' },
[5] = { ACTION_NOTHING, ACTION_REPEAT, ACTION_CAPS, ASCII_CR, ASCII_LF, 'o', 'l', ASCII_PERIOD },
[6] = { ASCII_TILDE, ASCII_RT_SQUARE_BRACE, ASCII_LT_SQUARE_BRACE, '-', ':', ASCII_ZERO, '9',
'8' },
[7] = { ASCII_AT, '7', '6', '5', '4', '3', '2', '1' },
ASDF_CLASSIC_DIP_SWITCHES
};
const FLASH keycode_matrix_t ascii_shift_matrix = {
[0] = { ACTION_NOTHING, ACTION_SHIFT, ACTION_SHIFT, ACTION_NOTHING, ASCII_ESC, ASCII_TAB,
ACTION_CTRL, ASCII_VERT_BAR },
[1] = { ASCII_DEL, 'P', '+', '?', ASCII_SPACE, 'Z', 'A', 'Q' },
[2] = { ASCII_ACTION_CLEAR, '<', 'M', 'N', 'B', 'V', 'C', 'X' },
[3] = { ACTION_NOTHING, 'K', 'J', 'H', 'G', 'F', 'D', 'S' },
[4] = { ACTION_NOTHING, 'I', 'U', 'Y', 'T', 'R', 'E', 'W' },
[5] = { ACTION_NOTHING, ACTION_REPEAT, ACTION_CAPS, ASCII_CR, ASCII_LF, 'O', 'L', '>' },
[6] = { ASCII_TILDE, ASCII_RT_CURLY_BRACE, ASCII_LT_CURLY_BRACE, '=', '*', ASCII_ZERO,
ASCII_RT_PAREN, ASCII_LT_PAREN },
[7] = { ASCII_GRAVE_ACCENT, ASCII_SINGLE_QUOTE, '&', '%', '$', '#', ASCII_DOUBLE_QUOTE, '!' },
ASDF_CLASSIC_DIP_SWITCHES
};
const FLASH keycode_matrix_t ascii_caps_matrix = {
[0] = { ACTION_NOTHING, ACTION_SHIFT, ACTION_SHIFT, ACTION_NOTHING, ASCII_ESC, ASCII_TAB,
ACTION_CTRL, ASCII_BACKSLASH },
[1] = { ASCII_DEL, 'P', ';', '/', ASCII_SPACE, 'Z', 'A', 'Q' },
[2] = { ASCII_ACTION_BREAK, ASCII_COMMA, 'M', 'N', 'B', 'V', 'C', 'X' },
[3] = { ACTION_NOTHING, 'K', 'J', 'H', 'G', 'F', 'D', 'S' },
[4] = { ACTION_NOTHING, 'I', 'U', 'Y', 'T', 'R', 'E', 'W' },
[5] = { ACTION_NOTHING, ACTION_REPEAT, ACTION_CAPS, ASCII_CR, ASCII_LF, 'O', 'L', ASCII_PERIOD },
[6] = { ASCII_TILDE, ASCII_RT_SQUARE_BRACE, ASCII_LT_SQUARE_BRACE, '-', ':', ASCII_ZERO, '9',
'8' },
[7] = { ASCII_AT, '7', '6', '5', '4', '3', '2', '1' },
ASDF_CLASSIC_DIP_SWITCHES
};
const FLASH keycode_matrix_t ascii_ctrl_matrix = {
[0] = { ACTION_NOTHING, ACTION_SHIFT, ACTION_SHIFT, ACTION_NOTHING, ASCII_ESC, ASCII_TAB,
ACTION_CTRL, 0x1c },
[1] = { ACTION_NOTHING, ASCII_CTRL_P, ACTION_NOTHING, ACTION_NOTHING, ASCII_SPACE, ASCII_CTRL_Z,
ASCII_CTRL_A, ASCII_CTRL_Q },
[2] = { ASCII_ACTION_RESET, ASCII_COMMA, ASCII_CTRL_M, ASCII_CTRL_N, ASCII_CTRL_B, ASCII_CTRL_V,
ASCII_CTRL_C, ASCII_CTRL_X },
[3] = { ACTION_NOTHING, ASCII_CTRL_K, ASCII_CTRL_J, ASCII_CTRL_H, ASCII_CTRL_G, ASCII_CTRL_F,
ASCII_CTRL_D, ASCII_CTRL_S },
[4] = { ACTION_NOTHING, ASCII_CTRL_I, ASCII_CTRL_U, ASCII_CTRL_Y, ASCII_CTRL_T, ASCII_CTRL_R,
ASCII_CTRL_E, ASCII_CTRL_W },
[5] = { ACTION_NOTHING, ACTION_REPEAT, ACTION_CAPS, ASCII_CR, ASCII_LF, ASCII_CTRL_O,
ASCII_CTRL_L, ACTION_NOTHING },
[6] = { ACTION_NOTHING, 0x1d, ASCII_ESC, ACTION_NOTHING, ACTION_NOTHING, ACTION_FN_10,
ACTION_FN_9, ACTION_FN_8 },
[7] = { ASCII_NULL, ACTION_FN_7, ACTION_FN_6, ACTION_FN_5, ACTION_FN_4, ACTION_FN_3, ACTION_FN_2,
ACTION_FN_1 },
ASDF_CLASSIC_DIP_SWITCHES
};
static keycode_matrix_t *classic_maps[] = {
[CLASSIC_CAPS_MAP] = classic_caps_matrix,
[CLASSIC_PLAIN_MAP] = classic_plain_matrix,
[CLASSIC_SHIFT_MAP] = classic_shift_matrix,
[CLASSIC_CTRL_MAP] = classic_ctrl_matrix,
}
void classic_add_map(const classic_maps_index_t map_index,
modifier_index_t modifier_index)
{
asdf_keycode_t (*matrix)[CLASSIC_NUM_COLS] =
classic_maps[map_index];
asdf_keymaps_add_map(&matrix[0][0], modifier_index, (uint8_t) CLASSIC_NUM_ROWS,
(uint8_t) CLASSIC_NUM_COLS);
}
//-------|---------|---------+---------+---------+---------+---------+---------+
// Above line is 80 columns, and should display completely in the editor.

View File

@ -0,0 +1,50 @@
// -*- mode: C; tab-width: 4 ; indent-tabs-mode: nil -*-
//
// Unfified Keyboard Project
// ASDF keyboard firmware
//
// asdf_keymap_classic_add_map.h
//
// defines keymap matrices and add_map() function for classic layouts
//
// 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/>.
// To use this ascii for a new keymap, edit the keymaps definitions as
// desired. The keymaps are organized from row 0, counting upward, and each row
// includes the columns from 0-NUM_COLS.
//
#if !defined(ASDF_KEYMAP_CLASSIC_ADD_MAP_H)
#define ASDF_KEYMAP_CLASSIC_ADD_MAP_H
typedef enum {
CLASSIC_PLAIN_MAP,
CLASSIC_CAPS_MAP,
CLASSIC_SHIFT_MAP,
CLASSIC_CTRL_MAP,
} classic_map_index_t;
// function prototypes
void classic_add_map(const classic_map_index_t map_index, modifier_index_t modifier_index);
#endif /* !defined (ASDF_KEYMAP_CLASSIC_ADD_MAP_H) */
//-------|---------|---------+---------+---------+---------+---------+---------+
// Above line is 80 columns, and should display completely in the editor.

View File

@ -0,0 +1,71 @@
// -*- mode: C; tab-width: 2 ; indent-tabs-mode: nil -*-
//
// Unified Keyboard Project
// ASDF keyboard firmware
//
// asdf_keymap_classic.c
//
// Implements the "classic" ADM 3A style keymaps
//
// 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/>.
//
#include "asdf_keymap_classic.h"
#include "asdf_keymap_classic_add_map.h"
// PROCEDURE:
// INPUTS:
// OUTPUTS:
//
// DESCRIPTION:
//
// SIDE EFFECTS:
//
// NOTES:
//
// SCOPE:
//
// COMPLEXITY:
//
void setup_classic_caps_keymap(void)
{
// for the ALL CAPS keymap, the "plain" mode is the same as "all caps" mode:
classic_add_map(CLASSIC_CAPS_MAP, MOD_PLAIN_MAP);
classic_add_map(CLASSIC_CAPS_MAP, MOD_CAPS_MAP);
classic_add_map(CLASSIC_SHIFT_MAP, MOD_SHIFT_MAP);
classic_add_map(CLASSIC_CTRL_MAP, MOD_CTRL_MAP);
asdf_virtual_init();
// Assign power LED to virtual power LED, and initialize to ON
asdf_virtual_assign(CLASSIC_VIRTUAL_POWER_LED, CLASSIC_POWER_LED, V_NOFUNC, CLASSIC_POWER_LED_INIT_VALUE);
// Because the virtual power LED never changes, also assign the CAPSLOCK
// physical LED to the virtual Power LED, and intialize to OFF (or can change
// to ON depending on preference)
asdf_virtual_assign(CLASSIC_VIRTUAL_POWER_LED, CLASSIC_CAPS_LED, V_NOFUNC, CLASSIC_CAPS_LED_INIT_VALUE);
// assign RESET output to the virtual RESET output, configure to produce a short pulse when activated
asdf_virtual_assign(CLASSIC_VIRTUAL_RESET, CLASSIC_RESET_OUTPUT, V_PULSE_SHORT, !CLASSIC_RESET_ACTIVE_VALUE);
// assign the CLRSCR output to the virtual CLRSCR output, configure to produce a long pulse when activated
asdf_virtual_assign(CLASSIC_VIRTUAL_CLR_SCR, CLASSIC_CLR_SCR_OUT, V_PULSE_LONG, !CLASSIC_CLR_SCR_ACTIVE_VALUE);
}
//-------|---------|---------+---------+---------+---------+---------+---------+
// Above line is 80 columns, and should display completely in the editor.

View File

@ -0,0 +1,14 @@
// PROCEDURE:
// INPUTS:
// OUTPUTS:
//
// DESCRIPTION:
//
// SIDE EFFECTS:
//
// NOTES:
//
// SCOPE:
//
// COMPLEXITY:
//

View File

@ -49,9 +49,6 @@
// Data structure sizes:
// Max number of keymaps supported (defines size of keymap setup routine array)
#define ASDF_NUM_KEYMAPS 16
// size of the keycode output buffer.
#define ASDF_KEYCODE_BUFFER_SIZE 64

View File

@ -0,0 +1,39 @@
// -*- mode: C; tab-width: 2 ; indent-tabs-mode: nil -*-
//
// Unified Keyboard Project
// ASDF keyboard firmware
//
// asdf_keymap_table.c
//
// initialize keymap setup function table
//
// *** AUTO-generated file. DO NOT EDIT. ***
// *** To modify template, edit $ROOT/src/Keymaps/asdf_keymap_table.c.in ***
// *** To modify keymap list, edit $ROOT/keymap_list.cmake
//
// 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/>.
//
#include "asdf_keymap_table.h"
asdf_keymap_setup_function_t keymap_setup_function_lookup_table[ASDF_NUM_KEYMAPS] = {
@keymap_table@
}
//-------|---------|---------+---------+---------+---------+---------+---------+
// Above line is 80 columns, and should display completely in the editor.

View File

@ -0,0 +1,39 @@
// -*- mode: C; tab-width: 2 ; indent-tabs-mode: nil -*-
//
// Unified Keyboard Project
// ASDF keyboard firmware
//
// asdf_keymap_table.c
//
// initialize keymap setup function table
//
// *** AUTO-generated file. DO NOT EDIT. ***
// *** To modify template, edit $ROOT/src/Keymaps/asdf_keymap_table.c.in ***
// *** To modify keymap list, edit $ROOT/keymap_list.cmake
//
// 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/>.
//
#define ASDF_NUM_KEYMAPS @num_keymaps@
// define the type for a keymap setup function. Keymaps are registerd by storing
// a keymap setup function in the keymap setup array.
typedef void (*asdf_keymap_setup_function_t)(void);
//-------|---------|---------+---------+---------+---------+---------+---------+
// Above line is 80 columns, and should display completely in the editor.

View File

@ -20,6 +20,7 @@
// You should have received a copy of the GNU General Public License along with
// this program. If not, see <https://www.gnu.org/licenses/>.
#include <stdio.h> //FIXME
#include <stdint.h>
#include <stddef.h>
#include "asdf_config.h"
@ -28,6 +29,7 @@
#include "asdf_physical.h"
#include "asdf_virtual.h"
#include "asdf_hook.h"
#include "asdf_keymap_table.h"
#include "asdf_keymaps.h"
#include "asdf_modifiers.h"
@ -38,38 +40,12 @@ static asdf_keycode_map_t keymaps[ASDF_MOD_NUM_MODIFIERS] = {};
// List of keymap setup routines. Each keymap setup routine is responsible for
// populating the keymap matrices, setting up virtual devices, and setting up
// keymap-specific function hooks and initial conditions for the keymap.
static asdf_keymap_setup_function_t keymap_setup_function_lookup_table[ASDF_NUM_KEYMAPS];
extern asdf_keymap_setup_function_t keymap_setup_function_lookup_table[ASDF_NUM_KEYMAPS];
// The current keymap index. This is stored so bitwise operators on the keymap index can be performed.
static uint8_t current_keymap_index;
// PROCEDURE: asdf_keymaps_register
// INPUTS: (uint8_t) keymap_index - index of the keymap to be modified
// (asdf_keymap_setup_function_t) keymap setup function - called on
// keymap change to setup up the keymap
//
// OUTPUTS: none
//
// DESCRIPTION: Called by keymap building modules. This routine adds a keymap
// setup function into the keymap setup array.
//
// SIDE EFFECTS:
//
// NOTES: If the keymap modifier index is not a valid keymap index then no
// action is performed.
//
// SCOPE: public
//
// COMPLEXITY: 1
void asdf_keymaps_register(uint8_t keymap_index, asdf_keymap_setup_function_t keymap_setup_function)
{
if (keymap_index < ASDF_NUM_KEYMAPS)
{
keymap_setup_function_lookup_table[keymap_index] = keymap_setup_function;
}
}
// PROCEDURE: asdf_keymaps_add_map
// INPUTS: (asdf_keycode_t *) - pointer to the keycode matrix to add in to map
// (uint8_t) modifier_index - the modifier value for the keycode matrix being added
@ -220,9 +196,6 @@ void asdf_keymaps_dummy_function(void) {}
//
void asdf_keymaps_init(void)
{
for (uint8_t i = 0; i < ASDF_NUM_KEYMAPS; i++) {
keymap_setup_function_lookup_table[i] = &asdf_keymaps_dummy_function;
}
current_keymap_index = 0;
}

View File

@ -1,5 +1,5 @@
temporary_config_file(${ASDF_SRC_DIR}/Keymaps/asdf_all_keymap_defs_test.h ${CMAKE_CURRENT_BINARY_DIR}/asdf_keymap_defs.h)
temporary_config_file(${ASDF_SRC_DIR}/Arch/asdf_arch_test.h ${CMAKE_CURRENT_BINARY_DIR}/asdf_arch.h)
configure_file(${ASDF_SRC_DIR}/Keymaps/asdf_all_keymap_defs_test.h ${CMAKE_CURRENT_BINARY_DIR}/asdf_keymap_defs.h COPYONLY)
configure_file(${ASDF_SRC_DIR}/Arch/asdf_arch_test.h ${CMAKE_CURRENT_BINARY_DIR}/asdf_arch.h COPYONLY)
list(APPEND C_FLAGS
"-std=c99"
@ -16,17 +16,30 @@ list(APPEND C_FLAGS
"-Wstrict-prototypes"
"-Wundef"
"-Wold-style-definition"
"-g"
)
list(APPEND TEST_INCLUDES
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/unity
${CMAKE_CURRENT_BINARY_DIR}
${ASDF_SRC_DIR}
${ASDF_SRC_DIR}/Arch
)
add_library(unity
STATIC
${CMAKE_CURRENT_SOURCE_DIR}/unity/unity.c
)
target_include_directories(unity
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/unity
)
add_library(asdf_core
STATIC
asdf_keymap_table.c
${ASDF_SRC_DIR}/asdf.c
${ASDF_SRC_DIR}/asdf_buffer.c
${ASDF_SRC_DIR}/asdf_hook.c
@ -50,6 +63,7 @@ add_library(test_helpers
STATIC
${CMAKE_CURRENT_SOURCE_DIR}/test_asdf_lib.c
${CMAKE_CURRENT_SOURCE_DIR}/test_asdf_keymap_defs.c
${CMAKE_CURRENT_SOURCE_DIR}/asdf_keymap_table.c
)
target_include_directories(test_helpers
@ -69,7 +83,6 @@ function(setup_test testname)
add_executable(${testname}
${testname}.c
unity/unity.c
)
target_compile_options(${testname}
@ -82,7 +95,7 @@ function(setup_test testname)
${TEST_INCLUDES}
)
target_link_libraries(${testname} asdf_core test_helpers)
target_link_libraries(${testname} unity asdf_core test_helpers)
add_test(
NAME ${testname}

View File

@ -0,0 +1,52 @@
// -*- mode: C; tab-width: 2 ; indent-tabs-mode: nil -*-
//
// Unified Keyboard Project
// ASDF keyboard firmware
//
// asdf_keymap_table.c
//
// initialize keymap setup function table
//
// *** This is a special versiof for testing.
// *** Not auto-generated.
//
// 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/>.
//
#include "asdf_keymap_table.h"
#include "test_asdf_keymap_defs.h"
asdf_keymap_setup_function_t keymap_setup_function_lookup_table[ASDF_NUM_KEYMAPS] = {
[ASDF_TEST_PLAIN_MAP_INDEX] = setup_test_plain_map,
[ASDF_TEST_CAPS_MAP_INDEX] = setup_test_caps_map,
[ASDF_TEST2_PLAIN_MAP_INDEX] = setup_test2_plain_map,
[ASDF_TEST2_CAPS_MAP_INDEX] = setup_test2_caps_map,
// keymap assignments for the virtual device tests
[SINGLE_TESTS_KEYMAP] = &setup_test_vdevs_single,
[DOUBLE_ASSIGN_TEST_KEYMAP] = &setup_test_vdevs_double,
[TRIPLE_TESTS_KEYMAP] = setup_test_vdevs_triple,
[VCAPS_TEST_KEYMAP] = setup_test_vdevs_vcaps,
// keymap assignments for the hook mechanism tests
[ASDF_TEST_DEFAULT_SCANNER_MAP] = setup_test_hooks_alt_scanner,
[ASDF_TEST_ALTERNATE_OUTPUT_MAP] = setup_test_hooks_alt_output,
[ASDF_TEST_EACH_SCAN_MAP] = setup_test_hooks_each_scan,
};
//-------|---------|---------+---------+---------+---------+---------+---------+
// Above line is 80 columns, and should display completely in the editor.

View File

@ -0,0 +1,38 @@
// -*- mode: C; tab-width: 2 ; indent-tabs-mode: nil -*-
//
// Unified Keyboard Project
// ASDF keyboard firmware
//
// asdf_keymap_table.c
//
// initialize keymap setup function table
//
// *** This is configured for testing.
// *** NOT auto-generated
//
// 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/>.
//
#define ASDF_NUM_KEYMAPS 11
// define the type for a keymap setup function. Keymaps are registerd by storing
// a keymap setup function in the keymap setup array.
typedef void (*asdf_keymap_setup_function_t)(void);
//-------|---------|---------+---------+---------+---------+---------+---------+
// Above line is 80 columns, and should display completely in the editor.

View File

@ -30,13 +30,7 @@ void setUp(void)
asdf_keymaps_init();
asdf_init();
asdf_keymaps_register(ASDF_TEST_PLAIN_MAP_INDEX, &setup_test_hooks_map0);
asdf_keymaps_register(ASDF_TEST_CAPS_MAP_INDEX, &setup_test_hooks_map1);
asdf_keymaps_register(ASDF_TEST2_PLAIN_MAP_INDEX, &setup_test_hooks_map2);
asdf_keymaps_register(ASDF_TEST2_CAPS_MAP_INDEX, &setup_test_hooks_map3);
asdf_keymaps_select(0);
asdf_keymaps_select(ASDF_TEST_DEFAULT_SCANNER_MAP);
}
void tearDown(void) {}
@ -57,7 +51,7 @@ void test_default_scan_hook_is_default_scanner(void)
TEST_ASSERT_EQUAL_INT((int) asdf_arch_read_row(100), (int) testval);
}
// test_alternate_scan_hook
// test_alternate_scan_hook
void test_alternate_scan_hook(void)
{
asdf_keymaps_select(ASDF_TEST_ALTERNATE_SCANNER_MAP);

View File

@ -23,11 +23,12 @@
// this program. If not, see <https://www.gnu.org/licenses/>.
//
#include <test_asdf_keymap_defs.h>
#include "test_asdf_keymap_defs.h"
#include "asdf_ascii.h"
#include "asdf_modifiers.h"
#include "asdf_keymaps.h"
#include "test_asdf_lib.h"
#include "asdf_keymap_table.h"
static const asdf_keycode_t test_PLAIN_matrix[TEST_NUM_ROWS][TEST_NUM_COLS] = ASDF_TEST_PLAIN_MAP;
static const asdf_keycode_t test_SHIFT_matrix[TEST_NUM_ROWS][TEST_NUM_COLS] = ASDF_TEST_SHIFT_MAP;
@ -50,7 +51,7 @@ void test_keymaps_add_map(const asdf_keycode_t (*matrix)[TEST_NUM_COLS],
void setup_test_plain_map(void)
{
test_keymaps_add_map(&test_PLAIN_matrix[0], MOD_PLAIN_MAP);
test_keymaps_add_map(test_PLAIN_matrix, MOD_PLAIN_MAP);
test_keymaps_add_map(test_CAPS_matrix, MOD_CAPS_MAP);
test_keymaps_add_map(test_SHIFT_matrix, MOD_SHIFT_MAP);
test_keymaps_add_map(test_CTRL_matrix, MOD_CTRL_MAP);
@ -80,7 +81,7 @@ void setup_test2_caps_map(void)
test_keymaps_add_map(test2_CTRL_matrix, MOD_CTRL_MAP);
}
void setup_test_vdevs_map0(void)
void setup_test_vdevs_single(void)
{
setup_test_plain_map();
@ -95,6 +96,15 @@ void setup_test_vdevs_map0(void)
/* single pulse */
asdf_virtual_assign(VOUT3, PHYSICAL_OUT3, V_PULSE_SHORT, 0);
asdf_virtual_sync();
}
void setup_test_vdevs_double(void)
{
setup_test_plain_map();
asdf_virtual_init();
/* first of double assignment attempt */
asdf_virtual_assign(VOUT4, PHYSICAL_LED1, V_NOFUNC, 0);
@ -104,9 +114,8 @@ void setup_test_vdevs_map0(void)
asdf_virtual_sync();
}
void setup_test_vdevs_map1(void)
void setup_test_vdevs_triple(void)
{
setup_test_caps_map();
asdf_virtual_init();
@ -119,7 +128,7 @@ void setup_test_vdevs_map1(void)
asdf_virtual_sync();
}
void setup_test_vdevs_map2(void)
void setup_test_vdevs_vcaps(void)
{
setup_test2_plain_map();
@ -133,43 +142,22 @@ void setup_test_vdevs_map2(void)
asdf_virtual_sync();
}
void setup_test_vdevs_map3(void)
void setup_test_hooks_alt_scanner(void)
{
setup_test2_caps_map();
asdf_virtual_init();
asdf_virtual_assign(VCAPS_LED, PHYSICAL_LED1, V_NOFUNC, 0);
asdf_virtual_assign(VSHIFT_LED, PHYSICAL_LED2, V_NOFUNC, 0);
asdf_virtual_assign(VOUT2, PHYSICAL_OUT3, V_NOFUNC, 0);
asdf_virtual_assign(VOUT2, ASDF_PHYSICAL_NUM_RESOURCES, V_NOFUNC, 0);
asdf_virtual_sync();
}
void setup_test_hooks_map0(void)
{
setup_test_plain_map();
setup_test2_plain_map();
asdf_hook_init();
}
void setup_test_hooks_map1(void)
{
setup_test_caps_map();
asdf_hook_init();
}
void setup_test_hooks_map2(void)
void setup_test_hooks_alt_output(void)
{
setup_test2_plain_map();
asdf_hook_init();
asdf_hook_assign(ASDF_HOOK_SCANNER, (void (*)(void)) &test_hook_read_row);
asdf_hook_assign(ASDF_HOOK_OUTPUT, (void (*)(void)) &test_hook_output);
asdf_hook_assign(ASDF_HOOK_SCANNER, (void (*)(void)) &test_hook_read_row);
}
void setup_test_hooks_map3(void)
void setup_test_hooks_each_scan(void)
{
setup_test2_caps_map();

View File

@ -204,32 +204,34 @@
#define ASDF_TEST2_PLAIN_MAP_INDEX 2
#define ASDF_TEST2_CAPS_MAP_INDEX 3
// keymap assignments for the virtual device tests
#define SINGLE_TESTS_KEYMAP ASDF_TEST_PLAIN_MAP_INDEX
#define DOUBLE_ASSIGN_TEST_KEYMAP ASDF_TEST_PLAIN_MAP_INDEX
#define TRIPLE_TESTS_KEYMAP ASDF_TEST_CAPS_MAP_INDEX
#define VCAPS_TEST_KEYMAP ASDF_TEST2_PLAIN_MAP_INDEX
#define VSHIFT_TEST_KEYMAP ASDF_TEST2_PLAIN_MAP_INDEX
#define SINGLE_TESTS_KEYMAP 4
#define DOUBLE_ASSIGN_TEST_KEYMAP 5
#define TRIPLE_TESTS_KEYMAP 6
#define VCAPS_TEST_KEYMAP 7
#define VSHIFT_TEST_KEYMAP VCAPS_TEST_KEYMAP
// keymap assignments for the hook mechanism tests
#define ASDF_TEST_ALTERNATE_SCANNER_MAP ASDF_TEST2_PLAIN_MAP_INDEX
#define ASDF_TEST_ALTERNATE_OUTPUT_MAP ASDF_TEST2_PLAIN_MAP_INDEX
#define ASDF_TEST_EACH_SCAN_MAP ASDF_TEST2_CAPS_MAP_INDEX
#define ASDF_TEST_DEFAULT_SCANNER_MAP 8
#define ASDF_TEST_ALTERNATE_SCANNER_MAP 9
#define ASDF_TEST_ALTERNATE_OUTPUT_MAP 9
#define ASDF_TEST_EACH_SCAN_MAP 10
void setup_test_plain_map(void);
void setup_test_caps_map(void);
void setup_test2_plain_map(void);
void setup_test2_caps_map(void);
void setup_test_vdevs_map0(void);
void setup_test_vdevs_map1(void);
void setup_test_vdevs_map2(void);
void setup_test_vdevs_map3(void);
void setup_test_vdevs_single(void);
void setup_test_vdevs_double(void);
void setup_test_vdevs_triple(void);
void setup_test_vdevs_vcaps(void);
void setup_test_hooks_alt_scanner(void);
void setup_test_hooks_alt_output(void);
void setup_test_hooks_each_scan(void);
void setup_test_hooks_map0(void);
void setup_test_hooks_map1(void);
void setup_test_hooks_map2(void);
void setup_test_hooks_map3(void);

View File

@ -1,10 +1,11 @@
#include <stdint.h>
#include <stdarg.h>
#include "asdf_arch_test.h"
#include "asdf_arch.h"
#include "unity.h"
#include "asdf.h"
#include "asdf_ascii.h"
#include "asdf_modifiers.h"
#include "asdf_keymap_table.h"
#include "test_asdf_keymap_defs.h"
#include "asdf_keymaps.h"
#include "test_asdf_lib.h"
@ -122,6 +123,7 @@ void setUp(void)
coord_t *temp;
asdf_keymaps_init();
asdf_keymaps_select(ASDF_TEST_PLAIN_MAP_INDEX);
temp = find_code(TESTALPHA);
alpha_sample = *temp;
@ -132,10 +134,6 @@ void setUp(void)
temp = find_code(TESTKEYMAP_TAG);
keymap_tag = *temp;
asdf_keymaps_register(ASDF_TEST_PLAIN_MAP_INDEX, &setup_test_plain_map);
asdf_keymaps_register(ASDF_TEST_CAPS_MAP_INDEX, &setup_test_caps_map);
asdf_keymaps_register(ASDF_TEST2_PLAIN_MAP_INDEX, &setup_test2_plain_map);
asdf_keymaps_register(ASDF_TEST2_CAPS_MAP_INDEX, &setup_test2_caps_map);
}
void tearDown(void) {}

View File

@ -16,12 +16,7 @@ void setUp(void)
asdf_arch_init();
asdf_keymaps_init();
asdf_keymaps_register(ASDF_TEST_PLAIN_MAP_INDEX, &setup_test_vdevs_map0);
asdf_keymaps_register(ASDF_TEST_CAPS_MAP_INDEX, &setup_test_vdevs_map1);
asdf_keymaps_register(ASDF_TEST2_PLAIN_MAP_INDEX, &setup_test_vdevs_map2);
asdf_keymaps_register(ASDF_TEST2_CAPS_MAP_INDEX, &setup_test_vdevs_map3);
asdf_keymaps_select(0);
asdf_keymaps_select(
}