diff options
| author | tmk <nobody@nowhere> | 2012-06-08 00:37:46 +0900 |
|---|---|---|
| committer | tmk <nobody@nowhere> | 2012-06-08 13:32:38 +0900 |
| commit | afb08462085132acf7a1962522952f7dbf064519 (patch) | |
| tree | bc60f28142bc36d882f5930191ba8da98a27c47c /keyboard/macway | |
| parent | 63d82fcaeb78d0764f39667b937262ed4a692c17 (diff) | |
| download | qmk_firmware-afb08462085132acf7a1962522952f7dbf064519.tar.gz qmk_firmware-afb08462085132acf7a1962522952f7dbf064519.zip | |
Made directories for keyboard and converter projects.
Diffstat (limited to 'keyboard/macway')
| -rw-r--r-- | keyboard/macway/Makefile | 53 | ||||
| -rw-r--r-- | keyboard/macway/config.h | 65 | ||||
| -rw-r--r-- | keyboard/macway/doc/back.jpg | bin | 0 -> 122135 bytes | |||
| -rw-r--r-- | keyboard/macway/doc/case.jpg | bin | 0 -> 146003 bytes | |||
| -rw-r--r-- | keyboard/macway/doc/keys.jpg | bin | 0 -> 116365 bytes | |||
| -rw-r--r-- | keyboard/macway/doc/side.jpg | bin | 0 -> 109755 bytes | |||
| -rw-r--r-- | keyboard/macway/doc/switch.jpg | bin | 0 -> 115526 bytes | |||
| -rw-r--r-- | keyboard/macway/doc/teensy.jpg | bin | 0 -> 165814 bytes | |||
| -rw-r--r-- | keyboard/macway/doc/wiring.jpg | bin | 0 -> 165569 bytes | |||
| -rw-r--r-- | keyboard/macway/doc/withHHKB.jpg | bin | 0 -> 152832 bytes | |||
| -rw-r--r-- | keyboard/macway/doc/withThinkPad.jpg | bin | 0 -> 118993 bytes | |||
| -rw-r--r-- | keyboard/macway/keymap.c | 195 | ||||
| -rw-r--r-- | keyboard/macway/led.c | 24 | ||||
| -rw-r--r-- | keyboard/macway/matrix.c | 271 |
14 files changed, 608 insertions, 0 deletions
diff --git a/keyboard/macway/Makefile b/keyboard/macway/Makefile new file mode 100644 index 000000000..afee38b12 --- /dev/null +++ b/keyboard/macway/Makefile | |||
| @@ -0,0 +1,53 @@ | |||
| 1 | # Target file name (without extension). | ||
| 2 | TARGET = macway | ||
| 3 | |||
| 4 | # Directory common source filess exist | ||
| 5 | TOP_DIR = ../.. | ||
| 6 | |||
| 7 | # Directory keyboard dependent files exist | ||
| 8 | TARGET_DIR = . | ||
| 9 | |||
| 10 | # keyboard dependent files | ||
| 11 | SRC = main.c \ | ||
| 12 | keymap.c \ | ||
| 13 | matrix.c \ | ||
| 14 | led.c | ||
| 15 | |||
| 16 | CONFIG_H = config.h | ||
| 17 | |||
| 18 | |||
| 19 | # MCU name, you MUST set this to match the board you are using | ||
| 20 | # type "make clean" after changing this, so all files will be rebuilt | ||
| 21 | #MCU = at90usb162 # Teensy 1.0 | ||
| 22 | MCU = atmega32u4 # Teensy 2.0 | ||
| 23 | #MCU = at90usb646 # Teensy++ 1.0 | ||
| 24 | #MCU = at90usb1286 # Teensy++ 2.0 | ||
| 25 | |||
| 26 | |||
| 27 | # Processor frequency. | ||
| 28 | # Normally the first thing your program should do is set the clock prescaler, | ||
| 29 | # so your program will run at the correct speed. You should also set this | ||
| 30 | # variable to same clock speed. The _delay_ms() macro uses this, and many | ||
| 31 | # examples use this variable to calculate timings. Do not add a "UL" here. | ||
| 32 | F_CPU = 16000000 | ||
| 33 | |||
| 34 | |||
| 35 | # Build Options | ||
| 36 | # comment out to disable the options. | ||
| 37 | # | ||
| 38 | MOUSEKEY_ENABLE = yes # Mouse keys | ||
| 39 | #PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support | ||
| 40 | EXTRAKEY_ENABLE = yes # Audio control and System control | ||
| 41 | #NKRO_ENABLE = yes # USB Nkey Rollover | ||
| 42 | |||
| 43 | |||
| 44 | |||
| 45 | #---------------- Programming Options -------------------------- | ||
| 46 | PROGRAM_CMD = teensy_loader_cli -mmcu=$(MCU) -w -v $(TARGET).hex | ||
| 47 | |||
| 48 | |||
| 49 | |||
| 50 | include $(TOP_DIR)/protocol/pjrc.mk | ||
| 51 | include $(TOP_DIR)/protocol.mk | ||
| 52 | include $(TOP_DIR)/common.mk | ||
| 53 | include $(TOP_DIR)/rules.mk | ||
diff --git a/keyboard/macway/config.h b/keyboard/macway/config.h new file mode 100644 index 000000000..2e68bf252 --- /dev/null +++ b/keyboard/macway/config.h | |||
| @@ -0,0 +1,65 @@ | |||
| 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 | #ifndef CONFIG_H | ||
| 19 | #define CONFIG_H | ||
| 20 | |||
| 21 | /* controller configuration */ | ||
| 22 | #include "controller_teensy.h" | ||
| 23 | |||
| 24 | #define VENDOR_ID 0xFEED | ||
| 25 | #define PRODUCT_ID 0xBEE0 | ||
| 26 | #define MANUFACTURER t.m.k. | ||
| 27 | #define PRODUCT Macway mod | ||
| 28 | #define DESCRIPTION t.m.k. keyboard firmware for Macway mod | ||
| 29 | |||
| 30 | |||
| 31 | /* matrix size */ | ||
| 32 | #define MATRIX_ROWS 9 | ||
| 33 | #define MATRIX_COLS 8 | ||
| 34 | /* define if matrix has ghost */ | ||
| 35 | #define MATRIX_HAS_GHOST | ||
| 36 | /* Set 0 if need no debouncing */ | ||
| 37 | #define DEBOUNCE 5 | ||
| 38 | |||
| 39 | |||
| 40 | /* key combination for command */ | ||
| 41 | #define IS_COMMAND() ( \ | ||
| 42 | keyboard_report->mods == (MOD_BIT(KB_LSHIFT) | MOD_BIT(KB_LCTRL) | MOD_BIT(KB_LALT) | MOD_BIT(KB_LGUI)) || \ | ||
| 43 | keyboard_report->mods == (MOD_BIT(KB_LSHIFT) | MOD_BIT(KB_RSHIFT)) \ | ||
| 44 | ) | ||
| 45 | |||
| 46 | |||
| 47 | /* mouse keys */ | ||
| 48 | #ifdef MOUSEKEY_ENABLE | ||
| 49 | # define MOUSEKEY_DELAY_TIME 192 | ||
| 50 | #endif | ||
| 51 | |||
| 52 | |||
| 53 | /* PS/2 mouse */ | ||
| 54 | #ifdef PS2_MOUSE_ENABLE | ||
| 55 | # define PS2_CLOCK_PORT PORTF | ||
| 56 | # define PS2_CLOCK_PIN PINF | ||
| 57 | # define PS2_CLOCK_DDR DDRF | ||
| 58 | # define PS2_CLOCK_BIT 0 | ||
| 59 | # define PS2_DATA_PORT PORTF | ||
| 60 | # define PS2_DATA_PIN PINF | ||
| 61 | # define PS2_DATA_DDR DDRF | ||
| 62 | # define PS2_DATA_BIT 1 | ||
| 63 | #endif | ||
| 64 | |||
| 65 | #endif | ||
diff --git a/keyboard/macway/doc/back.jpg b/keyboard/macway/doc/back.jpg new file mode 100644 index 000000000..0774401f6 --- /dev/null +++ b/keyboard/macway/doc/back.jpg | |||
| Binary files differ | |||
diff --git a/keyboard/macway/doc/case.jpg b/keyboard/macway/doc/case.jpg new file mode 100644 index 000000000..c776d5e05 --- /dev/null +++ b/keyboard/macway/doc/case.jpg | |||
| Binary files differ | |||
diff --git a/keyboard/macway/doc/keys.jpg b/keyboard/macway/doc/keys.jpg new file mode 100644 index 000000000..f340ebe8e --- /dev/null +++ b/keyboard/macway/doc/keys.jpg | |||
| Binary files differ | |||
diff --git a/keyboard/macway/doc/side.jpg b/keyboard/macway/doc/side.jpg new file mode 100644 index 000000000..bdf8268f2 --- /dev/null +++ b/keyboard/macway/doc/side.jpg | |||
| Binary files differ | |||
diff --git a/keyboard/macway/doc/switch.jpg b/keyboard/macway/doc/switch.jpg new file mode 100644 index 000000000..a1500d707 --- /dev/null +++ b/keyboard/macway/doc/switch.jpg | |||
| Binary files differ | |||
diff --git a/keyboard/macway/doc/teensy.jpg b/keyboard/macway/doc/teensy.jpg new file mode 100644 index 000000000..07207475d --- /dev/null +++ b/keyboard/macway/doc/teensy.jpg | |||
| Binary files differ | |||
diff --git a/keyboard/macway/doc/wiring.jpg b/keyboard/macway/doc/wiring.jpg new file mode 100644 index 000000000..0f3490f10 --- /dev/null +++ b/keyboard/macway/doc/wiring.jpg | |||
| Binary files differ | |||
diff --git a/keyboard/macway/doc/withHHKB.jpg b/keyboard/macway/doc/withHHKB.jpg new file mode 100644 index 000000000..9921856e7 --- /dev/null +++ b/keyboard/macway/doc/withHHKB.jpg | |||
| Binary files differ | |||
diff --git a/keyboard/macway/doc/withThinkPad.jpg b/keyboard/macway/doc/withThinkPad.jpg new file mode 100644 index 000000000..231c61d03 --- /dev/null +++ b/keyboard/macway/doc/withThinkPad.jpg | |||
| Binary files differ | |||
diff --git a/keyboard/macway/keymap.c b/keyboard/macway/keymap.c new file mode 100644 index 000000000..ae9f595fc --- /dev/null +++ b/keyboard/macway/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 Macway mod | ||
| 20 | */ | ||
| 21 | #include <stdint.h> | ||
| 22 | #include <stdbool.h> | ||
| 23 | #include <avr/pgmspace.h> | ||
| 24 | #include "usb_keycodes.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 | K11, K10, K20, K30, K40, K41, K51, K50, K60, K70, K80, K81, K61, K02, \ | ||
| 35 | K12, K13, K23, K33, K43, K42, K52, K53, K63, K73, K83, K82, K62, \ | ||
| 36 | K15, K14, K24, K34, K44, K45, K55, K54, K64, K74, K84, K85, K06, \ | ||
| 37 | K67, K16, K26, K36, K46, K47, K57, K56, K66, K76, K87, K32, K35, \ | ||
| 38 | K75, K22, K00, K07, K21, K04, K37, K27, K17 \ | ||
| 39 | ) { \ | ||
| 40 | { KB_##K00, KB_NO, KB_##K02, KB_NO, KB_##K04, KB_NO, KB_##K06, KB_##K07 }, \ | ||
| 41 | { KB_##K10, KB_##K11, KB_##K12, KB_##K13, KB_##K14, KB_##K15, KB_##K16, KB_##K17 }, \ | ||
| 42 | { KB_##K20, KB_##K21, KB_##K22, KB_##K23, KB_##K24, KB_NO, KB_##K26, KB_##K27 }, \ | ||
| 43 | { KB_##K30, KB_NO, KB_##K32, KB_##K33, KB_##K34, KB_##K35, KB_##K36, KB_##K37 }, \ | ||
| 44 | { KB_##K40, KB_##K41, KB_##K42, KB_##K43, KB_##K44, KB_##K45, KB_##K46, KB_##K47 }, \ | ||
| 45 | { KB_##K50, KB_##K51, KB_##K52, KB_##K53, KB_##K54, KB_##K55, KB_##K56, KB_##K57 }, \ | ||
| 46 | { KB_##K60, KB_##K61, KB_##K62, KB_##K63, KB_##K64, KB_NO, KB_##K66, KB_##K67 }, \ | ||
| 47 | { KB_##K70, KB_NO, KB_NO, KB_##K73, KB_##K74, KB_##K75, KB_##K76, KB_NO }, \ | ||
| 48 | { KB_##K80, KB_##K81, KB_##K82, KB_##K83, KB_##K84, KB_##K85, KB_NO, KB_##K87 } \ | ||
| 49 | } | ||
| 50 | |||
| 51 | #define KEYCODE(layer, row, col) (pgm_read_byte(&keymaps[(layer)][(row)][(col)])) | ||
| 52 | |||
| 53 | |||
| 54 | // Assign Fn key(0-7) to a layer to which switch with the Fn key pressed. | ||
| 55 | static const uint8_t PROGMEM fn_layer[] = { | ||
| 56 | 0, // Fn0 | ||
| 57 | 1, // Fn1 | ||
| 58 | 2, // Fn2 | ||
| 59 | 3, // Fn3 | ||
| 60 | 4, // Fn4 | ||
| 61 | 0, // Fn5 | ||
| 62 | 2, // Fn6 | ||
| 63 | 3 // Fn7 | ||
| 64 | }; | ||
| 65 | |||
| 66 | // Assign Fn key(0-7) to a keycode sent when release Fn key without use of the layer. | ||
| 67 | // See layer.c for details. | ||
| 68 | static const uint8_t PROGMEM fn_keycode[] = { | ||
| 69 | KB_NO, // Fn0 | ||
| 70 | KB_NO, // Fn1 | ||
| 71 | KB_SLSH, // Fn2 | ||
| 72 | KB_SCLN, // Fn3 | ||
| 73 | KB_SPC, // Fn4 | ||
| 74 | KB_NO, // Fn5 | ||
| 75 | KB_NO, // Fn6 | ||
| 76 | KB_NO // Fn7 | ||
| 77 | }; | ||
| 78 | |||
| 79 | static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
| 80 | /* Layer 0: Default Layer | ||
| 81 | * ,-----------------------------------------------------------. | ||
| 82 | * |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | | ||
| 83 | * |-----------------------------------------------------------| | ||
| 84 | * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| | | ||
| 85 | * |-----------------------------------------------------' | | ||
| 86 | * |Contro| A| S| D| F| G| H| J| K| L|Fn3| '|Return | | ||
| 87 | * |-----------------------------------------------------------| | ||
| 88 | * |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift |Fn1| | ||
| 89 | * |-----------------------------------------------------------| | ||
| 90 | * |Fn7|Gui |Alt |Fn4 |Alt |Gui|Fn6|Fn6|Ctr| | ||
| 91 | * `-----------------------------------------------------------' | ||
| 92 | */ | ||
| 93 | KEYMAP(ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, \ | ||
| 94 | TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, \ | ||
| 95 | LCTL,A, S, D, F, G, H, J, K, L, FN3, QUOT,ENT, \ | ||
| 96 | LSFT,Z, X, C, V, B, N, M, COMM,DOT, FN2, RSFT,FN1, \ | ||
| 97 | FN7, LGUI,LALT,FN4, RALT,BSLS,GRV, FN6, RCTL), | ||
| 98 | |||
| 99 | |||
| 100 | /* Layer 1: HHKB mode (HHKB Fn) | ||
| 101 | * ,-----------------------------------------------------------. | ||
| 102 | * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Delete | | ||
| 103 | * |-----------------------------------------------------------| | ||
| 104 | * |Caps | | | | | | | |Psc|Slk|Pus|Up | | | | ||
| 105 | * |-----------------------------------------------------' | | ||
| 106 | * |Contro|VoD|VoU|Mut| | | *| /|Hom|PgU|Lef|Rig|Enter | | ||
| 107 | * |-----------------------------------------------------------| | ||
| 108 | * |Shift | | | | | | +| -|End|PgD|Dow|Shift |xxx| | ||
| 109 | * |-----------------------------------------------------------| | ||
| 110 | * | |Gui |Alt | |Alt |Gui| | |Ctr| | ||
| 111 | * `-----------------------------------------------------------' | ||
| 112 | */ | ||
| 113 | KEYMAP(ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, \ | ||
| 114 | CAPS,NO, NO, NO, NO, NO, NO, NO, PSCR,SLCK,BRK, UP, NO, \ | ||
| 115 | LCTL,VOLD,VOLU,MUTE,NO, NO, PAST,PSLS,HOME,PGUP,LEFT,RGHT,ENT, \ | ||
| 116 | LSFT,NO, NO, NO, NO, NO, PPLS,PMNS,END, PGDN,DOWN,RSFT,FN1, \ | ||
| 117 | NO, LGUI,LALT,SPC, RALT,NO, NO, NO, RCTL), | ||
| 118 | |||
| 119 | |||
| 120 | /* Layer 2: Vi mode (Quote/Rmeta) | ||
| 121 | * ,-----------------------------------------------------------. | ||
| 122 | * | `| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12| ` | | ||
| 123 | * |-----------------------------------------------------------| | ||
| 124 | * | \ |Hom|PgD|Up |PgU|End|Hom|PgD|PgU|End| | | | | | ||
| 125 | * |-----------------------------------------------------' | | ||
| 126 | * |Contro| |Lef|Dow|Rig| |Lef|Dow|Up |Rig| | | \ | | ||
| 127 | * |-----------------------------------------------------------| | ||
| 128 | * |Shift | | | | | |Hom|PgD|PgU|End|xxx|Shift | | | ||
| 129 | * |-----------------------------------------------------------| | ||
| 130 | * | |Gui |Alt |Space |Alt |Gui|Fn6|Fn6|Ctr| | ||
| 131 | * `-----------------------------------------------------------' | ||
| 132 | */ | ||
| 133 | KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, GRV, \ | ||
| 134 | BSLS,HOME,PGDN,UP, PGUP,END, HOME,PGDN,PGUP,END, NO, NO, NO, \ | ||
| 135 | LCTL,NO, LEFT,DOWN,RGHT,NO, LEFT,DOWN,UP, RGHT,NO, NO, BSLS, \ | ||
| 136 | LSFT,NO, NO, NO, NO, NO, HOME,PGDN,PGUP,END, FN2, RSFT,NO, \ | ||
| 137 | NO, LGUI,LALT,SPC, RALT,RGUI,FN6, FN6, RCTL), | ||
| 138 | |||
| 139 | |||
| 140 | /* Layer 3: Mouse mode (Semicolon) | ||
| 141 | * ,-----------------------------------------------------------. | ||
| 142 | * | `| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12| ` | | ||
| 143 | * |-----------------------------------------------------------| | ||
| 144 | * | \ |MwL|MwD|McU|MwU|MwR|MwL|MwD|MwU|MwR| | | | | | ||
| 145 | * |-----------------------------------------------------' | | ||
| 146 | * |Contro| |McL|McD|McR| |McL|McD|McU|McR|xxx| | \ | | ||
| 147 | * |-----------------------------------------------------------| | ||
| 148 | * |Shift | | |Mb1|Mb2|Mb3|Mb2|Mb1| | | |Shift | | | ||
| 149 | * |-----------------------------------------------------------| | ||
| 150 | * |xxx|Gui |Alt |Mb1 |Alt | | | | | | ||
| 151 | * `-----------------------------------------------------------' | ||
| 152 | * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel | ||
| 153 | */ | ||
| 154 | KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, GRV, \ | ||
| 155 | BSLS,WH_L,WH_D,MS_U,WH_U,WH_R,WH_L,WH_D,WH_U,WH_R,NO, NO, NO, \ | ||
| 156 | LCTL,NO, MS_L,MS_D,MS_R,NO, MS_L,MS_D,MS_U,MS_R,FN3, NO, BSLS, \ | ||
| 157 | LSFT,NO, NO, BTN1,BTN2,BTN3,BTN2,BTN1,NO, NO, NO, RSFT,NO, \ | ||
| 158 | FN7, LGUI,LALT,BTN1,RALT,NO, NO, NO, NO), | ||
| 159 | |||
| 160 | |||
| 161 | /* Layer 4: Matias half keyboard style (Space) | ||
| 162 | * ,-----------------------------------------------------------. | ||
| 163 | * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Delete | | ||
| 164 | * |-----------------------------------------------------------| | ||
| 165 | * |Backs| P| O| I| U| Y| T| R| E| W| Q|Tab|Tab| | | ||
| 166 | * |-----------------------------------------------------' | | ||
| 167 | * |Contro| ;| L| K| J| H| G| F| D| S| A|Con|Control | | ||
| 168 | * |-----------------------------------------------------------| | ||
| 169 | * |Shift | /| .| ,| M| N| B| V| C| X| Z|Shift | | | ||
| 170 | * |-----------------------------------------------------------| | ||
| 171 | * | |Gui |Alt |xxxxxxxxxxxxxxxxxxxxxx|Alt |Gui| | |Ctr| | ||
| 172 | * `-----------------------------------------------------------' | ||
| 173 | */ | ||
| 174 | KEYMAP(MINS,0, 9, 8, 7, 6, 5, 4, 3, 2, 1, NO, NO, ESC, \ | ||
| 175 | BSPC,P, O, I, U, Y, T, R, E, W, Q, TAB, TAB, \ | ||
| 176 | LCTL,SCLN,L, K, J, H, G, F, D, S, A, RCTL,RCTL, \ | ||
| 177 | LSFT,SLSH,DOT, COMM,M, N, B, V, C, X, Z, RSFT,NO, \ | ||
| 178 | NO, LGUI,LALT,FN4, RALT,RGUI,NO, NO, RCTL), | ||
| 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 fn_bits) | ||
| 188 | { | ||
| 189 | return pgm_read_byte(&fn_layer[biton(fn_bits)]); | ||
| 190 | } | ||
| 191 | |||
| 192 | uint8_t keymap_fn_keycode(uint8_t fn_bits) | ||
| 193 | { | ||
| 194 | return pgm_read_byte(&fn_keycode[(biton(fn_bits))]); | ||
| 195 | } | ||
diff --git a/keyboard/macway/led.c b/keyboard/macway/led.c new file mode 100644 index 000000000..f76545f0b --- /dev/null +++ b/keyboard/macway/led.c | |||
| @@ -0,0 +1,24 @@ | |||
| 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 | #include "stdint.h" | ||
| 19 | #include "led.h" | ||
| 20 | |||
| 21 | |||
| 22 | void led_set(uint8_t usb_led) | ||
| 23 | { | ||
| 24 | } | ||
diff --git a/keyboard/macway/matrix.c b/keyboard/macway/matrix.c new file mode 100644 index 000000000..56fb85896 --- /dev/null +++ b/keyboard/macway/matrix.c | |||
| @@ -0,0 +1,271 @@ | |||
| 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 | * 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 | #if (MATRIX_COLS > 16) | ||
| 32 | # error "MATRIX_COLS must not exceed 16" | ||
| 33 | #endif | ||
| 34 | #if (MATRIX_ROWS > 255) | ||
| 35 | # error "MATRIX_ROWS must not exceed 255" | ||
| 36 | #endif | ||
| 37 | |||
| 38 | |||
| 39 | #ifndef DEBOUNCE | ||
| 40 | # define DEBOUNCE 0 | ||
| 41 | #endif | ||
| 42 | static uint8_t debouncing = DEBOUNCE; | ||
| 43 | |||
| 44 | // matrix state buffer(1:on, 0:off) | ||
| 45 | #if (MATRIX_COLS <= 8) | ||
| 46 | static uint8_t *matrix; | ||
| 47 | static uint8_t *matrix_prev; | ||
| 48 | static uint8_t _matrix0[MATRIX_ROWS]; | ||
| 49 | static uint8_t _matrix1[MATRIX_ROWS]; | ||
| 50 | #else | ||
| 51 | static uint16_t *matrix; | ||
| 52 | static uint16_t *matrix_prev; | ||
| 53 | static uint16_t _matrix0[MATRIX_ROWS]; | ||
| 54 | static uint16_t _matrix1[MATRIX_ROWS]; | ||
| 55 | #endif | ||
| 56 | |||
| 57 | #ifdef MATRIX_HAS_GHOST | ||
| 58 | static bool matrix_has_ghost_in_row(uint8_t row); | ||
| 59 | #endif | ||
| 60 | static uint8_t read_col(void); | ||
| 61 | static void unselect_rows(void); | ||
| 62 | static void select_row(uint8_t row); | ||
| 63 | |||
| 64 | |||
| 65 | inline | ||
| 66 | uint8_t matrix_rows(void) | ||
| 67 | { | ||
| 68 | return MATRIX_ROWS; | ||
| 69 | } | ||
| 70 | |||
| 71 | inline | ||
| 72 | uint8_t matrix_cols(void) | ||
| 73 | { | ||
| 74 | return MATRIX_COLS; | ||
| 75 | } | ||
| 76 | |||
| 77 | void matrix_init(void) | ||
| 78 | { | ||
| 79 | // initialize row and col | ||
| 80 | unselect_rows(); | ||
| 81 | // Input with pull-up(DDR:0, PORT:1) | ||
| 82 | DDRB = 0x00; | ||
| 83 | PORTB = 0xFF; | ||
| 84 | |||
| 85 | // initialize matrix state: all keys off | ||
| 86 | for (uint8_t i=0; i < MATRIX_ROWS; i++) _matrix0[i] = 0x00; | ||
| 87 | for (uint8_t i=0; i < MATRIX_ROWS; i++) _matrix1[i] = 0x00; | ||
| 88 | matrix = _matrix0; | ||
| 89 | matrix_prev = _matrix1; | ||
| 90 | } | ||
| 91 | |||
| 92 | uint8_t matrix_scan(void) | ||
| 93 | { | ||
| 94 | if (!debouncing) { | ||
| 95 | uint8_t *tmp = matrix_prev; | ||
| 96 | matrix_prev = matrix; | ||
| 97 | matrix = tmp; | ||
| 98 | } | ||
| 99 | |||
| 100 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
| 101 | unselect_rows(); | ||
| 102 | select_row(i); | ||
| 103 | _delay_us(30); // without this wait read unstable value. | ||
| 104 | if (matrix[i] != (uint8_t)~read_col()) { | ||
| 105 | matrix[i] = (uint8_t)~read_col(); | ||
| 106 | if (debouncing) { | ||
| 107 | debug("bounce!: "); debug_hex(debouncing); print("\n"); | ||
| 108 | } | ||
| 109 | debouncing = DEBOUNCE; | ||
| 110 | } | ||
| 111 | } | ||
| 112 | unselect_rows(); | ||
| 113 | |||
| 114 | if (debouncing) { | ||
| 115 | debouncing--; | ||
| 116 | } | ||
| 117 | |||
| 118 | return 1; | ||
| 119 | } | ||
| 120 | |||
| 121 | bool matrix_is_modified(void) | ||
| 122 | { | ||
| 123 | if (debouncing) return false; | ||
| 124 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
| 125 | if (matrix[i] != matrix_prev[i]) { | ||
| 126 | return true; | ||
| 127 | } | ||
| 128 | } | ||
| 129 | return false; | ||
| 130 | } | ||
| 131 | |||
| 132 | inline | ||
| 133 | bool matrix_has_ghost(void) | ||
| 134 | { | ||
| 135 | #ifdef MATRIX_HAS_GHOST | ||
| 136 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
| 137 | if (matrix_has_ghost_in_row(i)) | ||
| 138 | return true; | ||
| 139 | } | ||
| 140 | #endif | ||
| 141 | return false; | ||
| 142 | } | ||
| 143 | |||
| 144 | inline | ||
| 145 | bool matrix_is_on(uint8_t row, uint8_t col) | ||
| 146 | { | ||
| 147 | return (matrix[row] & (1<<col)); | ||
| 148 | } | ||
| 149 | |||
| 150 | inline | ||
| 151 | #if (MATRIX_COLS <= 8) | ||
| 152 | uint8_t matrix_get_row(uint8_t row) | ||
| 153 | #else | ||
| 154 | uint16_t matrix_get_row(uint8_t row) | ||
| 155 | #endif | ||
| 156 | { | ||
| 157 | return matrix[row]; | ||
| 158 | } | ||
| 159 | |||
| 160 | void matrix_print(void) | ||
| 161 | { | ||
| 162 | print("\nr/c 01234567\n"); | ||
| 163 | for (uint8_t row = 0; row < matrix_rows(); row++) { | ||
| 164 | phex(row); print(": "); | ||
| 165 | #if (MATRIX_COLS <= 8) | ||
| 166 | pbin_reverse(matrix_get_row(row)); | ||
| 167 | #else | ||
| 168 | pbin_reverse16(matrix_get_row(row)); | ||
| 169 | #endif | ||
| 170 | #ifdef MATRIX_HAS_GHOST | ||
| 171 | if (matrix_has_ghost_in_row(row)) { | ||
| 172 | print(" <ghost"); | ||
| 173 | } | ||
| 174 | #endif | ||
| 175 | print("\n"); | ||
| 176 | } | ||
| 177 | } | ||
| 178 | |||
| 179 | uint8_t matrix_key_count(void) | ||
| 180 | { | ||
| 181 | uint8_t count = 0; | ||
| 182 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
| 183 | #if (MATRIX_COLS <= 8) | ||
| 184 | count += bitpop(matrix[i]); | ||
| 185 | #else | ||
| 186 | count += bitpop16(matrix[i]); | ||
| 187 | #endif | ||
| 188 | } | ||
| 189 | return count; | ||
| 190 | } | ||
| 191 | |||
| 192 | #ifdef MATRIX_HAS_GHOST | ||
| 193 | inline | ||
| 194 | static bool matrix_has_ghost_in_row(uint8_t row) | ||
| 195 | { | ||
| 196 | // no ghost exists in case less than 2 keys on | ||
| 197 | if (((matrix[row] - 1) & matrix[row]) == 0) | ||
| 198 | return false; | ||
| 199 | |||
| 200 | // ghost exists in case same state as other row | ||
| 201 | for (uint8_t i=0; i < MATRIX_ROWS; i++) { | ||
| 202 | if (i != row && (matrix[i] & matrix[row]) == matrix[row]) | ||
| 203 | return true; | ||
| 204 | } | ||
| 205 | return false; | ||
| 206 | } | ||
| 207 | #endif | ||
| 208 | |||
| 209 | inline | ||
| 210 | static uint8_t read_col(void) | ||
| 211 | { | ||
| 212 | return PINB; | ||
| 213 | } | ||
| 214 | |||
| 215 | inline | ||
| 216 | static void unselect_rows(void) | ||
| 217 | { | ||
| 218 | // Hi-Z(DDR:0, PORT:0) to unselect | ||
| 219 | DDRC &= ~0b11000000; // PC: 7,6 | ||
| 220 | PORTC &= ~0b11000000; | ||
| 221 | DDRD &= ~0b11000111; // PD: 7,6,2,1,0 | ||
| 222 | PORTD &= ~0b11000111; | ||
| 223 | DDRF &= ~0b11000000; // PF: 7,6 | ||
| 224 | PORTF &= ~0b11000000; | ||
| 225 | } | ||
| 226 | |||
| 227 | inline | ||
| 228 | static void select_row(uint8_t row) | ||
| 229 | { | ||
| 230 | // Output low(DDR:1, PORT:0) to select | ||
| 231 | // row: 0 1 2 3 4 5 6 7 8 | ||
| 232 | // pin: PD0, PC7, PD7, PF6, PD6, PD1, PD2, PC6, PF7 | ||
| 233 | switch (row) { | ||
| 234 | case 0: | ||
| 235 | DDRD |= (1<<0); | ||
| 236 | PORTD &= ~(1<<0); | ||
| 237 | break; | ||
| 238 | case 1: | ||
| 239 | DDRC |= (1<<7); | ||
| 240 | PORTC &= ~(1<<7); | ||
| 241 | break; | ||
| 242 | case 2: | ||
| 243 | DDRD |= (1<<7); | ||
| 244 | PORTD &= ~(1<<7); | ||
| 245 | break; | ||
| 246 | case 3: | ||
| 247 | DDRF |= (1<<6); | ||
| 248 | PORTF &= ~(1<<6); | ||
| 249 | break; | ||
| 250 | case 4: | ||
| 251 | DDRD |= (1<<6); | ||
| 252 | PORTD &= ~(1<<6); | ||
| 253 | break; | ||
| 254 | case 5: | ||
| 255 | DDRD |= (1<<1); | ||
| 256 | PORTD &= ~(1<<1); | ||
| 257 | break; | ||
| 258 | case 6: | ||
| 259 | DDRD |= (1<<2); | ||
| 260 | PORTD &= ~(1<<2); | ||
| 261 | break; | ||
| 262 | case 7: | ||
| 263 | DDRC |= (1<<6); | ||
| 264 | PORTC &= ~(1<<6); | ||
| 265 | break; | ||
| 266 | case 8: | ||
| 267 | DDRF |= (1<<7); | ||
| 268 | PORTF &= ~(1<<7); | ||
| 269 | break; | ||
| 270 | } | ||
| 271 | } | ||
