diff options
| author | Nikolaus Wittenstein <nikolaus.wittenstein@gmail.com> | 2019-01-22 18:17:41 -0500 |
|---|---|---|
| committer | Drashna Jaelre <drashna@live.com> | 2019-01-22 15:17:41 -0800 |
| commit | 6b1009b7a876db1f0cc5674cfa64739139ea4098 (patch) | |
| tree | 889b7b868977d0d19a64d061d2d629be081feb1f | |
| parent | 2a33d2c4243e6fdca9849ff1caadbaea941e8c85 (diff) | |
| download | qmk_firmware-6b1009b7a876db1f0cc5674cfa64739139ea4098.tar.gz qmk_firmware-6b1009b7a876db1f0cc5674cfa64739139ea4098.zip | |
[Keyboard] Add DataHand keyboard support (#4847)
| -rw-r--r-- | keyboards/handwired/datahand/config.h | 87 | ||||
| -rw-r--r-- | keyboards/handwired/datahand/datahand.h | 133 | ||||
| -rw-r--r-- | keyboards/handwired/datahand/keymaps/default/keymap.c | 313 | ||||
| -rw-r--r-- | keyboards/handwired/datahand/matrix.c | 125 | ||||
| -rw-r--r-- | keyboards/handwired/datahand/readme.md | 15 | ||||
| -rw-r--r-- | keyboards/handwired/datahand/rules.mk | 59 | ||||
| -rw-r--r-- | keyboards/readme.md | 1 |
7 files changed, 733 insertions, 0 deletions
diff --git a/keyboards/handwired/datahand/config.h b/keyboards/handwired/datahand/config.h new file mode 100644 index 000000000..1ba8479f0 --- /dev/null +++ b/keyboards/handwired/datahand/config.h | |||
| @@ -0,0 +1,87 @@ | |||
| 1 | /* Copyright 2017-2019 Nikolaus Wittenstein <nikolaus.wittenstein@gmail.com> | ||
| 2 | * | ||
| 3 | * Permission to use, copy, modify, and/or distribute this software for any | ||
| 4 | * purpose with or without fee is hereby granted, provided that the above | ||
| 5 | * copyright notice and this permission notice appear in all copies. | ||
| 6 | * | ||
| 7 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
| 8 | * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND | ||
| 9 | * FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
| 10 | * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
| 11 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
| 12 | * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
| 13 | * PERFORMANCE OF THIS SOFTWARE. | ||
| 14 | */ | ||
| 15 | |||
| 16 | #pragma once | ||
| 17 | |||
| 18 | #include "config_common.h" | ||
| 19 | |||
| 20 | /* USB Device descriptor parameter */ | ||
| 21 | /* Taken from the DataHand PS/2-USB adaptor. */ | ||
| 22 | #define VENDOR_ID 0x13BA | ||
| 23 | #define PRODUCT_ID 0x0017 | ||
| 24 | #define DEVICE_VER 0x0001 | ||
| 25 | #define MANUFACTURER DataHand | ||
| 26 | #define PRODUCT DataHand | ||
| 27 | #define DESCRIPTION DataHand Teensy++ 2.0 conversion | ||
| 28 | |||
| 29 | /* key matrix size */ | ||
| 30 | #define MATRIX_ROWS 13 | ||
| 31 | #define MATRIX_COLS 4 | ||
| 32 | |||
| 33 | #define DIODE_DIRECTION CUSTOM_MATRIX | ||
| 34 | |||
| 35 | /* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ | ||
| 36 | #define DEBOUNCING_DELAY 0 | ||
| 37 | |||
| 38 | /* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ | ||
| 39 | #define LOCKING_SUPPORT_ENABLE | ||
| 40 | /* Locking resynchronize hack */ | ||
| 41 | #define LOCKING_RESYNC_ENABLE | ||
| 42 | |||
| 43 | /* | ||
| 44 | * Force NKRO | ||
| 45 | * | ||
| 46 | * Force NKRO (nKey Rollover) to be enabled by default, regardless of the saved | ||
| 47 | * state in the bootmagic EEPROM settings. (Note that NKRO must be enabled in the | ||
| 48 | * makefile for this to work.) | ||
| 49 | * | ||
| 50 | * If forced on, NKRO can be disabled via magic key (default = LShift+RShift+N) | ||
| 51 | * until the next keyboard reset. | ||
| 52 | * | ||
| 53 | * NKRO may prevent your keystrokes from being detected in the BIOS, but it is | ||
| 54 | * fully operational during normal computer usage. | ||
| 55 | * | ||
| 56 | * For a less heavy-handed approach, enable NKRO via magic key (LShift+RShift+N) | ||
| 57 | * or via bootmagic (hold SPACE+N while plugging in the keyboard). Once set by | ||
| 58 | * bootmagic, NKRO mode will always be enabled until it is toggled again during a | ||
| 59 | * power-up. | ||
| 60 | */ | ||
| 61 | #define FORCE_NKRO | ||
| 62 | |||
| 63 | /* | ||
| 64 | * Magic Key Options | ||
| 65 | * | ||
| 66 | * Magic keys are hotkey commands that allow control over firmware functions of | ||
| 67 | * the keyboard. They are best used in combination with the HID Listen program, | ||
| 68 | * found here: https://www.pjrc.com/teensy/hid_listen.html | ||
| 69 | * | ||
| 70 | * The options below allow the magic key functionality to be changed. This is | ||
| 71 | * useful if your keyboard/keypad is missing keys and you want magic key support. | ||
| 72 | */ | ||
| 73 | |||
| 74 | /* key combination for magic key command */ | ||
| 75 | #define IS_COMMAND() ( \ | ||
| 76 | keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ | ||
| 77 | ) | ||
| 78 | |||
| 79 | /* | ||
| 80 | * Command/Windows key option | ||
| 81 | * | ||
| 82 | * If you define this, the thumb enter key becomes the Command/Windows key. There's still an enter key on the right | ||
| 83 | * ring finger, so this key is much better utilized as the otherwise nonexistent Command key. I think some newer | ||
| 84 | * DataHands let you remap right ring east as Command, but having it on the thumb is nicer. Comment out this define | ||
| 85 | * to use the original layout. | ||
| 86 | */ | ||
| 87 | #define DATAHAND_THUMB_RETURN_COMMAND | ||
diff --git a/keyboards/handwired/datahand/datahand.h b/keyboards/handwired/datahand/datahand.h new file mode 100644 index 000000000..cb9a4d3e3 --- /dev/null +++ b/keyboards/handwired/datahand/datahand.h | |||
| @@ -0,0 +1,133 @@ | |||
| 1 | /* Copyright 2017-2019 Nikolaus Wittenstein <nikolaus.wittenstein@gmail.com> | ||
| 2 | * | ||
| 3 | * Permission to use, copy, modify, and/or distribute this software for any | ||
| 4 | * purpose with or without fee is hereby granted, provided that the above | ||
| 5 | * copyright notice and this permission notice appear in all copies. | ||
| 6 | * | ||
| 7 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
| 8 | * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND | ||
| 9 | * FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
| 10 | * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
| 11 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
| 12 | * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
| 13 | * PERFORMANCE OF THIS SOFTWARE. | ||
| 14 | */ | ||
| 15 | |||
| 16 | #pragma once | ||
| 17 | |||
| 18 | #include "quantum.h" | ||
| 19 | |||
| 20 | /* This a shortcut to help you visually see your layout. | ||
| 21 | * The first section contains all of the arguements; the second converts the arguments into a two-dimensional array. | ||
| 22 | */ | ||
| 23 | |||
| 24 | /* Each code is three letters | ||
| 25 | * l or r - left or right hand | ||
| 26 | * p, r, m, i, t - pinky, ring finger, middle finger, index finger, thumb | ||
| 27 | * fingers: n, s, e, w, c - north, south, east, west, and center (manual calls this "well" but we already have "west") | ||
| 28 | * thumb: p, n, c, l, u, k - pad, nail, center, lock (harder center), up, knuckle | ||
| 29 | */ | ||
| 30 | #define LAYOUT( \ | ||
| 31 | lpn, lrn, lmn, lin, rin, rmn, rrn, rpn, \ | ||
| 32 | lpw, lpc, lpe, lrw, lrc, lre, lmw, lmc, lme, liw, lic, lie, riw, ric, rie, rmw, rmc, rme, rrw, rrc, rre, rpw, rpc, rpe, \ | ||
| 33 | lps, lrs, lms, lis, ris, rms, rrs, rps, \ | ||
| 34 | ltp, ltn, rtn, rtp, \ | ||
| 35 | ltc, rtc, \ | ||
| 36 | ltl, rtl, \ | ||
| 37 | ltu, ltk, rtk, rtu) \ | ||
| 38 | { \ | ||
| 39 | {riw, rin, lpw, lpn},\ | ||
| 40 | {ric, rie, lpc, lpe},\ | ||
| 41 | {ris, rms, lps, lrs},\ | ||
| 42 | {rmw, rmn, lrw, lrn},\ | ||
| 43 | {rmc, rme, lrc, lre},\ | ||
| 44 | {rrw, rrn, lmw, lmn},\ | ||
| 45 | {rrc, rre, lmc, lme},\ | ||
| 46 | {rrs, rps, lms, lis},\ | ||
| 47 | {rpw, rpn, liw, lin},\ | ||
| 48 | {rpc, rpe, lic, lie},\ | ||
| 49 | {rtk, rtn, ltk, ltn},\ | ||
| 50 | {rtc, rtl, ltc, ltl},\ | ||
| 51 | {rtp, rtu, ltp, ltu},\ | ||
| 52 | } | ||
| 53 | |||
| 54 | /* Mode LEDs are active-low on Port B on the Teensy. */ | ||
| 55 | #define LED_MODE_PORT PORTB | ||
| 56 | #define LED_TENKEY (1<<3) | ||
| 57 | #define LED_FN (1<<4) | ||
| 58 | #define LED_NORMAL (1<<5) | ||
| 59 | #define LED_NAS (1<<6) | ||
| 60 | |||
| 61 | /* Lock LEDs are active-low on Port F on the Teensy. */ | ||
| 62 | #define LED_LOCK_PORT PORTF | ||
| 63 | #define LED_CAPS_LOCK (1<<4) | ||
| 64 | #define LED_MOUSE_LOCK (1<<5) | ||
| 65 | #define LED_NUM_LOCK (1<<6) | ||
| 66 | #define LED_SCROLL_LOCK (1<<7) | ||
| 67 | |||
| 68 | |||
| 69 | /* Appendix: | ||
| 70 | * Table based on https://geekhack.org/index.php?topic=12212.msg2059319#msg2059319 | ||
| 71 | * Some pin assignments (e.g. for PS/2 I/O) have been fixed. | ||
| 72 | * | ||
| 73 | * Teensy Datahand 8051 pin pin 8051 Datahand Teensy | ||
| 74 | * ------ -------- ---- --- --- ---- -------- ------ | ||
| 75 | * GND Mtrx send A P1.0 1 40 VCC VCC VCC | ||
| 76 | * PB7 Mtrx send B P1.1 2 39 P0.0 LED RH NAS PB6 | ||
| 77 | * PD0 Mtrx send C P1.2 3 38 P0.1 LED RH NORM PB5 | ||
| 78 | * PD1 Mtrx send D P1.3 4 37 P0.2 LED RH FCTN PB4 | ||
| 79 | * PD2 RH rcv 0 P1.4 5 36 P0.3 LED RH 10K PB3 | ||
| 80 | * PD3 RH rcv 1 P1.5 6 35 P0.4 LED RH unused PB2 | ||
| 81 | * PD4 LH rcv 0 P1.6 7 34 P0.5 LED RH unused PE1 | ||
| 82 | * PD5 LH rcv 1 P1.7 8 33 P0.6 LED RH unused PE0 | ||
| 83 | * PD6 Reset button RST 9 32 P0.7 ? PE7 | ||
| 84 | * PD7 ? P3.0 10 31 VPP - PE6 | ||
| 85 | * PE0 ? P3.1 11 30 ALE - GND | ||
| 86 | * PE1 kbd data P3.2 12 29 PSEN - AREF | ||
| 87 | * PC0 ? P3.3 13 28 P2.7 ? PF0 | ||
| 88 | * PC1 kbd clk P3.4 14 27 P2.6 ? PF1 | ||
| 89 | * PC2 ? P3.5 15 26 P2.5 ? PF2 | ||
| 90 | * PC3 RAM P3.6 16 25 P2.4 ? PF3 | ||
| 91 | * PC4 RAM P3.7 17 24 P2.3 LED D15 LH (CAPLK) PF4 | ||
| 92 | * PC5 XTAL2 XTAL2 18 23 P2.2 LED D13 LH (MSELK) PF5 | ||
| 93 | * PC6 XTAL1 XTAL1 19 22 P2.1 LED D6 LH (NUMLK) PF6 | ||
| 94 | * PC7 GND GND 20 21 P2.0 LED D14 LH (SCRLK) PF7 | ||
| 95 | * | ||
| 96 | * JP3 Pinout | ||
| 97 | * 2 - keyboard data | ||
| 98 | * 3 - keyboard clock | ||
| 99 | * | ||
| 100 | * In order to get the Teensy to work, we need to move pin 1 to a different pin. This is | ||
| 101 | * because on the Teensy pin 1 is ground, but we need to write to pin 1 in order to read | ||
| 102 | * the keyboard matrix. An ideal pin to move it to is VPP (pin 31), because this pin tells | ||
| 103 | * the 8051 whether it should read from external or internal memory. The Teensy doesn't | ||
| 104 | * care about that. | ||
| 105 | * | ||
| 106 | * The easiest way to reassign the pin is to use standoffs. You can check out this thread: | ||
| 107 | * https://geekhack.org/index.php?topic=12212.msg235382#msg235382 for a picture of what | ||
| 108 | * this looks like. Note that in the picture the pin has been reassigned to pin 12. We | ||
| 109 | * don't want to do that because we're going to use that pin to send data over PS/2. | ||
| 110 | * | ||
| 111 | * We could if we wanted also reassign the PS/2 pins to Teensy hardware UART pins, but | ||
| 112 | * that's more work. Instead we'll just bit-bang PS/2 because it's an old, slow protocol | ||
| 113 | * (and because there's already a bit-banged PS/2 host implementation in QMK - we just | ||
| 114 | * need to add the device side). | ||
| 115 | * | ||
| 116 | * So overall, we want the following inputs and outputs: | ||
| 117 | * Outputs: | ||
| 118 | * Matrix: | ||
| 119 | * PB7 | ||
| 120 | * PD0 | ||
| 121 | * PD1 | ||
| 122 | * PE6 (moved from pin1, GND) | ||
| 123 | * LEDs: | ||
| 124 | * PB3-6 | ||
| 125 | * PF4-7 | ||
| 126 | * Inputs: | ||
| 127 | * Matrix: | ||
| 128 | * PD2-5 | ||
| 129 | * I/Os (start up as inputs): | ||
| 130 | * PS/2: | ||
| 131 | * PC1 | ||
| 132 | * PE1 | ||
| 133 | */ | ||
diff --git a/keyboards/handwired/datahand/keymaps/default/keymap.c b/keyboards/handwired/datahand/keymaps/default/keymap.c new file mode 100644 index 000000000..8f4453559 --- /dev/null +++ b/keyboards/handwired/datahand/keymaps/default/keymap.c | |||
| @@ -0,0 +1,313 @@ | |||
| 1 | /* Copyright 2017-2019 Nikolaus Wittenstein <nikolaus.wittenstein@gmail.com> | ||
| 2 | * | ||
| 3 | * Permission to use, copy, modify, and/or distribute this software for any | ||
| 4 | * purpose with or without fee is hereby granted, provided that the above | ||
| 5 | * copyright notice and this permission notice appear in all copies. | ||
| 6 | * | ||
| 7 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
| 8 | * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND | ||
| 9 | * FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
| 10 | * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
| 11 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
| 12 | * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
| 13 | * PERFORMANCE OF THIS SOFTWARE. | ||
| 14 | */ | ||
| 15 | |||
| 16 | #include QMK_KEYBOARD_H | ||
| 17 | |||
| 18 | #include <stdbool.h> | ||
| 19 | |||
| 20 | /* Datahand features not supported: | ||
| 21 | * * All online reprogramming (user settings using the reset button). | ||
| 22 | * * Program Selection features. | ||
| 23 | * * Macros. | ||
| 24 | * * Direct substitutions. | ||
| 25 | * * L/R Modf. | ||
| 26 | * * Mouse Click Lock (Function Direct Access + Mouse Button key). | ||
| 27 | * * Different mouse movement speeds with the two pointer fingers, and using both pointer fingers to move even faster. | ||
| 28 | * | ||
| 29 | * As far as I know, everything else works. | ||
| 30 | */ | ||
| 31 | |||
| 32 | enum layer { | ||
| 33 | NORMAL, | ||
| 34 | #ifdef DATAHAND_THUMB_RETURN_COMMAND | ||
| 35 | NORMAL_THUMB_RETURN_COMMAND, | ||
| 36 | #endif | ||
| 37 | FUNCTION_MOUSE, | ||
| 38 | FUNCTION_ARROWS, | ||
| 39 | NAS, | ||
| 40 | NAS_NUMLOCK, | ||
| 41 | NAS_TENKEY, | ||
| 42 | NAS_TENKEY_NUMLOCK, | ||
| 43 | |||
| 44 | NUM_LAYERS | ||
| 45 | }; | ||
| 46 | |||
| 47 | enum custom_keycodes { | ||
| 48 | N = SAFE_RANGE, /* Normal */ | ||
| 49 | NS, /* NAS */ | ||
| 50 | NSL, /* NAS Lock */ | ||
| 51 | NLK, /* Numlock */ | ||
| 52 | FN, /* Function mode - needs to be able to switch to mouse or arrow layer */ | ||
| 53 | TK0, /* Ten-key off button */ | ||
| 54 | TK1, /* Ten-key on button */ | ||
| 55 | AR, /* FN arrow mode */ | ||
| 56 | MS, /* FN mouse mode */ | ||
| 57 | DZ, /* Double zero button */ | ||
| 58 | }; | ||
| 59 | |||
| 60 | static bool mouse_enabled = true; | ||
| 61 | static bool tenkey_enabled = false; | ||
| 62 | static bool numlock_enabled = false; | ||
| 63 | static bool nas_locked = false; | ||
| 64 | |||
| 65 | /* Declared weak so that it can easily be overridden. */ | ||
| 66 | __attribute__((weak)) const uint16_t PROGMEM keymaps[NUM_LAYERS][MATRIX_ROWS][MATRIX_COLS] = { | ||
| 67 | [NORMAL] = LAYOUT( | ||
| 68 | KC_Q, KC_W, KC_E, KC_R, KC_U, KC_I, KC_O, KC_P, | ||
| 69 | KC_DEL, KC_A, KC_LBRC, KC_ESC, KC_S, KC_B, KC_GRV, KC_D, KC_T, KC_DQT, KC_F, KC_G, KC_H, KC_J, KC_QUOT, KC_Y, KC_K, KC_COLN, KC_N, KC_L, KC_ENT, KC_RBRC, KC_SCLN, KC_BSLS, | ||
| 70 | KC_Z, KC_X, KC_C, KC_V, KC_M, KC_COMM, KC_DOT, KC_SLSH, | ||
| 71 | KC_ENT, KC_TAB, KC_BSPC, KC_SPC, | ||
| 72 | KC_LSFT, NS, | ||
| 73 | KC_CAPS, NSL, | ||
| 74 | N, KC_LCTL, KC_LALT, FN), | ||
| 75 | |||
| 76 | #ifdef DATAHAND_THUMB_RETURN_COMMAND | ||
| 77 | [NORMAL_THUMB_RETURN_COMMAND] = LAYOUT( | ||
| 78 | _______, _______, _______, _______, _______, _______, _______, _______, | ||
| 79 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | ||
| 80 | _______, _______, _______, _______, _______, _______, _______, _______, | ||
| 81 | KC_LCMD, _______, _______, _______, | ||
| 82 | _______, _______, | ||
| 83 | _______, _______, | ||
| 84 | _______, _______, _______, _______), | ||
| 85 | #endif | ||
| 86 | |||
| 87 | [FUNCTION_MOUSE] = LAYOUT( | ||
| 88 | KC_F2, KC_F4, KC_F6, KC_MS_U, KC_MS_U, KC_F8, KC_F10, KC_PGUP, | ||
| 89 | _______, KC_NO, KC_SLCK, _______, KC_BTN3, NLK, KC_BTN1, MS, KC_BTN2, KC_MS_L, KC_BTN1, KC_MS_R, KC_MS_L, KC_BTN2, KC_MS_R, KC_END, AR, KC_LSFT, KC_INS, KC_9, KC_ENT, KC_F11, KC_0, KC_F12, | ||
| 90 | KC_F1, KC_F3, KC_F5, KC_MS_D, KC_MS_D, KC_F7, KC_F9, KC_PGDN, | ||
| 91 | _______, _______, _______, _______, | ||
| 92 | _______, _______, | ||
| 93 | _______, _______, | ||
| 94 | _______, _______, _______, _______), | ||
| 95 | [FUNCTION_ARROWS] = LAYOUT( | ||
| 96 | _______, _______, _______, KC_UP, KC_UP, _______, _______, _______, | ||
| 97 | _______, _______, _______, _______, KC_LCTL, _______, _______, _______, _______, KC_LEFT, KC_HOME, KC_RGHT, KC_LEFT, KC_HOME, KC_RGHT, _______, _______, _______, _______, _______, _______, _______, _______, _______, | ||
| 98 | _______, _______, _______, KC_DOWN, KC_DOWN, _______, _______, _______, | ||
| 99 | _______, _______, _______, _______, | ||
| 100 | _______, _______, | ||
| 101 | _______, _______, | ||
| 102 | _______, _______, _______, _______), | ||
| 103 | [NAS] = LAYOUT( | ||
| 104 | KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, | ||
| 105 | _______, KC_1, KC_TILD, _______, KC_2, NLK, KC_LABK, KC_3, KC_RABK, KC_SLSH, KC_4, KC_5, KC_6, KC_7, KC_UNDS, KC_CIRC, KC_8, KC_ENT, KC_SCLN, KC_9, KC_BSLS, TK0, KC_0, TK1, | ||
| 106 | KC_EQL, KC_X, KC_PERC, KC_MINS, KC_PLUS, KC_DOT, KC_SLSH, KC_QUES, | ||
| 107 | _______, _______, _______, _______, | ||
| 108 | _______, _______, | ||
| 109 | _______, _______, | ||
| 110 | _______, _______, _______, _______), | ||
| 111 | [NAS_NUMLOCK] = LAYOUT( | ||
| 112 | _______, _______, _______, _______, _______, KC_PAST, _______, _______, | ||
| 113 | _______, KC_KP_1, _______, _______, KC_KP_2, _______, _______, KC_KP_3, _______, KC_PSLS, KC_KP_4, KC_KP_5, KC_KP_6, KC_KP_7, _______, _______, KC_KP_8, _______, _______, KC_KP_9, KC_PENT, _______, KC_KP_0, _______, | ||
| 114 | KC_PEQL, _______, _______, KC_PMNS, KC_PPLS, _______, KC_PDOT, _______, | ||
| 115 | _______, _______, _______, _______, | ||
| 116 | _______, _______, | ||
| 117 | _______, _______, | ||
| 118 | _______, _______, _______, _______), | ||
| 119 | [NAS_TENKEY] = LAYOUT( | ||
| 120 | _______, _______, _______, KC_UP, KC_7, KC_8, KC_9, KC_ASTR, | ||
| 121 | _______, KC_QUOT, _______, _______, KC_DLR, _______, _______, KC_AMPR, _______, KC_LEFT, KC_HOME, KC_RGHT, KC_0, KC_4, DZ, KC_PLUS, KC_5, KC_MINS, KC_EQL, KC_6, KC_ENT, _______, KC_DOT, _______, | ||
| 122 | KC_LPRN, KC_RPRN, _______, KC_DOWN, KC_1, KC_2, KC_3, KC_SLSH, | ||
| 123 | _______, _______, _______, _______, | ||
| 124 | _______, _______, | ||
| 125 | _______, _______, | ||
| 126 | _______, _______, _______, _______), | ||
| 127 | [NAS_TENKEY_NUMLOCK] = LAYOUT( | ||
| 128 | _______, _______, _______, _______, KC_KP_7, KC_KP_8, KC_KP_9, KC_PAST, | ||
| 129 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_KP_0, KC_KP_4, _______, KC_PPLS, KC_KP_5, KC_PMNS, KC_PEQL, KC_KP_6, KC_PENT, _______, KC_PDOT, _______, | ||
| 130 | _______, _______, _______, _______, KC_KP_1, KC_KP_2, KC_KP_3, KC_PSLS, | ||
| 131 | _______, _______, _______, _______, | ||
| 132 | _______, _______, | ||
| 133 | _______, _______, | ||
| 134 | _______, _______, _______, _______), | ||
| 135 | }; | ||
| 136 | |||
| 137 | static void lock_led_set(bool on, uint8_t led) { | ||
| 138 | if (on) { | ||
| 139 | LED_LOCK_PORT &= ~led; | ||
| 140 | } else { | ||
| 141 | LED_LOCK_PORT |= led; | ||
| 142 | } | ||
| 143 | } | ||
| 144 | |||
| 145 | static void mode_led_set(uint8_t led) { | ||
| 146 | static const uint8_t ALL_MODE_LEDS = LED_FN | LED_NORMAL | LED_NAS | LED_TENKEY; | ||
| 147 | LED_MODE_PORT |= ALL_MODE_LEDS; | ||
| 148 | LED_MODE_PORT &= ~led; | ||
| 149 | } | ||
| 150 | |||
| 151 | static void layer_set(bool on, uint8_t layer) { | ||
| 152 | if (on) { | ||
| 153 | layer_on(layer); | ||
| 154 | } else { | ||
| 155 | layer_off(layer); | ||
| 156 | } | ||
| 157 | |||
| 158 | if (layer_state_is(NAS) || layer_state_is(NAS_NUMLOCK) || layer_state_is(NAS_TENKEY) || layer_state_is(NAS_TENKEY_NUMLOCK)) { | ||
| 159 | if (tenkey_enabled) { | ||
| 160 | mode_led_set(LED_NAS | LED_TENKEY); | ||
| 161 | } else { | ||
| 162 | mode_led_set(LED_NAS); | ||
| 163 | } | ||
| 164 | } else if (layer_state_is(FUNCTION_MOUSE) || layer_state_is(FUNCTION_ARROWS)) { | ||
| 165 | mode_led_set(LED_FN); | ||
| 166 | } else if (layer_state_is(NORMAL)) { | ||
| 167 | mode_led_set(LED_NORMAL); | ||
| 168 | } | ||
| 169 | } | ||
| 170 | |||
| 171 | static void set_normal(void) { | ||
| 172 | layer_move(NORMAL); | ||
| 173 | |||
| 174 | #ifdef DATAHAND_THUMB_RETURN_COMMAND | ||
| 175 | layer_set(true, NORMAL_THUMB_RETURN_COMMAND); | ||
| 176 | #endif | ||
| 177 | |||
| 178 | /* Then call layer_set to update LEDs. */ | ||
| 179 | layer_set(true, NORMAL); | ||
| 180 | } | ||
| 181 | |||
| 182 | static void set_nas(bool on) { | ||
| 183 | /* Always turn on the base NAS layer so other layers can fall through. */ | ||
| 184 | layer_set(on, NAS); | ||
| 185 | |||
| 186 | layer_set(on && numlock_enabled, NAS_NUMLOCK); | ||
| 187 | layer_set(on && tenkey_enabled, NAS_TENKEY); | ||
| 188 | layer_set(on && tenkey_enabled && numlock_enabled, NAS_TENKEY_NUMLOCK); | ||
| 189 | } | ||
| 190 | |||
| 191 | static void set_tenkey(bool on) { | ||
| 192 | tenkey_enabled = on; | ||
| 193 | |||
| 194 | /* We have to be on the NAS layer in order to be able to toggle TK. | ||
| 195 | * Re-toggle it on so that we move to the right layer (and set the right LED). | ||
| 196 | */ | ||
| 197 | set_nas(true); | ||
| 198 | } | ||
| 199 | |||
| 200 | static void toggle_numlock(void) { | ||
| 201 | numlock_enabled = !numlock_enabled; | ||
| 202 | lock_led_set(numlock_enabled, LED_NUM_LOCK); | ||
| 203 | |||
| 204 | if (layer_state_is(NAS)) { | ||
| 205 | /* If we're already in NAS, re-set it so that we activate the numlock layer. */ | ||
| 206 | set_nas(true); | ||
| 207 | } | ||
| 208 | } | ||
| 209 | |||
| 210 | static void set_function(void) { | ||
| 211 | /* Make sure to turn off NAS if we're entering function */ | ||
| 212 | set_nas(false); | ||
| 213 | |||
| 214 | /* Always turn on the mouse layer so the arrow layer can fall through. */ | ||
| 215 | layer_set(true, FUNCTION_MOUSE); | ||
| 216 | layer_set(!mouse_enabled, FUNCTION_ARROWS); | ||
| 217 | } | ||
| 218 | |||
| 219 | static void set_mouse_enabled(bool on) { | ||
| 220 | mouse_enabled = on; | ||
| 221 | |||
| 222 | /* Re-run set_function to set our layers correctly. */ | ||
| 223 | set_function(); | ||
| 224 | } | ||
| 225 | |||
| 226 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
| 227 | bool pressed = record->event.pressed; | ||
| 228 | |||
| 229 | switch(keycode) { | ||
| 230 | case N: | ||
| 231 | if (pressed) { | ||
| 232 | set_normal(); | ||
| 233 | } | ||
| 234 | break; | ||
| 235 | |||
| 236 | case NS: | ||
| 237 | if (pressed) { | ||
| 238 | nas_locked = false; | ||
| 239 | } | ||
| 240 | set_nas(pressed); | ||
| 241 | break; | ||
| 242 | |||
| 243 | case NSL: | ||
| 244 | if (pressed) { | ||
| 245 | nas_locked = true; | ||
| 246 | set_nas(true); | ||
| 247 | } | ||
| 248 | break; | ||
| 249 | |||
| 250 | case NLK: | ||
| 251 | if (pressed) { | ||
| 252 | toggle_numlock(); | ||
| 253 | SEND_STRING(SS_DOWN(X_NUMLOCK)); | ||
| 254 | } else { | ||
| 255 | SEND_STRING(SS_UP(X_NUMLOCK)); | ||
| 256 | } | ||
| 257 | break; | ||
| 258 | |||
| 259 | case FN: | ||
| 260 | if (pressed) { | ||
| 261 | set_function(); | ||
| 262 | } | ||
| 263 | break; | ||
| 264 | |||
| 265 | case TK0: | ||
| 266 | if (pressed) { | ||
| 267 | set_tenkey(false); | ||
| 268 | } | ||
| 269 | break; | ||
| 270 | |||
| 271 | case TK1: | ||
| 272 | if (pressed) { | ||
| 273 | set_tenkey(true); | ||
| 274 | } | ||
| 275 | break; | ||
| 276 | |||
| 277 | case MS: | ||
| 278 | if (pressed) { | ||
| 279 | set_mouse_enabled(true); | ||
| 280 | } | ||
| 281 | break; | ||
| 282 | |||
| 283 | case AR: | ||
| 284 | if (pressed) { | ||
| 285 | set_mouse_enabled(false); | ||
| 286 | } | ||
| 287 | break; | ||
| 288 | |||
| 289 | case DZ: | ||
| 290 | if (pressed) { | ||
| 291 | SEND_STRING(SS_TAP(X_KP_0) SS_TAP(X_KP_0)); | ||
| 292 | } | ||
| 293 | break; | ||
| 294 | } | ||
| 295 | |||
| 296 | return true; | ||
| 297 | }; | ||
| 298 | |||
| 299 | void matrix_init_user(void) { | ||
| 300 | #ifdef DATAHAND_THUMB_RETURN_COMMAND | ||
| 301 | set_normal(); | ||
| 302 | #endif | ||
| 303 | } | ||
| 304 | |||
| 305 | void matrix_scan_user(void) { | ||
| 306 | |||
| 307 | } | ||
| 308 | |||
| 309 | void led_set_user(uint8_t usb_led) { | ||
| 310 | lock_led_set(usb_led & (1<<USB_LED_NUM_LOCK), LED_NUM_LOCK); | ||
| 311 | lock_led_set(usb_led & (1<<USB_LED_CAPS_LOCK), LED_CAPS_LOCK); | ||
| 312 | lock_led_set(usb_led & (1<<USB_LED_SCROLL_LOCK), LED_SCROLL_LOCK); | ||
| 313 | } | ||
diff --git a/keyboards/handwired/datahand/matrix.c b/keyboards/handwired/datahand/matrix.c new file mode 100644 index 000000000..a08450d77 --- /dev/null +++ b/keyboards/handwired/datahand/matrix.c | |||
| @@ -0,0 +1,125 @@ | |||
| 1 | /* Copyright 2017-2019 Nikolaus Wittenstein <nikolaus.wittenstein@gmail.com> | ||
| 2 | * | ||
| 3 | * Permission to use, copy, modify, and/or distribute this software for any | ||
| 4 | * purpose with or without fee is hereby granted, provided that the above | ||
| 5 | * copyright notice and this permission notice appear in all copies. | ||
| 6 | * | ||
| 7 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
| 8 | * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND | ||
| 9 | * FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
| 10 | * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
| 11 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
| 12 | * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
| 13 | * PERFORMANCE OF THIS SOFTWARE. | ||
| 14 | */ | ||
| 15 | |||
| 16 | #include "datahand.h" | ||
| 17 | |||
| 18 | #include "matrix.h" | ||
| 19 | #include "action.h" | ||
| 20 | |||
| 21 | #include <stdint.h> | ||
| 22 | #include <stdbool.h> | ||
| 23 | #include <avr/io.h> | ||
| 24 | |||
| 25 | static matrix_row_t matrix[MATRIX_ROWS]; | ||
| 26 | |||
| 27 | static matrix_row_t read_cols(void); | ||
| 28 | static void select_row(uint8_t row); | ||
| 29 | |||
| 30 | void matrix_init(void) { | ||
| 31 | /* See datahand.h for more detail on pins. */ | ||
| 32 | |||
| 33 | /* 7 - matrix scan; 6-3 - mode LEDs */ | ||
| 34 | DDRB = 0b11111000; | ||
| 35 | |||
| 36 | /* 1-0 - matrix scan */ | ||
| 37 | DDRD = 0b00000011; | ||
| 38 | |||
| 39 | /* 6 - matrix scan */ | ||
| 40 | DDRE = 0b01000000; | ||
| 41 | |||
| 42 | /* 7-4 - lock LEDs */ | ||
| 43 | DDRF = 0b11110000; | ||
| 44 | |||
| 45 | /* Turn off the non-Normal LEDs (they're active low). */ | ||
| 46 | PORTB |= LED_TENKEY | LED_FN | LED_NAS; | ||
| 47 | |||
| 48 | /* Turn off the lock LEDs. */ | ||
| 49 | PORTF |= LED_CAPS_LOCK | LED_NUM_LOCK | LED_SCROLL_LOCK | LED_MOUSE_LOCK; | ||
| 50 | |||
| 51 | matrix_init_user(); | ||
| 52 | } | ||
| 53 | |||
| 54 | uint8_t matrix_scan(void) { | ||
| 55 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
| 56 | select_row(row); | ||
| 57 | /* The default hardware works down to at least 100us, but I have a replacement | ||
| 58 | * photodiode that responds a little more slowly. Cranking it up to 1000us fixes | ||
| 59 | * shadowing issues. | ||
| 60 | */ | ||
| 61 | _delay_us(1000); | ||
| 62 | matrix[row] = read_cols(); | ||
| 63 | } | ||
| 64 | |||
| 65 | matrix_scan_user(); | ||
| 66 | |||
| 67 | return 1; | ||
| 68 | } | ||
| 69 | |||
| 70 | matrix_row_t matrix_get_row(uint8_t row) { | ||
| 71 | return matrix[row]; | ||
| 72 | } | ||
| 73 | |||
| 74 | void matrix_print(void) { | ||
| 75 | print("\nr/c 01234567\n"); | ||
| 76 | |||
| 77 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
| 78 | phex(row); | ||
| 79 | print(": "); | ||
| 80 | print_bin_reverse8(matrix_get_row(row)); | ||
| 81 | print("\n"); | ||
| 82 | } | ||
| 83 | } | ||
| 84 | |||
| 85 | bool process_record_kb(uint16_t keycode, keyrecord_t *record) { | ||
| 86 | return process_record_user(keycode, record); | ||
| 87 | } | ||
| 88 | |||
| 89 | static void select_row(uint8_t row) { | ||
| 90 | /* Original 8051: P1 bits 0-3 (pins 1-4) | ||
| 91 | * Teensy++: PE0, PB7, PD0, PD1 | ||
| 92 | */ | ||
| 93 | |||
| 94 | if (row & (1<<0)) { | ||
| 95 | PORTE |= (1<<6); | ||
| 96 | } else { | ||
| 97 | PORTE &= ~(1<<6); | ||
| 98 | } | ||
| 99 | |||
| 100 | if (row & (1<<1)) { | ||
| 101 | PORTB |= (1<<7); | ||
| 102 | } else { | ||
| 103 | PORTB &= ~(1<<7); | ||
| 104 | } | ||
| 105 | |||
| 106 | if (row & (1<<2)) { | ||
| 107 | PORTD |= (1<<0); | ||
| 108 | } else { | ||
| 109 | PORTD &= ~(1<<0); | ||
| 110 | } | ||
| 111 | |||
| 112 | if (row & (1<<3)) { | ||
| 113 | PORTD |= (1<<1); | ||
| 114 | } else { | ||
| 115 | PORTD &= ~(1<<1); | ||
| 116 | } | ||
| 117 | } | ||
| 118 | |||
| 119 | static matrix_row_t read_cols(void) { | ||
| 120 | /* Original 8051: P1 bits 4-7 (pins 5-8) | ||
| 121 | * Teensy++: PD bits 2-5 | ||
| 122 | */ | ||
| 123 | |||
| 124 | return (PIND & 0b00111100) >> 2; | ||
| 125 | } | ||
diff --git a/keyboards/handwired/datahand/readme.md b/keyboards/handwired/datahand/readme.md new file mode 100644 index 000000000..923cebb00 --- /dev/null +++ b/keyboards/handwired/datahand/readme.md | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | # DataHand | ||
| 2 | |||
| 3 | A keyboard designed to prevent RSI. See [Wikipedia](https://en.wikipedia.org/wiki/DataHand) and [this website](http://octopup.org/computer/datahand) for more info. | ||
| 4 | |||
| 5 | To use this firmware, you have to replace the stock microcontroller with a Teensy++ 2.0. This is relatively easy and also reversible. See the notes at the bottom of datahand.h for more info. | ||
| 6 | |||
| 7 | Keyboard Maintainer: [Nikolaus Wittenstein](https://github.com/adzenith) | ||
| 8 | Hardware Supported: DataHand Personal or Pro II | ||
| 9 | Hardware Availability: No longer in production | ||
| 10 | |||
| 11 | Make example for this keyboard (after setting up your build environment): | ||
| 12 | |||
| 13 | make handwired/datahand:default | ||
| 14 | |||
| 15 | See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs). | ||
diff --git a/keyboards/handwired/datahand/rules.mk b/keyboards/handwired/datahand/rules.mk new file mode 100644 index 000000000..59f14e17a --- /dev/null +++ b/keyboards/handwired/datahand/rules.mk | |||
| @@ -0,0 +1,59 @@ | |||
| 1 | # Project-specific includes | ||
| 2 | SRC = matrix.c | ||
| 3 | |||
| 4 | # MCU name | ||
| 5 | MCU = at90usb1286 | ||
| 6 | |||
| 7 | # Processor frequency. | ||
| 8 | # This will define a symbol, F_CPU, in all source code files equal to the | ||
| 9 | # processor frequency in Hz. You can then use this symbol in your source code to | ||
| 10 | # calculate timings. Do NOT tack on a 'UL' at the end, this will be done | ||
| 11 | # automatically to create a 32-bit value in your source code. | ||
| 12 | # | ||
| 13 | # This will be an integer division of F_USB below, as it is sourced by | ||
| 14 | # F_USB after it has run through any CPU prescalers. Note that this value | ||
| 15 | # does not *change* the processor frequency - it should merely be updated to | ||
| 16 | # reflect the processor speed set externally so that the code can use accurate | ||
| 17 | # software delays. | ||
| 18 | F_CPU = 16000000 | ||
| 19 | |||
| 20 | # | ||
| 21 | # LUFA specific | ||
| 22 | # | ||
| 23 | # Target architecture (see library "Board Types" documentation). | ||
| 24 | ARCH = AVR8 | ||
| 25 | |||
| 26 | # Input clock frequency. | ||
| 27 | # This will define a symbol, F_USB, in all source code files equal to the | ||
| 28 | # input clock frequency (before any prescaling is performed) in Hz. This value may | ||
| 29 | # differ from F_CPU if prescaling is used on the latter, and is required as the | ||
| 30 | # raw input clock is fed directly to the PLL sections of the AVR for high speed | ||
| 31 | # clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' | ||
| 32 | # at the end, this will be done automatically to create a 32-bit value in your | ||
| 33 | # source code. | ||
| 34 | # | ||
| 35 | # If no clock division is performed on the input clock inside the AVR (via the | ||
| 36 | # CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. | ||
| 37 | F_USB = $(F_CPU) | ||
| 38 | |||
| 39 | # Interrupt driven control endpoint task(+60) | ||
| 40 | OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT | ||
| 41 | |||
| 42 | BOOTLOADER = halfkay | ||
| 43 | |||
| 44 | # Build Options | ||
| 45 | BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) | ||
| 46 | MOUSEKEY_ENABLE = yes # Mouse keys(+4700) | ||
| 47 | EXTRAKEY_ENABLE = yes # Audio control and System control(+450) | ||
| 48 | CONSOLE_ENABLE = yes # Console for debug(+400) | ||
| 49 | COMMAND_ENABLE = yes # Commands for debug and configuration | ||
| 50 | NKRO_ENABLE = yes # USB Nkey Rollover | ||
| 51 | BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality on B7 by default | ||
| 52 | MIDI_ENABLE = no # MIDI controls | ||
| 53 | UNICODE_ENABLE = no # Unicode | ||
| 54 | BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID | ||
| 55 | AUDIO_ENABLE = no # Audio output on port C6 | ||
| 56 | CUSTOM_MATRIX = yes # We definitely have a nonstandard matrix | ||
| 57 | |||
| 58 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE | ||
| 59 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend | ||
diff --git a/keyboards/readme.md b/keyboards/readme.md index 5ba98c6c4..8b0c10ab4 100644 --- a/keyboards/readme.md +++ b/keyboards/readme.md | |||
| @@ -38,6 +38,7 @@ These keyboards are part of the QMK repository, but their manufacturers are not | |||
| 38 | * [Arrow Pad](/keyboards/arrow_pad) — A custom creation by IBNobody. | 38 | * [Arrow Pad](/keyboards/arrow_pad) — A custom creation by IBNobody. |
| 39 | * [Atreus](/keyboards/atreus) — Made by Technomancy. | 39 | * [Atreus](/keyboards/atreus) — Made by Technomancy. |
| 40 | * [Bantam44](/keyboards/bantam44) — It is a 44-key 40% staggered keyboard. | 40 | * [Bantam44](/keyboards/bantam44) — It is a 44-key 40% staggered keyboard. |
| 41 | * [DataHand](/keyboards/handwired/datahand) — DataHand keyboard converted to use a Teensy board. | ||
| 41 | * [Ergodox Infinity](/keyboards/ergodox_infinity) - Ergonomic Split Keyboard by Input Club. | 42 | * [Ergodox Infinity](/keyboards/ergodox_infinity) - Ergonomic Split Keyboard by Input Club. |
| 42 | * [GH60](/keyboards/gh60) — A 60% Geekhack community-driven project. | 43 | * [GH60](/keyboards/gh60) — A 60% Geekhack community-driven project. |
| 43 | * [GON NerD](/keyboards/gonnerd) — Korean custom 60% PCB | 44 | * [GON NerD](/keyboards/gonnerd) — Korean custom 60% PCB |
