From b60f9c6ac6fa9f63cba7ffb6872095a8f0788e42 Mon Sep 17 00:00:00 2001 From: tmk Date: Mon, 11 Feb 2013 13:56:05 +0900 Subject: [PATCH] Boot Magic key for gh60 --- common/keyboard.c | 11 ++++++- keyboard/gh60/README.md | 72 ++++++++++++++++++++++++----------------- keyboard/gh60/config.h | 13 ++++++++ keyboard/gh60/keymap.c | 8 ++--- keyboard/gh60/matrix.c | 2 +- 5 files changed, 70 insertions(+), 36 deletions(-) diff --git a/common/keyboard.c b/common/keyboard.c index 5e9945ba..2c88b3e4 100644 --- a/common/keyboard.c +++ b/common/keyboard.c @@ -14,6 +14,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#include +#include #include "keyboard.h" #include "matrix.h" #include "keymap.h" @@ -40,8 +42,15 @@ void keyboard_init(void) timer_init(); matrix_init(); - /* boot magic keys goes here */ + /* matrix scan for boot magic keys */ +#ifdef DEBOUNCE + uint8_t scan = DEBOUNCE * 2; + while (scan--) { matrix_scan(); _delay_ms(1); } +#else matrix_scan(); +#endif + + /* boot magic keys */ #ifdef IS_BOOTMAGIC_BOOTLOADER /* kick up bootloader */ if (IS_BOOTMAGIC_BOOTLOADER()) bootloader_jump(); diff --git a/keyboard/gh60/README.md b/keyboard/gh60/README.md index 73eb4b6d..289467ab 100644 --- a/keyboard/gh60/README.md +++ b/keyboard/gh60/README.md @@ -10,27 +10,56 @@ DIY compact keyboard designed and run by komar007 and Geekhack community. ## Build Move to this directory then just run `make` like: - $ make -f Makfile.pjrc + $ make -f Makfile.[pjrc|lufa] + + +## Boot Magic +- `Fn` key for bootloader kick up. +- `D` key for Debug enable. ## Keymap +Two version of keymap are available. `Plan` and `Funky`. See keymap.c to define your own favourite keymap. -###Keymap with funky layers. - Layer 0: Default Layer +### 1. Plain keymap +This will be useful if you want to use key mapping tool like AHK. +To get this plain keymap do `make`: + + $ make -f Makefile.[pjrc|lufa] plain + +### Layer 0 + ,-----------------------------------------------------------. + |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | + |-----------------------------------------------------------| + |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| + |-----------------------------------------------------------| + |Caps | A| S| D| F| G| H| J| K| L| ;| '|Return | + |-----------------------------------------------------------| + |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift | + |-----------------------------------------------------------| + |Ctrl|Gui |Alt | Space |Alt |Gui |App |Ctrl| + `-----------------------------------------------------------' + + +### 2. Funky layers. + + $ make -f Makefile.[pjrc|lufa] + +#### Layer 0: Default Layer ,-----------------------------------------------------------. |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | |-----------------------------------------------------------| |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |-----------------------------------------------------------| - |Caps | A| S| D| F| G| H| J| K| L|Fn3| '|Return | + |Caps | A| S| D| F| G| H| J| K| L|*L3| '|Return | |-----------------------------------------------------------| - |Shift | Z| X| C| V| B| N| M| ,| .|Fn2|Shift | + |Shift | Z| X| C| V| B| N| M| ,| .|*L2|Shift | |-----------------------------------------------------------| - |Ctrl|Gui |Alt | Space |Alt |Gui |App |Fn1 | + |Ctrl|Gui |Alt | Space |Alt |*L3 |*L3 |*L1 | `-----------------------------------------------------------' - Layer 1: HHKB mode +#### Layer 1: HHKB mode ,-----------------------------------------------------------. |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Delete | |-----------------------------------------------------------| @@ -40,10 +69,10 @@ See keymap.c to define your own favourite keymap. |-----------------------------------------------------------| |Shift | | | | | | +| -|End|PgD|Dow|Shift | |-----------------------------------------------------------| - |Ctrl|Gui |Alt | Space |Alt |Gui |App |xxx | + |Ctrl|Gui |Alt | Space |Alt |Gui |App |*L0 | `-----------------------------------------------------------' - Layer 2: Vi mode +#### Layer 2: Vi mode ,-----------------------------------------------------------. | `| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Backsp | |-----------------------------------------------------------| @@ -51,39 +80,22 @@ See keymap.c to define your own favourite keymap. |-----------------------------------------------------------| |Contro| |Lef|Dow|Rig| |Lef|Dow|Up |Rig| | |Return | |-----------------------------------------------------------| - |Shift | | | | | |Hom|PgD|PgU|End|xxx|Shift | + |Shift | | | | | |Hom|PgD|PgU|End|*L0|Shift | |-----------------------------------------------------------| |Ctrl|Gui |Alt | Space |Alt |Gui |App |Ctrl| `-----------------------------------------------------------' - Layer 3: Mouse mode +#### Layer 3: Mouse mode ,-----------------------------------------------------------. | `| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Backsp | |-----------------------------------------------------------| |Tab |MwL|MwD|McU|MwU|MwR|MwL|MwD|MwU|MwR| | | | | |-----------------------------------------------------------| - |Contro| |McL|McD|McR| |McL|McD|McU|McR|xxx| |Return | + |Contro| |McL|McD|McR| |McL|McD|McU|McR|*L0| |Return | |-----------------------------------------------------------| |Shift | | |Mb1|Mb2|Mb3|Mb2|Mb1| | | |Shift | |-----------------------------------------------------------| - |Ctrl|Gui |Alt | Space |Alt |Gui |xxx |Ctrl| + |Ctrl|Gui |Alt | Space |Alt |*L0 |*L0 |Ctrl| `-----------------------------------------------------------' Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel -### Plain keymap without Fn layer. -This will be useful if you want to use key mapping tool like AHK. -To get this plain keymap run: - - $ make -f Makefile.pjrc plain - - ,-----------------------------------------------------------. - |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | - |-----------------------------------------------------------| - |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| - |-----------------------------------------------------------| - |Caps | A| S| D| F| G| H| J| K| L| ;| '|Return | - |-----------------------------------------------------------| - |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift | - |-----------------------------------------------------------| - |Ctrl|Gui |Alt | Space |Alt |Gui |App |Ctrl| - `-----------------------------------------------------------' diff --git a/keyboard/gh60/config.h b/keyboard/gh60/config.h index 6e7b1bd7..a760d5df 100644 --- a/keyboard/gh60/config.h +++ b/keyboard/gh60/config.h @@ -47,4 +47,17 @@ along with this program. If not, see . keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ ) +/* + * Boot magic keys + * call some function by pressing key when pluging cable or powering on. + */ +/* key position on matrix(ROW:COL) */ +#define KEY_FN 0x4A +#define KEY_D 0x23 +#define KEY_IS_ON(key) matrix_is_on((key)>>4, (key)&0xF) +/* kick up bootloader */ +#define IS_BOOTMAGIC_BOOTLOADER() KEY_IS_ON(KEY_FN) +/* debug on */ +#define IS_BOOTMAGIC_DEBUG() KEY_IS_ON(KEY_D) + #endif diff --git a/keyboard/gh60/keymap.c b/keyboard/gh60/keymap.c index 2608c98c..07045d7a 100644 --- a/keyboard/gh60/keymap.c +++ b/keyboard/gh60/keymap.c @@ -24,7 +24,7 @@ along with this program. If not, see . #include "keymap.h" -/* GH60 keymap definition macro +/* GH60 keymap definition macro * K2C, K31 and K3C are extra keys for ISO */ #define KEYMAP( \ @@ -48,7 +48,7 @@ along with this program. If not, see . K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2D, \ K30, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3D, \ K40, K41, K42, K45, K4A, K4B, K4C, K4D \ -) KEYMAP( \ +) KEYMAP( \ K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, \ K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \ K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, NO, K2D, \ @@ -136,7 +136,7 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * |-----------------------------------------------------------| * |Ctrl|Gui |Alt | Space |Alt |Gui |App |xxx | * `-----------------------------------------------------------' - */ + */ KEYMAP_ANSI( PWR, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, \ CAPS,NO, NO, NO, NO, NO, NO, NO, PSCR,SLCK,PAUS,UP, NO, INS, \ @@ -174,7 +174,7 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * |-----------------------------------------------------------| * |Ctrl|Gui |Alt | Space | |xxx |xxx | | * `-----------------------------------------------------------' - * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel + * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel */ KEYMAP_ANSI( GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, BSPC, \ diff --git a/keyboard/gh60/matrix.c b/keyboard/gh60/matrix.c index 6ded8158..85e58fe3 100644 --- a/keyboard/gh60/matrix.c +++ b/keyboard/gh60/matrix.c @@ -131,7 +131,7 @@ uint16_t matrix_get_row(uint8_t row) void matrix_print(void) { - print("\nr/c 01234567890ABCDEF\n"); + print("\nr/c 0123456789ABCDEF\n"); for (uint8_t row = 0; row < MATRIX_ROWS; row++) { phex(row); print(": "); pbin_reverse16(matrix_get_row(row)); -- 2.46.2