Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b15a71beba | ||
|
|
05be1de1aa | ||
|
|
5b503cc543 | ||
|
|
69ec54f3a4 | ||
|
|
57113c7e49 | ||
|
|
5e86f087f8 | ||
|
|
933842067d |
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@@ -14,4 +14,4 @@
|
||||
"*.hpp": "cpp",
|
||||
"xstddef": "c"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +1,30 @@
|
||||
#include "ca66.h"
|
||||
#include "config.h"
|
||||
|
||||
void bootmagic_lite(void)
|
||||
{
|
||||
// The lite version of TMK's bootmagic.
|
||||
// 100% less potential for accidentally making the
|
||||
// keyboard do stupid things.
|
||||
|
||||
// We need multiple scans because debouncing can't be turned off.
|
||||
matrix_scan();
|
||||
wait_ms(DEBOUNCING_DELAY);
|
||||
matrix_scan();
|
||||
|
||||
// If the Esc (matrix 0,0) is held down on power up,
|
||||
// reset the EEPROM valid state and jump to bootloader.
|
||||
if ( matrix_get_row(0) & (1<<0) )
|
||||
{
|
||||
// Set the TMK/QMK EEPROM state as invalid.
|
||||
eeconfig_disable();
|
||||
// Jump to bootloader.
|
||||
bootloader_jump();
|
||||
}
|
||||
}
|
||||
|
||||
void matrix_init_kb(void)
|
||||
{
|
||||
bootmagic_lite();
|
||||
matrix_init_user();
|
||||
}
|
||||
|
||||
@@ -34,8 +34,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
// #define MASTER_RIGHT
|
||||
// #define EE_HANDS
|
||||
|
||||
#define TAPPING_TERM 120
|
||||
#define TAPPING_TOGGLE 3
|
||||
/* Use RGB Underglow */
|
||||
|
||||
#undef RGBLED_NUM
|
||||
#define RGBLIGHT_ANIMATIONS
|
||||
|
||||
@@ -17,7 +17,7 @@ extern keymap_config_t keymap_config;
|
||||
#define _ADJUST 4
|
||||
|
||||
enum custom_keycodes {
|
||||
QWERTY = SAFE_RANGE, // デフォルトレイヤー用
|
||||
QWERTY = SAFE_RANGE, // QWERTYレイヤーへ
|
||||
MCR1, // マクロ1
|
||||
MCR2, // マクロ2
|
||||
MCR3, // マクロ3
|
||||
@@ -35,14 +35,17 @@ enum custom_keycodes {
|
||||
#define KC_RASE LT(_RAISE, KC_HENK) // タップで変換 ホールドでRaise
|
||||
#define KC_LSLB MT(MOD_LSFT, JP_LBRC) // タップで[ ホールドで左Shift
|
||||
#define KC_RSRB MT(MOD_RSFT, JP_RBRC) // タップで] ホールドで右Shift
|
||||
#define KC_ALTB MT(MOD_LALT, KC_TAB) // タップでTAB ホールドで左ALT
|
||||
#define KC_ESCA LT(_ADJUST,KC_ESC) // タップでESC ホールドでADJUSTレイヤーon
|
||||
#define KC_ALTB MT(MOD_LALT, KC_TAB) // タップでTAB ホールドで左Alt
|
||||
#define CTL_ZH CTL_T(KC_ZKHK) // タップで半角/全角 ホールドで左Control (Windows)
|
||||
#define WN_CAPS S(KC_CAPS) // Caps Lock (Windows)
|
||||
#define KC_ALPS LALT(KC_PSCR) // Alt + PrintScreen
|
||||
#define LOWER MO(_LOWER)
|
||||
#define RAISE MO(_RAISE)
|
||||
#define GAME DF(_GAME)
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
|
||||
/* QWERTY
|
||||
/* QWERTY // WindowsでJIS配列時のデフォルトキーマップ
|
||||
* ,-------------------------------------------------------. ,-------------------------------------------------------.
|
||||
* |Tab/Alt| Q | W | E | R | T | - | | ~ | Y | U | I | O | P | BSPC |
|
||||
* |-------+-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------+-------|
|
||||
@@ -50,97 +53,123 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
* |-------+-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------+-------|
|
||||
* | [/Sft | Z | X | C | V | B | F2 | | Home | N | M | , | . | / | ]/Sft |
|
||||
* |-------+-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------+-------|
|
||||
* | TT | GUI | \ | Esc/ | LOWER | Enter | Del | | End | Space | RAISE | Left | Down | Up | Right |
|
||||
* |(_GAME)| | |_ADJUST| 無変換| | | | | | 変換 | | | | |
|
||||
* |WN CAPS| GUI | \ | Esc |無変換 | Enter | Del | | End | Space | 変換 | Left | Down | Up | Right |
|
||||
* | | | | | LOWER | | | | | | RAISE | | | | |
|
||||
* `-------------------------------------------------------' `-------------------------------------------------------'
|
||||
*/
|
||||
|
||||
[_QWERTY] = KEYMAP( \
|
||||
KC_ALTB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_MINS, JP_TILD, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, \
|
||||
CTL_ZH, KC_A, KC_S, KC_D, KC_F, KC_G, JP_LPRN, JP_RPRN, KC_H, KC_J, KC_K, KC_L, WN_SCLN, JP_QUOT, \
|
||||
KC_LSLB, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_F2, KC_HOME, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSRB, \
|
||||
TT(_GAME),KC_LGUI, JP_YEN, KC_ESCA, KC_LOWR, KC_ENT, KC_DEL, KC_END, KC_SPC, KC_RASE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
|
||||
KC_ALTB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_MINS, JP_TILD, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, \
|
||||
CTL_ZH, KC_A, KC_S, KC_D, KC_F, KC_G, JP_LPRN, JP_RPRN, KC_H, KC_J, KC_K, KC_L, WN_SCLN, JP_QUOT, \
|
||||
KC_LSLB, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_F2, KC_HOME, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSRB, \
|
||||
WN_CAPS, KC_LGUI, JP_YEN, KC_ESC, KC_LOWR, KC_ENT, KC_DEL, KC_END, KC_SPC, KC_RASE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
|
||||
),
|
||||
|
||||
/* LOWER
|
||||
/* LOWER // 数字入力用レイヤー
|
||||
* ,-------------------------------------------------------. ,-------------------------------------------------------.
|
||||
* |Tab/Alt| 1 | 2 | 3 | 4 | 5 | 6 | | Esc | 7 | 8 | 9 | O | = | BSPC |
|
||||
* | | 1 | 2 | 3 | 4 | 5 | 6 | | Esc | 7 | 8 | 9 | . | = | |
|
||||
* |-------+-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------+-------|
|
||||
* |ZH/Ctrl| F1 | F2 | F3 | F4 | F5 | F6 | | F2 | 4 | 5 | 6 | - | / | Enter |
|
||||
* | | F1 | F2 | F3 | F4 | F5 | F6 | | F2 | 4 | 5 | 6 | - | / | Enter |
|
||||
* |-------+-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------+-------|
|
||||
* | Shift | F7 | F8 | F9 | F10 | F11 | F12 | | Home | 1 | 2 | 3 | + | * | Shift |
|
||||
* | Shift | F7 | F8 | F9 | F10 | F11 | F12 | | | 1 | 2 | 3 | + | * | Shift |
|
||||
* |-------+-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------+-------|
|
||||
* |XXXXXXX| GUI |XXXXXXX| Esc | | Enter | Del | | End | 0 | . | Left | Down | Up | Right |
|
||||
* | | |XXXXXXX| | | | | | | 0 | | | | | |
|
||||
* `-------------------------------------------------------' `-------------------------------------------------------'
|
||||
*/
|
||||
|
||||
[_LOWER] = KEYMAP( \
|
||||
_______, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_ESC, KC_7, KC_8, KC_9, KC_0, JP_EQL, _______, \
|
||||
_______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F2, KC_P4, KC_P5, KC_P6, KC_PMNS, KC_PSLS, KC_ENT, \
|
||||
KC_LSFT, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, KC_P1, KC_P2, KC_P3, KC_PPLS, KC_PAST, KC_RSFT, \
|
||||
_______, _______, XXXXXXX, KC_ESC, _______, _______, _______, _______, KC_P0, KC_PDOT, _______, _______, _______, _______ \
|
||||
_______, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_ESC, KC_7, KC_8, KC_9, KC_PDOT, JP_EQL, _______, \
|
||||
_______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F2, KC_P4, KC_P5, KC_P6, KC_PMNS, KC_PSLS, KC_ENT, \
|
||||
KC_LSFT, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, KC_P1, KC_P2, KC_P3, KC_PPLS, KC_PAST, KC_RSFT, \
|
||||
_______, _______, XXXXXXX, _______, _______, _______, _______, _______, KC_0, _______, _______, _______, _______, _______ \
|
||||
),
|
||||
|
||||
/* RAISE
|
||||
/* RAISE // 記号入力用レイヤー
|
||||
* ,-------------------------------------------------------. ,-------------------------------------------------------.
|
||||
* |Tab/Alt| ! | @ | # | $ | % | _ | | ` | ^ | & | Ins | \ |PrntScr| BSPC |
|
||||
* | | ! | @ | # | $ | % | _ | | ` | ^ | & | Ins | \ |PrntScr| |
|
||||
* |-------+-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------+-------|
|
||||
* |ZH/Ctrl|XXXXXXX|XXXXXXX|XXXXXXX|XXXXXXX|XXXXXXX| { | | } | Left | Down | Up | Right | ; | " |
|
||||
* | |XXXXXXX|XXXXXXX|XXXXXXX|XXXXXXX|XXXXXXX| { | | } | Left | Down | Up | Right | ; | " |
|
||||
* |-------+-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------+-------|
|
||||
* | Shift |XXXXXXX|XXXXXXX|XXXXXXX|XXXXXXX|XXXXXXX|XXXXXXX| |PageUp |XXXXXXX|XXXXXXX| < | > | ? | Shift |
|
||||
* | Shift |M-PLAY |M-MUTE |VOL_DWN|VOL_UP |PREV_TR|NEXT_TR| |PageUp |XXXXXXX|XXXXXXX| < | > | ? | Shift |
|
||||
* |-------+-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------+-------|
|
||||
* |XXXXXXX| GUI | | | Esc |XXXXXXX| Enter | Del | |PageDwn| Space | | Left | Down | Up | Right |
|
||||
* | | | | | | | | | |PageDwn| | | | | | |
|
||||
* `-------------------------------------------------------' `-------------------------------------------------------'
|
||||
*/
|
||||
|
||||
[_RAISE] = KEYMAP( \
|
||||
_______, KC_EXLM, JP_AT, KC_HASH, KC_DLR, KC_PERC, JP_UNDS, JP_GRV, JP_CIRC, JP_AMPR, KC_INS, JP_YEN, KC_ALPS, _______, \
|
||||
_______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, JP_LCBR, JP_RCBR, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_SCLN, JP_DQT, \
|
||||
KC_LSFT, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_PGUP, XXXXXXX, XXXXXXX, KC_LT, KC_GT, KC_QUES, KC_RSFT, \
|
||||
_______, _______, JP_PIPE, KC_ESC, XXXXXXX, _______, _______, KC_PGDN, _______, _______, _______, _______, _______, _______ \
|
||||
_______, KC_EXLM, JP_AT, KC_HASH, KC_DLR, KC_PERC, JP_UNDS, JP_GRV, JP_CIRC, JP_AMPR, KC_INS, JP_YEN, KC_ALPS, _______, \
|
||||
_______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, JP_LCBR, JP_RCBR, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_SCLN, JP_DQT, \
|
||||
KC_LSFT, KC_MPLY, KC_MUTE, KC_VOLD, KC_VOLU, KC_MPRV, KC_MNXT, KC_PGUP, XXXXXXX, XXXXXXX, KC_LT, KC_GT, KC_QUES, KC_RSFT, \
|
||||
_______, _______, JP_PIPE, _______, _______, _______, _______, KC_PGDN, _______, _______, _______, _______, _______, _______ \
|
||||
),
|
||||
|
||||
/* GAME
|
||||
/* GAME // 左手はゲーム用レイヤー、右手はNumPad
|
||||
* ,-------------------------------------------------------. ,-------------------------------------------------------.
|
||||
* | Esc | Q | W | E | R | T |PrntScr| | | | | | | | |
|
||||
* | Tab | Q | W | E | R | T |PrntScr| | Esc | 7 | 8 | 9 | . | = | BSPC |
|
||||
* |-------+-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------+-------|
|
||||
* | Ctrl | A | S | D | F | G | F5 | | | | | | | | |
|
||||
* | Ctrl | A | S | D | F | G | F1 | | F2 | 4 | 5 | 6 | - | / | Enter |
|
||||
* |-------+-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------+-------|
|
||||
* | Shift | Z | X | C | V | B | F2 | |PageUp | | | | | | |
|
||||
* | Shift | Z | X | C | V | B | F2 | | Home | 1 | 2 | 3 | + | * | Shift |
|
||||
* |-------+-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------+-------|
|
||||
* | | GUI | Tab | Alt | Space | Enter | Del | |PageDwn| Space |XXXXXXX| Left | Down | Up | Right |
|
||||
* | Del | GUI | Alt | Esc | LOWER | Space | Enter | | End | 0 | RAISE | Left | Down | Up | Right |
|
||||
* `-------------------------------------------------------' `-------------------------------------------------------'
|
||||
*/
|
||||
[_GAME] = KEYMAP( \
|
||||
KC_ESC, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_ALPS, _______, _______, _______, _______, _______, _______, _______, \
|
||||
KC_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, JP_LBRC, _______, _______, _______, _______, _______, _______, _______, \
|
||||
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_F2, KC_PGUP, _______, _______, _______, _______, _______, _______, \
|
||||
_______, KC_LGUI, KC_TAB, KC_LALT, KC_SPC, KC_ENT, KC_DEL, KC_PGDN, _______, XXXXXXX, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
|
||||
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_ALPS, KC_ESC, KC_P7, KC_P8, KC_P9, KC_PDOT, JP_EQL, KC_BSPC, \
|
||||
KC_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_F1, KC_F2, KC_P4, KC_P5, KC_P6, KC_PMNS, KC_PSLS, KC_ENT, \
|
||||
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_F2, KC_HOME, KC_P1, KC_P2, KC_P3, KC_PPLS, KC_PAST, KC_RSFT, \
|
||||
KC_DEL, KC_LGUI, KC_LALT, KC_ESC, LOWER, KC_SPC, KC_ENT, KC_PGDN, KC_P0, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
|
||||
),
|
||||
|
||||
/* ADJUST
|
||||
/* ADJUST // 設定用レイヤー (LOWER+RAISE)
|
||||
* ,-------------------------------------------------------. ,-------------------------------------------------------.
|
||||
* |RGB_TOG| MCR1 | MCR2 | MCR3 |XXXXXXX|XXXXXXX|XXXXXXX| |XXXXXXX|PLAY_M1|PLAY_M2|REC_M1 |REC_M2 |STP_REC| BSPC |
|
||||
* |-------+-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------+-------|
|
||||
* | RESET |RGB_MOD|_PLAIN |_BREATH|RGB_HuI|RGB_SaI|RGB_VaI| |XXXXXXX|QWERTY |XXXXXXX|XXXXXXX|XXXXXXX|XXXXXXX|XXXXXXX|
|
||||
* | RESET | | | | | | | |XXXXXXX|XXXXXXX|QWERTY | GAME |XXXXXXX|XXXXXXX|XXXXXXX|
|
||||
* |-------+-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------+-------|
|
||||
* | Shift |_RAINBW|_SNAKE |_GRADIE|RGB_HuD|RGB_SaD|RGB_VaD| |XXXXXXX| M-PLAY|M-MUTE |VOL_DWN|VOL_UP |PREV_TR|NEXT_TR|
|
||||
* | Shift | | | | | | | |XXXXXXX| M-PLAY|M-MUTE |VOL_DWN|VOL_UP |PREV_TR|NEXT_TR|
|
||||
* |-------+-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------+-------|
|
||||
* | DEBUG |XXXXXXX|XXXXXXX| |XXXXXXX|XXXXXXX|XXXXXXX| |XXXXXXX|XXXXXXX|XXXXXXX| Left | Down | Up | Right |
|
||||
* | DEBUG |XXXXXXX|XXXXXXX| | |XXXXXXX|XXXXXXX| |XXXXXXX|XXXXXXX| | Left | Down | Up | Right |
|
||||
* `-------------------------------------------------------' `-------------------------------------------------------'
|
||||
*/
|
||||
|
||||
[_ADJUST] = KEYMAP( \
|
||||
RGB_TOG, MCR1, MCR2, MCR3, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, DYN_MACRO_PLAY1, DYN_MACRO_PLAY2, DYN_REC_START1, DYN_REC_START2, DYN_REC_STOP, KC_BSPC, \
|
||||
RESET, RGB_MOD, RGB_M_P, RGB_M_B, RGB_HUI, RGB_SAI, RGB_VAI, XXXXXXX, QWERTY, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, \
|
||||
KC_LSFT, RGB_M_R, RGB_M_SN,RGB_M_G, RGB_HUD, RGB_SAD, RGB_VAD, XXXXXXX, KC_MPLY, KC_MUTE, KC_VOLD, KC_VOLU, KC_MPRV, KC_MNXT, \
|
||||
DEBUG, XXXXXXX, XXXXXXX, _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
|
||||
RGB_TOG, MCR1, MCR2, MCR3, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, DYN_MACRO_PLAY1, DYN_MACRO_PLAY2, DYN_REC_START1, DYN_REC_START2, DYN_REC_STOP, KC_BSPC, \
|
||||
RESET, RGB_MOD, RGB_M_P, RGB_M_B, RGB_HUI, RGB_SAI, RGB_VAI, XXXXXXX, XXXXXXX, QWERTY, GAME, XXXXXXX, XXXXXXX, XXXXXXX, \
|
||||
KC_LSFT, RGB_M_R, RGB_M_SN,RGB_M_G, RGB_HUD, RGB_SAD, RGB_VAD, XXXXXXX, KC_MPLY, KC_MUTE, KC_VOLD, KC_VOLU, KC_MPRV, KC_MNXT, \
|
||||
DEBUG, XXXXXXX, XXXXXXX, _______, _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, _______, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
|
||||
),
|
||||
|
||||
};
|
||||
|
||||
void persistent_default_layer_set(uint16_t default_layer) {
|
||||
eeconfig_update_default_layer(default_layer);
|
||||
default_layer_set(default_layer);
|
||||
// RGB Underglow使用時のレイヤー毎のカラー切り替え
|
||||
uint32_t layer_state_set_keymap (uint32_t state) {
|
||||
return state;
|
||||
}
|
||||
|
||||
void matrix_init_user(void) {
|
||||
#ifdef RGBLIGHT_ENABLE
|
||||
rgblight_enable();
|
||||
rgblight_setrgb_teal();
|
||||
#endif
|
||||
}
|
||||
|
||||
uint32_t layer_state_set_user(uint32_t state) {
|
||||
state = update_tri_layer_state(state, _RAISE, _LOWER, _ADJUST);
|
||||
#ifdef RGBLIGHT_ENABLE
|
||||
switch (biton32(state)) {
|
||||
case _RAISE:
|
||||
rgblight_setrgb_chartreuse(); // RAISE:シャルトリューズ
|
||||
break;
|
||||
case _LOWER:
|
||||
rgblight_setrgb_pink(); // LOWER:ピンク
|
||||
break;
|
||||
case _ADJUST:
|
||||
rgblight_setrgb_red(); // ADJUST:レッド
|
||||
break;
|
||||
default: // for any other layers, or the default layer
|
||||
rgblight_setrgb_teal(); // 他:ティール
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
return state;
|
||||
}
|
||||
|
||||
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
@@ -151,7 +180,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
switch (keycode) {
|
||||
case QWERTY:
|
||||
if (record->event.pressed) {
|
||||
persistent_default_layer_set(1UL<<_QWERTY);
|
||||
set_single_persistent_default_layer(_QWERTY);
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
@@ -171,19 +200,19 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
break;
|
||||
case MCR1:
|
||||
if (record->event.pressed) {
|
||||
SEND_STRING("hogehoge"); // 送信文字列
|
||||
SEND_STRING("hoge"); // 送信文字列
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
case MCR2:
|
||||
if (record->event.pressed) {
|
||||
SEND_STRING("hogehogehoge"SS_TAP(X_ENTER)); // 送信文字列
|
||||
SEND_STRING("hogehoge"SS_TAP(X_ENTER)); // 送信文字列
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
case MCR3:
|
||||
if (record->event.pressed) {
|
||||
SEND_STRING("hoge@hoge.co.jp"); // 送信文字列
|
||||
SEND_STRING("hoge@hoge.hoge"); // 送信文字列
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
|
||||
@@ -6,62 +6,62 @@ Designed for Japanese Keyboardists using JIS on the Ergo42.
|
||||
|
||||
````
|
||||
QWERTY
|
||||
,-------------------------------------------------------. ,-------------------------------------------------------.
|
||||
|Tab/Alt| Q | W | E | R | T | - | | ~ | Y | U | I | O | P | BSPC |
|
||||
|-------+-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------+-------|
|
||||
|ZH/Ctrl| A | S | D | F | G | ( | | ) | H | J | K | L | : | ' |
|
||||
|-------+-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------+-------|
|
||||
| [/Sft | Z | X | C | V | B | F2 | | Home | N | M | , | . | / | ]/Sft |
|
||||
|-------+-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------+-------|
|
||||
| TT | GUI | \ | Esc/ | LOWER | Enter | Del | | End | Space | RAISE | Left | Down | Up | Right |
|
||||
|(_GAME)| | |_ADJUST| –³•ÏŠ·| | | | | | •ÏŠ· | | | | |
|
||||
`-------------------------------------------------------' `-------------------------------------------------------'
|
||||
,-------------------------------------------------------. ,-------------------------------------------------------.
|
||||
|Tab/Alt| Q | W | E | R | T | - | | ~ | Y | U | I | O | P | BSPC |
|
||||
|-------+-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------+-------|
|
||||
|ZH/Ctrl| A | S | D | F | G | ( | | ) | H | J | K | L | : | ' |
|
||||
|-------+-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------+-------|
|
||||
| [/Sft | Z | X | C | V | B | F2 | | Home | N | M | , | . | / | ]/Sft |
|
||||
|-------+-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------+-------|
|
||||
|WN CAPS| GUI | \ | Esc | MHEN/ | Enter | Del | | End | Space | HENK/ | Left | Down | Up | Right |
|
||||
| | | | | LOWER | | | | | | RAISE | | | | |
|
||||
`-------------------------------------------------------' `-------------------------------------------------------'
|
||||
|
||||
LOWER
|
||||
,-------------------------------------------------------. ,-------------------------------------------------------.
|
||||
|Tab/Alt| 1 | 2 | 3 | 4 | 5 | 6 | | Esc | 7 | 8 | 9 | O | = | BSPC |
|
||||
|-------+-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------+-------|
|
||||
| Ctrl | F1 | F2 | F3 | F4 | F5 | F6 | | F2 | 4 | 5 | 6 | - | / | Enter |
|
||||
|-------+-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------+-------|
|
||||
| Shift | F7 | F8 | F9 | F10 | F11 | F12 | | Home | 1 | 2 | 3 | + | * | Shift |
|
||||
|-------+-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------+-------|
|
||||
|XXXXXXX| GUI |XXXXXXX| Esc | | Enter | Del | | End | 0 | . | Left | Down | Up | Right |
|
||||
`-------------------------------------------------------' `-------------------------------------------------------'
|
||||
,-------------------------------------------------------. ,-------------------------------------------------------.
|
||||
| | 1 | 2 | 3 | 4 | 5 | 6 | | Esc | 7 | 8 | 9 | . | = | |
|
||||
|-------+-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------+-------|
|
||||
| | F1 | F2 | F3 | F4 | F5 | F6 | | F2 | 4 | 5 | 6 | - | / | Enter |
|
||||
|-------+-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------+-------|
|
||||
| Shift | F7 | F8 | F9 | F10 | F11 | F12 | | | 1 | 2 | 3 | + | * | Shift |
|
||||
|-------+-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------+-------|
|
||||
| | |XXXXXXX| | | | | | | 0 | | | | | |
|
||||
`-------------------------------------------------------' `-------------------------------------------------------'
|
||||
|
||||
RAISE
|
||||
,-------------------------------------------------------. ,-------------------------------------------------------.
|
||||
|Tab/Alt| ! | @ | # | $ | % | _ | | ` | ^ | & | Ins | \ |PrntScr| BSPC |
|
||||
|-------+-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------+-------|
|
||||
| Ctrl |XXXXXXX|XXXXXXX|XXXXXXX|XXXXXXX|XXXXXXX| { | | } | Left | Down | Up | Right | ; | " |
|
||||
|-------+-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------+-------|
|
||||
| Shift |XXXXXXX|XXXXXXX|XXXXXXX|XXXXXXX|XXXXXXX|XXXXXXX| |PageUp |XXXXXXX|XXXXXXX| < | > | ? | Shift |
|
||||
|-------+-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------+-------|
|
||||
|XXXXXXX| GUI | | | Esc |XXXXXXX| Enter | Del | |PageDwn| Space | | Left | Down | Up | Right |
|
||||
`-------------------------------------------------------' `-------------------------------------------------------'
|
||||
|
||||
GAME
|
||||
,-------------------------------------------------------. ,-------------------------------------------------------.
|
||||
| Esc | Q | W | E | R | T |PrntScr| | | | | | | | |
|
||||
|-------+-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------+-------|
|
||||
| Ctrl | A | S | D | F | G | F5 | | | | | | | | |
|
||||
|-------+-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------+-------|
|
||||
| Shift | Z | X | C | V | B | F2 | |PageUp | | | | | | |
|
||||
|-------+-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------+-------|
|
||||
| | GUI | Tab | Alt | Space | Enter | Del | |PageDwn| Space |XXXXXXX| Left | Down | Up | Right |
|
||||
`-------------------------------------------------------' `-------------------------------------------------------'
|
||||
,-------------------------------------------------------. ,-------------------------------------------------------.
|
||||
| | ! | @ | # | $ | % | _ | | ` | ^ | & | Ins | \ |PrntScr| |
|
||||
|-------+-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------+-------|
|
||||
| |XXXXXXX|XXXXXXX|XXXXXXX|XXXXXXX|XXXXXXX| { | | } | Left | Down | Up | Right | ; | " |
|
||||
|-------+-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------+-------|
|
||||
| | M-PLAY|M-MUTE |VOL_DWN|VOL_UP |PREV_TR|NEXT_TR| |PageUp |XXXXXXX|XXXXXXX| < | > | ? | Shift |
|
||||
|-------+-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------+-------|
|
||||
| | | | | | | | | |PageDwn| | | | | | |
|
||||
`-------------------------------------------------------' `-------------------------------------------------------'
|
||||
|
||||
ADJUST
|
||||
,-------------------------------------------------------. ,-------------------------------------------------------.
|
||||
|RGB_TOG| MCR1 | MCR2 | MCR3 |XXXXXXX|XXXXXXX|XXXXXXX| |XXXXXXX|PLAY_M1|PLAY_M2|REC_M1 |REC_M2 |STP_REC| BSPC |
|
||||
|-------+-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------+-------|
|
||||
| RESET |RGB_MOD|_PLAIN |_BREATH|RGB_HuI|RGB_SaI|RGB_VaI| |XXXXXXX|QWERTY |XXXXXXX|XXXXXXX|XXXXXXX|XXXXXXX|XXXXXXX|
|
||||
|-------+-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------+-------|
|
||||
| Shift |_RAINBW|_SNAKE |_GRADIE|RGB_HuD|RGB_SaD|RGB_VaD| |XXXXXXX| M-PLAY|M-MUTE |VOL_DWN|VOL_UP |PREV_TR|NEXT_TR|
|
||||
|-------+-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------+-------|
|
||||
| DEBUG |XXXXXXX|XXXXXXX| |XXXXXXX|XXXXXXX|XXXXXXX| |XXXXXXX|XXXXXXX|XXXXXXX| Left | Down | Up | Right |
|
||||
`-------------------------------------------------------' `-------------------------------------------------------'
|
||||
,-------------------------------------------------------. ,-------------------------------------------------------.
|
||||
|RGB_TOG| MCR1 | MCR2 | MCR3 |XXXXXXX|XXXXXXX|XXXXXXX| |XXXXXXX|PLAY_M1|PLAY_M2|REC_M1 |REC_M2 |STP_REC| BSPC |
|
||||
|-------+-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------+-------|
|
||||
| RESET | | | | | | | |XXXXXXX|XXXXXXX|QWERTY | GAME |XXXXXXX|XXXXXXX|XXXXXXX|
|
||||
|-------+-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------+-------|
|
||||
| Shift | | | | | | | |XXXXXXX| M-PLAY|M-MUTE |VOL_DWN|VOL_UP |PREV_TR|NEXT_TR|
|
||||
|-------+-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------+-------|
|
||||
| DEBUG |XXXXXXX|XXXXXXX| | |XXXXXXX|XXXXXXX| |XXXXXXX|XXXXXXX| | Left | Down | Up | Right |
|
||||
`-------------------------------------------------------' `-------------------------------------------------------'
|
||||
|
||||
GAME
|
||||
,-------------------------------------------------------. ,-------------------------------------------------------.
|
||||
| Tab | Q | W | E | R | T |PrntScr| | Esc | 7 | 8 | 9 | . | = | BSPC |
|
||||
|-------+-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------+-------|
|
||||
| Ctrl | A | S | D | F | G | F1 | | F2 | 4 | 5 | 6 | - | / | Enter |
|
||||
|-------+-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------+-------|
|
||||
| Shift | Z | X | C | V | B | F2 | | Home | 1 | 2 | 3 | + | * | Shift |
|
||||
|-------+-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------+-------|
|
||||
| Del | GUI | Alt | Esc | LOWER | Space | Enter | | End | 0 | RAISE | Left | Down | Up | Right |
|
||||
`-------------------------------------------------------' `-------------------------------------------------------'
|
||||
````
|
||||
|
||||
## Notes
|
||||
|
||||
Supports RGB Underglow and Dynamic Macros.
|
||||
Supports RGB Underglow color sync to layer switching.
|
||||
|
||||
49
keyboards/facew/config.h
Normal file
49
keyboards/facew/config.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef FACEW_CONFIG_H
|
||||
#define FACEW_CONFIG_H
|
||||
|
||||
#include "config_common.h"
|
||||
|
||||
#define VENDOR_ID 0x20A0
|
||||
#define PRODUCT_ID 0x422D
|
||||
#define MANUFACTURER NotActuallyWinkeyless
|
||||
#define PRODUCT facew
|
||||
|
||||
#define RGBLED_NUM 16
|
||||
|
||||
#define MATRIX_ROWS 8
|
||||
#define MATRIX_COLS 11
|
||||
|
||||
#define MATRIX_ROW_PINS { B0, B1, B2, B3, B4, B5, B6, B7 }
|
||||
#define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6}
|
||||
#define UNUSED_PINS
|
||||
|
||||
#define DIODE_DIRECTION COL2ROW
|
||||
#define DEBOUNCING_DELAY 5
|
||||
|
||||
#define NO_BACKLIGHT_CLOCK
|
||||
#define BACKLIGHT_LEVELS 1
|
||||
#define RGBLIGHT_ANIMATIONS
|
||||
|
||||
#define NO_UART 1
|
||||
|
||||
/* key combination for command */
|
||||
#define IS_COMMAND() (keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)))
|
||||
|
||||
#endif
|
||||
66
keyboards/facew/facew.c
Normal file
66
keyboards/facew/facew.c
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "facew.h"
|
||||
#ifdef BACKLIGHT_ENABLE
|
||||
#include "backlight.h"
|
||||
#endif
|
||||
#ifdef RGBLIGHT_ENABLE
|
||||
#include "rgblight.h"
|
||||
#endif
|
||||
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
#include "action_layer.h"
|
||||
#include "i2c.h"
|
||||
#include "quantum.h"
|
||||
|
||||
#ifdef RGBLIGHT_ENABLE
|
||||
extern rgblight_config_t rgblight_config;
|
||||
|
||||
void rgblight_set(void) {
|
||||
if (!rgblight_config.enable) {
|
||||
for (uint8_t i = 0; i < RGBLED_NUM; i++) {
|
||||
led[i].r = 0;
|
||||
led[i].g = 0;
|
||||
led[i].b = 0;
|
||||
}
|
||||
}
|
||||
|
||||
i2c_init();
|
||||
i2c_send(0xb0, (uint8_t*)led, 3 * RGBLED_NUM);
|
||||
}
|
||||
#endif
|
||||
|
||||
__attribute__ ((weak))
|
||||
void matrix_scan_user(void) {
|
||||
}
|
||||
|
||||
void backlight_init_ports(void) {
|
||||
DDRD |= (1<<0 | 1<<1 | 1<<4 | 1<<6);
|
||||
PORTD &= ~(1<<0 | 1<<1 | 1<<4 | 1<<6);
|
||||
}
|
||||
|
||||
void backlight_set(uint8_t level) {
|
||||
if (level == 0) {
|
||||
// Turn out the lights
|
||||
PORTD &= ~(1<<0 | 1<<1 | 1<<4 | 1<<6);
|
||||
} else {
|
||||
// Turn on the lights
|
||||
PORTD |= (1<<0 | 1<<1 | 1<<4 | 1<<6);
|
||||
}
|
||||
}
|
||||
57
keyboards/facew/facew.h
Normal file
57
keyboards/facew/facew.h
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef FACEW_H
|
||||
#define FACEW_H
|
||||
|
||||
#include "quantum.h"
|
||||
|
||||
#define LAYOUT_all( \
|
||||
K61, K71, K72, K73, K74, K64, K65, K75, K76, K77, K78, K68, K66, K10, K60,\
|
||||
K11, K01, K02, K03, K04, K14, K15, K05, K06, K07, K08, K18, K16, K20, \
|
||||
K12, K21, K22, K23, K24, K34, K35, K25, K26, K27, K28, K38, K40, \
|
||||
K19, K13, K41, K42, K43, K44, K54, K55, K45, K46, K47, K58, K49, K50,\
|
||||
K09, K00, K39, K30, K59, K69, K57, K29\
|
||||
){ \
|
||||
{ KC_NO, K01, K02, K03, K04, K05, K06, K07, K08, K09, K00}, \
|
||||
{ KC_NO, K11, K12, K13, K14, K15, K16, KC_NO, K18, K19, K10}, \
|
||||
{ KC_NO, K21, K22, K23, K24, K25, K26, K27, K28, K29, K20}, \
|
||||
{ KC_NO, KC_NO, KC_NO, KC_NO, K34, K35, KC_NO, KC_NO, K38, K39, K30}, \
|
||||
{ KC_NO, K41, K42, K43, K44, K45, K46, K47, KC_NO, K49, K40}, \
|
||||
{ KC_NO, KC_NO, KC_NO, KC_NO, K54, K55, KC_NO, K57, K58, K59, K50}, \
|
||||
{ KC_NO, K61, KC_NO, KC_NO, K64, K65, K66, KC_NO, K68, K69, K60}, \
|
||||
{ KC_NO, K71, K72, K73, K74, K75, K76, K77, K78, KC_NO, KC_NO}, \
|
||||
}
|
||||
|
||||
#define LAYOUT_60_ansi( \
|
||||
K61, K71, K72, K73, K74, K64, K65, K75, K76, K77, K78, K68, K66, K60,\
|
||||
K11, K01, K02, K03, K04, K14, K15, K05, K06, K07, K08, K18, K16, K20, \
|
||||
K12, K21, K22, K23, K24, K34, K35, K25, K26, K27, K28, K38, K40, \
|
||||
K19, K41, K42, K43, K44, K54, K55, K45, K46, K47, K58, K49, \
|
||||
K09, K00, K39, K30, K59, K69, K57, K29\
|
||||
){ \
|
||||
{ KC_NO, K01, K02, K03, K04, K05, K06, K07, K08, K09, K00}, \
|
||||
{ KC_NO, K11, K12, KC_NO, K14, K15, K16, KC_NO, K18, K19, KC_NO}, \
|
||||
{ KC_NO, K21, K22, K23, K24, K25, K26, K27, K28, K29, K20}, \
|
||||
{ KC_NO, KC_NO, KC_NO, KC_NO, K34, K35, KC_NO, KC_NO, K38, K39, K30}, \
|
||||
{ KC_NO, K41, K42, K43, K44, K45, K46, K47, KC_NO, K49, K40}, \
|
||||
{ KC_NO, KC_NO, KC_NO, KC_NO, K54, K55, KC_NO, K57, K58, K59, KC_NO}, \
|
||||
{ KC_NO, K61, KC_NO, KC_NO, K64, K65, K66, KC_NO, K68, K69, K60}, \
|
||||
{ KC_NO, K71, K72, K73, K74, K75, K76, K77, K78, KC_NO, KC_NO}, \
|
||||
}
|
||||
|
||||
#endif
|
||||
106
keyboards/facew/i2c.c
Normal file
106
keyboards/facew/i2c.c
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
Copyright 2016 Luiz Ribeiro <luizribeiro@gmail.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// Please do not modify this file
|
||||
|
||||
#include <avr/io.h>
|
||||
#include <util/twi.h>
|
||||
|
||||
#include "i2c.h"
|
||||
|
||||
void i2c_set_bitrate(uint16_t bitrate_khz) {
|
||||
uint8_t bitrate_div = ((F_CPU / 1000l) / bitrate_khz);
|
||||
if (bitrate_div >= 16) {
|
||||
bitrate_div = (bitrate_div - 16) / 2;
|
||||
}
|
||||
TWBR = bitrate_div;
|
||||
}
|
||||
|
||||
void i2c_init(void) {
|
||||
// set pull-up resistors on I2C bus pins
|
||||
PORTC |= 0b11;
|
||||
|
||||
i2c_set_bitrate(400);
|
||||
|
||||
// enable TWI (two-wire interface)
|
||||
TWCR |= (1 << TWEN);
|
||||
|
||||
// enable TWI interrupt and slave address ACK
|
||||
TWCR |= (1 << TWIE);
|
||||
TWCR |= (1 << TWEA);
|
||||
}
|
||||
|
||||
uint8_t i2c_start(uint8_t address) {
|
||||
// reset TWI control register
|
||||
TWCR = 0;
|
||||
|
||||
// begin transmission and wait for it to end
|
||||
TWCR = (1<<TWINT) | (1<<TWSTA) | (1<<TWEN);
|
||||
while (!(TWCR & (1<<TWINT)));
|
||||
|
||||
// check if the start condition was successfully transmitted
|
||||
if ((TWSR & 0xF8) != TW_START) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// transmit address and wait
|
||||
TWDR = address;
|
||||
TWCR = (1<<TWINT) | (1<<TWEN);
|
||||
while (!(TWCR & (1<<TWINT)));
|
||||
|
||||
// check if the device has acknowledged the READ / WRITE mode
|
||||
uint8_t twst = TW_STATUS & 0xF8;
|
||||
if ((twst != TW_MT_SLA_ACK) && (twst != TW_MR_SLA_ACK)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void i2c_stop(void) {
|
||||
TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTO);
|
||||
}
|
||||
|
||||
uint8_t i2c_write(uint8_t data) {
|
||||
TWDR = data;
|
||||
|
||||
// transmit data and wait
|
||||
TWCR = (1<<TWINT) | (1<<TWEN);
|
||||
while (!(TWCR & (1<<TWINT)));
|
||||
|
||||
if ((TWSR & 0xF8) != TW_MT_DATA_ACK) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t i2c_send(uint8_t address, uint8_t *data, uint16_t length) {
|
||||
if (i2c_start(address)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (uint16_t i = 0; i < length; i++) {
|
||||
if (i2c_write(data[i])) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
i2c_stop();
|
||||
|
||||
return 0;
|
||||
}
|
||||
27
keyboards/facew/i2c.h
Normal file
27
keyboards/facew/i2c.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
Copyright 2016 Luiz Ribeiro <luizribeiro@gmail.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// Please do not modify this file
|
||||
|
||||
#ifndef __I2C_H__
|
||||
#define __I2C_H__
|
||||
|
||||
void i2c_init(void);
|
||||
void i2c_set_bitrate(uint16_t bitrate_khz);
|
||||
uint8_t i2c_send(uint8_t address, uint8_t *data, uint16_t length);
|
||||
|
||||
#endif
|
||||
16
keyboards/facew/info.json
Normal file
16
keyboards/facew/info.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"keyboard_name": "FaceW",
|
||||
"url": "",
|
||||
"maintainer": "qmk",
|
||||
"width": 15,
|
||||
"height": 5,
|
||||
"layouts": {
|
||||
"LAYOUT_all": {
|
||||
"layout": [{"label":"~", "x":0, "y":0}, {"label":"!", "x":1, "y":0}, {"label":"@", "x":2, "y":0}, {"label":"#", "x":3, "y":0}, {"label":"$", "x":4, "y":0}, {"label":"%", "x":5, "y":0}, {"label":"^", "x":6, "y":0}, {"label":"&", "x":7, "y":0}, {"label":"*", "x":8, "y":0}, {"label":"(", "x":9, "y":0}, {"label":")", "x":10, "y":0}, {"label":"_", "x":11, "y":0}, {"label":"+", "x":12, "y":0}, {"x":13, "y":0}, {"x":14, "y":0}, {"label":"Tab", "x":0, "y":1, "w":1.5}, {"label":"Q", "x":1.5, "y":1}, {"label":"W", "x":2.5, "y":1}, {"label":"E", "x":3.5, "y":1}, {"label":"R", "x":4.5, "y":1}, {"label":"T", "x":5.5, "y":1}, {"label":"Y", "x":6.5, "y":1}, {"label":"U", "x":7.5, "y":1}, {"label":"I", "x":8.5, "y":1}, {"label":"O", "x":9.5, "y":1}, {"label":"P", "x":10.5, "y":1}, {"label":"{", "x":11.5, "y":1}, {"label":"}", "x":12.5, "y":1}, {"label":"|", "x":13.5, "y":1, "w":1.5}, {"label":"Caps Lock", "x":0, "y":2, "w":1.75}, {"label":"A", "x":1.75, "y":2}, {"label":"S", "x":2.75, "y":2}, {"label":"D", "x":3.75, "y":2}, {"label":"F", "x":4.75, "y":2}, {"label":"G", "x":5.75, "y":2}, {"label":"H", "x":6.75, "y":2}, {"label":"J", "x":7.75, "y":2}, {"label":"K", "x":8.75, "y":2}, {"label":"L", "x":9.75, "y":2}, {"label":":", "x":10.75, "y":2}, {"label":"\"", "x":11.75, "y":2}, {"label":"Enter", "x":12.75, "y":2, "w":2.25}, {"label":"Shift", "x":0, "y":3, "w":1.25}, {"x":1.25, "y":3}, {"label":"Z", "x":2.25, "y":3}, {"label":"X", "x":3.25, "y":3}, {"label":"C", "x":4.25, "y":3}, {"label":"V", "x":5.25, "y":3}, {"label":"B", "x":6.25, "y":3}, {"label":"N", "x":7.25, "y":3}, {"label":"M", "x":8.25, "y":3}, {"label":"<", "x":9.25, "y":3}, {"label":">", "x":10.25, "y":3}, {"label":"?", "x":11.25, "y":3}, {"label":"Shift", "x":12.25, "y":3, "w":1.75}, {"x":14, "y":3}, {"label":"Ctrl", "x":0, "y":4, "w":1.25}, {"label":"Win", "x":1.25, "y":4, "w":1.25}, {"label":"Alt", "x":2.5, "y":4, "w":1.25}, {"x":3.75, "y":4, "w":6.25}, {"label":"Alt", "x":10, "y":4, "w":1.25}, {"label":"Win", "x":11.25, "y":4, "w":1.25}, {"label":"Menu", "x":12.5, "y":4, "w":1.25}, {"label":"Ctrl", "x":13.75, "y":4, "w":1.25}]
|
||||
},
|
||||
|
||||
"LAYOUT_60_ansi": {
|
||||
"layout": [{"label":"~", "x":0, "y":0}, {"label":"!", "x":1, "y":0}, {"label":"@", "x":2, "y":0}, {"label":"#", "x":3, "y":0}, {"label":"$", "x":4, "y":0}, {"label":"%", "x":5, "y":0}, {"label":"^", "x":6, "y":0}, {"label":"&", "x":7, "y":0}, {"label":"*", "x":8, "y":0}, {"label":"(", "x":9, "y":0}, {"label":")", "x":10, "y":0}, {"label":"_", "x":11, "y":0}, {"label":"+", "x":12, "y":0}, {"label":"Backspace", "x":13, "y":0, "w":2}, {"label":"Tab", "x":0, "y":1, "w":1.5}, {"label":"Q", "x":1.5, "y":1}, {"label":"W", "x":2.5, "y":1}, {"label":"E", "x":3.5, "y":1}, {"label":"R", "x":4.5, "y":1}, {"label":"T", "x":5.5, "y":1}, {"label":"Y", "x":6.5, "y":1}, {"label":"U", "x":7.5, "y":1}, {"label":"I", "x":8.5, "y":1}, {"label":"O", "x":9.5, "y":1}, {"label":"P", "x":10.5, "y":1}, {"label":"{", "x":11.5, "y":1}, {"label":"}", "x":12.5, "y":1}, {"label":"|", "x":13.5, "y":1, "w":1.5}, {"label":"Caps Lock", "x":0, "y":2, "w":1.75}, {"label":"A", "x":1.75, "y":2}, {"label":"S", "x":2.75, "y":2}, {"label":"D", "x":3.75, "y":2}, {"label":"F", "x":4.75, "y":2}, {"label":"G", "x":5.75, "y":2}, {"label":"H", "x":6.75, "y":2}, {"label":"J", "x":7.75, "y":2}, {"label":"K", "x":8.75, "y":2}, {"label":"L", "x":9.75, "y":2}, {"label":":", "x":10.75, "y":2}, {"label":"\"", "x":11.75, "y":2}, {"label":"Enter", "x":12.75, "y":2, "w":2.25}, {"label":"Shift", "x":0, "y":3, "w":2.25}, {"label":"Z", "x":2.25, "y":3}, {"label":"X", "x":3.25, "y":3}, {"label":"C", "x":4.25, "y":3}, {"label":"V", "x":5.25, "y":3}, {"label":"B", "x":6.25, "y":3}, {"label":"N", "x":7.25, "y":3}, {"label":"M", "x":8.25, "y":3}, {"label":"<", "x":9.25, "y":3}, {"label":">", "x":10.25, "y":3}, {"label":"?", "x":11.25, "y":3}, {"label":"Shift", "x":12.25, "y":3, "w":2.75}, {"label":"Ctrl", "x":0, "y":4, "w":1.25}, {"label":"Win", "x":1.25, "y":4, "w":1.25}, {"label":"Alt", "x":2.5, "y":4, "w":1.25}, {"x":3.75, "y":4, "w":6.25}, {"label":"Alt", "x":10, "y":4, "w":1.25}, {"label":"Win", "x":11.25, "y":4, "w":1.25}, {"label":"Menu", "x":12.5, "y":4, "w":1.25}, {"label":"Ctrl", "x":13.75, "y":4, "w":1.25}]
|
||||
}
|
||||
}
|
||||
}
|
||||
43
keyboards/facew/keymaps/default/keymap.c
Normal file
43
keyboards/facew/keymaps/default/keymap.c
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include QMK_KEYBOARD_H
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
[0] = LAYOUT_all(
|
||||
KC_GESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSLS, KC_GRV,
|
||||
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSPC,
|
||||
MO(1), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT,
|
||||
KC_LSFT, KC_NO, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, MO(1),
|
||||
KC_LCTL, KC_LGUI, KC_LALT, KC_SPACE, KC_RALT, KC_RGUI, KC_MENU, KC_RCTL
|
||||
),
|
||||
[1] = LAYOUT_all(
|
||||
KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_TRNS, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_HOME, KC_END, KC_DEL,
|
||||
MO(1), KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_LEFT, KC_DOWN, KC_UP, KC_RIGHT, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGUP, KC_PGDN, KC_TRNS, KC_TRNS, MO(2),
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS
|
||||
),
|
||||
[2] = LAYOUT_all(
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RESET,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
MO(1), KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS
|
||||
),
|
||||
};
|
||||
|
||||
51
keyboards/facew/keymaps/mechmerlin/keymap.c
Normal file
51
keyboards/facew/keymaps/mechmerlin/keymap.c
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include QMK_KEYBOARD_H
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
[0] = LAYOUT_all(
|
||||
KC_GESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_NO, KC_BSPC,
|
||||
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS,
|
||||
KC_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT,
|
||||
KC_LSFT, KC_NO, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, TG(2),
|
||||
KC_LCTL, KC_LGUI, KC_LALT, KC_SPACE, MO(1), KC_RALT, KC_RGUI, KC_RCTL
|
||||
),
|
||||
[1] = LAYOUT_all(
|
||||
KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_NO, KC_DEL,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
KC_CAPS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
MO(3), KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MUTE, KC_VOLD, KC_VOLU, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS
|
||||
),
|
||||
[2] = LAYOUT_all(
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_UP, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_LEFT, KC_DOWN, KC_RIGHT
|
||||
),
|
||||
|
||||
[3] = LAYOUT_all(
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RESET, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS
|
||||
),
|
||||
};
|
||||
|
||||
18
keyboards/facew/keymaps/mechmerlin/readme.md
Normal file
18
keyboards/facew/keymaps/mechmerlin/readme.md
Normal file
@@ -0,0 +1,18 @@
|
||||
MechMerlin's FaceW Sprit Edition Layout
|
||||
======================
|
||||
|
||||
This is the preferred 60% layout used by u/merlin36, host of the [MechMerlin YouTube channel](www.youtube.com/mechmerlin).
|
||||
|
||||
## Keyboard Notes
|
||||
- The FaceW Sprit Edition can be purchased on [mechanicalkeyboards.com](www.mechanicalkeyboards.com)
|
||||
- Uses ps2avru instead of ps2avrgb
|
||||
- To put in reset mode hold `q` while inserting the USB cable
|
||||
- Use flashing instructions from ps2avrgb QMK port
|
||||
|
||||
## Keymap Notes
|
||||
- Does not support any form of inswitch lighting as Merlin hates them.
|
||||
- Arrow toggle switch to the right of right shift
|
||||
- Reset is FN + Left Shift + R
|
||||
|
||||
### Build
|
||||
To build this keymap, simply run `make facew:mechmerlin` from the qmk_firmware directory.
|
||||
106
keyboards/facew/matrix.c
Normal file
106
keyboards/facew/matrix.c
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <avr/io.h>
|
||||
#include <util/delay.h>
|
||||
|
||||
#include "matrix.h"
|
||||
|
||||
#ifndef DEBOUNCE
|
||||
#define DEBOUNCE 5
|
||||
#endif
|
||||
|
||||
static uint8_t debouncing = DEBOUNCE;
|
||||
|
||||
static matrix_row_t matrix[MATRIX_ROWS];
|
||||
static matrix_row_t matrix_debouncing[MATRIX_ROWS];
|
||||
|
||||
void matrix_init(void) {
|
||||
// all outputs for rows high
|
||||
DDRB = 0xFF;
|
||||
PORTB = 0xFF;
|
||||
// all inputs for columns
|
||||
DDRA = 0x00;
|
||||
DDRC &= ~(0x111111<<2);
|
||||
DDRD &= ~(1<<PIND7);
|
||||
// all columns are pulled-up
|
||||
PORTA = 0xFF;
|
||||
PORTC |= (0b111111<<2);
|
||||
PORTD |= (1<<PIND7);
|
||||
|
||||
// initialize matrix state: all keys off
|
||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
||||
matrix[row] = 0x00;
|
||||
matrix_debouncing[row] = 0x00;
|
||||
}
|
||||
}
|
||||
|
||||
void matrix_set_row_status(uint8_t row) {
|
||||
DDRB = (1 << row);
|
||||
PORTB = ~(1 << row);
|
||||
}
|
||||
|
||||
uint8_t bit_reverse(uint8_t x) {
|
||||
x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa);
|
||||
x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc);
|
||||
x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0);
|
||||
return x;
|
||||
}
|
||||
|
||||
uint8_t matrix_scan(void) {
|
||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
||||
matrix_set_row_status(row);
|
||||
_delay_us(5);
|
||||
|
||||
matrix_row_t cols = (
|
||||
// cols 0..7, PORTA 0 -> 7
|
||||
(~PINA) & 0xFF
|
||||
) | (
|
||||
// cols 8..13, PORTC 7 -> 0
|
||||
bit_reverse((~PINC) & 0xFF) << 8
|
||||
) | (
|
||||
// col 14, PORTD 7
|
||||
((~PIND) & (1 << PIND7)) << 7
|
||||
);
|
||||
|
||||
if (matrix_debouncing[row] != cols) {
|
||||
matrix_debouncing[row] = cols;
|
||||
debouncing = DEBOUNCE;
|
||||
}
|
||||
}
|
||||
|
||||
if (debouncing) {
|
||||
if (--debouncing) {
|
||||
_delay_ms(1);
|
||||
} else {
|
||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
||||
matrix[i] = matrix_debouncing[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
matrix_scan_user();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline matrix_row_t matrix_get_row(uint8_t row) {
|
||||
return matrix[row];
|
||||
}
|
||||
|
||||
void matrix_print(void) {
|
||||
}
|
||||
24
keyboards/facew/readme.md
Normal file
24
keyboards/facew/readme.md
Normal file
@@ -0,0 +1,24 @@
|
||||
# FaceW
|
||||
|
||||
A 60% no frills keyboard.
|
||||
|
||||
The FaceW is a special run of the WKL B.Face sourced from Sprit that doesn't have underglow RGB LEDs
|
||||
but does have in switch LEDs. Also unlike the B.Face, it is based on ps2avru instead of ps2avrGB. It
|
||||
is designed and manufactured in Korea. It originally uses BootMapperClient for programming but
|
||||
can now also use QMK.
|
||||
|
||||
Keyboard Maintainer: [MechMerlin](www.github.com/mechmerlin)
|
||||
Hardware Supported: FaceW Sprit Edition PCB
|
||||
Hardware Availability: https://mechanicalkeyboards.com/shop/index.php?l=product_detail&p=1352
|
||||
|
||||
## Keyboard Notes
|
||||
- The FaceW Sprit Edition can be purchased on [mechanicalkeyboards.com](www.mechanicalkeyboards.com)
|
||||
- Uses ps2avru instead of ps2avrgb
|
||||
- To put in reset mode hold `q` while inserting the USB cable
|
||||
- When flashing, type `bootloadHID -r yourfile.hex` and wait awhile
|
||||
|
||||
Make example for this keyboard (after setting up your build environment):
|
||||
|
||||
make facew:default
|
||||
|
||||
See [build environment setup](https://docs.qmk.fm/build_environment_setup.html) then the [make instructions](https://docs.qmk.fm/make_instructions.html) for more information.
|
||||
52
keyboards/facew/rules.mk
Normal file
52
keyboards/facew/rules.mk
Normal file
@@ -0,0 +1,52 @@
|
||||
# Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
# MCU name
|
||||
MCU = atmega32a
|
||||
PROTOCOL = VUSB
|
||||
|
||||
# unsupported features for now
|
||||
NO_UART = yes
|
||||
NO_SUSPEND_POWER_DOWN = yes
|
||||
|
||||
# processor frequency
|
||||
F_CPU = 12000000
|
||||
|
||||
# Bootloader
|
||||
# This definition is optional, and if your keyboard supports multiple bootloaders of
|
||||
# different sizes, comment this out, and the correct address will be loaded
|
||||
# automatically (+60). See bootloader.mk for all options.
|
||||
BOOTLOADER = bootloadHID
|
||||
|
||||
# build options
|
||||
BOOTMAGIC_ENABLE = yes
|
||||
MOUSEKEY_ENABLE = yes
|
||||
EXTRAKEY_ENABLE = yes
|
||||
CONSOLE_ENABLE = yes
|
||||
COMMAND_ENABLE = yes
|
||||
BACKLIGHT_ENABLE = no
|
||||
RGBLIGHT_ENABLE = no
|
||||
RGBLIGHT_CUSTOM_DRIVER = yes
|
||||
|
||||
OPT_DEFS = -DDEBUG_LEVEL=0
|
||||
|
||||
# custom matrix setup
|
||||
CUSTOM_MATRIX = yes
|
||||
SRC = matrix.c i2c.c
|
||||
|
||||
# programming options
|
||||
PROGRAM_CMD = ./util/atmega32a_program.py $(TARGET).hex
|
||||
|
||||
LAYOUTS = 60_ansi
|
||||
396
keyboards/facew/usbconfig.h
Normal file
396
keyboards/facew/usbconfig.h
Normal file
@@ -0,0 +1,396 @@
|
||||
/* Name: usbconfig.h
|
||||
* Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers
|
||||
* Author: Christian Starkjohann
|
||||
* Creation Date: 2005-04-01
|
||||
* Tabsize: 4
|
||||
* Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH
|
||||
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
|
||||
* This Revision: $Id: usbconfig-prototype.h 785 2010-05-30 17:57:07Z cs $
|
||||
*/
|
||||
|
||||
#ifndef __usbconfig_h_included__
|
||||
#define __usbconfig_h_included__
|
||||
|
||||
#include "config.h"
|
||||
|
||||
/*
|
||||
General Description:
|
||||
This file is an example configuration (with inline documentation) for the USB
|
||||
driver. It configures V-USB for USB D+ connected to Port D bit 2 (which is
|
||||
also hardware interrupt 0 on many devices) and USB D- to Port D bit 4. You may
|
||||
wire the lines to any other port, as long as D+ is also wired to INT0 (or any
|
||||
other hardware interrupt, as long as it is the highest level interrupt, see
|
||||
section at the end of this file).
|
||||
*/
|
||||
|
||||
/* ---------------------------- Hardware Config ---------------------------- */
|
||||
|
||||
#define USB_CFG_IOPORTNAME D
|
||||
/* This is the port where the USB bus is connected. When you configure it to
|
||||
* "B", the registers PORTB, PINB and DDRB will be used.
|
||||
*/
|
||||
#define USB_CFG_DMINUS_BIT 3
|
||||
/* This is the bit number in USB_CFG_IOPORT where the USB D- line is connected.
|
||||
* This may be any bit in the port.
|
||||
*/
|
||||
#define USB_CFG_DPLUS_BIT 2
|
||||
/* This is the bit number in USB_CFG_IOPORT where the USB D+ line is connected.
|
||||
* This may be any bit in the port. Please note that D+ must also be connected
|
||||
* to interrupt pin INT0! [You can also use other interrupts, see section
|
||||
* "Optional MCU Description" below, or you can connect D- to the interrupt, as
|
||||
* it is required if you use the USB_COUNT_SOF feature. If you use D- for the
|
||||
* interrupt, the USB interrupt will also be triggered at Start-Of-Frame
|
||||
* markers every millisecond.]
|
||||
*/
|
||||
#define USB_CFG_CLOCK_KHZ (F_CPU/1000)
|
||||
/* Clock rate of the AVR in kHz. Legal values are 12000, 12800, 15000, 16000,
|
||||
* 16500, 18000 and 20000. The 12.8 MHz and 16.5 MHz versions of the code
|
||||
* require no crystal, they tolerate +/- 1% deviation from the nominal
|
||||
* frequency. All other rates require a precision of 2000 ppm and thus a
|
||||
* crystal!
|
||||
* Since F_CPU should be defined to your actual clock rate anyway, you should
|
||||
* not need to modify this setting.
|
||||
*/
|
||||
#define USB_CFG_CHECK_CRC 0
|
||||
/* Define this to 1 if you want that the driver checks integrity of incoming
|
||||
* data packets (CRC checks). CRC checks cost quite a bit of code size and are
|
||||
* currently only available for 18 MHz crystal clock. You must choose
|
||||
* USB_CFG_CLOCK_KHZ = 18000 if you enable this option.
|
||||
*/
|
||||
|
||||
/* ----------------------- Optional Hardware Config ------------------------ */
|
||||
|
||||
/* #define USB_CFG_PULLUP_IOPORTNAME D */
|
||||
/* If you connect the 1.5k pullup resistor from D- to a port pin instead of
|
||||
* V+, you can connect and disconnect the device from firmware by calling
|
||||
* the macros usbDeviceConnect() and usbDeviceDisconnect() (see usbdrv.h).
|
||||
* This constant defines the port on which the pullup resistor is connected.
|
||||
*/
|
||||
/* #define USB_CFG_PULLUP_BIT 4 */
|
||||
/* This constant defines the bit number in USB_CFG_PULLUP_IOPORT (defined
|
||||
* above) where the 1.5k pullup resistor is connected. See description
|
||||
* above for details.
|
||||
*/
|
||||
|
||||
/* --------------------------- Functional Range ---------------------------- */
|
||||
|
||||
#define USB_CFG_HAVE_INTRIN_ENDPOINT 1
|
||||
/* Define this to 1 if you want to compile a version with two endpoints: The
|
||||
* default control endpoint 0 and an interrupt-in endpoint (any other endpoint
|
||||
* number).
|
||||
*/
|
||||
#define USB_CFG_HAVE_INTRIN_ENDPOINT3 1
|
||||
/* Define this to 1 if you want to compile a version with three endpoints: The
|
||||
* default control endpoint 0, an interrupt-in endpoint 3 (or the number
|
||||
* configured below) and a catch-all default interrupt-in endpoint as above.
|
||||
* You must also define USB_CFG_HAVE_INTRIN_ENDPOINT to 1 for this feature.
|
||||
*/
|
||||
#define USB_CFG_EP3_NUMBER 3
|
||||
/* If the so-called endpoint 3 is used, it can now be configured to any other
|
||||
* endpoint number (except 0) with this macro. Default if undefined is 3.
|
||||
*/
|
||||
/* #define USB_INITIAL_DATATOKEN USBPID_DATA1 */
|
||||
/* The above macro defines the startup condition for data toggling on the
|
||||
* interrupt/bulk endpoints 1 and 3. Defaults to USBPID_DATA1.
|
||||
* Since the token is toggled BEFORE sending any data, the first packet is
|
||||
* sent with the oposite value of this configuration!
|
||||
*/
|
||||
#define USB_CFG_IMPLEMENT_HALT 0
|
||||
/* Define this to 1 if you also want to implement the ENDPOINT_HALT feature
|
||||
* for endpoint 1 (interrupt endpoint). Although you may not need this feature,
|
||||
* it is required by the standard. We have made it a config option because it
|
||||
* bloats the code considerably.
|
||||
*/
|
||||
#define USB_CFG_SUPPRESS_INTR_CODE 0
|
||||
/* Define this to 1 if you want to declare interrupt-in endpoints, but don't
|
||||
* want to send any data over them. If this macro is defined to 1, functions
|
||||
* usbSetInterrupt() and usbSetInterrupt3() are omitted. This is useful if
|
||||
* you need the interrupt-in endpoints in order to comply to an interface
|
||||
* (e.g. HID), but never want to send any data. This option saves a couple
|
||||
* of bytes in flash memory and the transmit buffers in RAM.
|
||||
*/
|
||||
#define USB_CFG_INTR_POLL_INTERVAL 1
|
||||
/* If you compile a version with endpoint 1 (interrupt-in), this is the poll
|
||||
* interval. The value is in milliseconds and must not be less than 10 ms for
|
||||
* low speed devices.
|
||||
*/
|
||||
#define USB_CFG_IS_SELF_POWERED 0
|
||||
/* Define this to 1 if the device has its own power supply. Set it to 0 if the
|
||||
* device is powered from the USB bus.
|
||||
*/
|
||||
#define USB_CFG_MAX_BUS_POWER 500
|
||||
/* Set this variable to the maximum USB bus power consumption of your device.
|
||||
* The value is in milliamperes. [It will be divided by two since USB
|
||||
* communicates power requirements in units of 2 mA.]
|
||||
*/
|
||||
#define USB_CFG_IMPLEMENT_FN_WRITE 1
|
||||
/* Set this to 1 if you want usbFunctionWrite() to be called for control-out
|
||||
* transfers. Set it to 0 if you don't need it and want to save a couple of
|
||||
* bytes.
|
||||
*/
|
||||
#define USB_CFG_IMPLEMENT_FN_READ 0
|
||||
/* Set this to 1 if you need to send control replies which are generated
|
||||
* "on the fly" when usbFunctionRead() is called. If you only want to send
|
||||
* data from a static buffer, set it to 0 and return the data from
|
||||
* usbFunctionSetup(). This saves a couple of bytes.
|
||||
*/
|
||||
#define USB_CFG_IMPLEMENT_FN_WRITEOUT 0
|
||||
/* Define this to 1 if you want to use interrupt-out (or bulk out) endpoints.
|
||||
* You must implement the function usbFunctionWriteOut() which receives all
|
||||
* interrupt/bulk data sent to any endpoint other than 0. The endpoint number
|
||||
* can be found in 'usbRxToken'.
|
||||
*/
|
||||
#define USB_CFG_HAVE_FLOWCONTROL 0
|
||||
/* Define this to 1 if you want flowcontrol over USB data. See the definition
|
||||
* of the macros usbDisableAllRequests() and usbEnableAllRequests() in
|
||||
* usbdrv.h.
|
||||
*/
|
||||
#define USB_CFG_DRIVER_FLASH_PAGE 0
|
||||
/* If the device has more than 64 kBytes of flash, define this to the 64 k page
|
||||
* where the driver's constants (descriptors) are located. Or in other words:
|
||||
* Define this to 1 for boot loaders on the ATMega128.
|
||||
*/
|
||||
#define USB_CFG_LONG_TRANSFERS 0
|
||||
/* Define this to 1 if you want to send/receive blocks of more than 254 bytes
|
||||
* in a single control-in or control-out transfer. Note that the capability
|
||||
* for long transfers increases the driver size.
|
||||
*/
|
||||
/* #define USB_RX_USER_HOOK(data, len) if(usbRxToken == (uchar)USBPID_SETUP) blinkLED(); */
|
||||
/* This macro is a hook if you want to do unconventional things. If it is
|
||||
* defined, it's inserted at the beginning of received message processing.
|
||||
* If you eat the received message and don't want default processing to
|
||||
* proceed, do a return after doing your things. One possible application
|
||||
* (besides debugging) is to flash a status LED on each packet.
|
||||
*/
|
||||
/* #define USB_RESET_HOOK(resetStarts) if(!resetStarts){hadUsbReset();} */
|
||||
/* This macro is a hook if you need to know when an USB RESET occurs. It has
|
||||
* one parameter which distinguishes between the start of RESET state and its
|
||||
* end.
|
||||
*/
|
||||
/* #define USB_SET_ADDRESS_HOOK() hadAddressAssigned(); */
|
||||
/* This macro (if defined) is executed when a USB SET_ADDRESS request was
|
||||
* received.
|
||||
*/
|
||||
#define USB_COUNT_SOF 1
|
||||
/* define this macro to 1 if you need the global variable "usbSofCount" which
|
||||
* counts SOF packets. This feature requires that the hardware interrupt is
|
||||
* connected to D- instead of D+.
|
||||
*/
|
||||
/* #ifdef __ASSEMBLER__
|
||||
* macro myAssemblerMacro
|
||||
* in YL, TCNT0
|
||||
* sts timer0Snapshot, YL
|
||||
* endm
|
||||
* #endif
|
||||
* #define USB_SOF_HOOK myAssemblerMacro
|
||||
* This macro (if defined) is executed in the assembler module when a
|
||||
* Start Of Frame condition is detected. It is recommended to define it to
|
||||
* the name of an assembler macro which is defined here as well so that more
|
||||
* than one assembler instruction can be used. The macro may use the register
|
||||
* YL and modify SREG. If it lasts longer than a couple of cycles, USB messages
|
||||
* immediately after an SOF pulse may be lost and must be retried by the host.
|
||||
* What can you do with this hook? Since the SOF signal occurs exactly every
|
||||
* 1 ms (unless the host is in sleep mode), you can use it to tune OSCCAL in
|
||||
* designs running on the internal RC oscillator.
|
||||
* Please note that Start Of Frame detection works only if D- is wired to the
|
||||
* interrupt, not D+. THIS IS DIFFERENT THAN MOST EXAMPLES!
|
||||
*/
|
||||
#define USB_CFG_CHECK_DATA_TOGGLING 0
|
||||
/* define this macro to 1 if you want to filter out duplicate data packets
|
||||
* sent by the host. Duplicates occur only as a consequence of communication
|
||||
* errors, when the host does not receive an ACK. Please note that you need to
|
||||
* implement the filtering yourself in usbFunctionWriteOut() and
|
||||
* usbFunctionWrite(). Use the global usbCurrentDataToken and a static variable
|
||||
* for each control- and out-endpoint to check for duplicate packets.
|
||||
*/
|
||||
#define USB_CFG_HAVE_MEASURE_FRAME_LENGTH 0
|
||||
/* define this macro to 1 if you want the function usbMeasureFrameLength()
|
||||
* compiled in. This function can be used to calibrate the AVR's RC oscillator.
|
||||
*/
|
||||
#define USB_USE_FAST_CRC 0
|
||||
/* The assembler module has two implementations for the CRC algorithm. One is
|
||||
* faster, the other is smaller. This CRC routine is only used for transmitted
|
||||
* messages where timing is not critical. The faster routine needs 31 cycles
|
||||
* per byte while the smaller one needs 61 to 69 cycles. The faster routine
|
||||
* may be worth the 32 bytes bigger code size if you transmit lots of data and
|
||||
* run the AVR close to its limit.
|
||||
*/
|
||||
|
||||
/* -------------------------- Device Description --------------------------- */
|
||||
|
||||
#define USB_CFG_VENDOR_ID (VENDOR_ID & 0xFF), ((VENDOR_ID >> 8) & 0xFF)
|
||||
/* USB vendor ID for the device, low byte first. If you have registered your
|
||||
* own Vendor ID, define it here. Otherwise you may use one of obdev's free
|
||||
* shared VID/PID pairs. Be sure to read USB-IDs-for-free.txt for rules!
|
||||
* *** IMPORTANT NOTE ***
|
||||
* This template uses obdev's shared VID/PID pair for Vendor Class devices
|
||||
* with libusb: 0x16c0/0x5dc. Use this VID/PID pair ONLY if you understand
|
||||
* the implications!
|
||||
*/
|
||||
#define USB_CFG_DEVICE_ID (PRODUCT_ID & 0xFF), ((PRODUCT_ID >> 8) & 0xFF)
|
||||
/* This is the ID of the product, low byte first. It is interpreted in the
|
||||
* scope of the vendor ID. If you have registered your own VID with usb.org
|
||||
* or if you have licensed a PID from somebody else, define it here. Otherwise
|
||||
* you may use one of obdev's free shared VID/PID pairs. See the file
|
||||
* USB-IDs-for-free.txt for details!
|
||||
* *** IMPORTANT NOTE ***
|
||||
* This template uses obdev's shared VID/PID pair for Vendor Class devices
|
||||
* with libusb: 0x16c0/0x5dc. Use this VID/PID pair ONLY if you understand
|
||||
* the implications!
|
||||
*/
|
||||
#define USB_CFG_DEVICE_VERSION 0x00, 0x02
|
||||
/* Version number of the device: Minor number first, then major number.
|
||||
*/
|
||||
#define USB_CFG_VENDOR_NAME 'w', 'i', 'n', 'k', 'e', 'y', 'l', 'e', 's', 's', '.', 'k', 'r'
|
||||
#define USB_CFG_VENDOR_NAME_LEN 13
|
||||
/* These two values define the vendor name returned by the USB device. The name
|
||||
* must be given as a list of characters under single quotes. The characters
|
||||
* are interpreted as Unicode (UTF-16) entities.
|
||||
* If you don't want a vendor name string, undefine these macros.
|
||||
* ALWAYS define a vendor name containing your Internet domain name if you use
|
||||
* obdev's free shared VID/PID pair. See the file USB-IDs-for-free.txt for
|
||||
* details.
|
||||
*/
|
||||
#define USB_CFG_DEVICE_NAME 'p', 's', '2', 'a', 'v', 'r', 'G', 'B'
|
||||
#define USB_CFG_DEVICE_NAME_LEN 8
|
||||
/* Same as above for the device name. If you don't want a device name, undefine
|
||||
* the macros. See the file USB-IDs-for-free.txt before you assign a name if
|
||||
* you use a shared VID/PID.
|
||||
*/
|
||||
/*#define USB_CFG_SERIAL_NUMBER 'N', 'o', 'n', 'e' */
|
||||
/*#define USB_CFG_SERIAL_NUMBER_LEN 0 */
|
||||
/* Same as above for the serial number. If you don't want a serial number,
|
||||
* undefine the macros.
|
||||
* It may be useful to provide the serial number through other means than at
|
||||
* compile time. See the section about descriptor properties below for how
|
||||
* to fine tune control over USB descriptors such as the string descriptor
|
||||
* for the serial number.
|
||||
*/
|
||||
#define USB_CFG_DEVICE_CLASS 0
|
||||
#define USB_CFG_DEVICE_SUBCLASS 0
|
||||
/* See USB specification if you want to conform to an existing device class.
|
||||
* Class 0xff is "vendor specific".
|
||||
*/
|
||||
#define USB_CFG_INTERFACE_CLASS 3 /* HID */
|
||||
#define USB_CFG_INTERFACE_SUBCLASS 1 /* Boot */
|
||||
#define USB_CFG_INTERFACE_PROTOCOL 1 /* Keyboard */
|
||||
/* See USB specification if you want to conform to an existing device class or
|
||||
* protocol. The following classes must be set at interface level:
|
||||
* HID class is 3, no subclass and protocol required (but may be useful!)
|
||||
* CDC class is 2, use subclass 2 and protocol 1 for ACM
|
||||
*/
|
||||
#define USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH 0
|
||||
/* Define this to the length of the HID report descriptor, if you implement
|
||||
* an HID device. Otherwise don't define it or define it to 0.
|
||||
* If you use this define, you must add a PROGMEM character array named
|
||||
* "usbHidReportDescriptor" to your code which contains the report descriptor.
|
||||
* Don't forget to keep the array and this define in sync!
|
||||
*/
|
||||
|
||||
/* #define USB_PUBLIC static */
|
||||
/* Use the define above if you #include usbdrv.c instead of linking against it.
|
||||
* This technique saves a couple of bytes in flash memory.
|
||||
*/
|
||||
|
||||
/* ------------------- Fine Control over USB Descriptors ------------------- */
|
||||
/* If you don't want to use the driver's default USB descriptors, you can
|
||||
* provide our own. These can be provided as (1) fixed length static data in
|
||||
* flash memory, (2) fixed length static data in RAM or (3) dynamically at
|
||||
* runtime in the function usbFunctionDescriptor(). See usbdrv.h for more
|
||||
* information about this function.
|
||||
* Descriptor handling is configured through the descriptor's properties. If
|
||||
* no properties are defined or if they are 0, the default descriptor is used.
|
||||
* Possible properties are:
|
||||
* + USB_PROP_IS_DYNAMIC: The data for the descriptor should be fetched
|
||||
* at runtime via usbFunctionDescriptor(). If the usbMsgPtr mechanism is
|
||||
* used, the data is in FLASH by default. Add property USB_PROP_IS_RAM if
|
||||
* you want RAM pointers.
|
||||
* + USB_PROP_IS_RAM: The data returned by usbFunctionDescriptor() or found
|
||||
* in static memory is in RAM, not in flash memory.
|
||||
* + USB_PROP_LENGTH(len): If the data is in static memory (RAM or flash),
|
||||
* the driver must know the descriptor's length. The descriptor itself is
|
||||
* found at the address of a well known identifier (see below).
|
||||
* List of static descriptor names (must be declared PROGMEM if in flash):
|
||||
* char usbDescriptorDevice[];
|
||||
* char usbDescriptorConfiguration[];
|
||||
* char usbDescriptorHidReport[];
|
||||
* char usbDescriptorString0[];
|
||||
* int usbDescriptorStringVendor[];
|
||||
* int usbDescriptorStringDevice[];
|
||||
* int usbDescriptorStringSerialNumber[];
|
||||
* Other descriptors can't be provided statically, they must be provided
|
||||
* dynamically at runtime.
|
||||
*
|
||||
* Descriptor properties are or-ed or added together, e.g.:
|
||||
* #define USB_CFG_DESCR_PROPS_DEVICE (USB_PROP_IS_RAM | USB_PROP_LENGTH(18))
|
||||
*
|
||||
* The following descriptors are defined:
|
||||
* USB_CFG_DESCR_PROPS_DEVICE
|
||||
* USB_CFG_DESCR_PROPS_CONFIGURATION
|
||||
* USB_CFG_DESCR_PROPS_STRINGS
|
||||
* USB_CFG_DESCR_PROPS_STRING_0
|
||||
* USB_CFG_DESCR_PROPS_STRING_VENDOR
|
||||
* USB_CFG_DESCR_PROPS_STRING_PRODUCT
|
||||
* USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER
|
||||
* USB_CFG_DESCR_PROPS_HID
|
||||
* USB_CFG_DESCR_PROPS_HID_REPORT
|
||||
* USB_CFG_DESCR_PROPS_UNKNOWN (for all descriptors not handled by the driver)
|
||||
*
|
||||
* Note about string descriptors: String descriptors are not just strings, they
|
||||
* are Unicode strings prefixed with a 2 byte header. Example:
|
||||
* int serialNumberDescriptor[] = {
|
||||
* USB_STRING_DESCRIPTOR_HEADER(6),
|
||||
* 'S', 'e', 'r', 'i', 'a', 'l'
|
||||
* };
|
||||
*/
|
||||
|
||||
#define USB_CFG_DESCR_PROPS_DEVICE 0
|
||||
#define USB_CFG_DESCR_PROPS_CONFIGURATION USB_PROP_IS_DYNAMIC
|
||||
//#define USB_CFG_DESCR_PROPS_CONFIGURATION 0
|
||||
#define USB_CFG_DESCR_PROPS_STRINGS 0
|
||||
#define USB_CFG_DESCR_PROPS_STRING_0 0
|
||||
#define USB_CFG_DESCR_PROPS_STRING_VENDOR 0
|
||||
#define USB_CFG_DESCR_PROPS_STRING_PRODUCT 0
|
||||
#define USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER 0
|
||||
#define USB_CFG_DESCR_PROPS_HID USB_PROP_IS_DYNAMIC
|
||||
//#define USB_CFG_DESCR_PROPS_HID 0
|
||||
#define USB_CFG_DESCR_PROPS_HID_REPORT USB_PROP_IS_DYNAMIC
|
||||
//#define USB_CFG_DESCR_PROPS_HID_REPORT 0
|
||||
#define USB_CFG_DESCR_PROPS_UNKNOWN 0
|
||||
|
||||
#define usbMsgPtr_t unsigned short
|
||||
/* If usbMsgPtr_t is not defined, it defaults to 'uchar *'. We define it to
|
||||
* a scalar type here because gcc generates slightly shorter code for scalar
|
||||
* arithmetics than for pointer arithmetics. Remove this define for backward
|
||||
* type compatibility or define it to an 8 bit type if you use data in RAM only
|
||||
* and all RAM is below 256 bytes (tiny memory model in IAR CC).
|
||||
*/
|
||||
|
||||
/* ----------------------- Optional MCU Description ------------------------ */
|
||||
|
||||
/* The following configurations have working defaults in usbdrv.h. You
|
||||
* usually don't need to set them explicitly. Only if you want to run
|
||||
* the driver on a device which is not yet supported or with a compiler
|
||||
* which is not fully supported (such as IAR C) or if you use a differnt
|
||||
* interrupt than INT0, you may have to define some of these.
|
||||
*/
|
||||
/* #define USB_INTR_CFG MCUCR */
|
||||
/* #define USB_INTR_CFG_SET ((1 << ISC00) | (1 << ISC01)) */
|
||||
/* #define USB_INTR_CFG_CLR 0 */
|
||||
/* #define USB_INTR_ENABLE GIMSK */
|
||||
/* #define USB_INTR_ENABLE_BIT INT0 */
|
||||
/* #define USB_INTR_PENDING GIFR */
|
||||
/* #define USB_INTR_PENDING_BIT INTF0 */
|
||||
/* #define USB_INTR_VECTOR INT0_vect */
|
||||
|
||||
/* Set INT1 for D- falling edge to count SOF */
|
||||
/* #define USB_INTR_CFG EICRA */
|
||||
#define USB_INTR_CFG_SET ((1 << ISC11) | (0 << ISC10))
|
||||
/* #define USB_INTR_CFG_CLR 0 */
|
||||
/* #define USB_INTR_ENABLE EIMSK */
|
||||
#define USB_INTR_ENABLE_BIT INT1
|
||||
/* #define USB_INTR_PENDING EIFR */
|
||||
#define USB_INTR_PENDING_BIT INTF1
|
||||
#define USB_INTR_VECTOR INT1_vect
|
||||
|
||||
#endif /* __usbconfig_h_included__ */
|
||||
@@ -5,7 +5,7 @@
|
||||
"width": 14.5,
|
||||
"height": 5,
|
||||
"layouts": {
|
||||
"KEYMAP": {
|
||||
"LAYOUT": {
|
||||
"layout": [{"x":0, "y":0}, {"x":1, "y":0}, {"x":2, "y":0}, {"x":3, "y":0}, {"x":4, "y":0}, {"x":5, "y":0}, {"x":8.5, "y":0}, {"x":9.5, "y":0}, {"x":10.5, "y":0}, {"x":11.5, "y":0}, {"x":12.5, "y":0}, {"x":13.5, "y":0}, {"x":0, "y":1}, {"x":1, "y":1}, {"x":2, "y":1}, {"x":3, "y":1}, {"x":4, "y":1}, {"x":5, "y":1}, {"x":8.5, "y":1}, {"x":9.5, "y":1}, {"x":10.5, "y":1}, {"x":11.5, "y":1}, {"x":12.5, "y":1}, {"x":13.5, "y":1}, {"x":0, "y":2}, {"x":1, "y":2}, {"x":2, "y":2}, {"x":3, "y":2}, {"x":4, "y":2}, {"x":5, "y":2}, {"x":8.5, "y":2}, {"x":9.5, "y":2}, {"x":10.5, "y":2}, {"x":11.5, "y":2}, {"x":12.5, "y":2}, {"x":13.5, "y":2}, {"x":0, "y":3}, {"x":1, "y":3}, {"x":2, "y":3}, {"x":3, "y":3}, {"x":4, "y":3}, {"x":5, "y":3}, {"x":6, "y":3}, {"x":7.5, "y":3}, {"x":8.5, "y":3}, {"x":9.5, "y":3}, {"x":10.5, "y":3}, {"x":11.5, "y":3}, {"x":12.5, "y":3}, {"x":13.5, "y":3}, {"x":4, "y":4}, {"x":5, "y":4}, {"x":6, "y":4}, {"x":7.5, "y":4}, {"x":8.5, "y":4}, {"x":9.5, "y":4}]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@ enum custom_keycodes {
|
||||
ONEHANDL,
|
||||
RLAYER,
|
||||
LLAYER,
|
||||
RLOCK,
|
||||
LLOCK,
|
||||
DUAL,
|
||||
CONFIG,
|
||||
};
|
||||
@@ -44,13 +46,15 @@ enum {
|
||||
/* LAYERS */
|
||||
#define KC_LLAY LLAYER
|
||||
#define KC_RLAY RLAYER
|
||||
#define KC_RLOK RLOCK
|
||||
#define KC_LLOK LLOCK
|
||||
#define KC_QWER QWERTY
|
||||
#define KC_DVOR DVORAK
|
||||
#define KC_COLE COLEMAK
|
||||
#define KC_ONER ONEHANDR
|
||||
#define KC_ONEL ONEHANDL
|
||||
#define KC_DUAL DUAL
|
||||
#define KC_CONF OSL(_CONFIG)
|
||||
#define KC_CONF CONFIG
|
||||
|
||||
/* Custom Shortened Keys */
|
||||
#define KC_MCTB LCTL(KC_TAB)
|
||||
@@ -71,7 +75,7 @@ enum {
|
||||
#define KC_BLUP BL_INC
|
||||
#define KC_BLDN BL_DEC
|
||||
#define KC_SYSR KC_SYSREQ
|
||||
#define KC_FLASH RESET
|
||||
#define KC_REST RESET
|
||||
|
||||
/* Tap Dance */
|
||||
#define KC_LGUA TD(TD_LGUIAPP)
|
||||
@@ -82,13 +86,13 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
|
||||
[_QWERTY] = LAYOUT_kc(
|
||||
//,----+----+----+----+----+----. ,----+----+----+----+----+----.
|
||||
LEAD, 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 0 ,BSPC,
|
||||
XXXX, 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 0 ,BSPC,
|
||||
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||
TAB , Q , W , E , R , T , Y , U , I , O , P ,DEL ,
|
||||
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||
CTEC, A , S , D , F , G , H , J , K , L ,SCLN,ENT ,
|
||||
//|----+----+----+----+----+----+----. ,----|----+----+----+----+----+----|
|
||||
SHCL, Z , X , C , V , B ,XXXX, XXXX, N , M ,COMM,DOT ,SLSH,RSFT,
|
||||
SHCL, Z , X , C , V , B ,LLOK, RLOK, N , M ,COMM,DOT ,SLSH,RSFT,
|
||||
//`----+----+----+--+-+----+----+----/ \----+----+----+----+----+----+----'
|
||||
LALT,LLAY,TAB , SPC ,RLAY,LGUA
|
||||
// `----+----+----' `----+----+----'
|
||||
@@ -96,13 +100,13 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
|
||||
[_COLEMAK] = LAYOUT_kc(
|
||||
//,----+----+----+----+----+----. ,----+----+----+----+----+----.
|
||||
LEAD, 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 0 ,BSPC,
|
||||
XXXX, 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 0 ,BSPC,
|
||||
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||
TAB , Q , W , F , P , G , J , L , U , Y ,SCLN,DEL ,
|
||||
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||
CTEC, A , R , S , T , D , H , N , E , I ,SCLN,ENT ,
|
||||
CTEC, A , R , S , T , D , H , N , E , I , O ,ENT ,
|
||||
//|----+----+----+----+----+----+----. ,----|----+----+----+----+----+----|
|
||||
SHCL, Z , X , C , V , B ,XXXX, XXXX, K , M ,COMM,DOT ,SLSH,RSFT,
|
||||
SHCL, Z , X , C , V , B ,LLOK, RLOK, K , M ,COMM,DOT ,SLSH,RSFT,
|
||||
//`----+----+----+--+-+----+----+----/ \----+----+----+----+----+----+----'
|
||||
LALT,LLAY,TAB , SPC ,RLAY,LGUA
|
||||
// `----+----+----' `----+----+----'
|
||||
@@ -110,13 +114,13 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
|
||||
[_DVORAK] = LAYOUT_kc(
|
||||
//,----+----+----+----+----+----. ,----+----+----+----+----+----.
|
||||
LEAD, 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 0 ,BSPC,
|
||||
XXXX, 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 0 ,BSPC,
|
||||
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||
TAB ,QUOT,COMM,DOT , P , Y , F , G , C , R , L ,SLSH,
|
||||
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||
CTEC, A , O , E , U , I , D , H , T , N , S ,ENT ,
|
||||
//|----+----+----+----+----+----+----. ,----|----+----+----+----+----+----|
|
||||
SHCL,SCLN, Q , J , K , X ,XXXX, XXXX, B , M , W , V , Z ,EQL ,
|
||||
SHCL,SCLN, Q , J , K , X ,LLOK, RLOK, B , M , W , V , Z ,EQL ,
|
||||
//`----+----+----+--+-+----+----+----/ \----+----+----+----+----+----+----'
|
||||
LALT,LLAY,TAB , SPC ,RLAY,LGUA
|
||||
// `----+----+----' `----+----+----'
|
||||
@@ -138,7 +142,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
|
||||
[_ONEHANDL] = LAYOUT_kc(
|
||||
//,----+----+----+----+----+----. ,----+----+----+----+----+----.
|
||||
XXXX,XXXX,XXXX,XXXX,XXXX,XXXX, 5 , 4 , 3 , 2 , 1 ,LEAD,
|
||||
XXXX,XXXX,XXXX,XXXX,XXXX,XXXX, 5 , 4 , 3 , 2 , 1 ,XXXX,
|
||||
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||
XXXX,XXXX,XXXX,XXXX,XXXX,XXXX, T , R , E , W , Q ,TAB ,
|
||||
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||
@@ -152,14 +156,14 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
|
||||
[_RLAYER] = LAYOUT_kc(
|
||||
//,----+----+----+----+----+----. ,----+----+----+----+----+----.
|
||||
,XXXX,XXXX,XXXX,XXXX,XXXX, MUTE,VOLD,VOLU,BLDN,BLUP, ,
|
||||
,SLCK,SYSR,PSCR,INS ,PAUS, MUTE,VOLD,VOLU,BLDN,BLUP, ,
|
||||
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||
,TILD,GRV ,EQL ,LBRC,RBRC, PGUP,ASTR, UP ,AMPR,CIRC, ,
|
||||
,TILD,GRV ,EQL ,LBRC,RBRC, ASTR,HOME, UP ,PGUP,PLUS, ,
|
||||
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||
,EXLM,PIPE,DLR ,LPRN,RPRN, HOME,LEFT,DOWN,RGHT,END ,QUOT,
|
||||
,EXLM,PIPE,DLR ,LPRN,RPRN, AMPR,LEFT,DOWN,RGHT,MINS,QUOT,
|
||||
//|----+----+----+----+----+----+----. ,----|----+----+----+----+----+----|
|
||||
, AT ,HASH,PERC,LCBR,RCBR,LGUI, ,PGDN,UNDS,MINS,PLUS,BSLS, ,
|
||||
//`----+----+----+--+-+----+----+----/ \----+----+----+----+----+----+----'
|
||||
, AT ,HASH,PERC,LCBR,RCBR, , ,CIRC,END ,UNDS,PGDN,BSLS, ,
|
||||
//`----+----+----+--+-+----+----+----/ \----+----+----+----+----+----+----'
|
||||
, , , , ,
|
||||
// `----+----+----' `----+----+----'
|
||||
),
|
||||
@@ -172,7 +176,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||
,XXXX,MCST,DOWN,MCTB,ENT , SLSH, 4 , 5 , 6 ,MINS, ,
|
||||
//|----+----+----+----+----+----+----. ,----|----+----+----+----+----+----|
|
||||
,XXXX,XXXX,BSPC,SPC ,SINS,F11 , F12 ,EQL , 1 , 2 , 3 ,DOT , ,
|
||||
,XXXX,XXXX,BSPC,SINS,SPC ,F11 , F12 ,EQL , 1 , 2 , 3 ,DOT , ,
|
||||
//`----+----+----+--+-+----+----+----/ \----+----+----+----+----+----+----'
|
||||
, , , 0 , ,
|
||||
// `----+----+----' `----+----+----'
|
||||
@@ -180,7 +184,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
|
||||
[_DUAL] = LAYOUT_kc(
|
||||
//,----+----+----+----+----+----. ,----+----+----+----+----+----.
|
||||
,XXXX,XXXX,PSCR,INS ,XXXX, XXXX,SLEP,SLCK,PAUS,SYSR,XXXX,
|
||||
,XXXX,XXXX,XXXX,XXXX,XXXX, XXXX,XXXX,XXXX,XXXX,XXXX,XXXX,
|
||||
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||
,XXXX,XXXX,XXXX,XXXX,XXXX, XXXX,XXXX,MS_U,XXXX,XXXX,MCAD,
|
||||
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||
@@ -194,7 +198,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
|
||||
[_CONFIG] = LAYOUT_kc(
|
||||
//,----+----+----+----+----+----. ,----+----+----+----+----+----.
|
||||
FLASH,XXXX,XXXX,XXXX,XXXX,XXXX, XXXX,XXXX,XXXX,XXXX,XXXX,XXXX,
|
||||
REST,XXXX,XXXX,XXXX,XXXX,XXXX, XXXX,XXXX,XXXX,XXXX,XXXX,XXXX,
|
||||
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||
XXXX,QWER,XXXX,XXXX,XXXX,XXXX, XXXX,XXXX,XXXX,ONER,XXXX,XXXX,
|
||||
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||
@@ -237,6 +241,11 @@ void persistent_default_layer_set(uint16_t default_layer) {
|
||||
default_layer_set(default_layer);
|
||||
}
|
||||
|
||||
/* Variables for layer light toggling */
|
||||
static uint16_t currentBL = 0;
|
||||
static uint16_t rlocked = 0;
|
||||
static uint16_t llocked = 0;
|
||||
|
||||
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
switch (keycode) {
|
||||
case QWERTY:
|
||||
@@ -263,14 +272,33 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
case CONFIG:
|
||||
if (record->event.pressed) {
|
||||
set_single_persistent_default_layer(_CONFIG);
|
||||
backlight_toggle();
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
case RLAYER:
|
||||
if (record->event.pressed) {
|
||||
layer_on(_RLAYER);
|
||||
update_tri_layer(_RLAYER, _LLAYER, _DUAL);
|
||||
/* add logic to toggle backlight change when on a layer */
|
||||
currentBL = get_backlight_level();
|
||||
if ( currentBL == 0 || currentBL == 1 ) {
|
||||
backlight_set(5);
|
||||
} else {
|
||||
backlight_set(0);
|
||||
}
|
||||
} else {
|
||||
unregister_code(KC_LGUI);
|
||||
rlocked = 0;
|
||||
layer_off(_RLAYER);
|
||||
update_tri_layer(_RLAYER, _LLAYER, _DUAL);
|
||||
if ( llocked == 0 ) {
|
||||
backlight_set(currentBL);
|
||||
} else {
|
||||
}
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
@@ -278,9 +306,51 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
if (record->event.pressed) {
|
||||
layer_on(_LLAYER);
|
||||
update_tri_layer(_RLAYER, _LLAYER, _DUAL);
|
||||
/* add logic to toggle backlight change when on a layer */
|
||||
currentBL = get_backlight_level();
|
||||
if ( currentBL == 0 || currentBL == 1 ) {
|
||||
backlight_set(5);
|
||||
} else {
|
||||
backlight_set(0);
|
||||
}
|
||||
} else {
|
||||
llocked = 0;
|
||||
layer_off(_LLAYER);
|
||||
update_tri_layer(_RLAYER, _LLAYER, _DUAL);
|
||||
if ( rlocked == 0 ) {
|
||||
backlight_set(currentBL);
|
||||
} else {
|
||||
}
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
case RLOCK:
|
||||
if (record->event.pressed) {
|
||||
layer_on(_RLAYER);
|
||||
/* add logic to toggle backlight change when on a layer */
|
||||
rlocked = 1;
|
||||
currentBL = get_backlight_level();
|
||||
if ( currentBL == 0 || currentBL == 1 ) {
|
||||
backlight_set(5);
|
||||
} else {
|
||||
backlight_set(0);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
case LLOCK:
|
||||
if (record->event.pressed) {
|
||||
layer_on(_LLAYER);
|
||||
/* add logic to toggle backlight change when on a layer */
|
||||
llocked = 1;
|
||||
currentBL = get_backlight_level();
|
||||
if ( currentBL == 0 || currentBL == 1 ) {
|
||||
backlight_set(5);
|
||||
} else {
|
||||
backlight_set(0);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
|
||||
@@ -13,6 +13,8 @@ USB report options are supported.
|
||||
Hardware Supported: JJ50 with the ATmega32a chip.
|
||||
Hardware Availability: The JJ50 PCB is available from kprepublic on AliExpress and suchlike.
|
||||
|
||||
This version by Wayne K Jones (github.com/WarmCatUK)
|
||||
|
||||
|
||||
## Installing and Building
|
||||
|
||||
@@ -70,8 +72,10 @@ And flash the compiled hex file with `HIDBootFlash`. Simply put the board in fla
|
||||
1. Try plugging the board in while pressing `Backspace` (`Key below the top right key`). This will force it to boot only the bootloader without loading the firmware. Once this is done, just reflash the board with the original firmware.
|
||||
2. Sometimes USB hubs can act weird, so try connecting the board directly to your computer or plugging/unplugging the USB hub.
|
||||
3. If you get an error such as "Resource Unavailable" when attemting to flash on Linux, you may want to compile and run `tools/usb_detach.c`. See `tools/README.md` for more info.
|
||||
4. I was occasionally finding that I wasn't flashing changes that I was making to my keymap. If that happens, simply force rebuild by making with:
|
||||
4. I was occasionally finding that I wasn't flashing changes that I was making to my keymap. If that happens, remove the previous build and simply force rebuild by making with:
|
||||
```
|
||||
$ rm jj50_default.hex
|
||||
$ make -B jj50:default
|
||||
$ make -B jj50:default:program
|
||||
```
|
||||
|
||||
|
||||
212
keyboards/jj50/backlight.c
Normal file
212
keyboards/jj50/backlight.c
Normal file
@@ -0,0 +1,212 @@
|
||||
/**
|
||||
* Backlighting code for PS2AVRGB boards (ATMEGA32A)
|
||||
* Kenneth A. (github.com/krusli | krusli.me)
|
||||
*/
|
||||
|
||||
#include "backlight.h"
|
||||
#include "quantum.h"
|
||||
|
||||
#include <avr/pgmspace.h>
|
||||
#include <avr/interrupt.h>
|
||||
|
||||
#include "backlight_custom.h"
|
||||
#include "breathing_custom.h"
|
||||
|
||||
// DEBUG
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
// Port D: digital pins of the AVR chipset
|
||||
#define NUMLOCK_PORT (1 << 1) // 1st pin of Port D (digital)
|
||||
#define CAPSLOCK_PORT (1 << 2) // 2nd pin
|
||||
#define BACKLIGHT_PORT (1 << 4) // 4th pin
|
||||
#define SCROLLLOCK_PORT (1 << 6) // 6th pin
|
||||
|
||||
#define TIMER_CLK_DIV64 0x03 ///< Timer clocked at F_CPU/64
|
||||
#define TIMER1PRESCALE TIMER_CLK_DIV64 ///< timer 1 prescaler default
|
||||
|
||||
#define TIMER_PRESCALE_MASK 0x07 ///< Timer Prescaler Bit-Mask
|
||||
|
||||
#define PWM_MAX 0xFF
|
||||
#define TIMER_TOP 255 // 8 bit PWM
|
||||
|
||||
extern backlight_config_t backlight_config;
|
||||
|
||||
/**
|
||||
* References
|
||||
* Port Registers: https://www.arduino.cc/en/Reference/PortManipulation
|
||||
* TCCR1A: https://electronics.stackexchange.com/questions/92350/what-is-the-difference-between-tccr1a-and-tccr1b
|
||||
* Timers: http://www.avrbeginners.net/architecture/timers/timers.html
|
||||
* 16-bit timer setup: http://sculland.com/ATmega168/Interrupts-And-Timers/16-Bit-Timer-Setup/
|
||||
* PS2AVRGB firmware: https://github.com/showjean/ps2avrU/tree/master/firmware
|
||||
*/
|
||||
|
||||
// @Override
|
||||
// turn LEDs on and off depending on USB caps/num/scroll lock states.
|
||||
void led_set_user(uint8_t usb_led) {
|
||||
if (usb_led & (1 << USB_LED_NUM_LOCK)) {
|
||||
// turn on
|
||||
DDRD |= NUMLOCK_PORT;
|
||||
PORTD |= NUMLOCK_PORT;
|
||||
} else {
|
||||
// turn off
|
||||
DDRD &= ~NUMLOCK_PORT;
|
||||
PORTD &= ~NUMLOCK_PORT;
|
||||
}
|
||||
|
||||
if (usb_led & (1 << USB_LED_CAPS_LOCK)) {
|
||||
DDRD |= CAPSLOCK_PORT;
|
||||
PORTD |= CAPSLOCK_PORT;
|
||||
} else {
|
||||
DDRD &= ~CAPSLOCK_PORT;
|
||||
PORTD &= ~CAPSLOCK_PORT;
|
||||
}
|
||||
|
||||
if (usb_led & (1 << USB_LED_SCROLL_LOCK)) {
|
||||
DDRD |= SCROLLLOCK_PORT;
|
||||
PORTD |= SCROLLLOCK_PORT;
|
||||
} else {
|
||||
DDRD &= ~SCROLLLOCK_PORT;
|
||||
PORTD &= ~SCROLLLOCK_PORT;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef BACKLIGHT_ENABLE
|
||||
|
||||
// sets up Timer 1 for 8-bit PWM
|
||||
void timer1PWMSetup(void) { // NOTE ONLY CALL THIS ONCE
|
||||
// default 8 bit mode
|
||||
TCCR1A &= ~(1 << 1); // cbi(TCCR1A,PWM11); <- set PWM11 bit to HIGH
|
||||
TCCR1A |= (1 << 0); // sbi(TCCR1A,PWM10); <- set PWM10 bit to LOW
|
||||
|
||||
// clear output compare value A
|
||||
// outb(OCR1AH, 0);
|
||||
// outb(OCR1AL, 0);
|
||||
|
||||
// clear output comparator registers for B
|
||||
OCR1BH = 0; // outb(OCR1BH, 0);
|
||||
OCR1BL = 0; // outb(OCR1BL, 0);
|
||||
}
|
||||
|
||||
bool is_init = false;
|
||||
void timer1Init(void) {
|
||||
// timer1SetPrescaler(TIMER1PRESCALE)
|
||||
// set to DIV/64
|
||||
(TCCR1B) = ((TCCR1B) & ~TIMER_PRESCALE_MASK) | TIMER1PRESCALE;
|
||||
|
||||
// reset TCNT1
|
||||
TCNT1H = 0; // outb(TCNT1H, 0);
|
||||
TCNT1L = 0; // outb(TCNT1L, 0);
|
||||
|
||||
// TOIE1: Timer Overflow Interrupt Enable (Timer 1);
|
||||
TIMSK |= _BV(TOIE1); // sbi(TIMSK, TOIE1);
|
||||
|
||||
is_init = true;
|
||||
}
|
||||
|
||||
void timer1UnInit(void) {
|
||||
// set prescaler back to NONE
|
||||
(TCCR1B) = ((TCCR1B) & ~TIMER_PRESCALE_MASK) | 0x00; // TIMERRTC_CLK_STOP
|
||||
|
||||
// disable timer overflow interrupt
|
||||
TIMSK &= ~_BV(TOIE1); // overflow bit?
|
||||
|
||||
setPWM(0);
|
||||
|
||||
is_init = false;
|
||||
}
|
||||
|
||||
|
||||
// handle TCNT1 overflow
|
||||
//! Interrupt handler for tcnt1 overflow interrupt
|
||||
ISR(TIMER1_OVF_vect, ISR_NOBLOCK)
|
||||
{
|
||||
// sei();
|
||||
// handle breathing here
|
||||
#ifdef BACKLIGHT_BREATHING
|
||||
if (is_breathing()) {
|
||||
custom_breathing_handler();
|
||||
}
|
||||
#endif
|
||||
|
||||
// TODO call user defined function
|
||||
}
|
||||
|
||||
// enable timer 1 PWM
|
||||
// timer1PWMBOn()
|
||||
void timer1PWMBEnable(void) {
|
||||
// turn on channel B (OC1B) PWM output
|
||||
// set OC1B as non-inverted PWM
|
||||
TCCR1A |= _BV(COM1B1);
|
||||
TCCR1A &= ~_BV(COM1B0);
|
||||
}
|
||||
|
||||
// disable timer 1 PWM
|
||||
// timer1PWMBOff()
|
||||
void timer1PWMBDisable(void) {
|
||||
TCCR1A &= ~_BV(COM1B1);
|
||||
TCCR1A &= ~_BV(COM1B0);
|
||||
}
|
||||
|
||||
void enableBacklight(void) {
|
||||
DDRD |= BACKLIGHT_PORT; // set digital pin 4 as output
|
||||
PORTD |= BACKLIGHT_PORT; // set digital pin 4 to high
|
||||
}
|
||||
|
||||
void disableBacklight(void) {
|
||||
// DDRD &= ~BACKLIGHT_PORT; // set digital pin 4 as input
|
||||
PORTD &= ~BACKLIGHT_PORT; // set digital pin 4 to low
|
||||
}
|
||||
|
||||
void startPWM(void) {
|
||||
timer1Init();
|
||||
timer1PWMBEnable();
|
||||
enableBacklight();
|
||||
}
|
||||
|
||||
void stopPWM(void) {
|
||||
timer1UnInit();
|
||||
disableBacklight();
|
||||
timer1PWMBDisable();
|
||||
}
|
||||
|
||||
void b_led_init_ports(void) {
|
||||
/* turn backlight on/off depending on user preference */
|
||||
#if BACKLIGHT_ON_STATE == 0
|
||||
// DDRx register: sets the direction of Port D
|
||||
// DDRD &= ~BACKLIGHT_PORT; // set digital pin 4 as input
|
||||
PORTD &= ~BACKLIGHT_PORT; // set digital pin 4 to low
|
||||
#else
|
||||
DDRD |= BACKLIGHT_PORT; // set digital pin 4 as output
|
||||
PORTD |= BACKLIGHT_PORT; // set digital pin 4 to high
|
||||
#endif
|
||||
|
||||
timer1PWMSetup();
|
||||
startPWM();
|
||||
|
||||
#ifdef BACKLIGHT_BREATHING
|
||||
breathing_enable();
|
||||
#endif
|
||||
}
|
||||
|
||||
void b_led_set(uint8_t level) {
|
||||
if (level > BACKLIGHT_LEVELS) {
|
||||
level = BACKLIGHT_LEVELS;
|
||||
}
|
||||
|
||||
setPWM((int)(TIMER_TOP * (float) level / BACKLIGHT_LEVELS));
|
||||
}
|
||||
|
||||
// called every matrix scan
|
||||
void b_led_task(void) {
|
||||
// do nothing for now
|
||||
}
|
||||
|
||||
void setPWM(uint16_t xValue) {
|
||||
if (xValue > TIMER_TOP) {
|
||||
xValue = TIMER_TOP;
|
||||
}
|
||||
OCR1B = xValue; // timer1PWMBSet(xValue);
|
||||
}
|
||||
|
||||
#endif // BACKLIGHT_ENABLE
|
||||
15
keyboards/jj50/backlight_custom.h
Normal file
15
keyboards/jj50/backlight_custom.h
Normal file
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* Backlighting code for PS2AVRGB boards (ATMEGA32A)
|
||||
* Kenneth A. (github.com/krusli | krusli.me)
|
||||
*/
|
||||
|
||||
#ifndef BACKLIGHT_CUSTOM_H
|
||||
#define BACKLIGHT_CUSTOM_H
|
||||
|
||||
#include <avr/pgmspace.h>
|
||||
void b_led_init_ports(void);
|
||||
void b_led_set(uint8_t level);
|
||||
void b_led_task(void);
|
||||
void setPWM(uint16_t xValue);
|
||||
|
||||
#endif // BACKLIGHT_CUSTOM_H
|
||||
140
keyboards/jj50/breathing_custom.h
Normal file
140
keyboards/jj50/breathing_custom.h
Normal file
@@ -0,0 +1,140 @@
|
||||
/**
|
||||
* Breathing effect code for PS2AVRGB boards (ATMEGA32A)
|
||||
* Works in conjunction with `backlight.c`.
|
||||
*
|
||||
* Code adapted from `quantum.c` to register with the existing TIMER1 overflow
|
||||
* handler in `backlight.c` instead of setting up its own timer.
|
||||
* Kenneth A. (github.com/krusli | krusli.me)
|
||||
*/
|
||||
|
||||
#ifdef BACKLIGHT_ENABLE
|
||||
#ifdef BACKLIGHT_BREATHING
|
||||
|
||||
#include "backlight_custom.h"
|
||||
|
||||
#ifndef BREATHING_PERIOD
|
||||
#define BREATHING_PERIOD 6
|
||||
#endif
|
||||
|
||||
#define breathing_min() do {breathing_counter = 0;} while (0)
|
||||
#define breathing_max() do {breathing_counter = breathing_period * 244 / 2;} while (0)
|
||||
|
||||
// TODO make this share code with quantum.c
|
||||
|
||||
#define BREATHING_NO_HALT 0
|
||||
#define BREATHING_HALT_OFF 1
|
||||
#define BREATHING_HALT_ON 2
|
||||
#define BREATHING_STEPS 128
|
||||
|
||||
static uint8_t breathing_period = BREATHING_PERIOD;
|
||||
static uint8_t breathing_halt = BREATHING_NO_HALT;
|
||||
static uint16_t breathing_counter = 0;
|
||||
|
||||
static bool breathing = false;
|
||||
|
||||
bool is_breathing(void) {
|
||||
return breathing;
|
||||
}
|
||||
|
||||
// See http://jared.geek.nz/2013/feb/linear-led-pwm
|
||||
static uint16_t cie_lightness(uint16_t v) {
|
||||
if (v <= 5243) // if below 8% of max
|
||||
return v / 9; // same as dividing by 900%
|
||||
else {
|
||||
uint32_t y = (((uint32_t) v + 10486) << 8) / (10486 + 0xFFFFUL); // add 16% of max and compare
|
||||
// to get a useful result with integer division, we shift left in the expression above
|
||||
// and revert what we've done again after squaring.
|
||||
y = y * y * y >> 8;
|
||||
if (y > 0xFFFFUL) // prevent overflow
|
||||
return 0xFFFFU;
|
||||
else
|
||||
return (uint16_t) y;
|
||||
}
|
||||
}
|
||||
|
||||
void breathing_enable(void) {
|
||||
breathing = true;
|
||||
breathing_counter = 0;
|
||||
breathing_halt = BREATHING_NO_HALT;
|
||||
// interrupt already registered
|
||||
}
|
||||
|
||||
void breathing_pulse(void) {
|
||||
if (get_backlight_level() == 0)
|
||||
breathing_min();
|
||||
else
|
||||
breathing_max();
|
||||
breathing_halt = BREATHING_HALT_ON;
|
||||
// breathing_interrupt_enable();
|
||||
breathing = true;
|
||||
}
|
||||
|
||||
void breathing_disable(void) {
|
||||
breathing = false;
|
||||
// backlight_set(get_backlight_level());
|
||||
b_led_set(get_backlight_level()); // custom implementation of backlight_set()
|
||||
}
|
||||
|
||||
void breathing_self_disable(void)
|
||||
{
|
||||
if (get_backlight_level() == 0)
|
||||
breathing_halt = BREATHING_HALT_OFF;
|
||||
else
|
||||
breathing_halt = BREATHING_HALT_ON;
|
||||
}
|
||||
|
||||
void breathing_toggle(void) {
|
||||
if (is_breathing())
|
||||
breathing_disable();
|
||||
else
|
||||
breathing_enable();
|
||||
}
|
||||
|
||||
void breathing_period_set(uint8_t value)
|
||||
{
|
||||
if (!value)
|
||||
value = 1;
|
||||
breathing_period = value;
|
||||
}
|
||||
|
||||
void breathing_period_default(void) {
|
||||
breathing_period_set(BREATHING_PERIOD);
|
||||
}
|
||||
|
||||
void breathing_period_inc(void)
|
||||
{
|
||||
breathing_period_set(breathing_period+1);
|
||||
}
|
||||
|
||||
void breathing_period_dec(void)
|
||||
{
|
||||
breathing_period_set(breathing_period-1);
|
||||
}
|
||||
|
||||
/* To generate breathing curve in python:
|
||||
* from math import sin, pi; [int(sin(x/128.0*pi)**4*255) for x in range(128)]
|
||||
*/
|
||||
static const uint8_t breathing_table[BREATHING_STEPS] PROGMEM = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 17, 20, 24, 28, 32, 36, 41, 46, 51, 57, 63, 70, 76, 83, 91, 98, 106, 113, 121, 129, 138, 146, 154, 162, 170, 178, 185, 193, 200, 207, 213, 220, 225, 231, 235, 240, 244, 247, 250, 252, 253, 254, 255, 254, 253, 252, 250, 247, 244, 240, 235, 231, 225, 220, 213, 207, 200, 193, 185, 178, 170, 162, 154, 146, 138, 129, 121, 113, 106, 98, 91, 83, 76, 70, 63, 57, 51, 46, 41, 36, 32, 28, 24, 20, 17, 15, 12, 10, 8, 6, 5, 4, 3, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
|
||||
// Use this before the cie_lightness function.
|
||||
static inline uint16_t scale_backlight(uint16_t v) {
|
||||
return v / BACKLIGHT_LEVELS * get_backlight_level();
|
||||
}
|
||||
|
||||
void custom_breathing_handler(void) {
|
||||
uint16_t interval = (uint16_t) breathing_period * 244 / BREATHING_STEPS;
|
||||
// resetting after one period to prevent ugly reset at overflow.
|
||||
breathing_counter = (breathing_counter + 1) % (breathing_period * 244);
|
||||
uint8_t index = breathing_counter / interval % BREATHING_STEPS;
|
||||
|
||||
if (((breathing_halt == BREATHING_HALT_ON) && (index == BREATHING_STEPS / 2)) ||
|
||||
((breathing_halt == BREATHING_HALT_OFF) && (index == BREATHING_STEPS - 1)))
|
||||
{
|
||||
// breathing_interrupt_disable();
|
||||
}
|
||||
|
||||
setPWM(cie_lightness(scale_backlight((uint16_t) pgm_read_byte(&breathing_table[index]) * 0x0101U)));
|
||||
}
|
||||
|
||||
#endif // BACKLIGHT_BREATHING
|
||||
#endif // BACKLIGHT_ENABLE
|
||||
@@ -35,11 +35,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#define MATRIX_COLS 15
|
||||
#define DIODE_DIRECTION ROW2COL
|
||||
|
||||
#define BACKLIGHT_PIN D4
|
||||
#define BACKLIGHT_LEVELS 3
|
||||
//#define BACKLIGHT_PIN D4
|
||||
#define BACKLIGHT_LEVELS 12
|
||||
|
||||
//#define RGB_DI_PIN C0
|
||||
#define RGBLED_NUM 5
|
||||
#define RGB_DI_PIN E2
|
||||
#define RGBLED_NUM 12
|
||||
#define RGBLIGHT_ANIMATIONS
|
||||
#define RGBLIGHT_HUE_STEP 12
|
||||
#define RGBLIGHT_SAT_STEP 15
|
||||
|
||||
@@ -16,7 +16,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "jj50.h"
|
||||
#include "rgblight.h"
|
||||
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
@@ -24,22 +23,72 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#include "i2c.h"
|
||||
#include "quantum.h"
|
||||
|
||||
#include "backlight.h"
|
||||
#include "backlight_custom.h"
|
||||
|
||||
// for keyboard subdirectory level init functions
|
||||
// @Override
|
||||
void matrix_init_kb(void) {
|
||||
// call user level keymaps, if any
|
||||
matrix_init_user();
|
||||
}
|
||||
|
||||
#ifdef BACKLIGHT_ENABLE
|
||||
/// Overrides functions in `quantum.c`
|
||||
void backlight_init_ports(void) {
|
||||
b_led_init_ports();
|
||||
}
|
||||
|
||||
void backlight_task(void) {
|
||||
b_led_task();
|
||||
}
|
||||
|
||||
void backlight_set(uint8_t level) {
|
||||
b_led_set(level);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef RGBLIGHT_ENABLE
|
||||
extern rgblight_config_t rgblight_config;
|
||||
|
||||
// custom RGB driver
|
||||
void rgblight_set(void) {
|
||||
if (!rgblight_config.enable) {
|
||||
for (uint8_t i = 0; i < RGBLED_NUM; i++) {
|
||||
for (uint8_t i=0; i<RGBLED_NUM; i++) {
|
||||
led[i].r = 0;
|
||||
led[i].g = 0;
|
||||
led[i].b = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
i2c_init();
|
||||
i2c_send(0xb0, (uint8_t*)led, 3 * RGBLED_NUM);
|
||||
}
|
||||
|
||||
__attribute__ ((weak))
|
||||
void matrix_scan_user(void) {
|
||||
bool rgb_init = false;
|
||||
|
||||
void matrix_scan_kb(void) {
|
||||
// if LEDs were previously on before poweroff, turn them back on
|
||||
if (rgb_init == false && rgblight_config.enable) {
|
||||
i2c_init();
|
||||
i2c_send(0xb0, (uint8_t*)led, 3 * RGBLED_NUM);
|
||||
rgb_init = true;
|
||||
}
|
||||
|
||||
rgblight_task();
|
||||
}
|
||||
#else
|
||||
void matrix_scan_kb(void) {
|
||||
#endif
|
||||
matrix_scan_user();
|
||||
/* Nothing else for now. */
|
||||
}
|
||||
|
||||
__attribute__((weak)) // overridable
|
||||
void matrix_init_user(void) {
|
||||
|
||||
}
|
||||
|
||||
__attribute__((weak)) // overridable
|
||||
void matrix_scan_user(void) {
|
||||
|
||||
}
|
||||
|
||||
@@ -20,11 +20,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#ifndef KEYMAP_COMMON_H
|
||||
#define KEYMAP_COMMON_H
|
||||
|
||||
#include "quantum.h"
|
||||
#include "quantum_keycodes.h"
|
||||
#include "keycode.h"
|
||||
#include "action.h"
|
||||
|
||||
#define KEYMAP( \
|
||||
void matrix_init_user(void);
|
||||
|
||||
#define LAYOUT( \
|
||||
K011, K010, K009, K008, K004, K005, K006, K007, K003, K002, K201, K000, \
|
||||
K111, K110, K109, K108, K104, K105, K106, K107, K103, K102, K001, K100, \
|
||||
K211, K210, K209, K208, K204, K205, K206, K207, K203, K202, K101, K200, \
|
||||
|
||||
@@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public LicensezZZ
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "jj50.h"
|
||||
#include QMK_KEYBOARD_H
|
||||
#include "action_layer.h"
|
||||
#include "rgblight.h"
|
||||
|
||||
@@ -25,9 +25,30 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#define _DEFLT 0
|
||||
#define _RAISE 1
|
||||
#define _LOWER 2
|
||||
#define _FN 3
|
||||
|
||||
enum custom_keycodes {
|
||||
P_MACRO = SAFE_RANGE
|
||||
};
|
||||
|
||||
// GBP £ Macro (sends alt 156 - windows users only)
|
||||
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
if (record->event.pressed) {
|
||||
switch(keycode) {
|
||||
case P_MACRO:
|
||||
SEND_STRING(SS_DOWN(X_LALT));
|
||||
SEND_STRING(SS_TAP(X_KP_1));
|
||||
SEND_STRING(SS_TAP(X_KP_5));
|
||||
SEND_STRING(SS_TAP(X_KP_6));
|
||||
SEND_STRING(SS_UP(X_LALT));
|
||||
return false; break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
|
||||
|
||||
/* Qwerty
|
||||
* ,-----------------------------------------------------------------------------------.
|
||||
* | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = |
|
||||
@@ -36,20 +57,19 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* | Esc | A | S | D | F | G | H | J | K | L | ; | " |
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* | Shift| Z | X | C | V | B | N | M | , | . | / |Enter |
|
||||
* | Shift| Z | X | C | V | B | N | M | , | . | / |Enter | (Hold for shift / tap for enter)
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* | | Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right |
|
||||
* | _FN | Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right |
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*/
|
||||
[_DEFLT] = KEYMAP( \
|
||||
[_DEFLT] = LAYOUT( \
|
||||
KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, \
|
||||
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, \
|
||||
KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, \
|
||||
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, SFT_T(KC_ENT),\
|
||||
BL_TOGG, KC_LCTL, KC_LALT, KC_LGUI, MO(_LOWER), KC_SPC,KC_SPC, MO(_RAISE),KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
|
||||
MO(_FN), KC_LCTL, KC_LALT, KC_LGUI, MO(_LOWER),KC_SPC,KC_SPC,MO(_RAISE),KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
|
||||
),
|
||||
|
||||
|
||||
|
||||
/* Raise
|
||||
* ,-----------------------------------------------------------------------------------.
|
||||
* | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 |
|
||||
@@ -63,15 +83,15 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
* | | | | | | | | Next | Vol- | Vol+ | Play |
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*/
|
||||
[_RAISE] = KEYMAP( \
|
||||
|
||||
[_RAISE] = LAYOUT( \
|
||||
KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, \
|
||||
KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL, \
|
||||
RESET, BL_INC, RGB_SAI, _______, _______, _______, _______, _______, _______, KC_LBRC, KC_RBRC, KC_BSLS, \
|
||||
_______, BL_DEC, _______, _______, _______, _______, _______, KC_NUHS, KC_NUBS, KC_PGUP, KC_PGDN, _______, \
|
||||
RESET, BL_INC, RGB_SAI, _______, _______, _______, _______, _______, _______, KC_LBRC, KC_RBRC, KC_BSLS, \
|
||||
_______, BL_DEC, _______, _______, _______, _______, _______, KC_NUHS, KC_NUBS, KC_PGUP, KC_PGDN, _______, \
|
||||
RGB_TOG, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
|
||||
),
|
||||
|
||||
|
||||
|
||||
/* Lower
|
||||
* ,-----------------------------------------------------------------------------------.
|
||||
* | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 |
|
||||
@@ -85,12 +105,33 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
* | | | | | | | | Next | Vol- | Vol+ | Play |
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*/
|
||||
[_LOWER] = KEYMAP( \
|
||||
|
||||
[_LOWER] = LAYOUT( \
|
||||
KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, \
|
||||
KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_DEL, \
|
||||
RESET, _______, _______, _______, _______, _______, _______, _______, _______, KC_LCBR, KC_RCBR, KC_PIPE, \
|
||||
RESET, _______, _______, _______, _______, _______, _______, _______, _______, KC_LCBR, KC_RCBR, KC_PIPE, \
|
||||
_______, _______, _______, _______, _______, _______, _______,S(KC_NUHS),S(KC_NUBS),KC_HOME, KC_END, _______, \
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
|
||||
)
|
||||
BL_STEP, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
|
||||
),
|
||||
|
||||
/* Fn
|
||||
* ,-----------------------------------------------------------------------------------.
|
||||
* | | | £ | | | | | | | | | |
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* | | | | | | | | | | | | |
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* | | | | | | | | | | | | |
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* | | | | | | | | | | | | |
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* | | | | | | | | |BL_OFF|BL_DEC|BL_INC|BL_ON |
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*/
|
||||
[_FN] = LAYOUT( \
|
||||
_______, _______, P_MACRO, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, BL_OFF, BL_DEC, BL_INC, BL_ON \
|
||||
)
|
||||
};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com>
|
||||
Modified 2018 by Wayne K Jones <github.com/WarmCatUK>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -36,17 +37,20 @@ void matrix_init(void) {
|
||||
// all inputs for columns
|
||||
DDRA = 0x00;
|
||||
DDRC &= ~(0x111111<<2);
|
||||
DDRD &= ~(1<<PIND7);
|
||||
//----> DDRD &= ~(1<<PIND7);
|
||||
// Port D not used on this keyboard
|
||||
// all columns are pulled-up
|
||||
PORTA = 0xFF;
|
||||
PORTC |= (0b111111<<2);
|
||||
//PORTD |= (1<<PIND7);
|
||||
// Port D not used on this keyboard
|
||||
|
||||
// initialize matrix state: all keys off
|
||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
||||
matrix[row] = 0x00;
|
||||
matrix_debouncing[row] = 0x00;
|
||||
}
|
||||
matrix_init_quantum(); // missing from original port by Luiz
|
||||
}
|
||||
|
||||
void matrix_set_row_status(uint8_t row) {
|
||||
@@ -72,9 +76,6 @@ uint8_t matrix_scan(void) {
|
||||
) | (
|
||||
// cols 8..13, PORTC 7 -> 0
|
||||
bit_reverse((~PINC) & 0xFF) << 8
|
||||
) | (
|
||||
// col 14, PORTD 7
|
||||
((~PIND) & (1 << PIND7)) << 7
|
||||
);
|
||||
|
||||
if (matrix_debouncing[row] != cols) {
|
||||
@@ -92,8 +93,8 @@ uint8_t matrix_scan(void) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
matrix_scan_user();
|
||||
matrix_scan_quantum(); // also missing in original PS2AVRGB implementation
|
||||
//matrix_scan_user();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -36,16 +36,30 @@ BOOTMAGIC_ENABLE = yes
|
||||
MOUSEKEY_ENABLE = no
|
||||
EXTRAKEY_ENABLE = yes
|
||||
CONSOLE_ENABLE = no
|
||||
COMMAND_ENABLE = no
|
||||
COMMAND_ENABLE = yes
|
||||
BACKLIGHT_ENABLE = yes
|
||||
RGBLIGHT_ENABLE = yes
|
||||
RGBLIGHT_CUSTOM_DRIVER = yes
|
||||
NKRO_ENABLE = no
|
||||
# Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
|
||||
|
||||
OPT_DEFS = -DDEBUG_LEVEL=0
|
||||
|
||||
DISABLE_WS2812 = no
|
||||
|
||||
KEY_LOCK_ENABLE = yes
|
||||
# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
|
||||
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
|
||||
|
||||
|
||||
#OPT_DEFS = -DDEBUG_LEVEL=0
|
||||
|
||||
# custom matrix setup
|
||||
CUSTOM_MATRIX = yes
|
||||
SRC = matrix.c i2c.c
|
||||
SRC = matrix.c i2c.c backlight.c
|
||||
|
||||
ifndef QUANTUM_DIR
|
||||
include ../../../../Makefile
|
||||
endif
|
||||
|
||||
# programming options
|
||||
PROGRAM_CMD = ./keyboards/ps2avrGB/program $(TARGET).hex
|
||||
|
||||
@@ -241,8 +241,8 @@ section at the end of this file).
|
||||
#define USB_CFG_DEVICE_VERSION 0x00, 0x02
|
||||
/* Version number of the device: Minor number first, then major number.
|
||||
*/
|
||||
#define USB_CFG_VENDOR_NAME 'w', 'i', 'n', 'k', 'e', 'y', 'l', 'e', 's', 's', '.', 'k', 'r'
|
||||
#define USB_CFG_VENDOR_NAME_LEN 13
|
||||
#define USB_CFG_VENDOR_NAME 'K', 'P', 'R', 'e', 'p', 'u', 'b', 'l', 'i', 'c'
|
||||
#define USB_CFG_VENDOR_NAME_LEN 10
|
||||
/* These two values define the vendor name returned by the USB device. The name
|
||||
* must be given as a list of characters under single quotes. The characters
|
||||
* are interpreted as Unicode (UTF-16) entities.
|
||||
@@ -251,8 +251,8 @@ section at the end of this file).
|
||||
* obdev's free shared VID/PID pair. See the file USB-IDs-for-free.txt for
|
||||
* details.
|
||||
*/
|
||||
#define USB_CFG_DEVICE_NAME 'p', 's', '2', 'a', 'v', 'r', 'G', 'B'
|
||||
#define USB_CFG_DEVICE_NAME_LEN 8
|
||||
#define USB_CFG_DEVICE_NAME 'J','J','5','0',' ','K','e','y','b','o','a','r','d'
|
||||
#define USB_CFG_DEVICE_NAME_LEN 13
|
||||
/* Same as above for the device name. If you don't want a device name, undefine
|
||||
* the macros. See the file USB-IDs-for-free.txt before you assign a name if
|
||||
* you use a shared VID/PID.
|
||||
|
||||
@@ -21,3 +21,4 @@ When adding your keymap to this list, keep it organised alphabetically (select l
|
||||
- **default** default layout from KBDFans
|
||||
- **mason**
|
||||
- **planck** Planck default layout
|
||||
- **xtonhasvim** A Planck-like layout with a few tweaks and a vim emulation layer.
|
||||
|
||||
49
keyboards/niu_mini/keymaps/xtonhasvim/config.h
Normal file
49
keyboards/niu_mini/keymaps/xtonhasvim/config.h
Normal file
@@ -0,0 +1,49 @@
|
||||
#ifndef CONFIG_USER_H
|
||||
#define CONFIG_USER_H
|
||||
|
||||
#include "../../config.h"
|
||||
|
||||
#define MUSIC_MASK (keycode != KC_NO)
|
||||
|
||||
/*
|
||||
* MIDI options
|
||||
*/
|
||||
|
||||
/* Prevent use of disabled MIDI features in the keymap */
|
||||
//#define MIDI_ENABLE_STRICT 1
|
||||
|
||||
/* enable basic MIDI features:
|
||||
- MIDI notes can be sent when in Music mode is on
|
||||
*/
|
||||
|
||||
#define MIDI_BASIC
|
||||
|
||||
/* enable advanced MIDI features:
|
||||
- MIDI notes can be added to the keymap
|
||||
- Octave shift and transpose
|
||||
- Virtual sustain, portamento, and modulation wheel
|
||||
- etc.
|
||||
*/
|
||||
//#define MIDI_ADVANCED
|
||||
|
||||
/* override number of MIDI tone keycodes (each octave adds 12 keycodes and allocates 12 bytes) */
|
||||
//#define MIDI_TONE_KEYCODE_OCTAVES 2
|
||||
|
||||
// help for fast typist+dual function keys?
|
||||
#define PERMISSIVE_HOLD
|
||||
|
||||
/* disable debug print */
|
||||
#define NO_DEBUG
|
||||
|
||||
/* disable print */
|
||||
#define NO_PRINT
|
||||
|
||||
/* speed up mousekeys a bit */
|
||||
#define MOUSEKEY_DELAY 50
|
||||
#define MOUSEKEY_INTERVAL 20
|
||||
#define MOUSEKEY_MAX_SPEED 8
|
||||
#define MOUSEKEY_TIME_TO_MAX 30
|
||||
#define MOUSEKEY_WHEEL_MAX_SPEED 8
|
||||
#define MOUSEKEY_WHEEL_TIME_TO_MAX 40
|
||||
|
||||
#endif
|
||||
210
keyboards/niu_mini/keymaps/xtonhasvim/keymap.c
Normal file
210
keyboards/niu_mini/keymaps/xtonhasvim/keymap.c
Normal file
@@ -0,0 +1,210 @@
|
||||
/* Copyright 2015-2017 Christon DeWan
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include QMK_KEYBOARD_H
|
||||
#include "action_layer.h"
|
||||
#include "xtonhasvim.h"
|
||||
|
||||
/************************************
|
||||
* states
|
||||
************************************/
|
||||
|
||||
enum layers {
|
||||
_QWERTY,
|
||||
_LOWER,
|
||||
_RAISE,
|
||||
_ADJUST,
|
||||
_MOVE,
|
||||
_MOUSE
|
||||
};
|
||||
|
||||
/************************************
|
||||
* keymaps!
|
||||
************************************/
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
|
||||
/* Qwerty
|
||||
* ,-----------------------------------------------------------------------------------.
|
||||
* | Tab | Q | W | E | R | T | Y | U | I | O | P | Bksp |
|
||||
* |------+------+------+------+------+-------------+------+------+------+------+------|
|
||||
* | Ctrl*| A* | S | D | F | G | H | J | K | L | ;* | " |
|
||||
* |------+------+------+------+------+------|------+------+------+------+------+------|
|
||||
* | Shift| Z | X | C | V | B | N | M | , | . | / |Enter |
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* | Mouse| | Alt | GUI |Lower*| Space |Raise*| GUI | Alt | | Vim |
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*
|
||||
* - Ctrl acts as Esc when tapped.
|
||||
* - Holding A or ; switches to movement layer.
|
||||
* - Raise and Lower are one-shot layers.
|
||||
*/
|
||||
[_QWERTY] = {
|
||||
{KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC},
|
||||
{LCTL_T(KC_ESC), LT(_MOVE,KC_A), KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, LT(_MOVE,KC_SCLN), KC_QUOT},
|
||||
{KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, RSFT_T(KC_ENT) },
|
||||
{TG(_MOUSE), X_____X, KC_LALT, KC_LGUI, OSL(_LOWER), KC_SPC, KC_SPC, OSL(_RAISE), KC_LGUI, KC_LALT, X_____X, VIM_START }
|
||||
},
|
||||
|
||||
/* Lower
|
||||
* ,-----------------------------------------------------------------------------------.
|
||||
* | ~ | F1 | F2 | F3 | F4 | F5 | F6 | _ | + | { | } | Bksp |
|
||||
* |------+------+------+------+------+-------------+------+------+------+------+------|
|
||||
* | Del | ! | @ | # | $ | % | ^ | & | * | ( | ) | | |
|
||||
* |------+------+------+------+------+------|------+------+------+------+------+------|
|
||||
* | | F7 | F8 | F9 | F10 | F11 | F12 | | | Home | End | |
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* | | | | | | | | Next | Vol- | Vol+ | Play |
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*/
|
||||
[_LOWER] = {
|
||||
{KC_TILD, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_BSPC},
|
||||
{KC_DEL, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_PIPE},
|
||||
{_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, KC_HOME, KC_END, _______},
|
||||
{_______, TO(_QWERTY), _______, _______, _______, _______, _______, OSL(_ADJUST), KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY}
|
||||
},
|
||||
|
||||
/* Raise
|
||||
* ,-----------------------------------------------------------------------------------.
|
||||
* | ` | F1 | F2 | F3 | F4 | F5 | F6 | - | = | [ | ] | Bksp |
|
||||
* |------+------+------+------+------+-------------+------+------+------+------+------|
|
||||
* | Del | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | \ |
|
||||
* |------+------+------+------+------+------|------+------+------+------+------+------|
|
||||
* | | F7 | F8 | F9 | F10 | F11 | F12 |ISO # |ISO / |Pg Up |Pg Dn | |
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* | | | | | | | | Next | Vol- | Vol+ | Play |
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*/
|
||||
[_RAISE] = {
|
||||
{KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSPC},
|
||||
{KC_DEL, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSLS},
|
||||
{_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, KC_PGUP, KC_PGDN, _______},
|
||||
{_______, TO(_QWERTY), _______, _______, OSL(_ADJUST), _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY}
|
||||
},
|
||||
|
||||
|
||||
/* Adjust (Lower + Raise)
|
||||
* ,-------------------------------------------------------------------------------------.
|
||||
* |RGBPlain| Reset| | | | | | | | | | Del |
|
||||
* |--------+------+------+------+------+-------------+------+------+------+------+------|
|
||||
* |RGBMode-| | |Aud on|Audoff|AGnorm|AGswap| | | | |Lite+ |
|
||||
* |--------+------+------+------+------+------|------+------+------+------+------+------|
|
||||
* |RGBMode+|Voice-|Voice+|Mus on|Musoff|MIDIon|MIDIof| | | | |Lite- |
|
||||
* |--------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* | RGB | | | | | | | | | | |
|
||||
* `-------------------------------------------------------------------------------------'
|
||||
*/
|
||||
[_ADJUST] = {
|
||||
{RGB_MODE_PLAIN, RESET, DEBUG, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL },
|
||||
{RGB_MODE_REVERSE, _______, MU_MOD, AU_ON, AU_OFF, AG_NORM, AG_SWAP, _______, _______, _______, _______, RGB_VAI},
|
||||
{RGB_MODE_FORWARD, MUV_DE, MUV_IN, MU_ON, MU_OFF, MI_ON, MI_OFF, _______, _______, _______, _______, RGB_VAD},
|
||||
{RGB_TOG, TO(_QWERTY), _______, _______, _______, _______, _______, _______, _______, _______, _______, _______}
|
||||
},
|
||||
|
||||
|
||||
/* movement layer (hold semicolon)
|
||||
*/
|
||||
[_MOVE] = {
|
||||
{TO(_QWERTY), X_____X, X_____X, X_____X, X_____X, X_____X, KC_HOME, KC_PGDN, KC_PGUP, KC_END, X_____X, X_____X},
|
||||
{_______, X_____X, LGUI(KC_LBRC), LGUI(LSFT(KC_LBRC)), LGUI(LSFT(KC_RBRC)), LGUI(KC_RBRC), KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, X_____X, X_____X},
|
||||
{_______, X_____X, X_____X, X_____X, X_____X, X_____X, X_____X, X_____X, X_____X, X_____X, X_____X, _______},
|
||||
{X_____X, TO(_QWERTY), _______, _______, _______, X_____X, X_____X, _______, _______, _______, TO(_QWERTY), _______}
|
||||
},
|
||||
|
||||
/* mouse layer
|
||||
*/
|
||||
[_MOUSE] = {
|
||||
{TO(_QWERTY), X_____X, X_____X, KC_MS_UP, X_____X, X_____X, KC_MS_WH_LEFT, KC_MS_WH_DOWN, KC_MS_WH_UP, KC_MS_WH_RIGHT, X_____X, X_____X },
|
||||
{_______, X_____X, KC_MS_LEFT, KC_MS_DOWN, KC_MS_RIGHT, X_____X, X_____X, KC_MS_BTN1, KC_MS_BTN2, KC_MS_BTN3, X_____X, X_____X},
|
||||
{_______, X_____X, X_____X, X_____X, X_____X, X_____X, X_____X, X_____X, X_____X, X_____X, X_____X, _______},
|
||||
{_______, TO(_QWERTY), _______, _______, _______, X_____X, X_____X, _______, _______, _______, TO(_QWERTY), _______}
|
||||
},
|
||||
|
||||
/* vim edit mode. just has an escape -> _CMD key */
|
||||
[_EDIT] = {
|
||||
{_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______},
|
||||
{VIM_START, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______},
|
||||
{_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______},
|
||||
{_______, TO(_QWERTY), _______, _______, _______, _______, _______, _______, _______, _______, TO(_QWERTY), _______}
|
||||
},
|
||||
|
||||
/* vim command layer.
|
||||
*/
|
||||
[_CMD] = {
|
||||
{X_____X, X_____X, VIM_W, VIM_E, X_____X, X_____X, VIM_Y, VIM_U, VIM_I, VIM_O, VIM_P, X_____X},
|
||||
{VIM_ESC, VIM_A, VIM_S, VIM_D, X_____X, VIM_G, VIM_H, VIM_J, VIM_K, VIM_L, X_____X, X_____X},
|
||||
{VIM_SHIFT, X_____X, VIM_X, VIM_C, VIM_V, VIM_B, X_____X, X_____X, VIM_COMMA, VIM_PERIOD, X_____X, VIM_SHIFT},
|
||||
{X_____X, TO(_QWERTY), _______, _______, X_____X, X_____X, X_____X, X_____X, _______, _______, TO(_QWERTY), X_____X}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
if(process_record_xtonhasvim(keycode, record)) {
|
||||
// do nothing so far
|
||||
return true;
|
||||
} else {
|
||||
// already handled by vim
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** Set just 4 LEDs closest to the user. Slightly less annoying to bystanders.*/
|
||||
void rgbflag(uint8_t r, uint8_t g, uint8_t b) {
|
||||
for(int i = 0; i < RGBLED_NUM; i++){
|
||||
switch(i) {
|
||||
case 9 ... 12:
|
||||
// rgblight_setrgb_at(r,g,b,i);
|
||||
led[i].r = r;
|
||||
led[i].g = g;
|
||||
led[i].b = b;
|
||||
break;
|
||||
default:
|
||||
// rgblight_setrgb_at(0,0,0,i);
|
||||
led[i].r = 0;
|
||||
led[i].g = 0;
|
||||
led[i].b = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
rgblight_set();
|
||||
}
|
||||
|
||||
uint32_t layer_state_set_user(uint32_t state) {
|
||||
if(rgblight_get_mode() == 1) {
|
||||
switch (biton32(state)) {
|
||||
case _RAISE:
|
||||
case _LOWER:
|
||||
case _ADJUST:
|
||||
rgbflag(0x00, 0x00, 0xFF);
|
||||
break;
|
||||
case _MOVE:
|
||||
case _MOUSE:
|
||||
rgbflag(0xFF, 0x00, 0x00);
|
||||
break;
|
||||
case _CMD:
|
||||
rgbflag(0x00, 0xFF, 0x00);
|
||||
break;
|
||||
case _EDIT:
|
||||
rgbflag(0x7A, 0x00, 0xFF);
|
||||
break;
|
||||
default: // for any other layers, or the default layer
|
||||
rgbflag(0x00, 0xFF, 0xFF);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return state;
|
||||
}
|
||||
9
keyboards/niu_mini/keymaps/xtonhasvim/readme.md
Normal file
9
keyboards/niu_mini/keymaps/xtonhasvim/readme.md
Normal file
@@ -0,0 +1,9 @@
|
||||
# Xton has a tiny keyboard! With Vim!
|
||||
|
||||
Based on the standard Planck layout with a few changes:
|
||||
|
||||
* Escape moved to dual-function with control.
|
||||
* Dedicated movement and mouse layers.
|
||||
* Top and middle row swapped in `_RAISE` and `_LOWER` because I never use F-keys.
|
||||
* Vim layers! See `users/xtonhasvim`.
|
||||
|
||||
6
keyboards/niu_mini/keymaps/xtonhasvim/rules.mk
Normal file
6
keyboards/niu_mini/keymaps/xtonhasvim/rules.mk
Normal file
@@ -0,0 +1,6 @@
|
||||
ifndef QUANTUM_DIR
|
||||
include ../../../../Makefile
|
||||
endif
|
||||
|
||||
MOUSEKEY_ENABLE = yes
|
||||
BACKLIGHT_ENABLE = no
|
||||
@@ -41,7 +41,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
* | | Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right |
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*/
|
||||
[_DEFLT] = KEYMAP_JJ50( \
|
||||
[_DEFLT] = LAYOUT_jj50( \
|
||||
KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, \
|
||||
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, \
|
||||
KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, \
|
||||
@@ -63,7 +63,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
* | | | | | | | | Next | Vol- | Vol+ | Play |
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*/
|
||||
[_RAISE] = KEYMAP_JJ50( \
|
||||
[_RAISE] = LAYOUT_jj50( \
|
||||
KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, \
|
||||
KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL, \
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, KC_LBRC, KC_RBRC, KC_BSLS, \
|
||||
@@ -85,7 +85,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
* | | | | | | | | Next | Vol- | Vol+ | Play |
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*/
|
||||
[_LOWER] = KEYMAP_JJ50( \
|
||||
[_LOWER] = LAYOUT_jj50( \
|
||||
KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, \
|
||||
KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_DEL, \
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, KC_LCBR, KC_RCBR, KC_PIPE, \
|
||||
|
||||
@@ -41,7 +41,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
{ K700, K701, K702, K703, K704, K705, K706, KC_NO, K708, K709, K710, K711, K712, K713, K714 } \
|
||||
}
|
||||
|
||||
#define KEYMAP_JJ50( \
|
||||
#define LAYOUT_jj50( \
|
||||
K011, K010, K009, K008, K004, K005, K006, K007, K003, K002, K201, K000, \
|
||||
K111, K110, K109, K108, K104, K105, K106, K107, K103, K102, K001, K100, \
|
||||
K211, K210, K209, K208, K204, K205, K206, K207, K203, K202, K101, K200, \
|
||||
|
||||
10
users/xtonhasvim/readme.md
Normal file
10
users/xtonhasvim/readme.md
Normal file
@@ -0,0 +1,10 @@
|
||||
|
||||
# Xton has Vim!
|
||||
|
||||
Contains common code for Xton's vim emulation (vimulation?) layer.
|
||||
|
||||
Inspired/stolen from the `ergodox_ez/vim` keymap. Rewritten to be a more straightforward state machine and support more macros. Vim layers `_CMD` and `_EDIT` are designed to lay on top of an otherwise fully-functional layout. `_CMD` runs the entire vim state machine while `_EDIT` should lay across your base layer and mask off just the escape key.
|
||||
|
||||
Works via OSX text editing shortcuts, mainly MOD+arrow combinations. This has some limitations and only works on OSX.
|
||||
|
||||
The `_CMD` layer will temporarily disable itself while *CMD* or *ALT* are held down so that typical OSX shortcuts can be used without switching out of vim mode.
|
||||
1
users/xtonhasvim/rules.mk
Normal file
1
users/xtonhasvim/rules.mk
Normal file
@@ -0,0 +1 @@
|
||||
SRC += xtonhasvim.c
|
||||
599
users/xtonhasvim/xtonhasvim.c
Normal file
599
users/xtonhasvim/xtonhasvim.c
Normal file
@@ -0,0 +1,599 @@
|
||||
/* Copyright 2015-2017 Christon DeWan
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "xtonhasvim.h"
|
||||
|
||||
/************************************
|
||||
* helper foo
|
||||
************************************/
|
||||
|
||||
#define PRESS(kc) register_code(kc)
|
||||
#define RELEASE(kc) unregister_code(kc)
|
||||
|
||||
static void TAP(uint16_t keycode) {
|
||||
PRESS(keycode);
|
||||
RELEASE(keycode);
|
||||
}
|
||||
|
||||
static void CMD(uint16_t keycode) {
|
||||
PRESS(KC_LGUI);
|
||||
TAP(keycode);
|
||||
RELEASE(KC_LGUI);
|
||||
}
|
||||
|
||||
static void CTRL(uint16_t keycode) {
|
||||
PRESS(KC_LCTRL);
|
||||
TAP(keycode);
|
||||
RELEASE(KC_LCTRL);
|
||||
}
|
||||
|
||||
static void SHIFT(uint16_t keycode) {
|
||||
PRESS(KC_LSHIFT);
|
||||
TAP(keycode);
|
||||
RELEASE(KC_LSHIFT);
|
||||
}
|
||||
|
||||
static void ALT(uint16_t keycode) {
|
||||
PRESS(KC_LALT);
|
||||
TAP(keycode);
|
||||
RELEASE(KC_LALT);
|
||||
}
|
||||
|
||||
|
||||
uint16_t vstate = VIM_START;
|
||||
bool yank_was_lines = false;
|
||||
bool SHIFTED = false;
|
||||
uint32_t mod_override_layer_state = 0;
|
||||
uint16_t mod_override_triggering_key = 0;
|
||||
bool do_check_kb_clear = false;
|
||||
|
||||
void vim_reset(void) {
|
||||
vstate = VIM_START;
|
||||
SHIFTED = false;
|
||||
yank_was_lines = false;
|
||||
}
|
||||
|
||||
void edit(void) { vstate = VIM_START; layer_on(_EDIT); layer_off(_CMD); }
|
||||
#define EDIT edit()
|
||||
|
||||
|
||||
void simple_movement(uint16_t keycode) {
|
||||
switch(keycode) {
|
||||
case VIM_B:
|
||||
PRESS(KC_LALT);
|
||||
SHIFT(KC_LEFT); // select to start of this word
|
||||
RELEASE(KC_LALT);
|
||||
break;
|
||||
case VIM_E:
|
||||
PRESS(KC_LALT);
|
||||
SHIFT(KC_RIGHT); // select to end of this word
|
||||
RELEASE(KC_LALT);
|
||||
break;
|
||||
case VIM_H:
|
||||
SHIFT(KC_LEFT);
|
||||
break;
|
||||
case VIM_J:
|
||||
CMD(KC_LEFT);
|
||||
SHIFT(KC_DOWN);
|
||||
SHIFT(KC_DOWN);
|
||||
break;
|
||||
case VIM_K:
|
||||
CMD(KC_LEFT);
|
||||
TAP(KC_DOWN);
|
||||
SHIFT(KC_UP);
|
||||
SHIFT(KC_UP);
|
||||
break;
|
||||
case VIM_L:
|
||||
SHIFT(KC_RIGHT);
|
||||
break;
|
||||
case VIM_W:
|
||||
PRESS(KC_LALT);
|
||||
SHIFT(KC_RIGHT); // select to end of this word
|
||||
SHIFT(KC_RIGHT); // select to end of next word
|
||||
SHIFT(KC_LEFT); // select to start of next word
|
||||
RELEASE(KC_LALT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool process_record_xtonhasvim(uint16_t keycode, keyrecord_t *record) {
|
||||
if(record->event.pressed && layer_state_is(_CMD) && IS_MOD(keycode)) {
|
||||
mod_override_layer_state = layer_state;
|
||||
mod_override_triggering_key = keycode;
|
||||
layer_clear();
|
||||
return true; // let the event fall through...
|
||||
}
|
||||
if(mod_override_layer_state && !record->event.pressed && keycode == mod_override_triggering_key) {
|
||||
layer_state_set(mod_override_layer_state);
|
||||
mod_override_layer_state = 0;
|
||||
mod_override_triggering_key = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (VIM_START <= keycode && keycode <= VIM_ESC) {
|
||||
if(keycode == VIM_SHIFT) {
|
||||
SHIFTED = record->event.pressed;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (record->event.pressed) {
|
||||
if(keycode == VIM_START) {
|
||||
// entry from anywhere
|
||||
layer_on(_CMD);
|
||||
vstate = VIM_START;
|
||||
return false;
|
||||
}
|
||||
switch(vstate) {
|
||||
case VIM_START:
|
||||
switch(keycode){
|
||||
/*****************************
|
||||
* ground state
|
||||
*****************************/
|
||||
case VIM_A:
|
||||
if(SHIFTED) {
|
||||
// CMD(KC_RIGHT);
|
||||
CTRL(KC_E);
|
||||
} else {
|
||||
TAP(KC_RIGHT);
|
||||
}
|
||||
EDIT;
|
||||
break;
|
||||
case VIM_B:
|
||||
PRESS(KC_LALT);
|
||||
PRESS(KC_LEFT);
|
||||
break;
|
||||
case VIM_C:
|
||||
if(SHIFTED) {
|
||||
PRESS(KC_LSHIFT);
|
||||
CMD(KC_RIGHT);
|
||||
RELEASE(KC_LSHIFT);
|
||||
CMD(KC_X);
|
||||
yank_was_lines = false;
|
||||
EDIT;
|
||||
} else {
|
||||
vstate = VIM_C;
|
||||
}
|
||||
break;
|
||||
case VIM_D:
|
||||
if(SHIFTED) {
|
||||
TAP(KC_K);
|
||||
} else {
|
||||
vstate = VIM_D;
|
||||
}
|
||||
break;
|
||||
case VIM_E:
|
||||
PRESS(KC_LALT);
|
||||
PRESS(KC_RIGHT);
|
||||
break;
|
||||
case VIM_G:
|
||||
if(SHIFTED) {
|
||||
TAP(KC_END);
|
||||
} else {
|
||||
vstate = VIM_G;
|
||||
}
|
||||
break;
|
||||
case VIM_H:
|
||||
PRESS(KC_LEFT);
|
||||
break;
|
||||
case VIM_I:
|
||||
if(SHIFTED){
|
||||
CTRL(KC_A);
|
||||
}
|
||||
EDIT;
|
||||
break;
|
||||
case VIM_J:
|
||||
if(SHIFTED) {
|
||||
CMD(KC_RIGHT);
|
||||
TAP(KC_DEL);
|
||||
} else {
|
||||
PRESS(KC_DOWN);
|
||||
}
|
||||
break;
|
||||
case VIM_K:
|
||||
PRESS(KC_UP);
|
||||
break;
|
||||
case VIM_L:
|
||||
PRESS(KC_RIGHT);
|
||||
break;
|
||||
case VIM_O:
|
||||
if(SHIFTED) {
|
||||
CMD(KC_LEFT);
|
||||
TAP(KC_ENTER);
|
||||
TAP(KC_UP);
|
||||
EDIT;
|
||||
} else {
|
||||
CMD(KC_RIGHT);
|
||||
TAP(KC_ENTER);
|
||||
EDIT;
|
||||
}
|
||||
break;
|
||||
case VIM_P:
|
||||
if(SHIFTED) {
|
||||
CMD(KC_LEFT);
|
||||
CMD(KC_V);
|
||||
} else {
|
||||
if(yank_was_lines) {
|
||||
CMD(KC_RIGHT);
|
||||
TAP(KC_RIGHT);
|
||||
CMD(KC_V);
|
||||
} else {
|
||||
CMD(KC_V);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case VIM_S:
|
||||
// s for substitute?
|
||||
if(SHIFTED) {
|
||||
CMD(KC_LEFT);
|
||||
PRESS(KC_LSHIFT);
|
||||
CMD(KC_RIGHT);
|
||||
RELEASE(KC_LSHIFT);
|
||||
CMD(KC_X);
|
||||
yank_was_lines = false;
|
||||
EDIT;
|
||||
} else {
|
||||
SHIFT(KC_RIGHT);
|
||||
CMD(KC_X);
|
||||
yank_was_lines = false;
|
||||
EDIT;
|
||||
}
|
||||
break;
|
||||
case VIM_U:
|
||||
if(SHIFTED) {
|
||||
PRESS(KC_LSFT);
|
||||
CMD(KC_Z);
|
||||
RELEASE(KC_LSHIFT);
|
||||
} else {
|
||||
CMD(KC_Z);
|
||||
}
|
||||
break;
|
||||
case VIM_V:
|
||||
if(SHIFTED) {
|
||||
CMD(KC_LEFT);
|
||||
SHIFT(KC_DOWN);
|
||||
vstate = VIM_VS;
|
||||
} else {
|
||||
vstate = VIM_V;
|
||||
}
|
||||
break;
|
||||
case VIM_W:
|
||||
PRESS(KC_LALT);
|
||||
TAP(KC_RIGHT);
|
||||
TAP(KC_RIGHT);
|
||||
TAP(KC_LEFT);
|
||||
RELEASE(KC_LALT);
|
||||
break;
|
||||
case VIM_X:
|
||||
// SHIFT(KC_RIGHT);
|
||||
// CMD(KC_X);
|
||||
PRESS(KC_DEL);
|
||||
break;
|
||||
case VIM_Y:
|
||||
if(SHIFTED) {
|
||||
CMD(KC_LEFT);
|
||||
SHIFT(KC_DOWN);
|
||||
CMD(KC_C);
|
||||
TAP(KC_RIGHT);
|
||||
yank_was_lines = true;
|
||||
} else {
|
||||
vstate = VIM_Y;
|
||||
}
|
||||
break;
|
||||
case VIM_COMMA:
|
||||
if(SHIFTED) {
|
||||
// indent
|
||||
CMD(KC_LBRACKET);
|
||||
} else {
|
||||
// toggle comment
|
||||
CMD(KC_SLASH);
|
||||
}
|
||||
break;
|
||||
case VIM_PERIOD:
|
||||
if(SHIFTED) {
|
||||
// outdent
|
||||
CMD(KC_RBRACKET);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case VIM_C:
|
||||
/*****************************
|
||||
* c- ...for change. I never use this...
|
||||
*****************************/
|
||||
switch(keycode) {
|
||||
case VIM_B:
|
||||
case VIM_E:
|
||||
case VIM_H:
|
||||
case VIM_J:
|
||||
case VIM_K:
|
||||
case VIM_L:
|
||||
case VIM_W:
|
||||
simple_movement(keycode);
|
||||
CMD(KC_X);
|
||||
yank_was_lines = false;
|
||||
EDIT;
|
||||
break;
|
||||
|
||||
case VIM_C:
|
||||
CMD(KC_LEFT);
|
||||
PRESS(KC_LSHIFT);
|
||||
CMD(KC_RIGHT);
|
||||
RELEASE(KC_LSHIFT);
|
||||
CMD(KC_X);
|
||||
yank_was_lines = false;
|
||||
EDIT;
|
||||
break;
|
||||
case VIM_I:
|
||||
vstate = VIM_CI;
|
||||
break;
|
||||
default:
|
||||
vstate = VIM_START;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case VIM_CI:
|
||||
/*****************************
|
||||
* ci- ...change inner word
|
||||
*****************************/
|
||||
switch(keycode) {
|
||||
case VIM_W:
|
||||
ALT(KC_LEFT);
|
||||
PRESS(KC_LSHIFT);
|
||||
ALT(KC_RIGHT);
|
||||
RELEASE(KC_LSHIFT);
|
||||
CMD(KC_X);
|
||||
yank_was_lines = false;
|
||||
EDIT;
|
||||
default:
|
||||
vstate = VIM_START;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case VIM_D:
|
||||
/*****************************
|
||||
* d- ...delete stuff
|
||||
*****************************/
|
||||
switch(keycode) {
|
||||
case VIM_B:
|
||||
case VIM_E:
|
||||
case VIM_H:
|
||||
case VIM_J:
|
||||
case VIM_K:
|
||||
case VIM_L:
|
||||
case VIM_W:
|
||||
simple_movement(keycode);
|
||||
CMD(KC_X);
|
||||
yank_was_lines = false;
|
||||
break;
|
||||
case VIM_D:
|
||||
CMD(KC_LEFT);
|
||||
SHIFT(KC_DOWN);
|
||||
CMD(KC_X);
|
||||
yank_was_lines = true;
|
||||
vstate = VIM_START;
|
||||
break;
|
||||
case VIM_I:
|
||||
vstate = VIM_DI;
|
||||
break;
|
||||
default:
|
||||
vstate = VIM_START;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case VIM_DI:
|
||||
/*****************************
|
||||
* ci- ...delete a word... FROM THE INSIDE!
|
||||
*****************************/
|
||||
switch(keycode) {
|
||||
case VIM_W:
|
||||
ALT(KC_LEFT);
|
||||
PRESS(KC_LSHIFT);
|
||||
ALT(KC_RIGHT);
|
||||
RELEASE(KC_LSHIFT);
|
||||
CMD(KC_X);
|
||||
yank_was_lines = false;
|
||||
vstate = VIM_START;
|
||||
default:
|
||||
vstate = VIM_START;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case VIM_V:
|
||||
/*****************************
|
||||
* visual!
|
||||
*****************************/
|
||||
switch(keycode) {
|
||||
case VIM_D:
|
||||
case VIM_X:
|
||||
CMD(KC_X);
|
||||
yank_was_lines = false;
|
||||
vstate = VIM_START;
|
||||
break;
|
||||
case VIM_B:
|
||||
PRESS(KC_LALT);
|
||||
PRESS(KC_LSHIFT);
|
||||
PRESS(KC_LEFT);
|
||||
// leave open for key repeat
|
||||
break;
|
||||
case VIM_E:
|
||||
PRESS(KC_LALT);
|
||||
PRESS(KC_LSHIFT);
|
||||
PRESS(KC_RIGHT);
|
||||
// leave open for key repeat
|
||||
break;
|
||||
case VIM_H:
|
||||
PRESS(KC_LSHIFT);
|
||||
PRESS(KC_LEFT);
|
||||
break;
|
||||
case VIM_I:
|
||||
vstate = VIM_VI;
|
||||
break;
|
||||
case VIM_J:
|
||||
PRESS(KC_LSHIFT);
|
||||
PRESS(KC_DOWN);
|
||||
break;
|
||||
case VIM_K:
|
||||
PRESS(KC_LSHIFT);
|
||||
PRESS(KC_UP);
|
||||
break;
|
||||
case VIM_L:
|
||||
PRESS(KC_LSHIFT);
|
||||
PRESS(KC_RIGHT);
|
||||
break;
|
||||
case VIM_W:
|
||||
PRESS(KC_LALT);
|
||||
SHIFT(KC_RIGHT); // select to end of this word
|
||||
SHIFT(KC_RIGHT); // select to end of next word
|
||||
SHIFT(KC_LEFT); // select to start of next word
|
||||
RELEASE(KC_LALT);
|
||||
break;
|
||||
case VIM_Y:
|
||||
CMD(KC_C);
|
||||
TAP(KC_RIGHT);
|
||||
yank_was_lines = false;
|
||||
vstate = VIM_START;
|
||||
break;
|
||||
case VIM_V:
|
||||
case VIM_ESC:
|
||||
TAP(KC_RIGHT);
|
||||
vstate = VIM_START;
|
||||
break;
|
||||
default:
|
||||
// do nothing
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case VIM_VI:
|
||||
/*****************************
|
||||
* vi- ...select a word... FROM THE INSIDE!
|
||||
*****************************/
|
||||
switch(keycode) {
|
||||
case VIM_W:
|
||||
ALT(KC_LEFT);
|
||||
PRESS(KC_LSHIFT);
|
||||
ALT(KC_RIGHT);
|
||||
RELEASE(KC_LSHIFT);
|
||||
vstate = VIM_V;
|
||||
default:
|
||||
// ignore
|
||||
vstate = VIM_V;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case VIM_VS:
|
||||
/*****************************
|
||||
* visual line
|
||||
*****************************/
|
||||
switch(keycode) {
|
||||
case VIM_D:
|
||||
case VIM_X:
|
||||
CMD(KC_X);
|
||||
yank_was_lines = true;
|
||||
vstate = VIM_START;
|
||||
break;
|
||||
case VIM_J:
|
||||
PRESS(KC_LSHIFT);
|
||||
PRESS(KC_DOWN);
|
||||
break;
|
||||
case VIM_K:
|
||||
PRESS(KC_LSHIFT);
|
||||
PRESS(KC_UP);
|
||||
break;
|
||||
case VIM_Y:
|
||||
CMD(KC_C);
|
||||
yank_was_lines = true;
|
||||
TAP(KC_RIGHT);
|
||||
vstate = VIM_START;
|
||||
break;
|
||||
case VIM_V:
|
||||
case VIM_ESC:
|
||||
TAP(KC_RIGHT);
|
||||
vstate = VIM_START;
|
||||
break;
|
||||
default:
|
||||
// do nothing
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case VIM_G:
|
||||
/*****************************
|
||||
* gg, and a grab-bag of other macros i find useful
|
||||
*****************************/
|
||||
switch(keycode) {
|
||||
case VIM_G:
|
||||
TAP(KC_HOME);
|
||||
break;
|
||||
// codes b
|
||||
case VIM_H:
|
||||
CTRL(KC_A);
|
||||
break;
|
||||
case VIM_J:
|
||||
PRESS(KC_PGDN);
|
||||
break;
|
||||
case VIM_K:
|
||||
PRESS(KC_PGUP);
|
||||
break;
|
||||
case VIM_L:
|
||||
CTRL(KC_E);
|
||||
break;
|
||||
default:
|
||||
// do nothing
|
||||
break;
|
||||
}
|
||||
vstate = VIM_START;
|
||||
break;
|
||||
case VIM_Y:
|
||||
/*****************************
|
||||
* yoink!
|
||||
*****************************/
|
||||
switch(keycode) {
|
||||
case VIM_B:
|
||||
case VIM_E:
|
||||
case VIM_H:
|
||||
case VIM_J:
|
||||
case VIM_K:
|
||||
case VIM_L:
|
||||
case VIM_W:
|
||||
simple_movement(keycode);
|
||||
CMD(KC_C);
|
||||
TAP(KC_RIGHT);
|
||||
yank_was_lines = false;
|
||||
break;
|
||||
case VIM_Y:
|
||||
CMD(KC_LEFT);
|
||||
SHIFT(KC_DOWN);
|
||||
CMD(KC_C);
|
||||
TAP(KC_RIGHT);
|
||||
yank_was_lines = true;
|
||||
break;
|
||||
default:
|
||||
// NOTHING
|
||||
break;
|
||||
}
|
||||
vstate = VIM_START;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
/************************
|
||||
* key release events
|
||||
************************/
|
||||
clear_keyboard();
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
66
users/xtonhasvim/xtonhasvim.h
Normal file
66
users/xtonhasvim/xtonhasvim.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/* Copyright 2015-2017 Christon DeWan
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef USERSPACE
|
||||
#define USERSPACE
|
||||
|
||||
#include QMK_KEYBOARD_H
|
||||
#include "action_layer.h"
|
||||
|
||||
#define X_____X KC_NO
|
||||
|
||||
bool process_record_xtonhasvim(uint16_t keycode, keyrecord_t *record);
|
||||
|
||||
enum xtonhasvim_keycodes {
|
||||
DUMMY = SAFE_RANGE,
|
||||
VIM_START, // bookend for vim states
|
||||
VIM_A,
|
||||
VIM_B,
|
||||
VIM_C,
|
||||
VIM_CI,
|
||||
VIM_D,
|
||||
VIM_DI,
|
||||
VIM_E,
|
||||
VIM_H,
|
||||
VIM_G,
|
||||
VIM_I,
|
||||
VIM_J,
|
||||
VIM_K,
|
||||
VIM_L,
|
||||
VIM_O,
|
||||
VIM_P,
|
||||
VIM_S,
|
||||
VIM_U,
|
||||
VIM_V,
|
||||
VIM_VS, // visual-line
|
||||
VIM_VI,
|
||||
VIM_W,
|
||||
VIM_X,
|
||||
VIM_Y,
|
||||
VIM_PERIOD, // to support indent/outdent
|
||||
VIM_COMMA, // and toggle comments
|
||||
VIM_SHIFT, // avoid side-effect of supporting real shift.
|
||||
VIM_ESC, // bookend
|
||||
VIM_SAFE_RANGE // start other keycodes here.
|
||||
};
|
||||
|
||||
enum xtonhasvim_layers {
|
||||
_EDIT = 12,
|
||||
_CMD
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user