aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md7
-rw-r--r--matrix.c95
-rw-r--r--unimap_00.c12
-rw-r--r--unimap_trans.h18
4 files changed, 80 insertions, 52 deletions
diff --git a/README.md b/README.md
index 516810d..89f9151 100644
--- a/README.md
+++ b/README.md
@@ -12,7 +12,10 @@ while supporting most of its original features and many new features:
* Full N Key Rollover.
The original firmware supported only 3-Key Rollover.
* The security key ("Bediensicherungsbaugruppe") is exposed as a key
- between F19 and F24.
+ between F18 and F24 (in the Unimap framework).
+ Inserting it will generate a keypress of F19-F24, depending on the "security key"
+ actually used. When removing it, F18 is additionally pressed which is mapped
+ to RCTRL but can be remapped using the Keymap editor as necessary.
* Supports the [Unimap keymapping framework](https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/doc/unimap.txt)
which eases adapting the keyboard layout and allows you to edit the keymap without
recompilation using the online [Keymap editor](http://www.tmk-kbd.com/tmk_keyboard/editor/unimap/).
@@ -116,6 +119,8 @@ Desolder the buzzer's 390R resistor and connect the side *facing away* from it
to a jumper cable.
It will connect to pin __FIXME__ of the Teensy.
+Desolder the IFFS cable.
+
Connect the VCC, GND and the control pin of the relay using jumper cables with
the Teensy.
The control pin should be connected to PB3 of the Teensy.
diff --git a/matrix.c b/matrix.c
index 8f98afd..7ca3def 100644
--- a/matrix.c
+++ b/matrix.c
@@ -89,53 +89,20 @@ uint8_t matrix_scan(void)
*/
_delay_us(30);
- uint8_t row = 0;
-
- /*
- * The first 4 bits in the 15th column
- * are sensed like ordinary keypresses but
- * in reality represent a 3-bit "security key"
- * (cf. Betriebsdokumentation, p.13f) with
- * an actual resolution of 6 encoded into a special
- * keylike device that's plugged into the keyboard.
- * It makes no sense to map these original bits into
- * the keyboard matrix.
- * Instead we translate it into one of six key presses
- * via unused fields of the keyboard matrix whenever
- * the "security" key is removed.
- * These pseudo-keypress are mapped to F19-F24 in unimap_trans
- * and could be mapped at the OS level, eg. to lock up the screen.
- */
- if (col+1 == MATRIX_COLS) {
- static uint8_t last_security_key = 0;
- uint8_t security_key = (!read_row(0) << 0) |
- (!read_row(1) << 1) |
- (!read_row(2) << 2);
-
- for (uint8_t i = 0; i < 6; i++)
- matrix_debouncing[i] &= ~(1 << col);
- if (security_key != last_security_key && security_key == 0 &&
- 1 <= last_security_key && last_security_key <= 6)
- matrix_debouncing[last_security_key-1] |= (1 << col);
-
- last_security_key = security_key;
- row = 6;
- }
-
- while (row < MATRIX_ROWS) {
+ for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
matrix_row_t prev_row = matrix_debouncing[row];
if (read_row(row)) {
matrix_debouncing[row] |= (1 << col);
- matrix_debouncing_pressed_keys++;
+ /* the "security key" bits do not count into the pressed keys */
+ if (col < MATRIX_COLS-1 || row > 3)
+ matrix_debouncing_pressed_keys++;
} else {
matrix_debouncing[row] &= ~(1 << col);
}
if (matrix_debouncing[row] != prev_row)
debouncing_time = timer_read();
-
- row++;
}
unselect_cols();
@@ -183,7 +150,61 @@ uint8_t matrix_scan(void)
memcpy(matrix, matrix_debouncing, sizeof(matrix));
matrix_pressed_keys = matrix_debouncing_pressed_keys;
+ /*
+ * The first 4 bits in the 15th column
+ * are sensed like ordinary keypresses but
+ * in reality represent a 3-bit "security key"
+ * (cf. Betriebsdokumentation, p.13f) with
+ * an actual resolution of 6 encoded into a special
+ * keylike device that's plugged into the keyboard.
+ * It makes no sense to map these original bits into
+ * the keyboard matrix.
+ * Instead we translate it into one of six key presses
+ * via unused fields of the keyboard matrix whenever
+ * the "security" key is removed.
+ * These pseudo-keypress are mapped to F19-F24 in unimap_trans
+ * and could be mapped at the OS level, eg. to lock up the screen.
+ * When removing the "security key", F18 is also pressed which
+ * will usually be mapped to a modifier but could also be left
+ * F18 and be used to lock up the screen, ignoring all the other
+ * pseudo-keys.
+ *
+ * FIXME: It would be more elegant to directly cause
+ * a key event to be generated, but this does not seem to be
+ * supported if we want to take the configurable keymap into account.
+ * Also, it might be more elegant to have all the pseudo-keys
+ * in a dedicated matrix row.
+ */
+ static uint8_t last_security_key = 0;
+ uint8_t security_key = (~(matrix[0] >> (MATRIX_COLS-1)) & (1 << 0)) |
+ (~(matrix[1] >> (MATRIX_COLS-2)) & (1 << 1)) |
+ (~(matrix[2] >> (MATRIX_COLS-3)) & (1 << 2));
+
+ for (uint8_t i = 0; i < 4; i++)
+ matrix[i] &= ~(1 << (MATRIX_COLS-1)); /* F19-F24 */
+
+ if (last_security_key == 0 && 1 <= security_key && security_key <= 6) {
+ dprintf("Security key %u inserted\n", security_key);
+ matrix[security_key-1] |= (1 << (MATRIX_COLS-1)); /* F19-F24 */
+ } else if (1 <= last_security_key && last_security_key <= 6 && security_key == 0) {
+ dprintf("Security key %u removed\n", last_security_key);
+ matrix[0] |= (1 << 13); /* F18 */
+ matrix[last_security_key-1] |= (1 << (MATRIX_COLS-1)); /* F19-F24 */
+ }
+
+ last_security_key = security_key;
+
debouncing_time = 0;
+ } else {
+ /*
+ * Physically inserting or removing the "security key" should
+ * result in a keypress event immediately followed by a kreyrelease.
+ * We therefore clear the matrix slots reserved for it, so that
+ * the key press is reported only for one scan cycle.
+ */
+ matrix[0] &= ~(1 << 13); /* F18 */
+ for (uint8_t i = 0; i < 4; i++)
+ matrix[i] &= ~(1 << (MATRIX_COLS-1)); /* F19-F24 */
}
/*
diff --git a/unimap_00.c b/unimap_00.c
index cd266a7..9c0f995 100644
--- a/unimap_00.c
+++ b/unimap_00.c
@@ -25,10 +25,10 @@ const action_t actionmaps[][UNIMAP_ROWS][UNIMAP_COLS] __attribute__ ((section ("
const action_t actionmaps[][UNIMAP_ROWS][UNIMAP_COLS] PROGMEM = {
#endif
[0] = UNIMAP_K7637(
- ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, PSCR,SLCK,PAUS, VOLD,VOLU,MUTE, F19,
- GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, END, DEL, NLCK,PSLS, F20,
- TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, HOME,PGUP, P7, P8, P9, PPLS, F21,
- CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT,NUHS, ENT, PGDN, P4, P5, P6, NO, F22,
- LSFT,NUBS,Z, X, C, V, B, N, M, COMM,DOT, SLSH, DOWN,UP, P1, P2, P3, PENT, F23,
- NO, LCTL, SPC, RALT, NO, LEFT,RGHT, P0, P00, PCMM,NO, F24),
+ ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, PSCR,SLCK,PAUS, VOLD,VOLU,MUTE, RCTL, F19,
+ GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, END, DEL, NLCK,PSLS, F20,
+ TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, HOME,PGUP, P7, P8, P9, PPLS, F21,
+ CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT,NUHS, ENT, PGDN, P4, P5, P6, NO, F22,
+ LSFT,NUBS,Z, X, C, V, B, N, M, COMM,DOT, SLSH, DOWN,UP, P1, P2, P3, PENT, F23,
+ NO, LCTL, SPC, RALT, NO, LEFT,RGHT, P0, P00, PCMM,NO, F24)
};
diff --git a/unimap_trans.h b/unimap_trans.h
index a616fd1..5c8694a 100644
--- a/unimap_trans.h
+++ b/unimap_trans.h
@@ -23,14 +23,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "unimap.h"
#define UNIMAP_K7637( \
- K29,K3A,K3B,K3C,K3D,K3E,K3F,K40,K41,K42,K43,K44,K45,K68, K46,K47,K48, K01,K02,K03, K6E, \
- K35,K1E,K1F,K20,K21,K22,K23,K24,K25,K26,K27,K2D,K2E,K2A, K4A,K4C, K53,K54, K6F, \
- K2B,K14,K1A,K08,K15,K17,K1C,K18,K0C,K12,K13,K2F,K30, K4D,K4B, K5F,K60,K61,K57, K70, \
- K39,K04,K16,K07,K09,K0A,K0B,K0D,K0E,K0F,K33,K34,K32, K28,K4E, K5C,K5D,K5E,K66, K71, \
- K79,K64,K1D,K1B,K06,K19,K05,K11,K10,K36,K37,K38, K51,K52, K59,K5A,K5B,K58, K72, \
- K78, K7A, K2C, K7E, K7C, K50,K4F, K62,K55,K63,K67, K73 \
+ K29,K3A,K3B,K3C,K3D,K3E,K3F,K40,K41,K42,K43,K44,K45,K68, K46,K47,K48, K01,K02,K03, K6D,K6E, \
+ K35,K1E,K1F,K20,K21,K22,K23,K24,K25,K26,K27,K2D,K2E,K2A, K4A,K4C, K53,K54, K6F, \
+ K2B,K14,K1A,K08,K15,K17,K1C,K18,K0C,K12,K13,K2F,K30, K4D,K4B, K5F,K60,K61,K57, K70, \
+ K39,K04,K16,K07,K09,K0A,K0B,K0D,K0E,K0F,K33,K34,K32, K28,K4E, K5C,K5D,K5E,K66, K71, \
+ K79,K64,K1D,K1B,K06,K19,K05,K11,K10,K36,K37,K38, K51,K52, K59,K5A,K5B,K58, K72, \
+ K78, K7A, K2C, K7E, K7C, K50,K4F, K62,K55,K63,K67, K73 \
) UNIMAP( \
- K68, NO, NO, NO, NO, NO,K6E,K6F,K70,K71,K72,K73, \
+ K68, NO, NO, NO, NO,K6D,K6E,K6F,K70,K71,K72,K73, \
K29, K3A,K3B,K3C,K3D,K3E,K3F,K40,K41,K42,K43,K44,K45, K46,K47,K48, K01,K02,K03, \
K35,K1E,K1F,K20,K21,K22,K23,K24,K25,K26,K27,K2D,K2E, NO,K2A, NO,K4A,K4B, K53,K54,K55, NO, \
K2B,K14,K1A,K08,K15,K17,K1C,K18,K0C,K12,K13,K2F,K30, NO, K4C,K4D,K4E, K5F,K60,K61,K57, \
@@ -82,10 +82,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* NOTE: The first 6 rows in the last column aren't in the original keyboard matrix - they are the
* result of mapping the "security" key.
+ * unimap_trans[0][13] is also an extension and is used to signal "security key" removal
+ * (usually mapped to a modifier).
*/
#define NO UNIMAP_NO
const uint8_t PROGMEM unimap_trans[MATRIX_ROWS][MATRIX_COLS] = {
- {0x02, 0x01, 0x48, 0x45, 0x46, 0x44, 0x40, 0x43, 0x3C, 0x29, 0x3D, 0x42, 0x3E, NO, 0x3A, 0x6E},
+ {0x02, 0x01, 0x48, 0x45, 0x46, 0x44, 0x40, 0x43, 0x3C, 0x29, 0x3D, 0x42, 0x3E, 0x6D, 0x3A, 0x6E},
{ NO, NO, NO, 0x51, 0x47, 0x34, 0x10, 0x38, 0x06, NO, 0x05, 0x37, 0x11, NO, 0x1B, 0x6F},
{0x61, 0x60, 0x5F, 0x2E, 0x4B, 0x2D, 0x23, 0x12, 0x1F, 0x2B, 0x17, 0x25, 0x22, 0x57, 0x1E, 0x70},
{0x5B, 0x5A, 0x59, 0x4D, 0x52, 0x30, 0x0D, 0x33, 0x07, 0x64, 0x09, 0x0E, 0x0B, 0x58, 0x14, 0x71},