diff options
Diffstat (limited to 'keyboard')
| -rw-r--r-- | keyboard/gh60/Makefile.lufa | 123 | ||||
| -rw-r--r-- | keyboard/gh60/Makefile.pjrc | 93 | ||||
| -rw-r--r-- | keyboard/gh60/README.md | 89 | ||||
| -rw-r--r-- | keyboard/gh60/config.h | 50 | ||||
| -rw-r--r-- | keyboard/gh60/keymap.c | 202 | ||||
| -rw-r--r-- | keyboard/gh60/led.c | 34 | ||||
| -rw-r--r-- | keyboard/gh60/matrix.c | 224 | ||||
| -rw-r--r-- | keyboard/hid_liber/Makefile.lufa | 120 | ||||
| -rw-r--r-- | keyboard/hid_liber/Makefile.pjrc | 90 | ||||
| -rw-r--r-- | keyboard/hid_liber/config.h | 56 | ||||
| -rw-r--r-- | keyboard/hid_liber/keymap.c | 195 | ||||
| -rw-r--r-- | keyboard/hid_liber/led.c | 34 | ||||
| -rw-r--r-- | keyboard/hid_liber/matrix.c | 234 | ||||
| -rw-r--r-- | keyboard/macway/matrix.c | 4 | ||||
| -rw-r--r-- | keyboard/phantom/Makefile.lufa | 120 | ||||
| -rw-r--r-- | keyboard/phantom/Makefile.pjrc | 90 | ||||
| -rw-r--r-- | keyboard/phantom/config.h | 56 | ||||
| -rw-r--r-- | keyboard/phantom/keymap.c | 172 | ||||
| -rw-r--r-- | keyboard/phantom/led.c | 34 | ||||
| -rw-r--r-- | keyboard/phantom/matrix.c | 249 |
20 files changed, 2267 insertions, 2 deletions
diff --git a/keyboard/gh60/Makefile.lufa b/keyboard/gh60/Makefile.lufa new file mode 100644 index 000000000..45402bb38 --- /dev/null +++ b/keyboard/gh60/Makefile.lufa | |||
| @@ -0,0 +1,123 @@ | |||
| 1 | #---------------------------------------------------------------------------- | ||
| 2 | # On command line: | ||
| 3 | # | ||
| 4 | # make all = Make software. | ||
| 5 | # | ||
| 6 | # make clean = Clean out built project files. | ||
| 7 | # | ||
| 8 | # make coff = Convert ELF to AVR COFF. | ||
| 9 | # | ||
| 10 | # make extcoff = Convert ELF to AVR Extended COFF. | ||
| 11 | # | ||
| 12 | # make program = Download the hex file to the device. | ||
| 13 | # Please customize your programmer settings(PROGRAM_CMD) | ||
| 14 | # | ||
| 15 | # make teensy = Download the hex file to the device, using teensy_loader_cli. | ||
| 16 | # (must have teensy_loader_cli installed). | ||
| 17 | # | ||
| 18 | # make dfu = Download the hex file to the device, using dfu-programmer (must | ||
| 19 | # have dfu-programmer installed). | ||
| 20 | # | ||
| 21 | # make flip = Download the hex file to the device, using Atmel FLIP (must | ||
| 22 | # have Atmel FLIP installed). | ||
| 23 | # | ||
| 24 | # make dfu-ee = Download the eeprom file to the device, using dfu-programmer | ||
| 25 | # (must have dfu-programmer installed). | ||
| 26 | # | ||
| 27 | # make flip-ee = Download the eeprom file to the device, using Atmel FLIP | ||
| 28 | # (must have Atmel FLIP installed). | ||
| 29 | # | ||
| 30 | # make debug = Start either simulavr or avarice as specified for debugging, | ||
| 31 | # with avr-gdb or avr-insight as the front end for debugging. | ||
| 32 | # | ||
| 33 | # make filename.s = Just compile filename.c into the assembler code only. | ||
| 34 | # | ||
| 35 | # make filename.i = Create a preprocessed source file for use in submitting | ||
| 36 | # bug reports to the GCC project. | ||
| 37 | # | ||
| 38 | # To rebuild project do "make clean" then "make all". | ||
| 39 | #---------------------------------------------------------------------------- | ||
| 40 | |||
| 41 | # Target file name (without extension). | ||
| 42 | TARGET = gh60_lufa | ||
| 43 | |||
| 44 | # Directory common source filess exist | ||
| 45 | TOP_DIR = ../.. | ||
| 46 | |||
| 47 | # Directory keyboard dependent files exist | ||
| 48 | TARGET_DIR = . | ||
| 49 | |||
| 50 | |||
| 51 | # List C source files here. (C dependencies are automatically generated.) | ||
| 52 | SRC += keymap.c \ | ||
| 53 | matrix.c \ | ||
| 54 | led.c | ||
| 55 | |||
| 56 | CONFIG_H = config.h | ||
| 57 | |||
| 58 | |||
| 59 | # MCU name | ||
| 60 | #MCU = at90usb1287 | ||
| 61 | MCU = atmega32u4 | ||
| 62 | |||
| 63 | # Processor frequency. | ||
| 64 | # This will define a symbol, F_CPU, in all source code files equal to the | ||
| 65 | # processor frequency in Hz. You can then use this symbol in your source code to | ||
| 66 | # calculate timings. Do NOT tack on a 'UL' at the end, this will be done | ||
| 67 | # automatically to create a 32-bit value in your source code. | ||
| 68 | # | ||
| 69 | # This will be an integer division of F_USB below, as it is sourced by | ||
| 70 | # F_USB after it has run through any CPU prescalers. Note that this value | ||
| 71 | # does not *change* the processor frequency - it should merely be updated to | ||
| 72 | # reflect the processor speed set externally so that the code can use accurate | ||
| 73 | # software delays. | ||
| 74 | F_CPU = 16000000 | ||
| 75 | |||
| 76 | |||
| 77 | # | ||
| 78 | # LUFA specific | ||
| 79 | # | ||
| 80 | # Target architecture (see library "Board Types" documentation). | ||
| 81 | ARCH = AVR8 | ||
| 82 | |||
| 83 | # Input clock frequency. | ||
| 84 | # This will define a symbol, F_USB, in all source code files equal to the | ||
| 85 | # input clock frequency (before any prescaling is performed) in Hz. This value may | ||
| 86 | # differ from F_CPU if prescaling is used on the latter, and is required as the | ||
| 87 | # raw input clock is fed directly to the PLL sections of the AVR for high speed | ||
| 88 | # clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' | ||
| 89 | # at the end, this will be done automatically to create a 32-bit value in your | ||
| 90 | # source code. | ||
| 91 | # | ||
| 92 | # If no clock division is performed on the input clock inside the AVR (via the | ||
| 93 | # CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. | ||
| 94 | F_USB = $(F_CPU) | ||
| 95 | |||
| 96 | |||
| 97 | # Build Options | ||
| 98 | # comment out to disable the options. | ||
| 99 | # | ||
| 100 | MOUSEKEY_ENABLE = yes # Mouse keys | ||
| 101 | EXTRAKEY_ENABLE = yes # Audio control and System control | ||
| 102 | CONSOLE_ENABLE = yes # Console for debug | ||
| 103 | #NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA | ||
| 104 | #PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support | ||
| 105 | |||
| 106 | |||
| 107 | # Boot Section Size in bytes | ||
| 108 | # Teensy halfKay 512 | ||
| 109 | # Atmel DFU loader 4096 | ||
| 110 | # LUFA bootloader 4096 | ||
| 111 | OPT_DEFS += -DBOOT_SIZE=4096 | ||
| 112 | |||
| 113 | |||
| 114 | # Search Path | ||
| 115 | VPATH += $(TARGET_DIR) | ||
| 116 | VPATH += $(TOP_DIR) | ||
| 117 | |||
| 118 | include $(TOP_DIR)/protocol/lufa.mk | ||
| 119 | include $(TOP_DIR)/common.mk | ||
| 120 | include $(TOP_DIR)/rules.mk | ||
| 121 | |||
| 122 | plain: OPT_DEFS += -DPLAIN_MAP | ||
| 123 | plain: all | ||
diff --git a/keyboard/gh60/Makefile.pjrc b/keyboard/gh60/Makefile.pjrc new file mode 100644 index 000000000..6b3a8d1ac --- /dev/null +++ b/keyboard/gh60/Makefile.pjrc | |||
| @@ -0,0 +1,93 @@ | |||
| 1 | #---------------------------------------------------------------------------- | ||
| 2 | # On command line: | ||
| 3 | # | ||
| 4 | # make all = Make software. | ||
| 5 | # | ||
| 6 | # make clean = Clean out built project files. | ||
| 7 | # | ||
| 8 | # make coff = Convert ELF to AVR COFF. | ||
| 9 | # | ||
| 10 | # make extcoff = Convert ELF to AVR Extended COFF. | ||
| 11 | # | ||
| 12 | # make program = Download the hex file to the device. | ||
| 13 | # Please customize your programmer settings(PROGRAM_CMD) | ||
| 14 | # | ||
| 15 | # make teensy = Download the hex file to the device, using teensy_loader_cli. | ||
| 16 | # (must have teensy_loader_cli installed). | ||
| 17 | # | ||
| 18 | # make dfu = Download the hex file to the device, using dfu-programmer (must | ||
| 19 | # have dfu-programmer installed). | ||
| 20 | # | ||
| 21 | # make flip = Download the hex file to the device, using Atmel FLIP (must | ||
| 22 | # have Atmel FLIP installed). | ||
| 23 | # | ||
| 24 | # make dfu-ee = Download the eeprom file to the device, using dfu-programmer | ||
| 25 | # (must have dfu-programmer installed). | ||
| 26 | # | ||
| 27 | # make flip-ee = Download the eeprom file to the device, using Atmel FLIP | ||
| 28 | # (must have Atmel FLIP installed). | ||
| 29 | # | ||
| 30 | # make debug = Start either simulavr or avarice as specified for debugging, | ||
| 31 | # with avr-gdb or avr-insight as the front end for debugging. | ||
| 32 | # | ||
| 33 | # make filename.s = Just compile filename.c into the assembler code only. | ||
| 34 | # | ||
| 35 | # make filename.i = Create a preprocessed source file for use in submitting | ||
| 36 | # bug reports to the GCC project. | ||
| 37 | # | ||
| 38 | # To rebuild project do "make clean" then "make all". | ||
| 39 | #---------------------------------------------------------------------------- | ||
| 40 | |||
| 41 | # Target file name (without extension). | ||
| 42 | TARGET = gh60_pjrc | ||
| 43 | |||
| 44 | # Directory common source filess exist | ||
| 45 | TOP_DIR = ../.. | ||
| 46 | |||
| 47 | # Directory keyboard dependent files exist | ||
| 48 | TARGET_DIR = . | ||
| 49 | |||
| 50 | # keyboard dependent files | ||
| 51 | SRC = keymap.c \ | ||
| 52 | matrix.c \ | ||
| 53 | led.c | ||
| 54 | |||
| 55 | CONFIG_H = config.h | ||
| 56 | |||
| 57 | |||
| 58 | # MCU name, you MUST set this to match the board you are using | ||
| 59 | # type "make clean" after changing this, so all files will be rebuilt | ||
| 60 | #MCU = at90usb162 # Teensy 1.0 | ||
| 61 | MCU = atmega32u4 # Teensy 2.0 | ||
| 62 | #MCU = at90usb646 # Teensy++ 1.0 | ||
| 63 | #MCU = at90usb1286 # Teensy++ 2.0 | ||
| 64 | |||
| 65 | |||
| 66 | # Processor frequency. | ||
| 67 | # Normally the first thing your program should do is set the clock prescaler, | ||
| 68 | # so your program will run at the correct speed. You should also set this | ||
| 69 | # variable to same clock speed. The _delay_ms() macro uses this, and many | ||
| 70 | # examples use this variable to calculate timings. Do not add a "UL" here. | ||
| 71 | F_CPU = 16000000 | ||
| 72 | |||
| 73 | |||
| 74 | # Build Options | ||
| 75 | # comment out to disable the options. | ||
| 76 | # | ||
| 77 | MOUSEKEY_ENABLE = yes # Mouse keys | ||
| 78 | #PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support | ||
| 79 | EXTRAKEY_ENABLE = yes # Audio control and System control | ||
| 80 | NKRO_ENABLE = yes # USB Nkey Rollover | ||
| 81 | CONSOLE_ENABLE = yes # Console for debug | ||
| 82 | |||
| 83 | |||
| 84 | # Search Path | ||
| 85 | VPATH += $(TARGET_DIR) | ||
| 86 | VPATH += $(TOP_DIR) | ||
| 87 | |||
| 88 | include $(TOP_DIR)/protocol/pjrc.mk | ||
| 89 | include $(TOP_DIR)/common.mk | ||
| 90 | include $(TOP_DIR)/rules.mk | ||
| 91 | |||
| 92 | plain: OPT_DEFS += -DPLAIN_MAP | ||
| 93 | plain: all | ||
diff --git a/keyboard/gh60/README.md b/keyboard/gh60/README.md new file mode 100644 index 000000000..73eb4b6d5 --- /dev/null +++ b/keyboard/gh60/README.md | |||
| @@ -0,0 +1,89 @@ | |||
| 1 | GH60 keyboard firmware | ||
| 2 | ====================== | ||
| 3 | DIY compact keyboard designed and run by komar007 and Geekhack community. | ||
| 4 | |||
| 5 | ## Threads on Geekhack.org | ||
| 6 | - [Prototyping](http://geekhack.org/index.php?topic=34959.0) | ||
| 7 | - [Beta-test](http://geekhack.org/index.php?topic=37570.0) | ||
| 8 | |||
| 9 | |||
| 10 | ## Build | ||
| 11 | Move to this directory then just run `make` like: | ||
| 12 | |||
| 13 | $ make -f Makfile.pjrc | ||
| 14 | |||
| 15 | |||
| 16 | ## Keymap | ||
| 17 | See keymap.c to define your own favourite keymap. | ||
| 18 | |||
| 19 | ###Keymap with funky layers. | ||
| 20 | Layer 0: Default Layer | ||
| 21 | ,-----------------------------------------------------------. | ||
| 22 | |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | | ||
| 23 | |-----------------------------------------------------------| | ||
| 24 | |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| | ||
| 25 | |-----------------------------------------------------------| | ||
| 26 | |Caps | A| S| D| F| G| H| J| K| L|Fn3| '|Return | | ||
| 27 | |-----------------------------------------------------------| | ||
| 28 | |Shift | Z| X| C| V| B| N| M| ,| .|Fn2|Shift | | ||
| 29 | |-----------------------------------------------------------| | ||
| 30 | |Ctrl|Gui |Alt | Space |Alt |Gui |App |Fn1 | | ||
| 31 | `-----------------------------------------------------------' | ||
| 32 | |||
| 33 | Layer 1: HHKB mode | ||
| 34 | ,-----------------------------------------------------------. | ||
| 35 | |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Delete | | ||
| 36 | |-----------------------------------------------------------| | ||
| 37 | |Caps | | | | | | | |Psc|Slk|Pus|Up | |Inser| | ||
| 38 | |-----------------------------------------------------------| | ||
| 39 | |Contro|VoD|VoU|Mut| | | *| /|Hom|PgU|Lef|Rig|Enter | | ||
| 40 | |-----------------------------------------------------------| | ||
| 41 | |Shift | | | | | | +| -|End|PgD|Dow|Shift | | ||
| 42 | |-----------------------------------------------------------| | ||
| 43 | |Ctrl|Gui |Alt | Space |Alt |Gui |App |xxx | | ||
| 44 | `-----------------------------------------------------------' | ||
| 45 | |||
| 46 | Layer 2: Vi mode | ||
| 47 | ,-----------------------------------------------------------. | ||
| 48 | | `| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Backsp | | ||
| 49 | |-----------------------------------------------------------| | ||
| 50 | |Tab |Hom|PgD|Up |PgU|End|Hom|PgD|PgU|End| | | | | | ||
| 51 | |-----------------------------------------------------------| | ||
| 52 | |Contro| |Lef|Dow|Rig| |Lef|Dow|Up |Rig| | |Return | | ||
| 53 | |-----------------------------------------------------------| | ||
| 54 | |Shift | | | | | |Hom|PgD|PgU|End|xxx|Shift | | ||
| 55 | |-----------------------------------------------------------| | ||
| 56 | |Ctrl|Gui |Alt | Space |Alt |Gui |App |Ctrl| | ||
| 57 | `-----------------------------------------------------------' | ||
| 58 | |||
| 59 | Layer 3: Mouse mode | ||
| 60 | ,-----------------------------------------------------------. | ||
| 61 | | `| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Backsp | | ||
| 62 | |-----------------------------------------------------------| | ||
| 63 | |Tab |MwL|MwD|McU|MwU|MwR|MwL|MwD|MwU|MwR| | | | | | ||
| 64 | |-----------------------------------------------------------| | ||
| 65 | |Contro| |McL|McD|McR| |McL|McD|McU|McR|xxx| |Return | | ||
| 66 | |-----------------------------------------------------------| | ||
| 67 | |Shift | | |Mb1|Mb2|Mb3|Mb2|Mb1| | | |Shift | | ||
| 68 | |-----------------------------------------------------------| | ||
| 69 | |Ctrl|Gui |Alt | Space |Alt |Gui |xxx |Ctrl| | ||
| 70 | `-----------------------------------------------------------' | ||
| 71 | Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel | ||
| 72 | |||
| 73 | ### Plain keymap without Fn layer. | ||
| 74 | This will be useful if you want to use key mapping tool like AHK. | ||
| 75 | To get this plain keymap run: | ||
| 76 | |||
| 77 | $ make -f Makefile.pjrc plain | ||
| 78 | |||
| 79 | ,-----------------------------------------------------------. | ||
| 80 | |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | | ||
| 81 | |-----------------------------------------------------------| | ||
| 82 | |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| | ||
| 83 | |-----------------------------------------------------------| | ||
| 84 | |Caps | A| S| D| F| G| H| J| K| L| ;| '|Return | | ||
| 85 | |-----------------------------------------------------------| | ||
| 86 | |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift | | ||
| 87 | |-----------------------------------------------------------| | ||
| 88 | |Ctrl|Gui |Alt | Space |Alt |Gui |App |Ctrl| | ||
| 89 | `-----------------------------------------------------------' | ||
diff --git a/keyboard/gh60/config.h b/keyboard/gh60/config.h new file mode 100644 index 000000000..6e7b1bd7a --- /dev/null +++ b/keyboard/gh60/config.h | |||
| @@ -0,0 +1,50 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2012 Jun Wako <wakojun@gmail.com> | ||
| 3 | |||
| 4 | This program is free software: you can redistribute it and/or modify | ||
| 5 | it under the terms of the GNU General Public License as published by | ||
| 6 | the Free Software Foundation, either version 2 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #ifndef CONFIG_H | ||
| 19 | #define CONFIG_H | ||
| 20 | |||
| 21 | |||
| 22 | /* USB Device descriptor parameter */ | ||
| 23 | #define VENDOR_ID 0xFEED | ||
| 24 | #define PRODUCT_ID 0x6060 | ||
| 25 | #define DEVICE_VER 0x0001 | ||
| 26 | #define MANUFACTURER geekhack | ||
| 27 | #define PRODUCT GH60 | ||
| 28 | |||
| 29 | |||
| 30 | /* message strings */ | ||
| 31 | #define DESCRIPTION t.m.k. keyboard firmware for GH60 | ||
| 32 | |||
| 33 | |||
| 34 | /* matrix size */ | ||
| 35 | #define MATRIX_ROWS 5 | ||
| 36 | #define MATRIX_COLS 14 | ||
| 37 | |||
| 38 | /* define if matrix has ghost */ | ||
| 39 | //#define MATRIX_HAS_GHOST | ||
| 40 | |||
| 41 | /* Set 0 if need no debouncing */ | ||
| 42 | #define DEBOUNCE 5 | ||
| 43 | |||
| 44 | |||
| 45 | /* key combination for command */ | ||
| 46 | #define IS_COMMAND() ( \ | ||
| 47 | keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ | ||
| 48 | ) | ||
| 49 | |||
| 50 | #endif | ||
diff --git a/keyboard/gh60/keymap.c b/keyboard/gh60/keymap.c new file mode 100644 index 000000000..2608c98c2 --- /dev/null +++ b/keyboard/gh60/keymap.c | |||
| @@ -0,0 +1,202 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2012 Jun Wako <wakojun@gmail.com> | ||
| 3 | |||
| 4 | This program is free software: you can redistribute it and/or modify | ||
| 5 | it under the terms of the GNU General Public License as published by | ||
| 6 | the Free Software Foundation, either version 2 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | #include <stdint.h> | ||
| 18 | #include <stdbool.h> | ||
| 19 | #include <avr/pgmspace.h> | ||
| 20 | #include "keycode.h" | ||
| 21 | #include "print.h" | ||
| 22 | #include "debug.h" | ||
| 23 | #include "util.h" | ||
| 24 | #include "keymap.h" | ||
| 25 | |||
| 26 | |||
| 27 | /* GH60 keymap definition macro | ||
| 28 | * K2C, K31 and K3C are extra keys for ISO | ||
| 29 | */ | ||
| 30 | #define KEYMAP( \ | ||
| 31 | K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, \ | ||
| 32 | K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \ | ||
| 33 | K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, \ | ||
| 34 | K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D, \ | ||
| 35 | K40, K41, K42, K45, K4A, K4B, K4C, K4D \ | ||
| 36 | ) { \ | ||
| 37 | { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07, KC_##K08, KC_##K09, KC_##K0A, KC_##K0B, KC_##K0C, KC_##K0D }, \ | ||
| 38 | { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17, KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D }, \ | ||
| 39 | { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27, KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D }, \ | ||
| 40 | { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37, KC_##K38, KC_##K39, KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D }, \ | ||
| 41 | { KC_##K40, KC_##K41, KC_##K42, KC_NO, KC_NO, KC_##K45, KC_NO, KC_NO, KC_NO, KC_NO, KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D } \ | ||
| 42 | } | ||
| 43 | |||
| 44 | /* ANSI valiant. No extra keys for ISO */ | ||
| 45 | #define KEYMAP_ANSI( \ | ||
| 46 | K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, \ | ||
| 47 | K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \ | ||
| 48 | K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2D, \ | ||
| 49 | K30, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3D, \ | ||
| 50 | K40, K41, K42, K45, K4A, K4B, K4C, K4D \ | ||
| 51 | ) KEYMAP( \ | ||
| 52 | K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, \ | ||
| 53 | K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \ | ||
| 54 | K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, NO, K2D, \ | ||
| 55 | K30, NO, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, NO, K3D, \ | ||
| 56 | K40, K41, K42, K45, K4A, K4B, K4C, K4D \ | ||
| 57 | ) | ||
| 58 | |||
| 59 | #define KEYCODE(layer, row, col) (pgm_read_byte(&keymaps[(layer)][(row)][(col)])) | ||
| 60 | |||
| 61 | |||
| 62 | // Assign Fn key(0-7) to a layer to which switch with the Fn key pressed. | ||
| 63 | static const uint8_t PROGMEM fn_layer[] = { | ||
| 64 | 0, // Fn0 | ||
| 65 | 1, // Fn1 | ||
| 66 | 2, // Fn2 | ||
| 67 | 3, // Fn3 | ||
| 68 | 3, // Fn4 | ||
| 69 | 0, // Fn5 | ||
| 70 | 0, // Fn6 | ||
| 71 | 0 // Fn7 | ||
| 72 | }; | ||
| 73 | |||
| 74 | // Assign Fn key(0-7) to a keycode sent when release Fn key without use of the layer. | ||
| 75 | // See layer.c for details. | ||
| 76 | static const uint8_t PROGMEM fn_keycode[] = { | ||
| 77 | KC_NO, // Fn0 | ||
| 78 | KC_NO, // Fn1 | ||
| 79 | KC_SLSH, // Fn2 | ||
| 80 | KC_SCLN, // Fn3 | ||
| 81 | KC_NO, // Fn4 | ||
| 82 | KC_NO, // Fn5 | ||
| 83 | KC_NO, // Fn6 | ||
| 84 | KC_NO // Fn7 | ||
| 85 | }; | ||
| 86 | |||
| 87 | static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
| 88 | #ifdef PLAIN_MAP | ||
| 89 | /* Layer 0: Default Layer | ||
| 90 | * ,-----------------------------------------------------------. | ||
| 91 | * |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | | ||
| 92 | * |-----------------------------------------------------------| | ||
| 93 | * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| | ||
| 94 | * |-----------------------------------------------------------| | ||
| 95 | * |Caps | A| S| D| F| G| H| J| K| L| ;| '|Return | | ||
| 96 | * |-----------------------------------------------------------| | ||
| 97 | * |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift | | ||
| 98 | * |-----------------------------------------------------------| | ||
| 99 | * |Ctrl|Gui |Alt | Space |Alt |Gui |App |Ctrl| | ||
| 100 | * `-----------------------------------------------------------' | ||
| 101 | */ | ||
| 102 | KEYMAP(ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, \ | ||
| 103 | TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, \ | ||
| 104 | CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT,NO, ENT, \ | ||
| 105 | LSFT,NO, Z, X, C, V, B, N, M, COMM,DOT, SLSH,NO, RSFT, \ | ||
| 106 | LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, RCTL), | ||
| 107 | #else | ||
| 108 | /* Layer 0: Default Layer | ||
| 109 | * ,-----------------------------------------------------------. | ||
| 110 | * |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | | ||
| 111 | * |-----------------------------------------------------------| | ||
| 112 | * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| | ||
| 113 | * |-----------------------------------------------------------| | ||
| 114 | * |Caps | A| S| D| F| G| H| J| K| L|Fn3| '|Return | | ||
| 115 | * |-----------------------------------------------------------| | ||
| 116 | * |Shift | Z| X| C| V| B| N| M| ,| .|Fn2|Shift | | ||
| 117 | * |-----------------------------------------------------------| | ||
| 118 | * |Ctrl|Gui |Alt | Space |Alt |Fn4 |Fn4 |Fn1 | | ||
| 119 | * `-----------------------------------------------------------' | ||
| 120 | */ | ||
| 121 | KEYMAP_ANSI( | ||
| 122 | ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, \ | ||
| 123 | TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, \ | ||
| 124 | LCTL,A, S, D, F, G, H, J, K, L, FN3, QUOT, ENT, \ | ||
| 125 | LSFT,Z, X, C, V, B, N, M, COMM,DOT, FN2, RSFT, \ | ||
| 126 | LCTL,LGUI,LALT, SPC, RALT,FN4, FN4, FN1), | ||
| 127 | /* Layer 1: HHKB mode | ||
| 128 | * ,-----------------------------------------------------------. | ||
| 129 | * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Delete | | ||
| 130 | * |-----------------------------------------------------------| | ||
| 131 | * |Caps | | | | | | | |Psc|Slk|Pus|Up | |Inser| | ||
| 132 | * |-----------------------------------------------------------| | ||
| 133 | * |Contro|VoD|VoU|Mut| | | *| /|Hom|PgU|Lef|Rig|Enter | | ||
| 134 | * |-----------------------------------------------------------| | ||
| 135 | * |Shift | | | | | | +| -|End|PgD|Dow|Shift | | ||
| 136 | * |-----------------------------------------------------------| | ||
| 137 | * |Ctrl|Gui |Alt | Space |Alt |Gui |App |xxx | | ||
| 138 | * `-----------------------------------------------------------' | ||
| 139 | */ | ||
| 140 | KEYMAP_ANSI( | ||
| 141 | PWR, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, \ | ||
| 142 | CAPS,NO, NO, NO, NO, NO, NO, NO, PSCR,SLCK,PAUS,UP, NO, INS, \ | ||
| 143 | LCTL,VOLD,VOLU,MUTE,NO, NO, PAST,PSLS,HOME,PGUP,LEFT,RGHT, ENT, \ | ||
| 144 | LSFT,NO, NO, NO, NO, NO, PPLS,PMNS,END, PGDN,DOWN, RSFT, \ | ||
| 145 | LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, FN1), | ||
| 146 | /* Layer 2: Vi mode (Slash) | ||
| 147 | * ,-----------------------------------------------------------. | ||
| 148 | * | `| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Backsp | | ||
| 149 | * |-----------------------------------------------------------| | ||
| 150 | * |Tab |Hom|PgD|Up |PgU|End|Hom|PgD|PgU|End| | | | | | ||
| 151 | * |-----------------------------------------------------------| | ||
| 152 | * |Contro| |Lef|Dow|Rig| |Lef|Dow|Up |Rig| | |Return | | ||
| 153 | * |-----------------------------------------------------------| | ||
| 154 | * |Shift | | | | | |Hom|PgD|PgU|End|xxx|Shift | | ||
| 155 | * |-----------------------------------------------------------| | ||
| 156 | * |Ctrl|Gui |Alt | Space |Alt |Gui |App |Ctrl| | ||
| 157 | * `-----------------------------------------------------------' | ||
| 158 | */ | ||
| 159 | KEYMAP_ANSI( | ||
| 160 | GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, BSPC, \ | ||
| 161 | TAB, HOME,PGDN,UP, PGUP,END, HOME,PGDN,PGUP,END, NO, NO, NO, NO, \ | ||
| 162 | LCTL,NO, LEFT,DOWN,RGHT,NO, LEFT,DOWN,UP, RGHT,NO, NO, ENT, \ | ||
| 163 | LSFT,NO, NO, NO, NO, NO, HOME,PGDN,PGUP,END, FN2, RSFT, \ | ||
| 164 | LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, RCTL), | ||
| 165 | /* Layer 3: Mouse mode (Semicolon/App) | ||
| 166 | * ,-----------------------------------------------------------. | ||
| 167 | * | `| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Backsp | | ||
| 168 | * |-----------------------------------------------------------| | ||
| 169 | * |Tab | | | | | |MwL|MwD|MwU|MwR| | | | | | ||
| 170 | * |-----------------------------------------------------------| | ||
| 171 | * |Contro| |Ac0|Ac1|Ac1| |McL|McD|McU|McR|xxx| |Return | | ||
| 172 | * |-----------------------------------------------------------| | ||
| 173 | * |Shift | | | | |Mb3|Mb2|Mb1|Mb4|Mb5| |Shift | | ||
| 174 | * |-----------------------------------------------------------| | ||
| 175 | * |Ctrl|Gui |Alt | Space | |xxx |xxx | | | ||
| 176 | * `-----------------------------------------------------------' | ||
| 177 | * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel | ||
| 178 | */ | ||
| 179 | KEYMAP_ANSI( | ||
| 180 | GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, BSPC, \ | ||
| 181 | TAB, NO, NO, NO, NO, NO, WH_L,WH_D,WH_U,WH_R,NO, NO, NO, NO, \ | ||
| 182 | LCTL,NO, ACL0,ACL1,ACL2,NO, MS_L,MS_D,MS_U,MS_R,FN3, NO, ENT, \ | ||
| 183 | LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,BTN4,BTN5,NO, RSFT, \ | ||
| 184 | LCTL,LGUI,LALT, BTN1, NO, FN4, FN4, NO ), | ||
| 185 | #endif | ||
| 186 | }; | ||
| 187 | |||
| 188 | |||
| 189 | uint8_t keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t col) | ||
| 190 | { | ||
| 191 | return KEYCODE(layer, row, col); | ||
| 192 | } | ||
| 193 | |||
| 194 | uint8_t keymap_fn_layer(uint8_t index) | ||
| 195 | { | ||
| 196 | return pgm_read_byte(&fn_layer[index]); | ||
| 197 | } | ||
| 198 | |||
| 199 | uint8_t keymap_fn_keycode(uint8_t index) | ||
| 200 | { | ||
| 201 | return pgm_read_byte(&fn_keycode[index]); | ||
| 202 | } | ||
diff --git a/keyboard/gh60/led.c b/keyboard/gh60/led.c new file mode 100644 index 000000000..62abcd79d --- /dev/null +++ b/keyboard/gh60/led.c | |||
| @@ -0,0 +1,34 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2012 Jun Wako <wakojun@gmail.com> | ||
| 3 | |||
| 4 | This program is free software: you can redistribute it and/or modify | ||
| 5 | it under the terms of the GNU General Public License as published by | ||
| 6 | the Free Software Foundation, either version 2 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #include <avr/io.h> | ||
| 19 | #include "stdint.h" | ||
| 20 | #include "led.h" | ||
| 21 | |||
| 22 | |||
| 23 | void led_set(uint8_t usb_led) | ||
| 24 | { | ||
| 25 | if (usb_led & (1<<USB_LED_CAPS_LOCK)) { | ||
| 26 | // output low | ||
| 27 | DDRB |= (1<<2); | ||
| 28 | PORTB &= ~(1<<2); | ||
| 29 | } else { | ||
| 30 | // Hi-Z | ||
| 31 | DDRB &= ~(1<<2); | ||
| 32 | PORTB &= ~(1<<2); | ||
| 33 | } | ||
| 34 | } | ||
diff --git a/keyboard/gh60/matrix.c b/keyboard/gh60/matrix.c new file mode 100644 index 000000000..6ded8158f --- /dev/null +++ b/keyboard/gh60/matrix.c | |||
| @@ -0,0 +1,224 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2012 Jun Wako <wakojun@gmail.com> | ||
| 3 | |||
| 4 | This program is free software: you can redistribute it and/or modify | ||
| 5 | it under the terms of the GNU General Public License as published by | ||
| 6 | the Free Software Foundation, either version 2 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | |||
| 18 | /* | ||
| 19 | * scan matrix | ||
| 20 | */ | ||
| 21 | #include <stdint.h> | ||
| 22 | #include <stdbool.h> | ||
| 23 | #include <avr/io.h> | ||
| 24 | #include <util/delay.h> | ||
| 25 | #include "print.h" | ||
| 26 | #include "debug.h" | ||
| 27 | #include "util.h" | ||
| 28 | #include "matrix.h" | ||
| 29 | |||
| 30 | |||
| 31 | #ifndef DEBOUNCE | ||
| 32 | # define DEBOUNCE 5 | ||
| 33 | #endif | ||
| 34 | static uint8_t debouncing = DEBOUNCE; | ||
| 35 | |||
| 36 | /* matrix state(1:on, 0:off) */ | ||
| 37 | static uint16_t *matrix; | ||
| 38 | static uint16_t *matrix_debouncing; | ||
| 39 | static uint16_t matrix0[MATRIX_ROWS]; | ||
| 40 | static uint16_t matrix1[MATRIX_ROWS]; | ||
| 41 | static bool is_modified; | ||
| 42 | |||
| 43 | static uint16_t read_cols(void); | ||
| 44 | static void init_cols(void); | ||
| 45 | static void unselect_rows(void); | ||
| 46 | static void select_row(uint8_t row); | ||
| 47 | |||
| 48 | |||
| 49 | inline | ||
| 50 | uint8_t matrix_rows(void) | ||
| 51 | { | ||
| 52 | return MATRIX_ROWS; | ||
| 53 | } | ||
| 54 | |||
| 55 | inline | ||
| 56 | uint8_t matrix_cols(void) | ||
| 57 | { | ||
| 58 | return MATRIX_COLS; | ||
| 59 | } | ||
| 60 | |||
| 61 | void matrix_init(void) | ||
| 62 | { | ||
| 63 | // initialize row and col | ||
| 64 | unselect_rows(); | ||
| 65 | init_cols(); | ||
| 66 | |||
| 67 | // initialize matrix state: all keys off | ||
| 68 | matrix = matrix0; | ||
| 69 | matrix_debouncing = matrix1; | ||
| 70 | for (uint8_t i=0; i < MATRIX_ROWS; i++) { | ||
| 71 | matrix[i] = 0; | ||
| 72 | matrix_debouncing[i] = 0; | ||
| 73 | } | ||
| 74 | is_modified = false; | ||
| 75 | } | ||
| 76 | |||
| 77 | uint8_t matrix_scan(void) | ||
| 78 | { | ||
| 79 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
| 80 | //unselect_rows(); | ||
| 81 | select_row(i); | ||
| 82 | _delay_us(30); // without this wait read unstable value. | ||
| 83 | uint16_t cols = read_cols(); | ||
| 84 | if (matrix_debouncing[i] != cols) { | ||
| 85 | matrix_debouncing[i] = cols; | ||
| 86 | if (debouncing) { | ||
| 87 | debug("bounce!: "); debug_hex(debouncing); debug("\n"); | ||
| 88 | } | ||
| 89 | debouncing = DEBOUNCE; | ||
| 90 | is_modified = false; | ||
| 91 | } | ||
| 92 | unselect_rows(); | ||
| 93 | } | ||
| 94 | //unselect_rows(); | ||
| 95 | |||
| 96 | if (debouncing) { | ||
| 97 | debouncing--; | ||
| 98 | _delay_ms(1); | ||
| 99 | } else { | ||
| 100 | uint16_t *tmp = matrix; | ||
| 101 | matrix = matrix_debouncing; | ||
| 102 | matrix_debouncing = tmp; | ||
| 103 | is_modified = true; | ||
| 104 | } | ||
| 105 | |||
| 106 | return 1; | ||
| 107 | } | ||
| 108 | |||
| 109 | bool matrix_is_modified(void) | ||
| 110 | { | ||
| 111 | return is_modified; | ||
| 112 | } | ||
| 113 | |||
| 114 | inline | ||
| 115 | bool matrix_has_ghost(void) | ||
| 116 | { | ||
| 117 | return false; | ||
| 118 | } | ||
| 119 | |||
| 120 | inline | ||
| 121 | bool matrix_is_on(uint8_t row, uint8_t col) | ||
| 122 | { | ||
| 123 | return (matrix[row] & (1<<col)); | ||
| 124 | } | ||
| 125 | |||
| 126 | inline | ||
| 127 | uint16_t matrix_get_row(uint8_t row) | ||
| 128 | { | ||
| 129 | return matrix[row]; | ||
| 130 | } | ||
| 131 | |||
| 132 | void matrix_print(void) | ||
| 133 | { | ||
| 134 | print("\nr/c 01234567890ABCDEF\n"); | ||
| 135 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
| 136 | phex(row); print(": "); | ||
| 137 | pbin_reverse16(matrix_get_row(row)); | ||
| 138 | print("\n"); | ||
| 139 | } | ||
| 140 | } | ||
| 141 | |||
| 142 | uint8_t matrix_key_count(void) | ||
| 143 | { | ||
| 144 | uint8_t count = 0; | ||
| 145 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
| 146 | count += bitpop16(matrix[i]); | ||
| 147 | } | ||
| 148 | return count; | ||
| 149 | } | ||
| 150 | |||
| 151 | /* Column pin configuration | ||
| 152 | * col: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 | ||
| 153 | * pin: F0 F1 E6 C7 C6 B6 D4 B1 B0 B5 B4 D7 D6 B3 | ||
| 154 | */ | ||
| 155 | static void init_cols(void) | ||
| 156 | { | ||
| 157 | // Input with pull-up(DDR:0, PORT:1) | ||
| 158 | DDRF &= ~(1<<0 | 1<<1); | ||
| 159 | PORTF |= (1<<0 | 1<<1); | ||
| 160 | DDRE &= ~(1<<6); | ||
| 161 | PORTE |= (1<<6); | ||
| 162 | DDRD &= ~(1<<7 | 1<<6 | 1<<4); | ||
| 163 | PORTD |= (1<<7 | 1<<6 | 1<<4); | ||
| 164 | DDRC &= ~(1<<7 | 1<<6); | ||
| 165 | PORTC |= (1<<7 | 1<<6); | ||
| 166 | DDRB &= ~(1<<6 | 1<< 5 | 1<<4 | 1<<3 | 1<<1 | 1<<0); | ||
| 167 | PORTB |= (1<<6 | 1<< 5 | 1<<4 | 1<<3 | 1<<1 | 1<<0); | ||
| 168 | } | ||
| 169 | |||
| 170 | static uint16_t read_cols(void) | ||
| 171 | { | ||
| 172 | return (PINF&(1<<0) ? 0 : (1<<0)) | | ||
| 173 | (PINF&(1<<1) ? 0 : (1<<1)) | | ||
| 174 | (PINE&(1<<6) ? 0 : (1<<2)) | | ||
| 175 | (PINC&(1<<7) ? 0 : (1<<3)) | | ||
| 176 | (PINC&(1<<6) ? 0 : (1<<4)) | | ||
| 177 | (PINB&(1<<6) ? 0 : (1<<5)) | | ||
| 178 | (PIND&(1<<4) ? 0 : (1<<6)) | | ||
| 179 | (PINB&(1<<1) ? 0 : (1<<7)) | | ||
| 180 | (PINB&(1<<0) ? 0 : (1<<8)) | | ||
| 181 | (PINB&(1<<5) ? 0 : (1<<9)) | | ||
| 182 | (PINB&(1<<4) ? 0 : (1<<10)) | | ||
| 183 | (PIND&(1<<7) ? 0 : (1<<11)) | | ||
| 184 | (PIND&(1<<6) ? 0 : (1<<12)) | | ||
| 185 | (PINB&(1<<3) ? 0 : (1<<13)); | ||
| 186 | } | ||
| 187 | |||
| 188 | /* Row pin configuration | ||
| 189 | * row: 0 1 2 3 4 | ||
| 190 | * pin: D0 D1 D2 D3 D5 | ||
| 191 | */ | ||
| 192 | static void unselect_rows(void) | ||
| 193 | { | ||
| 194 | // Hi-Z(DDR:0, PORT:0) to unselect | ||
| 195 | DDRD &= ~0b00101111; | ||
| 196 | PORTD &= ~0b00101111; | ||
| 197 | } | ||
| 198 | |||
| 199 | static void select_row(uint8_t row) | ||
| 200 | { | ||
| 201 | // Output low(DDR:1, PORT:0) to select | ||
| 202 | switch (row) { | ||
| 203 | case 0: | ||
| 204 | DDRD |= (1<<0); | ||
| 205 | PORTD &= ~(1<<0); | ||
| 206 | break; | ||
| 207 | case 1: | ||
| 208 | DDRD |= (1<<1); | ||
| 209 | PORTD &= ~(1<<1); | ||
| 210 | break; | ||
| 211 | case 2: | ||
| 212 | DDRD |= (1<<2); | ||
| 213 | PORTD &= ~(1<<2); | ||
| 214 | break; | ||
| 215 | case 3: | ||
| 216 | DDRD |= (1<<3); | ||
| 217 | PORTD &= ~(1<<3); | ||
| 218 | break; | ||
| 219 | case 4: | ||
| 220 | DDRD |= (1<<5); | ||
| 221 | PORTD &= ~(1<<5); | ||
| 222 | break; | ||
| 223 | } | ||
| 224 | } | ||
diff --git a/keyboard/hid_liber/Makefile.lufa b/keyboard/hid_liber/Makefile.lufa new file mode 100644 index 000000000..2d560b9a6 --- /dev/null +++ b/keyboard/hid_liber/Makefile.lufa | |||
| @@ -0,0 +1,120 @@ | |||
| 1 | #---------------------------------------------------------------------------- | ||
| 2 | # On command line: | ||
| 3 | # | ||
| 4 | # make all = Make software. | ||
| 5 | # | ||
| 6 | # make clean = Clean out built project files. | ||
| 7 | # | ||
| 8 | # make coff = Convert ELF to AVR COFF. | ||
| 9 | # | ||
| 10 | # make extcoff = Convert ELF to AVR Extended COFF. | ||
| 11 | # | ||
| 12 | # make program = Download the hex file to the device. | ||
| 13 | # Please customize your programmer settings(PROGRAM_CMD) | ||
| 14 | # | ||
| 15 | # make teensy = Download the hex file to the device, using teensy_loader_cli. | ||
| 16 | # (must have teensy_loader_cli installed). | ||
| 17 | # | ||
| 18 | # make dfu = Download the hex file to the device, using dfu-programmer (must | ||
| 19 | # have dfu-programmer installed). | ||
| 20 | # | ||
| 21 | # make flip = Download the hex file to the device, using Atmel FLIP (must | ||
| 22 | # have Atmel FLIP installed). | ||
| 23 | # | ||
| 24 | # make dfu-ee = Download the eeprom file to the device, using dfu-programmer | ||
| 25 | # (must have dfu-programmer installed). | ||
| 26 | # | ||
| 27 | # make flip-ee = Download the eeprom file to the device, using Atmel FLIP | ||
| 28 | # (must have Atmel FLIP installed). | ||
| 29 | # | ||
| 30 | # make debug = Start either simulavr or avarice as specified for debugging, | ||
| 31 | # with avr-gdb or avr-insight as the front end for debugging. | ||
| 32 | # | ||
| 33 | # make filename.s = Just compile filename.c into the assembler code only. | ||
| 34 | # | ||
| 35 | # make filename.i = Create a preprocessed source file for use in submitting | ||
| 36 | # bug reports to the GCC project. | ||
| 37 | # | ||
| 38 | # To rebuild project do "make clean" then "make all". | ||
| 39 | #---------------------------------------------------------------------------- | ||
| 40 | |||
| 41 | # Target file name (without extension). | ||
| 42 | TARGET = hid_liber_lufa | ||
| 43 | |||
| 44 | # Directory common source filess exist | ||
| 45 | TOP_DIR = ../.. | ||
| 46 | |||
| 47 | # Directory keyboard dependent files exist | ||
| 48 | TARGET_DIR = . | ||
| 49 | |||
| 50 | |||
| 51 | # List C source files here. (C dependencies are automatically generated.) | ||
| 52 | SRC += keymap.c \ | ||
| 53 | matrix.c \ | ||
| 54 | led.c | ||
| 55 | |||
| 56 | CONFIG_H = config.h | ||
| 57 | |||
| 58 | |||
| 59 | # MCU name | ||
| 60 | #MCU = at90usb1287 | ||
| 61 | MCU = atmega32u4 | ||
| 62 | |||
| 63 | # Processor frequency. | ||
| 64 | # This will define a symbol, F_CPU, in all source code files equal to the | ||
| 65 | # processor frequency in Hz. You can then use this symbol in your source code to | ||
| 66 | # calculate timings. Do NOT tack on a 'UL' at the end, this will be done | ||
| 67 | # automatically to create a 32-bit value in your source code. | ||
| 68 | # | ||
| 69 | # This will be an integer division of F_USB below, as it is sourced by | ||
| 70 | # F_USB after it has run through any CPU prescalers. Note that this value | ||
| 71 | # does not *change* the processor frequency - it should merely be updated to | ||
| 72 | # reflect the processor speed set externally so that the code can use accurate | ||
| 73 | # software delays. | ||
| 74 | F_CPU = 16000000 | ||
| 75 | |||
| 76 | |||
| 77 | # | ||
| 78 | # LUFA specific | ||
| 79 | # | ||
| 80 | # Target architecture (see library "Board Types" documentation). | ||
| 81 | ARCH = AVR8 | ||
| 82 | |||
| 83 | # Input clock frequency. | ||
| 84 | # This will define a symbol, F_USB, in all source code files equal to the | ||
| 85 | # input clock frequency (before any prescaling is performed) in Hz. This value may | ||
| 86 | # differ from F_CPU if prescaling is used on the latter, and is required as the | ||
| 87 | # raw input clock is fed directly to the PLL sections of the AVR for high speed | ||
| 88 | # clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' | ||
| 89 | # at the end, this will be done automatically to create a 32-bit value in your | ||
| 90 | # source code. | ||
| 91 | # | ||
| 92 | # If no clock division is performed on the input clock inside the AVR (via the | ||
| 93 | # CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. | ||
| 94 | F_USB = $(F_CPU) | ||
| 95 | |||
| 96 | |||
| 97 | # Build Options | ||
| 98 | # comment out to disable the options. | ||
| 99 | # | ||
| 100 | #MOUSEKEY_ENABLE = yes # Mouse keys | ||
| 101 | EXTRAKEY_ENABLE = yes # Audio control and System control | ||
| 102 | CONSOLE_ENABLE = yes # Console for debug | ||
| 103 | #NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA | ||
| 104 | #PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support | ||
| 105 | |||
| 106 | |||
| 107 | # Boot Section Size in bytes | ||
| 108 | # Teensy halfKay 512 | ||
| 109 | # Atmel DFU loader 4096 | ||
| 110 | # LUFA bootloader 4096 | ||
| 111 | OPT_DEFS += -DBOOT_SIZE=4096 | ||
| 112 | |||
| 113 | |||
| 114 | # Search Path | ||
| 115 | VPATH += $(TARGET_DIR) | ||
| 116 | VPATH += $(TOP_DIR) | ||
| 117 | |||
| 118 | include $(TOP_DIR)/protocol/lufa.mk | ||
| 119 | include $(TOP_DIR)/common.mk | ||
| 120 | include $(TOP_DIR)/rules.mk | ||
diff --git a/keyboard/hid_liber/Makefile.pjrc b/keyboard/hid_liber/Makefile.pjrc new file mode 100644 index 000000000..8e349c8da --- /dev/null +++ b/keyboard/hid_liber/Makefile.pjrc | |||
| @@ -0,0 +1,90 @@ | |||
| 1 | #---------------------------------------------------------------------------- | ||
| 2 | # On command line: | ||
| 3 | # | ||
| 4 | # make all = Make software. | ||
| 5 | # | ||
| 6 | # make clean = Clean out built project files. | ||
| 7 | # | ||
| 8 | # make coff = Convert ELF to AVR COFF. | ||
| 9 | # | ||
| 10 | # make extcoff = Convert ELF to AVR Extended COFF. | ||
| 11 | # | ||
| 12 | # make program = Download the hex file to the device. | ||
| 13 | # Please customize your programmer settings(PROGRAM_CMD) | ||
| 14 | # | ||
| 15 | # make teensy = Download the hex file to the device, using teensy_loader_cli. | ||
| 16 | # (must have teensy_loader_cli installed). | ||
| 17 | # | ||
| 18 | # make dfu = Download the hex file to the device, using dfu-programmer (must | ||
| 19 | # have dfu-programmer installed). | ||
| 20 | # | ||
| 21 | # make flip = Download the hex file to the device, using Atmel FLIP (must | ||
| 22 | # have Atmel FLIP installed). | ||
| 23 | # | ||
| 24 | # make dfu-ee = Download the eeprom file to the device, using dfu-programmer | ||
| 25 | # (must have dfu-programmer installed). | ||
| 26 | # | ||
| 27 | # make flip-ee = Download the eeprom file to the device, using Atmel FLIP | ||
| 28 | # (must have Atmel FLIP installed). | ||
| 29 | # | ||
| 30 | # make debug = Start either simulavr or avarice as specified for debugging, | ||
| 31 | # with avr-gdb or avr-insight as the front end for debugging. | ||
| 32 | # | ||
| 33 | # make filename.s = Just compile filename.c into the assembler code only. | ||
| 34 | # | ||
| 35 | # make filename.i = Create a preprocessed source file for use in submitting | ||
| 36 | # bug reports to the GCC project. | ||
| 37 | # | ||
| 38 | # To rebuild project do "make clean" then "make all". | ||
| 39 | #---------------------------------------------------------------------------- | ||
| 40 | |||
| 41 | # Target file name (without extension). | ||
| 42 | TARGET = hid_liber_pjrc | ||
| 43 | |||
| 44 | # Directory common source filess exist | ||
| 45 | TOP_DIR = ../.. | ||
| 46 | |||
| 47 | # Directory keyboard dependent files exist | ||
| 48 | TARGET_DIR = . | ||
| 49 | |||
| 50 | # keyboard dependent files | ||
| 51 | SRC = keymap.c \ | ||
| 52 | matrix.c \ | ||
| 53 | led.c | ||
| 54 | |||
| 55 | CONFIG_H = config.h | ||
| 56 | |||
| 57 | |||
| 58 | # MCU name, you MUST set this to match the board you are using | ||
| 59 | # type "make clean" after changing this, so all files will be rebuilt | ||
| 60 | #MCU = at90usb162 # Teensy 1.0 | ||
| 61 | MCU = atmega32u4 # Teensy 2.0 | ||
| 62 | #MCU = at90usb646 # Teensy++ 1.0 | ||
| 63 | #MCU = at90usb1286 # Teensy++ 2.0 | ||
| 64 | |||
| 65 | |||
| 66 | # Processor frequency. | ||
| 67 | # Normally the first thing your program should do is set the clock prescaler, | ||
| 68 | # so your program will run at the correct speed. You should also set this | ||
| 69 | # variable to same clock speed. The _delay_ms() macro uses this, and many | ||
| 70 | # examples use this variable to calculate timings. Do not add a "UL" here. | ||
| 71 | F_CPU = 16000000 | ||
| 72 | |||
| 73 | |||
| 74 | # Build Options | ||
| 75 | # comment out to disable the options. | ||
| 76 | # | ||
| 77 | #MOUSEKEY_ENABLE = yes # Mouse keys | ||
| 78 | #PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support | ||
| 79 | EXTRAKEY_ENABLE = yes # Audio control and System control | ||
| 80 | NKRO_ENABLE = yes # USB Nkey Rollover | ||
| 81 | CONSOLE_ENABLE = yes # Console for debug | ||
| 82 | |||
| 83 | |||
| 84 | # Search Path | ||
| 85 | VPATH += $(TARGET_DIR) | ||
| 86 | VPATH += $(TOP_DIR) | ||
| 87 | |||
| 88 | include $(TOP_DIR)/protocol/pjrc.mk | ||
| 89 | include $(TOP_DIR)/common.mk | ||
| 90 | include $(TOP_DIR)/rules.mk | ||
diff --git a/keyboard/hid_liber/config.h b/keyboard/hid_liber/config.h new file mode 100644 index 000000000..a9b77c7dc --- /dev/null +++ b/keyboard/hid_liber/config.h | |||
| @@ -0,0 +1,56 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2012 Jun Wako <wakojun@gmail.com> | ||
| 3 | |||
| 4 | This program is free software: you can redistribute it and/or modify | ||
| 5 | it under the terms of the GNU General Public License as published by | ||
| 6 | the Free Software Foundation, either version 2 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #ifndef CONFIG_H | ||
| 19 | #define CONFIG_H | ||
| 20 | |||
| 21 | |||
| 22 | /* USB Device descriptor parameter */ | ||
| 23 | #define VENDOR_ID 0xFEED | ||
| 24 | #define PRODUCT_ID 0xB919 | ||
| 25 | #define DEVICE_VER 0x0001 | ||
| 26 | #define MANUFACTURER t.m.k. | ||
| 27 | #define PRODUCT HID Liberation | ||
| 28 | |||
| 29 | |||
| 30 | /* message strings */ | ||
| 31 | #define DESCRIPTION t.m.k. keyboard firmware for HID Liberation | ||
| 32 | |||
| 33 | |||
| 34 | /* matrix size */ | ||
| 35 | #define MATRIX_ROWS 18 | ||
| 36 | #define MATRIX_COLS 8 | ||
| 37 | |||
| 38 | /* define if matrix has ghost */ | ||
| 39 | //#define MATRIX_HAS_GHOST | ||
| 40 | |||
| 41 | /* Set 0 if need no debouncing */ | ||
| 42 | #define DEBOUNCE 8 | ||
| 43 | |||
| 44 | |||
| 45 | /* key combination for command */ | ||
| 46 | #define IS_COMMAND() ( \ | ||
| 47 | keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ | ||
| 48 | ) | ||
| 49 | |||
| 50 | // TODO: configurable | ||
| 51 | #define DEBUG_LED 0 | ||
| 52 | #define DEBUG_LED_CONFIG | ||
| 53 | #define DEBUG_LED_ON | ||
| 54 | #define DEBUG_LED_OFF | ||
| 55 | |||
| 56 | #endif | ||
diff --git a/keyboard/hid_liber/keymap.c b/keyboard/hid_liber/keymap.c new file mode 100644 index 000000000..e35f7245d --- /dev/null +++ b/keyboard/hid_liber/keymap.c | |||
| @@ -0,0 +1,195 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2011 Jun Wako <wakojun@gmail.com> | ||
| 3 | |||
| 4 | This program is free software: you can redistribute it and/or modify | ||
| 5 | it under the terms of the GNU General Public License as published by | ||
| 6 | the Free Software Foundation, either version 2 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | |||
| 18 | /* | ||
| 19 | * Keymap for HID Liberator controller | ||
| 20 | */ | ||
| 21 | #include <stdint.h> | ||
| 22 | #include <stdbool.h> | ||
| 23 | #include <avr/pgmspace.h> | ||
| 24 | #include "keycode.h" | ||
| 25 | #include "print.h" | ||
| 26 | #include "debug.h" | ||
| 27 | #include "util.h" | ||
| 28 | #include "keymap.h" | ||
| 29 | |||
| 30 | |||
| 31 | // Convert physical keyboard layout to matrix array. | ||
| 32 | // This is a macro to define keymap easily in keyboard layout form. | ||
| 33 | #define KEYMAP( \ | ||
| 34 | KG1, KH7, KJ7, KJ6, KJ1, KO5, KL1, KA6, KA7, KD7, KD5, KD1, KD2, KB5, KB3, KO3, \ | ||
| 35 | KG7, KG5, KH5, KJ5, KI5, KI7, KK7, KK5, KL5, KA5, KC5, KC7, KL7, KD6, KQ7, KN7, KM7, \ | ||
| 36 | KG6, KG3, KH3, KJ3, KI3, KI6, KK6, KK3, KL3, KA3, KC3, KC6, KL6, KD4, KP7, KN5, KM5, \ | ||
| 37 | KH6, KG4, KH4, KJ4, KI4, KI1, KK1, KK4, KL4, KA4, KC4, KC1, KD0, \ | ||
| 38 | KF6, KH1, KG0, KH0, KJ0, KI0, KI2, KK2, KK0, KL0, KA0, KC2, KF4, KN1, \ | ||
| 39 | KO7, KE6, KB1, KP1, KB2, KR4, KA2, KO0, KN2, KP2, KQ2 \ | ||
| 40 | ) { \ | ||
| 41 | /* 0 1 2 3 4 5 6 7 */ \ | ||
| 42 | /* A */ { KC_##KA0, KC_NO , KC_##KA2, KC_##KA3, KC_##KA4, KC_##KA5, KC_##KA6, KC_##KA7 }, \ | ||
| 43 | /* B */ { KC_NO , KC_##KB1, KC_##KB2, KC_##KB3, KC_NO , KC_##KB5, KC_NO , KC_NO }, \ | ||
| 44 | /* C */ { KC_NO , KC_##KC1, KC_##KC2, KC_##KC3, KC_##KC4, KC_##KC5, KC_##KC6, KC_##KC7 }, \ | ||
| 45 | /* D */ { KC_##KD0, KC_##KD1, KC_##KD2, KC_NO , KC_##KD4, KC_##KD5, KC_##KD6, KC_##KD7 }, \ | ||
| 46 | /* E */ { KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_##KE6, KC_NO }, \ | ||
| 47 | /* F */ { KC_NO , KC_NO , KC_NO , KC_NO , KC_##KF4, KC_NO , KC_##KF6, KC_NO }, \ | ||
| 48 | /* G */ { KC_##KG0, KC_##KG1, KC_NO , KC_##KG3, KC_##KG4, KC_##KG5, KC_##KG6, KC_##KG7 }, \ | ||
| 49 | /* H */ { KC_##KH0, KC_##KH1, KC_NO , KC_##KH3, KC_##KH4, KC_##KH5, KC_##KH6, KC_##KH7 }, \ | ||
| 50 | /* I */ { KC_##KI0, KC_##KI1, KC_##KI2, KC_##KI3, KC_##KI4, KC_##KI5, KC_##KI6, KC_##KI7 }, \ | ||
| 51 | /* J */ { KC_##KJ0, KC_##KJ1, KC_NO , KC_##KJ3, KC_##KJ4, KC_##KJ5, KC_##KJ6, KC_##KJ7 }, \ | ||
| 52 | /* K */ { KC_##KK0, KC_##KK1, KC_##KK2, KC_##KK3, KC_##KK4, KC_##KK5, KC_##KK6, KC_##KK7 }, \ | ||
| 53 | /* L */ { KC_##KL0, KC_##KL1, KC_NO , KC_##KL3, KC_##KL4, KC_##KL5, KC_##KL6, KC_##KL7 }, \ | ||
| 54 | /* M */ { KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_##KM5, KC_NO , KC_##KM7 }, \ | ||
| 55 | /* N */ { KC_NO , KC_##KN1, KC_##KN2, KC_NO , KC_NO , KC_##KN5, KC_NO , KC_##KN7 }, \ | ||
| 56 | /* O */ { KC_##KO0, KC_NO , KC_NO , KC_##KO3, KC_NO , KC_##KO5, KC_NO , KC_##KO7 }, \ | ||
| 57 | /* P */ { KC_NO , KC_##KP1, KC_##KP2, KC_NO , KC_NO , KC_NO , KC_NO , KC_##KP7 }, \ | ||
| 58 | /* Q */ { KC_NO , KC_NO , KC_##KQ2, KC_NO , KC_NO , KC_NO , KC_NO , KC_##KQ7 }, \ | ||
| 59 | /* R */ { KC_NO , KC_NO , KC_NO , KC_NO , KC_##KR4, KC_NO , KC_NO , KC_NO } \ | ||
| 60 | } | ||
| 61 | |||
| 62 | #define KEYCODE(layer, row, col) (pgm_read_byte(&keymaps[(layer)][(row)][(col)])) | ||
| 63 | |||
| 64 | |||
| 65 | // Assign Fn key(0-7) to a layer to which switch with the Fn key pressed. | ||
| 66 | static const uint8_t PROGMEM fn_layer[] = { | ||
| 67 | 0, // Fn0 | ||
| 68 | 1, // Fn1 | ||
| 69 | 2, // Fn2 | ||
| 70 | 3, // Fn3 | ||
| 71 | 4, // Fn4 | ||
| 72 | 5, // Fn5 | ||
| 73 | 6, // Fn6 | ||
| 74 | 7 // Fn7 | ||
| 75 | }; | ||
| 76 | |||
| 77 | // Assign Fn key(0-7) to a keycode sent when release Fn key without use of the layer. | ||
| 78 | // See layer.c for details. | ||
| 79 | static const uint8_t PROGMEM fn_keycode[] = { | ||
| 80 | KC_NO, // Fn0 | ||
| 81 | KC_NO, // Fn1 | ||
| 82 | KC_NO, // Fn2 | ||
| 83 | KC_NO, // Fn3 | ||
| 84 | KC_NO, // Fn4 | ||
| 85 | KC_NO, // Fn5 | ||
| 86 | KC_NO, // Fn6 | ||
| 87 | KC_NO // Fn7 | ||
| 88 | }; | ||
| 89 | |||
| 90 | /* | ||
| 91 | * Tenkeyless keyboard default layout, ISO & ANSI (ISO is between Left Shift | ||
| 92 | * and Z, and the ANSI \ key above Return/Enter is used for the additional ISO | ||
| 93 | * switch in the ASD row next to enter. Use NUBS as keycode for the first and | ||
| 94 | * NUHS as the keycode for the second. | ||
| 95 | * | ||
| 96 | * ,---. ,---------------. ,---------------. ,---------------. ,-----------. | ||
| 97 | * |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| | ||
| 98 | * `---' `---------------' `---------------' `---------------' `-----------' | ||
| 99 | * ,-----------------------------------------------------------. ,-----------. | ||
| 100 | * |~ | 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | |Ins|Hom|PgU| | ||
| 101 | * |-----------------------------------------------------------| |-----------| | ||
| 102 | * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|End|PgD| | ||
| 103 | * |-----------------------------------------------------------| `-----------' | ||
| 104 | * |Caps | A| S| D| F| G| H| J| K| L| ;| '|Return | | ||
| 105 | * |-----------------------------------------------------------| ,---. | ||
| 106 | * |Shft|ISO| Z| X| C| V| B| N| M| ,| .| /|Shift | |Up | | ||
| 107 | * |-----------------------------------------------------------| ,-----------. | ||
| 108 | * |Ctl|Gui|Alt| Space |Alt|Gui|App|Ctl| |Lef|Dow|Rig| | ||
| 109 | * `-----------------------------------------------------------' `-----------' | ||
| 110 | */ | ||
| 111 | |||
| 112 | |||
| 113 | static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
| 114 | /* Layer 0: Default Layer | ||
| 115 | * | ||
| 116 | * ANSI: | ||
| 117 | * | ||
| 118 | * ,---. ,---------------. ,---------------. ,---------------. ,-----------. | ||
| 119 | * |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| | ||
| 120 | * `---' `---------------' `---------------' `---------------' `-----------' | ||
| 121 | * ,-----------------------------------------------------------. ,-----------. | ||
| 122 | * |~ | 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | |Ins|Hom|PgU| | ||
| 123 | * |-----------------------------------------------------------| |-----------| | ||
| 124 | * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|End|PgD| | ||
| 125 | * |-----------------------------------------------------------| `-----------' | ||
| 126 | * |FN1 | A| S| D| F| G| H| J| K| L| ;| '|Return | | ||
| 127 | * |-----------------------------------------------------------| ,---. | ||
| 128 | * |Shft|iso| Z| X| C| V| B| N| M| ,| .| /|Shift | |Up | | ||
| 129 | * |-----------------------------------------------------------| ,-----------. | ||
| 130 | * |Ctl|Gui|Alt| Space |Alt|Gui|App|Ctl| |Lef|Dow|Rig| | ||
| 131 | * `-----------------------------------------------------------' `-----------' | ||
| 132 | */ | ||
| 133 | |||
| 134 | KEYMAP(\ | ||
| 135 | ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR, SLCK, BRK, \ | ||
| 136 | GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS, EQL, BSPC, INS, HOME, PGUP, \ | ||
| 137 | TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC, RBRC, BSLS, DEL, END, PGDN, \ | ||
| 138 | FN1, A, S, D, F, G, H, J, K, L, SCLN, QUOT, ENT, \ | ||
| 139 | LSFT, NUBS, Z, X, C, V, B, N, M, COMM, DOT, SLSH, RSFT, UP, \ | ||
| 140 | LCTL, LGUI, LALT, SPC, RALT, RGUI, APP, RCTL, LEFT, DOWN, RGHT), | ||
| 141 | |||
| 142 | /* EXAMPLE ISO keymap, see the NUBS and NUHS keycodes | ||
| 143 | * KEYMAP(\ | ||
| 144 | * ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR, SLCK, BRK, \ | ||
| 145 | * GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS, EQL, BSPC, INS, HOME, PGUP, \ | ||
| 146 | * TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC, RBRC, NUHS, DEL, END, PGDN, \ | ||
| 147 | * CAPS, A, S, D, F, G, H, J, K, L, SCLN, QUOT, ENT, \ | ||
| 148 | * LSFT, NUBS, Z, X, C, V, B, N, M, COMM, DOT, SLSH, RSFT, UP, \ | ||
| 149 | * LCTL, FN1, LALT, SPC, RALT, RGUI, APP, RCTL, LEFT, DOWN, RGHT), | ||
| 150 | */ | ||
| 151 | |||
| 152 | |||
| 153 | /* | ||
| 154 | * ,---. ,---------------. ,---------------. ,---------------. ,-----------. | ||
| 155 | * |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Slp| | ||
| 156 | * `---' `---------------' `---------------' `---------------' `-----------' | ||
| 157 | * ,-----------------------------------------------------------. ,-----------. | ||
| 158 | * |~ | 1| 2| 3| 4| 5| 6| 7| 8| 9|Mut|V- |V+ |Backsp | |Ins|Hom|PgU| | ||
| 159 | * |-----------------------------------------------------------| |-----------| | ||
| 160 | * |Tab | Q| W| E| R| T| Y| U| I|MSt|Ply|Prv|Nxt|Media| |Del|End|PgD| | ||
| 161 | * |-----------------------------------------------------------| `-----------' | ||
| 162 | * |FN1 | A| S| D| F| G| H| J| K| L| ;| '|Return | | ||
| 163 | * |-----------------------------------------------------------| ,---. | ||
| 164 | * |Shft|iso| Z| X|Clc| V| B| N| M| ,| .| /|Caps | |Up | | ||
| 165 | * |-----------------------------------------------------------| ,-----------. | ||
| 166 | * |Ctl|Gui|Alt| Space |Alt|Gui|App|Ctl| |Lef|Dow|Rig| | ||
| 167 | * `-----------------------------------------------------------' `-----------' | ||
| 168 | */ | ||
| 169 | |||
| 170 | KEYMAP(\ | ||
| 171 | ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR, SLCK, SLEP, \ | ||
| 172 | GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9,MUTE, VOLD, VOLU, BSPC, INS, HOME, PGUP, \ | ||
| 173 | TAB, Q, W, E, R, T, Y, U, I,MSTP,MPLY, MPRV, MNXT, MSEL, DEL, END, PGDN, \ | ||
| 174 | FN1, A, S, D, F, G, H, J, K, L, SCLN, QUOT, ENT, \ | ||
| 175 | LSFT, NUBS, Z, X,CALC, V, B, N, M, COMM, DOT, SLSH, CAPS, UP, \ | ||
| 176 | LCTL, LGUI, LALT, SPC, RALT, RGUI, APP, RCTL, LEFT, DOWN, RGHT), | ||
| 177 | |||
| 178 | |||
| 179 | }; | ||
| 180 | |||
| 181 | |||
| 182 | uint8_t keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t col) | ||
| 183 | { | ||
| 184 | return KEYCODE(layer, row, col); | ||
| 185 | } | ||
| 186 | |||
| 187 | uint8_t keymap_fn_layer(uint8_t index) | ||
| 188 | { | ||
| 189 | return pgm_read_byte(&fn_layer[index]); | ||
| 190 | } | ||
| 191 | |||
| 192 | uint8_t keymap_fn_keycode(uint8_t index) | ||
| 193 | { | ||
| 194 | return pgm_read_byte(&fn_keycode[index]); | ||
| 195 | } | ||
diff --git a/keyboard/hid_liber/led.c b/keyboard/hid_liber/led.c new file mode 100644 index 000000000..e577424c5 --- /dev/null +++ b/keyboard/hid_liber/led.c | |||
| @@ -0,0 +1,34 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2012 Jun Wako <wakojun@gmail.com> | ||
| 3 | |||
| 4 | This program is free software: you can redistribute it and/or modify | ||
| 5 | it under the terms of the GNU General Public License as published by | ||
| 6 | the Free Software Foundation, either version 2 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #include <avr/io.h> | ||
| 19 | #include "stdint.h" | ||
| 20 | #include "led.h" | ||
| 21 | |||
| 22 | |||
| 23 | void led_set(uint8_t usb_led) | ||
| 24 | { | ||
| 25 | if (usb_led & (1<<USB_LED_CAPS_LOCK)) | ||
| 26 | PORTB &= ~(1<<5); | ||
| 27 | else | ||
| 28 | PORTB |= (1<<5); | ||
| 29 | |||
| 30 | if (usb_led & (1<<USB_LED_SCROLL_LOCK)) | ||
| 31 | PORTB &= ~(1<<6); | ||
| 32 | else | ||
| 33 | PORTB |= (1<<6); | ||
| 34 | } | ||
diff --git a/keyboard/hid_liber/matrix.c b/keyboard/hid_liber/matrix.c new file mode 100644 index 000000000..2d939ef63 --- /dev/null +++ b/keyboard/hid_liber/matrix.c | |||
| @@ -0,0 +1,234 @@ | |||
| 1 | /* Copyright 2012 Jun Wako <wakojun@gmail.com> | ||
| 2 | * | ||
| 3 | * This is heavily based on hid_liber/board.{c|h}. | ||
| 4 | * https://github.com/BathroomEpiphanies/AVR-Keyboard | ||
| 5 | * | ||
| 6 | * Copyright (c) 2012 Fredrik Atmer, Bathroom Epiphanies Inc | ||
| 7 | * http://bathroomepiphanies.com | ||
| 8 | * | ||
| 9 | * As for liscensing consult with the original files or its author. | ||
| 10 | */ | ||
| 11 | #include <stdint.h> | ||
| 12 | #include <stdbool.h> | ||
| 13 | #include <avr/io.h> | ||
| 14 | #include <util/delay.h> | ||
| 15 | #include "print.h" | ||
| 16 | #include "debug.h" | ||
| 17 | #include "util.h" | ||
| 18 | #include "matrix.h" | ||
| 19 | |||
| 20 | |||
| 21 | #ifndef DEBOUNCE | ||
| 22 | # define DEBOUNCE 0 | ||
| 23 | #endif | ||
| 24 | static uint8_t debouncing = DEBOUNCE; | ||
| 25 | |||
| 26 | // bit array of key state(1:on, 0:off) | ||
| 27 | static matrix_row_t *matrix; | ||
| 28 | static matrix_row_t *matrix_debounced; | ||
| 29 | static matrix_row_t _matrix0[MATRIX_ROWS]; | ||
| 30 | static matrix_row_t _matrix1[MATRIX_ROWS]; | ||
| 31 | |||
| 32 | |||
| 33 | #define _DDRA (uint8_t *const)&DDRA | ||
| 34 | #define _DDRB (uint8_t *const)&DDRB | ||
| 35 | #define _DDRC (uint8_t *const)&DDRC | ||
| 36 | #define _DDRD (uint8_t *const)&DDRD | ||
| 37 | #define _DDRE (uint8_t *const)&DDRE | ||
| 38 | #define _DDRF (uint8_t *const)&DDRF | ||
| 39 | |||
| 40 | #define _PINA (uint8_t *const)&PINA | ||
| 41 | #define _PINB (uint8_t *const)&PINB | ||
| 42 | #define _PINC (uint8_t *const)&PINC | ||
| 43 | #define _PIND (uint8_t *const)&PIND | ||
| 44 | #define _PINE (uint8_t *const)&PINE | ||
| 45 | #define _PINF (uint8_t *const)&PINF | ||
| 46 | |||
| 47 | #define _PORTA (uint8_t *const)&PORTA | ||
| 48 | #define _PORTB (uint8_t *const)&PORTB | ||
| 49 | #define _PORTC (uint8_t *const)&PORTC | ||
| 50 | #define _PORTD (uint8_t *const)&PORTD | ||
| 51 | #define _PORTE (uint8_t *const)&PORTE | ||
| 52 | #define _PORTF (uint8_t *const)&PORTF | ||
| 53 | |||
| 54 | #define _BIT0 0x01 | ||
| 55 | #define _BIT1 0x02 | ||
| 56 | #define _BIT2 0x04 | ||
| 57 | #define _BIT3 0x08 | ||
| 58 | #define _BIT4 0x10 | ||
| 59 | #define _BIT5 0x20 | ||
| 60 | #define _BIT6 0x40 | ||
| 61 | #define _BIT7 0x80 | ||
| 62 | |||
| 63 | /* Specifies the ports and pin numbers for the rows */ | ||
| 64 | static | ||
| 65 | uint8_t *const row_ddr[MATRIX_ROWS] = { | ||
| 66 | _DDRB, _DDRB, | ||
| 67 | _DDRC, _DDRC, | ||
| 68 | _DDRD, _DDRD, _DDRD, _DDRD, _DDRD, _DDRD, _DDRD, _DDRD, | ||
| 69 | _DDRF, _DDRF, _DDRF, _DDRF, _DDRF, _DDRF}; | ||
| 70 | |||
| 71 | static | ||
| 72 | uint8_t *const row_port[MATRIX_ROWS] = { | ||
| 73 | _PORTB, _PORTB, | ||
| 74 | _PORTC, _PORTC, | ||
| 75 | _PORTD, _PORTD, _PORTD, _PORTD, _PORTD, _PORTD, _PORTD, _PORTD, | ||
| 76 | _PORTF, _PORTF, _PORTF, _PORTF, _PORTF, _PORTF}; | ||
| 77 | |||
| 78 | static | ||
| 79 | uint8_t *const row_pin[MATRIX_ROWS] = { | ||
| 80 | _PINB, _PINB, | ||
| 81 | _PINC, _PINC, | ||
| 82 | _PIND, _PIND, _PIND, _PIND, _PIND, _PIND, _PIND, _PIND, | ||
| 83 | _PINF, _PINF, _PINF, _PINF, _PINF, _PINF}; | ||
| 84 | |||
| 85 | static | ||
| 86 | const uint8_t row_bit[MATRIX_ROWS] = { | ||
| 87 | _BIT4, _BIT7, | ||
| 88 | _BIT6, _BIT7, | ||
| 89 | _BIT0, _BIT1, _BIT2, _BIT3, _BIT4, _BIT5, _BIT6, _BIT7, | ||
| 90 | _BIT0, _BIT1, _BIT4, _BIT5, _BIT6, _BIT7}; | ||
| 91 | |||
| 92 | static | ||
| 93 | const uint8_t mask = 0x0E; | ||
| 94 | |||
| 95 | /* Specifies the ports and pin numbers for the columns */ | ||
| 96 | static | ||
| 97 | const uint8_t col_bit[MATRIX_COLS] = { 0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E}; | ||
| 98 | |||
| 99 | static | ||
| 100 | inline void pull_column(int col) { | ||
| 101 | PORTB = col_bit[col] | (PORTB & ~mask); | ||
| 102 | } | ||
| 103 | |||
| 104 | static | ||
| 105 | inline void release_column(int col) { | ||
| 106 | } | ||
| 107 | |||
| 108 | /* PORTB is set as input with pull-up resistors | ||
| 109 | PORTC,D,E,F are set to high output */ | ||
| 110 | static | ||
| 111 | void setup_io_pins(void) { | ||
| 112 | uint8_t row; | ||
| 113 | DDRB |= 0x0E; | ||
| 114 | PORTB &= ~0x0E; | ||
| 115 | for(row = 0; row < MATRIX_ROWS; row++) { | ||
| 116 | *row_ddr[row] &= ~row_bit[row]; | ||
| 117 | *row_port[row] &= ~row_bit[row]; | ||
| 118 | } | ||
| 119 | } | ||
| 120 | |||
| 121 | static | ||
| 122 | void setup_leds(void) { | ||
| 123 | DDRB |= 0x60; | ||
| 124 | PORTB |= 0x60; | ||
| 125 | } | ||
| 126 | |||
| 127 | |||
| 128 | inline | ||
| 129 | uint8_t matrix_rows(void) | ||
| 130 | { | ||
| 131 | return MATRIX_ROWS; | ||
| 132 | } | ||
| 133 | |||
| 134 | inline | ||
| 135 | uint8_t matrix_cols(void) | ||
| 136 | { | ||
| 137 | return MATRIX_COLS; | ||
| 138 | } | ||
| 139 | |||
| 140 | void matrix_init(void) | ||
| 141 | { | ||
| 142 | // To use PORTF disable JTAG with writing JTD bit twice within four cycles. | ||
| 143 | MCUCR |= (1<<JTD); | ||
| 144 | MCUCR |= (1<<JTD); | ||
| 145 | |||
| 146 | // initialize row and col | ||
| 147 | setup_io_pins(); | ||
| 148 | setup_leds(); | ||
| 149 | |||
| 150 | // initialize matrix state: all keys off | ||
| 151 | for (uint8_t i=0; i < MATRIX_ROWS; i++) _matrix0[i] = 0x00; | ||
| 152 | for (uint8_t i=0; i < MATRIX_ROWS; i++) _matrix1[i] = 0x00; | ||
| 153 | matrix = _matrix0; | ||
| 154 | matrix_debounced = _matrix1; | ||
| 155 | } | ||
| 156 | |||
| 157 | uint8_t matrix_scan(void) | ||
| 158 | { | ||
| 159 | if (!debouncing) { | ||
| 160 | uint8_t *tmp = matrix_debounced; | ||
| 161 | matrix_debounced = matrix; | ||
| 162 | matrix = tmp; | ||
| 163 | } | ||
| 164 | |||
| 165 | for (uint8_t col = 0; col < MATRIX_COLS; col++) { // 0-7 | ||
| 166 | pull_column(col); // output hi on theline | ||
| 167 | _delay_us(5); // without this wait it won't read stable value. | ||
| 168 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { // 0-17 | ||
| 169 | bool prev_bit = matrix[row] & (1<<col); | ||
| 170 | bool curr_bit = *row_pin[row] & row_bit[row]; | ||
| 171 | if (prev_bit != curr_bit) { | ||
| 172 | matrix[row] ^= (1<<col); | ||
| 173 | if (debouncing) { | ||
| 174 | debug("bounce!: "); debug_hex(debouncing); print("\n"); | ||
| 175 | } | ||
| 176 | _delay_ms(1); // improved affect on bouncing | ||
| 177 | debouncing = DEBOUNCE; | ||
| 178 | } | ||
| 179 | } | ||
| 180 | release_column(col); | ||
| 181 | } | ||
| 182 | |||
| 183 | if (debouncing) { | ||
| 184 | debouncing--; | ||
| 185 | } | ||
| 186 | |||
| 187 | return 1; | ||
| 188 | } | ||
| 189 | |||
| 190 | bool matrix_is_modified(void) | ||
| 191 | { | ||
| 192 | // NOTE: no longer used | ||
| 193 | return true; | ||
| 194 | } | ||
| 195 | |||
| 196 | inline | ||
| 197 | bool matrix_has_ghost(void) | ||
| 198 | { | ||
| 199 | return false; | ||
| 200 | } | ||
| 201 | |||
| 202 | inline | ||
| 203 | bool matrix_is_on(uint8_t row, uint8_t col) | ||
| 204 | { | ||
| 205 | return (matrix_debounced[row] & (1<<col)); | ||
| 206 | } | ||
| 207 | |||
| 208 | inline | ||
| 209 | matrix_row_t matrix_get_row(uint8_t row) | ||
| 210 | { | ||
| 211 | return matrix_debounced[row]; | ||
| 212 | } | ||
| 213 | |||
| 214 | void matrix_print(void) | ||
| 215 | { | ||
| 216 | print("\nr/c 01234567\n"); | ||
| 217 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
| 218 | phex(row); print(": "); | ||
| 219 | pbin_reverse(matrix_get_row(row)); | ||
| 220 | print("\n"); | ||
| 221 | } | ||
| 222 | } | ||
| 223 | |||
| 224 | uint8_t matrix_key_count(void) | ||
| 225 | { | ||
| 226 | uint8_t count = 0; | ||
| 227 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
| 228 | for (uint8_t j = 0; j < MATRIX_COLS; j++) { | ||
| 229 | if (matrix_is_on(i, j)) | ||
| 230 | count++; | ||
| 231 | } | ||
| 232 | } | ||
| 233 | return count; | ||
| 234 | } | ||
diff --git a/keyboard/macway/matrix.c b/keyboard/macway/matrix.c index 394c3d970..4b0fd98f0 100644 --- a/keyboard/macway/matrix.c +++ b/keyboard/macway/matrix.c | |||
| @@ -217,9 +217,9 @@ static void unselect_rows(void) | |||
| 217 | { | 217 | { |
| 218 | // Hi-Z(DDR:0, PORT:0) to unselect | 218 | // Hi-Z(DDR:0, PORT:0) to unselect |
| 219 | DDRC &= ~0b01000000; // PC: 6 | 219 | DDRC &= ~0b01000000; // PC: 6 |
| 220 | PORTC &= ~0b11000000; | 220 | PORTC &= ~0b01000000; |
| 221 | DDRD &= ~0b11100111; // PD: 7,6,5,2,1,0 | 221 | DDRD &= ~0b11100111; // PD: 7,6,5,2,1,0 |
| 222 | PORTD &= ~0b11000111; | 222 | PORTD &= ~0b11100111; |
| 223 | DDRF &= ~0b11000000; // PF: 7,6 | 223 | DDRF &= ~0b11000000; // PF: 7,6 |
| 224 | PORTF &= ~0b11000000; | 224 | PORTF &= ~0b11000000; |
| 225 | } | 225 | } |
diff --git a/keyboard/phantom/Makefile.lufa b/keyboard/phantom/Makefile.lufa new file mode 100644 index 000000000..641d8c52a --- /dev/null +++ b/keyboard/phantom/Makefile.lufa | |||
| @@ -0,0 +1,120 @@ | |||
| 1 | #---------------------------------------------------------------------------- | ||
| 2 | # On command line: | ||
| 3 | # | ||
| 4 | # make all = Make software. | ||
| 5 | # | ||
| 6 | # make clean = Clean out built project files. | ||
| 7 | # | ||
| 8 | # make coff = Convert ELF to AVR COFF. | ||
| 9 | # | ||
| 10 | # make extcoff = Convert ELF to AVR Extended COFF. | ||
| 11 | # | ||
| 12 | # make program = Download the hex file to the device. | ||
| 13 | # Please customize your programmer settings(PROGRAM_CMD) | ||
| 14 | # | ||
| 15 | # make teensy = Download the hex file to the device, using teensy_loader_cli. | ||
| 16 | # (must have teensy_loader_cli installed). | ||
| 17 | # | ||
| 18 | # make dfu = Download the hex file to the device, using dfu-programmer (must | ||
| 19 | # have dfu-programmer installed). | ||
| 20 | # | ||
| 21 | # make flip = Download the hex file to the device, using Atmel FLIP (must | ||
| 22 | # have Atmel FLIP installed). | ||
| 23 | # | ||
| 24 | # make dfu-ee = Download the eeprom file to the device, using dfu-programmer | ||
| 25 | # (must have dfu-programmer installed). | ||
| 26 | # | ||
| 27 | # make flip-ee = Download the eeprom file to the device, using Atmel FLIP | ||
| 28 | # (must have Atmel FLIP installed). | ||
| 29 | # | ||
| 30 | # make debug = Start either simulavr or avarice as specified for debugging, | ||
| 31 | # with avr-gdb or avr-insight as the front end for debugging. | ||
| 32 | # | ||
| 33 | # make filename.s = Just compile filename.c into the assembler code only. | ||
| 34 | # | ||
| 35 | # make filename.i = Create a preprocessed source file for use in submitting | ||
| 36 | # bug reports to the GCC project. | ||
| 37 | # | ||
| 38 | # To rebuild project do "make clean" then "make all". | ||
| 39 | #---------------------------------------------------------------------------- | ||
| 40 | |||
| 41 | # Target file name (without extension). | ||
| 42 | TARGET = phantom_lufa | ||
| 43 | |||
| 44 | # Directory common source filess exist | ||
| 45 | TOP_DIR = ../.. | ||
| 46 | |||
| 47 | # Directory keyboard dependent files exist | ||
| 48 | TARGET_DIR = . | ||
| 49 | |||
| 50 | |||
| 51 | # List C source files here. (C dependencies are automatically generated.) | ||
| 52 | SRC += keymap.c \ | ||
| 53 | matrix.c \ | ||
| 54 | led.c | ||
| 55 | |||
| 56 | CONFIG_H = config.h | ||
| 57 | |||
| 58 | |||
| 59 | # MCU name | ||
| 60 | #MCU = at90usb1287 | ||
| 61 | MCU = atmega32u4 | ||
| 62 | |||
| 63 | # Processor frequency. | ||
| 64 | # This will define a symbol, F_CPU, in all source code files equal to the | ||
| 65 | # processor frequency in Hz. You can then use this symbol in your source code to | ||
| 66 | # calculate timings. Do NOT tack on a 'UL' at the end, this will be done | ||
| 67 | # automatically to create a 32-bit value in your source code. | ||
| 68 | # | ||
| 69 | # This will be an integer division of F_USB below, as it is sourced by | ||
| 70 | # F_USB after it has run through any CPU prescalers. Note that this value | ||
| 71 | # does not *change* the processor frequency - it should merely be updated to | ||
| 72 | # reflect the processor speed set externally so that the code can use accurate | ||
| 73 | # software delays. | ||
| 74 | F_CPU = 16000000 | ||
| 75 | |||
| 76 | |||
| 77 | # | ||
| 78 | # LUFA specific | ||
| 79 | # | ||
| 80 | # Target architecture (see library "Board Types" documentation). | ||
| 81 | ARCH = AVR8 | ||
| 82 | |||
| 83 | # Input clock frequency. | ||
| 84 | # This will define a symbol, F_USB, in all source code files equal to the | ||
| 85 | # input clock frequency (before any prescaling is performed) in Hz. This value may | ||
| 86 | # differ from F_CPU if prescaling is used on the latter, and is required as the | ||
| 87 | # raw input clock is fed directly to the PLL sections of the AVR for high speed | ||
| 88 | # clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' | ||
| 89 | # at the end, this will be done automatically to create a 32-bit value in your | ||
| 90 | # source code. | ||
| 91 | # | ||
| 92 | # If no clock division is performed on the input clock inside the AVR (via the | ||
| 93 | # CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. | ||
| 94 | F_USB = $(F_CPU) | ||
| 95 | |||
| 96 | |||
| 97 | # Build Options | ||
| 98 | # comment out to disable the options. | ||
| 99 | # | ||
| 100 | #MOUSEKEY_ENABLE = yes # Mouse keys | ||
| 101 | EXTRAKEY_ENABLE = yes # Audio control and System control | ||
| 102 | CONSOLE_ENABLE = yes # Console for debug | ||
| 103 | #NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA | ||
| 104 | #PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support | ||
| 105 | |||
| 106 | |||
| 107 | # Boot Section Size in bytes | ||
| 108 | # Teensy halfKay 512 | ||
| 109 | # Atmel DFU loader 4096 | ||
| 110 | # LUFA bootloader 4096 | ||
| 111 | OPT_DEFS += -DBOOT_SIZE=512 | ||
| 112 | |||
| 113 | |||
| 114 | # Search Path | ||
| 115 | VPATH += $(TARGET_DIR) | ||
| 116 | VPATH += $(TOP_DIR) | ||
| 117 | |||
| 118 | include $(TOP_DIR)/protocol/lufa.mk | ||
| 119 | include $(TOP_DIR)/common.mk | ||
| 120 | include $(TOP_DIR)/rules.mk | ||
diff --git a/keyboard/phantom/Makefile.pjrc b/keyboard/phantom/Makefile.pjrc new file mode 100644 index 000000000..67bf6df28 --- /dev/null +++ b/keyboard/phantom/Makefile.pjrc | |||
| @@ -0,0 +1,90 @@ | |||
| 1 | #---------------------------------------------------------------------------- | ||
| 2 | # On command line: | ||
| 3 | # | ||
| 4 | # make all = Make software. | ||
| 5 | # | ||
| 6 | # make clean = Clean out built project files. | ||
| 7 | # | ||
| 8 | # make coff = Convert ELF to AVR COFF. | ||
| 9 | # | ||
| 10 | # make extcoff = Convert ELF to AVR Extended COFF. | ||
| 11 | # | ||
| 12 | # make program = Download the hex file to the device. | ||
| 13 | # Please customize your programmer settings(PROGRAM_CMD) | ||
| 14 | # | ||
| 15 | # make teensy = Download the hex file to the device, using teensy_loader_cli. | ||
| 16 | # (must have teensy_loader_cli installed). | ||
| 17 | # | ||
| 18 | # make dfu = Download the hex file to the device, using dfu-programmer (must | ||
| 19 | # have dfu-programmer installed). | ||
| 20 | # | ||
| 21 | # make flip = Download the hex file to the device, using Atmel FLIP (must | ||
| 22 | # have Atmel FLIP installed). | ||
| 23 | # | ||
| 24 | # make dfu-ee = Download the eeprom file to the device, using dfu-programmer | ||
| 25 | # (must have dfu-programmer installed). | ||
| 26 | # | ||
| 27 | # make flip-ee = Download the eeprom file to the device, using Atmel FLIP | ||
| 28 | # (must have Atmel FLIP installed). | ||
| 29 | # | ||
| 30 | # make debug = Start either simulavr or avarice as specified for debugging, | ||
| 31 | # with avr-gdb or avr-insight as the front end for debugging. | ||
| 32 | # | ||
| 33 | # make filename.s = Just compile filename.c into the assembler code only. | ||
| 34 | # | ||
| 35 | # make filename.i = Create a preprocessed source file for use in submitting | ||
| 36 | # bug reports to the GCC project. | ||
| 37 | # | ||
| 38 | # To rebuild project do "make clean" then "make all". | ||
| 39 | #---------------------------------------------------------------------------- | ||
| 40 | |||
| 41 | # Target file name (without extension). | ||
| 42 | TARGET = phantom_pjrc | ||
| 43 | |||
| 44 | # Directory common source filess exist | ||
| 45 | TOP_DIR = ../.. | ||
| 46 | |||
| 47 | # Directory keyboard dependent files exist | ||
| 48 | TARGET_DIR = . | ||
| 49 | |||
| 50 | # keyboard dependent files | ||
| 51 | SRC = keymap.c \ | ||
| 52 | matrix.c \ | ||
| 53 | led.c | ||
| 54 | |||
| 55 | CONFIG_H = config.h | ||
| 56 | |||
| 57 | |||
| 58 | # MCU name, you MUST set this to match the board you are using | ||
| 59 | # type "make clean" after changing this, so all files will be rebuilt | ||
| 60 | #MCU = at90usb162 # Teensy 1.0 | ||
| 61 | MCU = atmega32u4 # Teensy 2.0 | ||
| 62 | #MCU = at90usb646 # Teensy++ 1.0 | ||
| 63 | #MCU = at90usb1286 # Teensy++ 2.0 | ||
| 64 | |||
| 65 | |||
| 66 | # Processor frequency. | ||
| 67 | # Normally the first thing your program should do is set the clock prescaler, | ||
| 68 | # so your program will run at the correct speed. You should also set this | ||
| 69 | # variable to same clock speed. The _delay_ms() macro uses this, and many | ||
| 70 | # examples use this variable to calculate timings. Do not add a "UL" here. | ||
| 71 | F_CPU = 16000000 | ||
| 72 | |||
| 73 | |||
| 74 | # Build Options | ||
| 75 | # comment out to disable the options. | ||
| 76 | # | ||
| 77 | #MOUSEKEY_ENABLE = yes # Mouse keys | ||
| 78 | #PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support | ||
| 79 | EXTRAKEY_ENABLE = yes # Audio control and System control | ||
| 80 | #NKRO_ENABLE = yes # USB Nkey Rollover | ||
| 81 | CONSOLE_ENABLE = yes # Console for debug | ||
| 82 | |||
| 83 | |||
| 84 | # Search Path | ||
| 85 | VPATH += $(TARGET_DIR) | ||
| 86 | VPATH += $(TOP_DIR) | ||
| 87 | |||
| 88 | include $(TOP_DIR)/protocol/pjrc.mk | ||
| 89 | include $(TOP_DIR)/common.mk | ||
| 90 | include $(TOP_DIR)/rules.mk | ||
diff --git a/keyboard/phantom/config.h b/keyboard/phantom/config.h new file mode 100644 index 000000000..9e8a823d7 --- /dev/null +++ b/keyboard/phantom/config.h | |||
| @@ -0,0 +1,56 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2012 Jun Wako <wakojun@gmail.com> | ||
| 3 | |||
| 4 | This program is free software: you can redistribute it and/or modify | ||
| 5 | it under the terms of the GNU General Public License as published by | ||
| 6 | the Free Software Foundation, either version 2 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #ifndef CONFIG_H | ||
| 19 | #define CONFIG_H | ||
| 20 | |||
| 21 | |||
| 22 | /* USB Device descriptor parameter */ | ||
| 23 | #define VENDOR_ID 0xFEED | ||
| 24 | #define PRODUCT_ID 0x6057 | ||
| 25 | #define DEVICE_VER 0x0001 | ||
| 26 | #define MANUFACTURER t.m.k. | ||
| 27 | #define PRODUCT Phantom | ||
| 28 | |||
| 29 | |||
| 30 | /* message strings */ | ||
| 31 | #define DESCRIPTION t.m.k. keyboard firmware for Phantom | ||
| 32 | |||
| 33 | |||
| 34 | /* matrix size */ | ||
| 35 | #define MATRIX_ROWS 6 | ||
| 36 | #define MATRIX_COLS 17 | ||
| 37 | |||
| 38 | /* define if matrix has ghost */ | ||
| 39 | //#define MATRIX_HAS_GHOST | ||
| 40 | |||
| 41 | /* Set 0 if need no debouncing */ | ||
| 42 | #define DEBOUNCE 7 | ||
| 43 | |||
| 44 | |||
| 45 | /* key combination for command */ | ||
| 46 | #define IS_COMMAND() ( \ | ||
| 47 | keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ | ||
| 48 | ) | ||
| 49 | |||
| 50 | // TODO: configurable | ||
| 51 | #define DEBUG_LED 0 | ||
| 52 | #define DEBUG_LED_CONFIG | ||
| 53 | #define DEBUG_LED_ON | ||
| 54 | #define DEBUG_LED_OFF | ||
| 55 | |||
| 56 | #endif | ||
diff --git a/keyboard/phantom/keymap.c b/keyboard/phantom/keymap.c new file mode 100644 index 000000000..0a95f9fbb --- /dev/null +++ b/keyboard/phantom/keymap.c | |||
| @@ -0,0 +1,172 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2011 Jun Wako <wakojun@gmail.com> | ||
| 3 | |||
| 4 | This program is free software: you can redistribute it and/or modify | ||
| 5 | it under the terms of the GNU General Public License as published by | ||
| 6 | the Free Software Foundation, either version 2 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | |||
| 18 | /* | ||
| 19 | * Keymap for Phantom controller | ||
| 20 | */ | ||
| 21 | #include <stdint.h> | ||
| 22 | #include <stdbool.h> | ||
| 23 | #include <avr/pgmspace.h> | ||
| 24 | #include "keycode.h" | ||
| 25 | #include "print.h" | ||
| 26 | #include "debug.h" | ||
| 27 | #include "util.h" | ||
| 28 | #include "keymap.h" | ||
| 29 | |||
| 30 | |||
| 31 | // Convert physical keyboard layout to matrix array. | ||
| 32 | // This is a macro to define keymap easily in keyboard layout form. | ||
| 33 | #define KEYMAP( \ | ||
| 34 | K5A, K5C, K5D, K5E, K5F, K5G, K5H, K5I, K5J, K5K, K5L, K5M, K5N, K5O, K5P, K5Q, \ | ||
| 35 | K5B, K4A, K4B, K4C, K4D, K4E, K4F, K4G, K4H, K4I, K4J, K4K, K4L, K4N, K4O, K4P, K4Q, \ | ||
| 36 | K3A, K3B, K3C, K3D, K3E, K3F, K3G, K3H, K3I, K3J, K3K, K3L, K3M, K3N, K3O, K3P, K3Q, \ | ||
| 37 | K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, K2J, K2K, K2L, K2N, K2O, K2P, K2Q, \ | ||
| 38 | K1A, K1C, K1D, K1E, K1F, K1G, K1H, K1I, K1J, K1K, K1L, K1N, K1O, K1P, K1Q, \ | ||
| 39 | K0A, K0B, K0C, K0H, K0K, K0L, K0M, K0N, K0O, K0P, K0Q \ | ||
| 40 | ) { \ | ||
| 41 | /* A B C D E F G H I J K L M N O P Q */ \ | ||
| 42 | /* 0 */ { KC_##K0A, KC_##K0B, KC_##K0C, KC_NO , KC_NO , KC_NO , KC_NO , KC_##K0H, KC_NO , KC_NO , KC_##K0K, KC_##K0L, KC_##K0M, KC_##K0N, KC_##K0O, KC_##K0P, KC_##K0Q}, \ | ||
| 43 | /* 1 */ { KC_##K1A, KC_NO , KC_##K1C, KC_##K1D, KC_##K1E, KC_##K1F, KC_##K1G, KC_##K1H, KC_##K1I, KC_##K1J, KC_##K1K, KC_##K1L, KC_NO , KC_##K1N, KC_##K1O, KC_##K1P, KC_##K1Q}, \ | ||
| 44 | /* 2 */ { KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D, KC_##K2E, KC_##K2F, KC_##K2G, KC_##K2H, KC_##K2I, KC_##K2J, KC_##K2K, KC_##K2L, KC_NO , KC_##K2N, KC_##K2O, KC_##K2P, KC_##K2Q}, \ | ||
| 45 | /* 3 */ { KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D, KC_##K3E, KC_##K3F, KC_##K3G, KC_##K3H, KC_##K3I, KC_##K3J, KC_##K3K, KC_##K3L, KC_##K3M, KC_##K3N, KC_##K3O, KC_##K3P, KC_##K3Q}, \ | ||
| 46 | /* 4 */ { KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D, KC_##K4E, KC_##K4F, KC_##K4G, KC_##K4H, KC_##K4I, KC_##K4J, KC_##K4K, KC_##K4L, KC_NO , KC_##K4N, KC_##K4O, KC_##K4P, KC_##K4Q}, \ | ||
| 47 | /* 5 */ { KC_##K5A, KC_##K5B, KC_##K5C, KC_##K5D, KC_##K5E, KC_##K5F, KC_##K5G, KC_##K5H, KC_##K5I, KC_##K5J, KC_##K5K, KC_##K5L, KC_##K5M, KC_##K5N, KC_##K5O, KC_##K5P, KC_##K5Q}, \ | ||
| 48 | } | ||
| 49 | |||
| 50 | #define KEYCODE(layer, row, col) (pgm_read_byte(&keymaps[(layer)][(row)][(col)])) | ||
| 51 | |||
| 52 | |||
| 53 | // Assign Fn key(0-7) to a layer to which switch with the Fn key pressed. | ||
| 54 | static const uint8_t PROGMEM fn_layer[] = { | ||
| 55 | 0, // Fn0 | ||
| 56 | 1, // Fn1 | ||
| 57 | 2, // Fn2 | ||
| 58 | 3, // Fn3 | ||
| 59 | 4, // Fn4 | ||
| 60 | 5, // Fn5 | ||
| 61 | 6, // Fn6 | ||
| 62 | 7 // Fn7 | ||
| 63 | }; | ||
| 64 | |||
| 65 | // Assign Fn key(0-7) to a keycode sent when release Fn key without use of the layer. | ||
| 66 | // See layer.c for details. | ||
| 67 | static const uint8_t PROGMEM fn_keycode[] = { | ||
| 68 | KC_NO, // Fn0 | ||
| 69 | KC_NO, // Fn1 | ||
| 70 | KC_NO, // Fn2 | ||
| 71 | KC_NO, // Fn3 | ||
| 72 | KC_NO, // Fn4 | ||
| 73 | KC_NO, // Fn5 | ||
| 74 | KC_NO, // Fn6 | ||
| 75 | KC_NO // Fn7 | ||
| 76 | }; | ||
| 77 | |||
| 78 | /* | ||
| 79 | * Phantom keyboard layout with winkeys and 7bit style editing block. I am | ||
| 80 | * Not in the mood to implement full 7-bit keymap. | ||
| 81 | * | ||
| 82 | * | ||
| 83 | * ,---. ,---------------. ,---------------. ,---------------. ,-----------. | ||
| 84 | * |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| | ||
| 85 | * `---' `---------------' `---------------' `---------------' `-----------' | ||
| 86 | * ,-----------------------------------------------------------. ,-----------. | ||
| 87 | * |~ | 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | |Ins|Hom|PgU| | ||
| 88 | * |-----------------------------------------------------------| |-----------| | ||
| 89 | * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|End|PgD| | ||
| 90 | * |-----------------------------------------------------------| |---|---|---| | ||
| 91 | * |Caps | A| S| D| F| G| H| J| K| L| ;| '|Return | |???|???|???| | ||
| 92 | * |-----------------------------------------------------------| |---|---|---| | ||
| 93 | * |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift | |???|Up |???| | ||
| 94 | * |-----------------------------------------------------------| |-----------| | ||
| 95 | * |Ctl|Gui|Alt| Space |Alt|Gui|App|Ctl| |Lef|Dow|Rig| | ||
| 96 | * `-----------------------------------------------------------' `-----------' | ||
| 97 | */ | ||
| 98 | |||
| 99 | |||
| 100 | static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
| 101 | /* Layer 0: Default Layer | ||
| 102 | * | ||
| 103 | * ANSI: | ||
| 104 | * | ||
| 105 | * ,---. ,---------------. ,---------------. ,---------------. ,-----------. | ||
| 106 | * |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| | ||
| 107 | * `---' `---------------' `---------------' `---------------' `-----------' | ||
| 108 | * ,-----------------------------------------------------------. ,-----------. | ||
| 109 | * |~ | 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | |Ins|Hom|PgU| | ||
| 110 | * |-----------------------------------------------------------| |-----------| | ||
| 111 | * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|End|PgD| | ||
| 112 | * |-----------------------------------------------------------| |---|---|---| | ||
| 113 | * |Caps | A| S| D| F| G| H| J| K| L| ;| '|Return | |???|???|???| | ||
| 114 | * |-----------------------------------------------------------| |---|---|---| | ||
| 115 | * |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift | |???|Up |???| | ||
| 116 | * |-----------------------------------------------------------| |-----------| | ||
| 117 | * |Ctl|Gui|Alt| Space |Alt|Gui|App|Ctl| |Lef|Dow|Rig| | ||
| 118 | * `-----------------------------------------------------------' `-----------' | ||
| 119 | */ | ||
| 120 | |||
| 121 | KEYMAP(\ | ||
| 122 | ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR, SLCK, BRK, \ | ||
| 123 | GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS, EQL, BSPC, INS, HOME, PGUP, \ | ||
| 124 | TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC, RBRC, BSLS, DEL, END, PGDN, \ | ||
| 125 | FN1, A, S, D, F, G, H, J, K, L, SCLN, QUOT, ENT, 0, 0, 0, \ | ||
| 126 | LSFT, Z, X, C, V, B, N, M, COMM, DOT, SLSH, RSFT, 0, UP, 0, \ | ||
| 127 | LCTL, LGUI, LALT, SPC, RALT, RGUI, APP, RCTL, LEFT, DOWN, RGHT), | ||
| 128 | |||
| 129 | |||
| 130 | /* | ||
| 131 | * ,---. ,---------------. ,---------------. ,---------------. ,-----------. | ||
| 132 | * |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Slp| | ||
| 133 | * `---' `---------------' `---------------' `---------------' `-----------' | ||
| 134 | * ,-----------------------------------------------------------. ,-----------. | ||
| 135 | * |~ | 1| 2| 3| 4| 5| 6| 7| 8| 9|Mut|V- |V+ |Backsp | |Ins|Hom|PgU| | ||
| 136 | * |-----------------------------------------------------------| |-----------| | ||
| 137 | * |Tab | Q| W| E| R| T| Y| U| I|MSt|Ply|Prv|Nxt|Media| |Del|End|PgD| | ||
| 138 | * |-----------------------------------------------------------| |-----------| | ||
| 139 | * |FN1 | A| S| D| F| G| H| J| K| L| ;| '|Return | |???|???|???| | ||
| 140 | * |-----------------------------------------------------------| |-----------| | ||
| 141 | * |Shft | Z| X|Clc| V| B| N| M| ,| .| /|Caps | |???|Up |???| | ||
| 142 | * |-----------------------------------------------------------| |-----------| | ||
| 143 | * |Ctl|Gui|Alt| Space |Alt|Gui|App|Ctl| |Lef|Dow|Rig| | ||
| 144 | * `-----------------------------------------------------------' `-----------' | ||
| 145 | */ | ||
| 146 | |||
| 147 | KEYMAP(\ | ||
| 148 | ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR, SLCK, SLEP, \ | ||
| 149 | GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9,MUTE, VOLD, VOLU, BSPC, INS, HOME, PGUP, \ | ||
| 150 | TAB, Q, W, E, R, T, Y, U, I,MSTP,MPLY, MPRV, MNXT, MSEL, DEL, END, PGDN, \ | ||
| 151 | FN1, A, S, D, F, G, H, J, K, L, SCLN, QUOT, ENT, 0, 0, 0, \ | ||
| 152 | LSFT, Z, X,CALC, V, B, N, M, COMM, DOT, SLSH, CAPS, 0, UP, 0, \ | ||
| 153 | LCTL, LGUI, LALT, SPC, RALT, RGUI, APP, RCTL, LEFT, DOWN, RGHT), | ||
| 154 | |||
| 155 | |||
| 156 | }; | ||
| 157 | |||
| 158 | |||
| 159 | uint8_t keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t col) | ||
| 160 | { | ||
| 161 | return KEYCODE(layer, row, col); | ||
| 162 | } | ||
| 163 | |||
| 164 | uint8_t keymap_fn_layer(uint8_t index) | ||
| 165 | { | ||
| 166 | return pgm_read_byte(&fn_layer[index]); | ||
| 167 | } | ||
| 168 | |||
| 169 | uint8_t keymap_fn_keycode(uint8_t index) | ||
| 170 | { | ||
| 171 | return pgm_read_byte(&fn_keycode[index]); | ||
| 172 | } | ||
diff --git a/keyboard/phantom/led.c b/keyboard/phantom/led.c new file mode 100644 index 000000000..109004ba8 --- /dev/null +++ b/keyboard/phantom/led.c | |||
| @@ -0,0 +1,34 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2012 Jun Wako <wakojun@gmail.com> | ||
| 3 | |||
| 4 | This program is free software: you can redistribute it and/or modify | ||
| 5 | it under the terms of the GNU General Public License as published by | ||
| 6 | the Free Software Foundation, either version 2 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #include <avr/io.h> | ||
| 19 | #include "stdint.h" | ||
| 20 | #include "led.h" | ||
| 21 | |||
| 22 | |||
| 23 | void led_set(uint8_t usb_led) | ||
| 24 | { | ||
| 25 | if (!(usb_led & (1<<USB_LED_CAPS_LOCK))) | ||
| 26 | DDRB &= ~(1<<6); | ||
| 27 | else | ||
| 28 | DDRB |= (1<<6); | ||
| 29 | |||
| 30 | if (!(usb_led & (1<<USB_LED_SCROLL_LOCK))) | ||
| 31 | DDRB &= ~(1<<7); | ||
| 32 | else | ||
| 33 | DDRB |= (1<<7); | ||
| 34 | } | ||
diff --git a/keyboard/phantom/matrix.c b/keyboard/phantom/matrix.c new file mode 100644 index 000000000..07f3f4289 --- /dev/null +++ b/keyboard/phantom/matrix.c | |||
| @@ -0,0 +1,249 @@ | |||
| 1 | /* Copyright 2012 Jun Wako <wakojun@gmail.com> | ||
| 2 | * | ||
| 3 | * This is heavily based on phantom/board.{c|h}. | ||
| 4 | * https://github.com/BathroomEpiphanies/AVR-Keyboard | ||
| 5 | * | ||
| 6 | * Copyright (c) 2012 Fredrik Atmer, Bathroom Epiphanies Inc | ||
| 7 | * http://bathroomepiphanies.com | ||
| 8 | * | ||
| 9 | * As for liscensing consult with the original files or its author. | ||
| 10 | */ | ||
| 11 | #include <stdint.h> | ||
| 12 | #include <stdbool.h> | ||
| 13 | #include <avr/io.h> | ||
| 14 | #include <util/delay.h> | ||
| 15 | #include "print.h" | ||
| 16 | #include "debug.h" | ||
| 17 | #include "util.h" | ||
| 18 | #include "matrix.h" | ||
| 19 | |||
| 20 | |||
| 21 | #ifndef DEBOUNCE | ||
| 22 | # define DEBOUNCE 0 | ||
| 23 | #endif | ||
| 24 | static uint8_t debouncing = DEBOUNCE; | ||
| 25 | |||
| 26 | // bit array of key state(1:on, 0:off) | ||
| 27 | static matrix_row_t *matrix; | ||
| 28 | static matrix_row_t *matrix_debounced; | ||
| 29 | static matrix_row_t _matrix0[MATRIX_ROWS]; | ||
| 30 | static matrix_row_t _matrix1[MATRIX_ROWS]; | ||
| 31 | |||
| 32 | |||
| 33 | #define _DDRA (uint8_t *const)&DDRA | ||
| 34 | #define _DDRB (uint8_t *const)&DDRB | ||
| 35 | #define _DDRC (uint8_t *const)&DDRC | ||
| 36 | #define _DDRD (uint8_t *const)&DDRD | ||
| 37 | #define _DDRE (uint8_t *const)&DDRE | ||
| 38 | #define _DDRF (uint8_t *const)&DDRF | ||
| 39 | |||
| 40 | #define _PINA (uint8_t *const)&PINA | ||
| 41 | #define _PINB (uint8_t *const)&PINB | ||
| 42 | #define _PINC (uint8_t *const)&PINC | ||
| 43 | #define _PIND (uint8_t *const)&PIND | ||
| 44 | #define _PINE (uint8_t *const)&PINE | ||
| 45 | #define _PINF (uint8_t *const)&PINF | ||
| 46 | |||
| 47 | #define _PORTA (uint8_t *const)&PORTA | ||
| 48 | #define _PORTB (uint8_t *const)&PORTB | ||
| 49 | #define _PORTC (uint8_t *const)&PORTC | ||
| 50 | #define _PORTD (uint8_t *const)&PORTD | ||
| 51 | #define _PORTE (uint8_t *const)&PORTE | ||
| 52 | #define _PORTF (uint8_t *const)&PORTF | ||
| 53 | |||
| 54 | #define _BIT0 0x01 | ||
| 55 | #define _BIT1 0x02 | ||
| 56 | #define _BIT2 0x04 | ||
| 57 | #define _BIT3 0x08 | ||
| 58 | #define _BIT4 0x10 | ||
| 59 | #define _BIT5 0x20 | ||
| 60 | #define _BIT6 0x40 | ||
| 61 | #define _BIT7 0x80 | ||
| 62 | |||
| 63 | /* Specifies the ports and pin numbers for the rows */ | ||
| 64 | static | ||
| 65 | uint8_t *const row_ddr[MATRIX_ROWS] = {_DDRB, _DDRB, _DDRB, _DDRB, _DDRB, _DDRB}; | ||
| 66 | |||
| 67 | static | ||
| 68 | uint8_t *const row_port[MATRIX_ROWS] = {_PORTB, _PORTB, _PORTB, _PORTB, _PORTB, _PORTB}; | ||
| 69 | |||
| 70 | static | ||
| 71 | uint8_t *const row_pin[MATRIX_ROWS] = {_PINB, _PINB, _PINB, _PINB, _PINB, _PINB}; | ||
| 72 | |||
| 73 | static | ||
| 74 | const uint8_t row_bit[MATRIX_ROWS] = { _BIT0, _BIT1, _BIT2, _BIT3, _BIT4, _BIT5}; | ||
| 75 | |||
| 76 | /* Specifies the ports and pin numbers for the columns */ | ||
| 77 | static | ||
| 78 | uint8_t *const col_ddr[MATRIX_COLS] = { _DDRD, _DDRC, _DDRC, _DDRD, _DDRD, _DDRE, | ||
| 79 | _DDRF, _DDRF, _DDRF, _DDRF, _DDRF, _DDRF, | ||
| 80 | _DDRD, _DDRD, _DDRD, _DDRD, _DDRD}; | ||
| 81 | |||
| 82 | static | ||
| 83 | uint8_t *const col_port[MATRIX_COLS] = {_PORTD, _PORTC, _PORTC, _PORTD, _PORTD, _PORTE, | ||
| 84 | _PORTF, _PORTF, _PORTF, _PORTF, _PORTF, _PORTF, | ||
| 85 | _PORTD, _PORTD, _PORTD, _PORTD, _PORTD}; | ||
| 86 | |||
| 87 | static | ||
| 88 | const uint8_t col_bit[MATRIX_COLS] = { _BIT5, _BIT7, _BIT6, _BIT4, _BIT0, _BIT6, | ||
| 89 | _BIT0, _BIT1, _BIT4, _BIT5, _BIT6, _BIT7, | ||
| 90 | _BIT7, _BIT6, _BIT1, _BIT2, _BIT3}; | ||
| 91 | |||
| 92 | static | ||
| 93 | inline void pull_column(int col) { | ||
| 94 | *col_port[col] &= ~col_bit[col]; | ||
| 95 | } | ||
| 96 | |||
| 97 | static | ||
| 98 | inline void release_column(int col) { | ||
| 99 | *col_port[col] |= col_bit[col]; | ||
| 100 | } | ||
| 101 | |||
| 102 | /* PORTB is set as input with pull-up resistors | ||
| 103 | PORTC,D,E,F are set to high output */ | ||
| 104 | |||
| 105 | static | ||
| 106 | void setup_io_pins(void) { | ||
| 107 | uint8_t row, col; | ||
| 108 | for(row = 0; row < MATRIX_ROWS; row++) { | ||
| 109 | *row_ddr[row] &= ~row_bit[row]; | ||
| 110 | *row_port[row] |= row_bit[row]; | ||
| 111 | } | ||
| 112 | for(col = 0; col < MATRIX_COLS; col++) { | ||
| 113 | *col_ddr[col] |= col_bit[col]; | ||
| 114 | *col_port[col] |= col_bit[col]; | ||
| 115 | } | ||
| 116 | } | ||
| 117 | |||
| 118 | /* LEDs are on output compare pins OC1B OC1C | ||
| 119 | This activates fast PWM mode on them. | ||
| 120 | Prescaler 256 and 8-bit counter results in | ||
| 121 | 16000000/256/256 = 244 Hz blink frequency. | ||
| 122 | LED_A: Caps Lock | ||
| 123 | LED_B: Scroll Lock */ | ||
| 124 | /* Output on PWM pins are turned off when the timer | ||
| 125 | reaches the value in the output compare register, | ||
| 126 | and are turned on when it reaches TOP (=256). */ | ||
| 127 | static | ||
| 128 | void setup_leds(void) { | ||
| 129 | TCCR1A |= // Timer control register 1A | ||
| 130 | (1<<WGM10) | // Fast PWM 8-bit | ||
| 131 | (1<<COM1B1)| // Clear OC1B on match, set at TOP | ||
| 132 | (1<<COM1C1); // Clear OC1C on match, set at TOP | ||
| 133 | TCCR1B |= // Timer control register 1B | ||
| 134 | (1<<WGM12) | // Fast PWM 8-bit | ||
| 135 | (1<<CS12); // Prescaler 256 | ||
| 136 | OCR1B = 250; // Output compare register 1B | ||
| 137 | OCR1C = 250; // Output compare register 1C | ||
| 138 | // LEDs: LED_A -> PORTB6, LED_B -> PORTB7 | ||
| 139 | DDRB &= 0x3F; | ||
| 140 | PORTB &= 0x3F; | ||
| 141 | } | ||
| 142 | |||
| 143 | |||
| 144 | inline | ||
| 145 | uint8_t matrix_rows(void) | ||
| 146 | { | ||
| 147 | return MATRIX_ROWS; | ||
| 148 | } | ||
| 149 | |||
| 150 | inline | ||
| 151 | uint8_t matrix_cols(void) | ||
| 152 | { | ||
| 153 | return MATRIX_COLS; | ||
| 154 | } | ||
| 155 | |||
| 156 | void matrix_init(void) | ||
| 157 | { | ||
| 158 | // To use PORTF disable JTAG with writing JTD bit twice within four cycles. | ||
| 159 | MCUCR |= (1<<JTD); | ||
| 160 | MCUCR |= (1<<JTD); | ||
| 161 | |||
| 162 | // initialize row and col | ||
| 163 | setup_io_pins(); | ||
| 164 | setup_leds(); | ||
| 165 | |||
| 166 | // initialize matrix state: all keys off | ||
| 167 | for (uint8_t i=0; i < MATRIX_ROWS; i++) _matrix0[i] = 0x00; | ||
| 168 | for (uint8_t i=0; i < MATRIX_ROWS; i++) _matrix1[i] = 0x00; | ||
| 169 | matrix = _matrix0; | ||
| 170 | matrix_debounced = _matrix1; | ||
| 171 | } | ||
| 172 | |||
| 173 | uint8_t matrix_scan(void) | ||
| 174 | { | ||
| 175 | if (!debouncing) { | ||
| 176 | matrix_row_t *tmp = matrix_debounced; | ||
| 177 | matrix_debounced = matrix; | ||
| 178 | matrix = tmp; | ||
| 179 | } | ||
| 180 | |||
| 181 | for (uint8_t col = 0; col < MATRIX_COLS; col++) { // 0-16 | ||
| 182 | pull_column(col); // output hi on theline | ||
| 183 | _delay_us(3); // without this wait it won't read stable value. | ||
| 184 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { // 0-5 | ||
| 185 | bool prev_bit = matrix[row] & ((matrix_row_t)1<<col); | ||
| 186 | bool curr_bit = !(*row_pin[row] & row_bit[row]); | ||
| 187 | if (prev_bit != curr_bit) { | ||
| 188 | matrix[row] ^= ((matrix_row_t)1<<col); | ||
| 189 | if (debouncing) { | ||
| 190 | debug("bounce!: "); debug_hex(debouncing); print("\n"); | ||
| 191 | } | ||
| 192 | debouncing = DEBOUNCE; | ||
| 193 | } | ||
| 194 | } | ||
| 195 | release_column(col); | ||
| 196 | } | ||
| 197 | |||
| 198 | if (debouncing) { | ||
| 199 | debouncing--; | ||
| 200 | } | ||
| 201 | |||
| 202 | return 1; | ||
| 203 | } | ||
| 204 | |||
| 205 | bool matrix_is_modified(void) | ||
| 206 | { | ||
| 207 | // NOTE: no longer used | ||
| 208 | return true; | ||
| 209 | } | ||
| 210 | |||
| 211 | inline | ||
| 212 | bool matrix_has_ghost(void) | ||
| 213 | { | ||
| 214 | return false; | ||
| 215 | } | ||
| 216 | |||
| 217 | inline | ||
| 218 | bool matrix_is_on(uint8_t row, uint8_t col) | ||
| 219 | { | ||
| 220 | return (matrix_debounced[row] & ((matrix_row_t)1<<col)); | ||
| 221 | } | ||
| 222 | |||
| 223 | inline | ||
| 224 | matrix_row_t matrix_get_row(uint8_t row) | ||
| 225 | { | ||
| 226 | return matrix_debounced[row]; | ||
| 227 | } | ||
| 228 | |||
| 229 | void matrix_print(void) | ||
| 230 | { | ||
| 231 | print("\nr/c 01234567\n"); | ||
| 232 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
| 233 | phex(row); print(": "); | ||
| 234 | pbin_reverse(matrix_get_row(row)); | ||
| 235 | print("\n"); | ||
| 236 | } | ||
| 237 | } | ||
| 238 | |||
| 239 | uint8_t matrix_key_count(void) | ||
| 240 | { | ||
| 241 | uint8_t count = 0; | ||
| 242 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
| 243 | for (uint8_t j = 0; j < MATRIX_COLS; j++) { | ||
| 244 | if (matrix_is_on(i, j)) | ||
| 245 | count++; | ||
| 246 | } | ||
| 247 | } | ||
| 248 | return count; | ||
| 249 | } | ||
