From c3b4f65c640c217a0c9bf99d6b30982f966e585c Mon Sep 17 00:00:00 2001 From: walkerstop Date: Thu, 14 Mar 2019 08:21:41 -0700 Subject: [PATCH] Added info.json for mt980 keyboard and fixes to walker keymap (#5391) * Added info.json and minor fixes to walker keymap * Fix url * Update keyboards/mt980/info.json Co-Authored-By: walkerstop * Update keyboards/mt980/info.json Co-Authored-By: walkerstop * Update keyboards/mt980/info.json Co-Authored-By: walkerstop * Update keyboards/mt980/info.json Co-Authored-By: walkerstop * Update keyboards/mt980/info.json Co-Authored-By: walkerstop * Update keyboards/mt980/info.json Co-Authored-By: walkerstop * Update keyboards/mt980/info.json Co-Authored-By: walkerstop * Fix user calling keymap functions * cancel oneshot layer on KC_TRNS * Fix to oneshot layer handling * Fix oneshot handling of reset * Move bootmagic key to Esc where it normally resides * Remove deprecated function * Treat shift-numlock as shift-insert in Walker layer --- keyboards/mt980/config.h | 4 + keyboards/mt980/info.json | 117 ++++++++++++++++++++++++ keyboards/mt980/keymaps/walker/keymap.c | 53 +++++++++-- keyboards/mt980/mt980.c | 9 +- 4 files changed, 171 insertions(+), 12 deletions(-) create mode 100644 keyboards/mt980/info.json diff --git a/keyboards/mt980/config.h b/keyboards/mt980/config.h index 9b5abf919..88c25a587 100644 --- a/keyboards/mt980/config.h +++ b/keyboards/mt980/config.h @@ -46,3 +46,7 @@ #define RGBLIGHT_VAL_STEP 8 #define RGBLIGHT_LIMIT_VAL 185 #endif + +/* Place bootmagic key on Esc */ +#define BOOTMAGIC_LITE_ROW 5 +#define BOOTMAGIC_LITE_COLUMN 0 diff --git a/keyboards/mt980/info.json b/keyboards/mt980/info.json new file mode 100644 index 000000000..f71d02285 --- /dev/null +++ b/keyboards/mt980/info.json @@ -0,0 +1,117 @@ +{ + "keyboard_name": "mt980", + "url": "https://shop110310565.taobao.com", + "maintainer": "walkerstop", + "width": 19.5, + "height": 6.75, + "layouts": { + "LAYOUT": { + "key_count": 103, + "layout": [ + {"label":"K50", "x":0, "y":0}, + {"label":"K52", "x":1.25, "y":0}, + {"label":"K53", "x":2.25, "y":0}, + {"label":"K54", "x":3.25, "y":0}, + {"label":"K55", "x":4.25, "y":0}, + {"label":"K57", "x":5.5, "y":0}, + {"label":"K58", "x":6.5, "y":0}, + {"label":"KB8", "x":7.5, "y":0}, + {"label":"KB7", "x":8.5, "y":0}, + {"label":"KB5", "x":9.75, "y":0}, + {"label":"KB4", "x":10.75, "y":0}, + {"label":"KB3", "x":11.75, "y":0}, + {"label":"KB6", "x":12.75, "y":0}, + {"label":"K51", "x":14, "y":0}, + {"label":"KB2", "x":15.5, "y":0}, + {"label":"KB1", "x":16.5, "y":0}, + {"label":"KB0", "x":17.5, "y":0}, + {"label":"K63", "x":18.5, "y":0}, + {"label":"K40", "x":0, "y":1.5}, + {"label":"K41", "x":1, "y":1.5}, + {"label":"K42", "x":2, "y":1.5}, + {"label":"K43", "x":3, "y":1.5}, + {"label":"K44", "x":4, "y":1.5}, + {"label":"K45", "x":5, "y":1.5}, + {"label":"K46", "x":6, "y":1.5}, + {"label":"K47", "x":7, "y":1.5}, + {"label":"K48", "x":8, "y":1.5}, + {"label":"KA8", "x":9, "y":1.5}, + {"label":"KA7", "x":10, "y":1.5}, + {"label":"KA5", "x":11, "y":1.5}, + {"label":"KA4", "x":12, "y":1.5}, + {"label":"KA3", "x":13, "y":1.5}, + {"label":"KA6", "x":14, "y":1.5}, + {"label":"KA2", "x":15.5, "y":1.5}, + {"label":"KA1", "x":16.5, "y":1.5}, + {"label":"KA0", "x":17.5, "y":1.5}, + {"label":"K64", "x":18.5, "y":1.5}, + {"label":"K30", "x":0, "y":2.5, "w":1.5}, + {"label":"K31", "x":1.5, "y":2.5}, + {"label":"K32", "x":2.5, "y":2.5}, + {"label":"K33", "x":3.5, "y":2.5}, + {"label":"K34", "x":4.5, "y":2.5}, + {"label":"K35", "x":5.5, "y":2.5}, + {"label":"K36", "x":6.5, "y":2.5}, + {"label":"K37", "x":7.5, "y":2.5}, + {"label":"K38", "x":8.5, "y":2.5}, + {"label":"K98", "x":9.5, "y":2.5}, + {"label":"K97", "x":10.5, "y":2.5}, + {"label":"K95", "x":11.5, "y":2.5}, + {"label":"K94", "x":12.5, "y":2.5}, + {"label":"K84", "x":13.5, "y":2.5, "w":1.5}, + {"label":"K96", "x":15.5, "y":2.5}, + {"label":"K92", "x":16.5, "y":2.5}, + {"label":"K91", "x":17.5, "y":2.5}, + {"label":"K90", "x":18.5, "y":2.5}, + {"label":"K20", "x":0, "y":3.5, "w":1.75}, + {"label":"K21", "x":1.75, "y":3.5}, + {"label":"K22", "x":2.75, "y":3.5}, + {"label":"K23", "x":3.75, "y":3.5}, + {"label":"K24", "x":4.75, "y":3.5}, + {"label":"K25", "x":5.75, "y":3.5}, + {"label":"K26", "x":6.75, "y":3.5}, + {"label":"K27", "x":7.75, "y":3.5}, + {"label":"K28", "x":8.75, "y":3.5}, + {"label":"K88", "x":9.75, "y":3.5}, + {"label":"K87", "x":10.75, "y":3.5}, + {"label":"K85", "x":11.75, "y":3.5}, + {"label":"K93", "x":12.75, "y":3.5, "w":2.25}, + {"label":"K86", "x":15.5, "y":3.5}, + {"label":"K82", "x":16.5, "y":3.5}, + {"label":"K81", "x":17.5, "y":3.5}, + {"label":"K80", "x":18.5, "y":3.5}, + {"label":"K10", "x":0, "y":4.5, "w":1.25}, + {"label":"K11", "x":1.25, "y":4.5}, + {"label":"K12", "x":2.25, "y":4.5}, + {"label":"K13", "x":3.25, "y":4.5}, + {"label":"K14", "x":4.25, "y":4.5}, + {"label":"K15", "x":5.25, "y":4.5}, + {"label":"K16", "x":6.25, "y":4.5}, + {"label":"K17", "x":7.25, "y":4.5}, + {"label":"K18", "x":8.25, "y":4.5}, + {"label":"K78", "x":9.25, "y":4.5}, + {"label":"K77", "x":10.25, "y":4.5}, + {"label":"K75", "x":11.25, "y":4.5}, + {"label":"K74", "x":12.25, "y":4.5, "w":1.75}, + {"label":"K73", "x":14.25, "y":4.75}, + {"label":"K76", "x":15.5, "y":4.5}, + {"label":"K72", "x":16.5, "y":4.5}, + {"label":"K71", "x":17.5, "y":4.5}, + {"label":"K70", "x":18.5, "y":4.5}, + {"label":"K00", "x":0, "y":5.5, "w":1.25}, + {"label":"K01", "x":1.25, "y":5.5}, + {"label":"K02", "x":2.25, "y":5.5, "w":1.25}, + {"label":"K06", "x":3.5, "y":5.5, "w":6.25}, + {"label":"K08", "x":9.75, "y":5.5}, + {"label":"K07", "x":10.75, "y":5.5}, + {"label":"K05", "x":11.75, "y":5.5, "w":1.25}, + {"label":"K04", "x":13.25, "y":5.75}, + {"label":"K03", "x":14.25, "y":5.75}, + {"label":"K66", "x":15.25, "y":5.75}, + {"label":"K62", "x":16.5, "y":5.5}, + {"label":"K61", "x":17.5, "y":5.5}, + {"label":"K60", "x":18.5, "y":5.5} + ] + } + } +} diff --git a/keyboards/mt980/keymaps/walker/keymap.c b/keyboards/mt980/keymaps/walker/keymap.c index c1db4f3d3..83a3fb816 100644 --- a/keyboards/mt980/keymaps/walker/keymap.c +++ b/keyboards/mt980/keymaps/walker/keymap.c @@ -99,35 +99,68 @@ void led_set_keymap(uint8_t usb_led) { } bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + case KC_TRNS: + case KC_NO: + /* Always cancel one-shot layer when another key gets pressed */ + if (record->event.pressed && is_oneshot_layer_active()) + clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED); + return true; + case RESET: + /* Don't allow reset from oneshot layer state */ + if (record->event.pressed && is_oneshot_layer_active()) { + clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED); + return false; + } + return true; case KC_PPLS: if (!numlock_on) { - if (get_oneshot_layer() == 1 || layer_state & 0x2) { - register_code(KC_HOME); - unregister_code(KC_HOME); + if (is_oneshot_layer_active() || layer_state & 0x2) { + if (record->event.pressed) + register_code(KC_HOME); + else + unregister_code(KC_HOME); clear_oneshot_layer_state(ONESHOT_START); } else { - register_code(KC_PGUP); - unregister_code(KC_PGUP); + if (record->event.pressed) + register_code(KC_PGUP); + else + unregister_code(KC_PGUP); } return false; } return true; case KC_PENT: if (!numlock_on) { - if (get_oneshot_layer() == 1 || layer_state & 0x2) { - register_code(KC_END); - unregister_code(KC_END); + if (is_oneshot_layer_active() || layer_state & 0x2) { + if (record->event.pressed) + register_code(KC_END); + else + unregister_code(KC_END); clear_oneshot_layer_state(ONESHOT_START); } else { - register_code(KC_PGDN); - unregister_code(KC_PGDN); + if (record->event.pressed) + register_code(KC_PGDN); + else + unregister_code(KC_PGDN); } return false; } return true; + case KC_NLCK: + /* Shift + NumLock will be treated as shift-Insert */ + if ((keyboard_report->mods & MOD_BIT (KC_LSFT)) || (keyboard_report->mods & MOD_BIT (KC_RSFT))) { + if (record->event.pressed) { + register_code(KC_INS); + unregister_code(KC_INS); + } + return false; + } + else + return true; default: return true; } diff --git a/keyboards/mt980/mt980.c b/keyboards/mt980/mt980.c index 1b03d1aed..5461a3b21 100644 --- a/keyboards/mt980/mt980.c +++ b/keyboards/mt980/mt980.c @@ -17,8 +17,13 @@ uint32_t layer_state_set_keymap (uint32_t state) { __attribute__ ((weak)) void led_set_keymap(uint8_t usb_led) {} -__attribute__ ((weak)) -void action_function_keymap(keyrecord_t *record, uint8_t id, uint8_t opt) {} +void matrix_init_user(void) { + matrix_init_keymap(); +} + +void matrix_scan_user(void) { + matrix_scan_keymap(); +} void keyboard_pre_init_user(void) { /* Set NUMLOCK indicator pin as output */