From 98a2e9dc0ef7b18826e21af75fd24861ac683173 Mon Sep 17 00:00:00 2001 From: jonavin <71780717+Jonavin@users.noreply.github.com> Date: Thu, 2 Sep 2021 00:12:57 -0400 Subject: [PATCH] [Keymap] new murphpad landscape keymap with encoder enhanced functions (#14103) Co-authored-by: Drashna Jaelre Co-authored-by: Ryan Co-authored-by: Jonavin <=> --- .../murphpad/keymaps/jonavin/config.h | 23 ++ .../murphpad/keymaps/jonavin/keymap.c | 343 ++++++++++++++++++ .../keymaps/jonavin/layout_landscape.h | 43 +++ .../murphpad/keymaps/jonavin/readme.md | 65 ++++ .../murphpad/keymaps/jonavin/rules.mk | 5 + 5 files changed, 479 insertions(+) create mode 100644 keyboards/mechwild/murphpad/keymaps/jonavin/config.h create mode 100644 keyboards/mechwild/murphpad/keymaps/jonavin/keymap.c create mode 100644 keyboards/mechwild/murphpad/keymaps/jonavin/layout_landscape.h create mode 100644 keyboards/mechwild/murphpad/keymaps/jonavin/readme.md create mode 100644 keyboards/mechwild/murphpad/keymaps/jonavin/rules.mk diff --git a/keyboards/mechwild/murphpad/keymaps/jonavin/config.h b/keyboards/mechwild/murphpad/keymaps/jonavin/config.h new file mode 100644 index 000000000..7c1621515 --- /dev/null +++ b/keyboards/mechwild/murphpad/keymaps/jonavin/config.h @@ -0,0 +1,23 @@ +/* Copyright 2021 Jonavin Eng + * + * 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 . + */ + +#pragma once + +// Standard encoder position. Set to 1 for top right optional position +#define ENCODER_DEFAULTACTIONS_INDEX 0 + +// Increase layers to 6 for VIA +#define DYNAMIC_KEYMAP_LAYER_COUNT 6 diff --git a/keyboards/mechwild/murphpad/keymaps/jonavin/keymap.c b/keyboards/mechwild/murphpad/keymaps/jonavin/keymap.c new file mode 100644 index 000000000..001abc502 --- /dev/null +++ b/keyboards/mechwild/murphpad/keymaps/jonavin/keymap.c @@ -0,0 +1,343 @@ +/* Copyright 2021 Kyle McCreery + * Copyright 2021 Jonavin Eng + * + * 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 . + */ +#include QMK_KEYBOARD_H +#include "jonavin.h" +#include "layout_landscape.h" + +#define LANDSCAPE_MODE + +// Defines names for use in layer keycodes and the keymap +enum layer_names { + _FN2 = 2, + _FN3, + _FN4, + _RGB +}; + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + + [_BASE] = LAYOUT_landscape( + TT(_FN1), TT(_FN2), KC_MUTE, + + KC_NLCK, KC_PSLS, KC_PAST, KC_PMNS, KC_PPLS, KC_BSPC, + KC_TAB, KC_P7, KC_P8, KC_P9, KC_PDOT, KC_RGUI, + KC_RSFT, KC_P4, KC_P5, KC_P6, KC_COMMA, KC_RCTL, + KC_P0, KC_P1, KC_P2, KC_P3, KC_PENT, KC_RALT, + + TT(_FN3), TT(_FN4), TT(_RGB) + ), + [_FN1] = LAYOUT_landscape( + _______, _______, ENCFUNC, + + _______, KC_F10, KC_F11, KC_F12, KC_PSCR, _______, + _______, KC_F7, KC_F8, KC_F9, KC_SLCK, _______, + _______, KC_F4, KC_F5, KC_F6, KC_PAUS, _______, + _______, KC_F1, KC_F2, KC_F3, _______, _______, + + _______, _______, _______ + ), + [_FN2] = LAYOUT_landscape( + _______, _______, RESET, + + _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, + + _______, _______, _______ + ), + [_FN3] = LAYOUT_landscape( + _______, _______, _______, + + _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, + + _______, _______, _______ + ), + [_FN4] = LAYOUT_landscape( + _______, _______, _______, + + _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, + + _______, _______, _______ + ), + [_RGB] = LAYOUT_landscape( + _______, _______, _______, + + _______, _______, _______, _______, _______, _______, + _______, RGB_HUD, RGB_SPI, RGB_HUI, RGB_SAI, _______, + _______, RGB_RMOD, RGB_TOG, RGB_MOD, RGB_SAD, _______, + _______, RGB_VAD, RGB_SPD, RGB_VAI, KC_NO, _______, + + _______, _______, _______ + ), +}; + +typedef struct { + char keydesc[6]; // this will be displayed on OLED + uint16_t keycode; // this is the keycode that will be sent when activted +} keycodedescType; + +static const keycodedescType PROGMEM keyselection[] = { + // list of key codes that will be scrolled through by encoder and description + {"TASK", KC_TASK}, + {"INS", KC_INS}, + {"DEL", KC_DEL}, + {"PrtSc", KC_PSCR}, + {"ScrLk", KC_SCLN}, + {"Break", KC_PAUS}, + {"C-A-D", KC_CAD}, // Ctrl-Alt-Del + {"AltF4", KC_AF4}, + {"PLAY", KC_MEDIA_PLAY_PAUSE}, + {"RESET", RESET}, // firmware flash mode +}; + +#define MAX_KEYSELECTION sizeof(keyselection)/sizeof(keyselection[0]) + +static uint8_t selectedkey_idx = 0; +static keycodedescType selectedkey_rec; + +static void set_selectedkey(uint8_t idx) { + // make a copy from PROGMEM + memcpy_P (&selectedkey_rec, &keyselection[idx], sizeof selectedkey_rec); + + //selectedkey_rec = keyselection[idx]; + +} + +void keyboard_post_init_keymap(void) { + // Call the keyboard post init code. + set_selectedkey(selectedkey_idx); +} + +bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + case ENCFUNC: + if (record->event.pressed) { + selectedkey_rec.keycode == RESET ? reset_keyboard() : tap_code16(selectedkey_rec.keycode); // handle RESET code + } else { + // when keycode is released + } + break; + } + return true; +}; + + +#ifdef ENCODER_ENABLE // Encoder Functionality + uint8_t selected_layer = 0; + + bool encoder_update_user(uint8_t index, bool clockwise) { + #ifdef OLED_ENABLE + oled_clear(); + oled_render(); + #endif + switch (index) { + case 0: // This is the only encoder right now, keeping for consistency + switch(get_highest_layer(layer_state)){ // special handling per layer + case _FN1: // on Fn layer select what the encoder does when pressed + if (!keyboard_report->mods) { + if ( clockwise ) { + if ( selectedkey_idx < MAX_KEYSELECTION-1) { + selectedkey_idx ++; + } else { + // do nothing + } + } else if ( !clockwise ) { + if ( selectedkey_idx > 0){ + selectedkey_idx --; + } else { + // do nothing + } + } + set_selectedkey(selectedkey_idx); + break; + } else { + // continue to default + } + default: // all other layers + if ( clockwise ) { + if (keyboard_report->mods & MOD_BIT(KC_RSFT) ) { // If you are holding Right Shift, encoder changes layers + if(selected_layer < (DYNAMIC_KEYMAP_LAYER_COUNT-1)) { + selected_layer ++; + layer_move(selected_layer); + } + } else if (keyboard_report->mods & MOD_BIT(KC_RCTL)) { // if holding Right Ctrl, navigate next word + tap_code16(LCTL(KC_RGHT)); + } else if (keyboard_report->mods & MOD_BIT(KC_RALT)) { // if holding Right Alt, change media next track + tap_code(KC_MEDIA_NEXT_TRACK); + } else { + tap_code(KC_VOLU); // Otherwise it just changes volume + } + } else if ( !clockwise ) { + if (keyboard_report->mods & MOD_BIT(KC_RSFT) ) { + if (selected_layer > 0) { + selected_layer --; + layer_move(selected_layer); + } + } else if (keyboard_report->mods & MOD_BIT(KC_RCTL)) { // if holding Right Ctrl, navigate previous word + tap_code16(LCTL(KC_LEFT)); + } else if (keyboard_report->mods & MOD_BIT(KC_RALT)) { // if holding Right Alt, change media previous track + tap_code(KC_MEDIA_PREV_TRACK); + } else { + tap_code(KC_VOLD); + } + } + break; + } + break; + } + return true; + } +#endif + + +#ifdef OLED_ENABLE + static void render_logo(void) { // Render MechWild "MW" Logo + static const char PROGMEM logo_1[] = {0x8A, 0x8B, 0x8C, 0x8D, 0x00}; + static const char PROGMEM logo_2[] = {0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0x00}; + static const char PROGMEM logo_3[] = {0xCA, 0xCB, 0xCC, 0xCD, 0x00}; + static const char PROGMEM logo_4[] = {0x20, 0x8E, 0x8F, 0x90, 0x00}; + oled_set_cursor(0,0); + oled_write_P(logo_1, false); + oled_set_cursor(0,1); + oled_write_P(logo_2, false); + oled_set_cursor(0,2); + oled_write_P(logo_3, false); + oled_set_cursor(0,3); + oled_write_P(logo_4, false); + } + + #ifdef LANDSCAPE_MODE + void oled_task_user(void) { + + render_logo(); + oled_set_cursor(8,2); + switch(selected_layer){ + case _BASE: + oled_write_P(PSTR("BASE"), false); + break; + case _FN1: + oled_write_P(PSTR("FN "), false); + oled_write(selectedkey_rec.keydesc, false); + break; + case _FN2: + oled_write_P(PSTR("FN2 "), false); + break; + case _FN3: + oled_write_P(PSTR("FN3 "), false); + break; + case _FN4: + oled_write_P(PSTR("FN4 "), false); + break; + case _RGB: + oled_write_P(PSTR("RGB "), false); + break; + default: + oled_write_P(PSTR(" ?? "), false); // Should never display, here as a catchall + } + oled_write_P(keymap_config.no_gui ? PSTR(" WL") : PSTR(" "), false); + oled_set_cursor(8,3); + if (get_highest_layer(layer_state) == selected_layer) { + oled_write_P(PSTR(" "), false); + } else { + switch (get_highest_layer(layer_state)) { + case _BASE: + oled_write_P(PSTR("Temp BASE"), false); + break; + case _FN1: + oled_write_P(PSTR("Temp FN "), false); + oled_write(selectedkey_rec.keydesc, false); + break; + case _FN2: + oled_write_P(PSTR("Temp FN2 "), false); + break; + case _FN3: + oled_write_P(PSTR("Temp FN3 "), false); + break; + case _FN4: + oled_write_P(PSTR("Temp FN4 "), false); + break; + case _RGB: + oled_write_P(PSTR("Temp RGB "), false); + break; + default: + oled_write_P(PSTR("Temp ????"), false); // Should never display, here as a catchall + } + } + led_t led_state = host_keyboard_led_state(); + oled_set_cursor(8,0); + oled_write_P(PSTR(" JONAVIN "), false); + oled_set_cursor(8,1); + oled_write_P(led_state.num_lock ? PSTR("NUM ") : PSTR(" "), false); + oled_write_P(led_state.caps_lock ? PSTR("CAPS ") : PSTR(" "), false); + oled_write_P(led_state.scroll_lock ? PSTR("SCR") : PSTR(" "), false); + } + #endif // LANDSCAPE_MODE + + // regular mode + #ifndef LANDSCAPE_MODE + oled_rotation_t oled_init_user(oled_rotation_t rotation) { + return OLED_ROTATION_270; // flips the display 270 degrees + } + + void oled_task_user(void) { + render_logo(); + oled_set_cursor(0,6); + + oled_write_ln_P(PSTR("Layer"), false); + + switch (get_highest_layer(layer_state)) { + case _BASE: + oled_write_ln_P(PSTR("Base"), false); + break; + case _FN1: + oled_write_ln_P(PSTR("FN 1"), false); + break; + case _FN2: + oled_write_ln_P(PSTR("FN 2"), false); + break; + case _FN3: + oled_write_ln_P(PSTR("FN 3"), false); + break; + case _FN4: + oled_write_ln_P(PSTR("FN 4"), false); + break; + case _RGB: + oled_write_ln_P(PSTR("RGB "), false); + break; + default: + oled_write_ln_P(PSTR("Undef"), false); + } + oled_write_ln_P(PSTR(""), false); + // Host Keyboard LED Status + led_t led_state = host_keyboard_led_state(); + oled_write_ln_P(led_state.num_lock ? PSTR("NUM ") : PSTR(" "), false); + oled_write_ln_P(led_state.caps_lock ? PSTR("CAP ") : PSTR(" "), false); + oled_write_ln_P(led_state.scroll_lock ? PSTR("SCR ") : PSTR(" "), false); + } + #endif // !LANDSCAPE_MODE + + void suspend_power_down_user(void) { // shutdown oled when powered down to prevent OLED from showing Mercutio all the time + oled_off(); + } +#endif diff --git a/keyboards/mechwild/murphpad/keymaps/jonavin/layout_landscape.h b/keyboards/mechwild/murphpad/keymaps/jonavin/layout_landscape.h new file mode 100644 index 000000000..2a3dce21d --- /dev/null +++ b/keyboards/mechwild/murphpad/keymaps/jonavin/layout_landscape.h @@ -0,0 +1,43 @@ +/* Copyright 2021 Jonavin Eng + * + * 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 . + */ + +#pragma once + +#include "quantum.h" + +/* First section contains the physical layout of the board and position of keys. + * + * Second is a two-dimensional array which represents the switch matrix. + */ + +#define LAYOUT_landscape( \ + k50, k40, k30, \ + k51, k41, k31, k20, k10, k00, \ + k52, k42, k32, k21, k11, k01, \ + k53, k43, k33, k22, k12, k02, \ + k54, k44, k34, k23, k13, k03, \ + \ + BACK00, BACK01, BACK02 \ +\ +) { \ + { BACK00, k00, k01, k02, k03 }, \ + { BACK01, k10, k11, k12, k13 }, \ + { BACK02, k20, k21, k22, k23 }, \ + { k30, k31, k32, k33, k34 }, \ + { k40, k41, k42, k43, k44 }, \ + { k50, k51, k52, k53, k54 } \ +} + diff --git a/keyboards/mechwild/murphpad/keymaps/jonavin/readme.md b/keyboards/mechwild/murphpad/keymaps/jonavin/readme.md new file mode 100644 index 000000000..933157063 --- /dev/null +++ b/keyboards/mechwild/murphpad/keymaps/jonavin/readme.md @@ -0,0 +1,65 @@ +Jonavin's Custom MurphPad Landscape Layout + +This allows you to use Murphpad in a horizontal/landscape orientation with extra layers + + - OLED has been rotated for landscape mode + - Keymap positions have been updated so it's easier to visualize the keymap in landscape + + [_BASE] = LAYOUT_landscape( + TT(_FN1), TT(_FN2), KC_MUTE, + + KC_NLCK, KC_PSLS, KC_PAST, KC_PMNS, KC_PPLS, KC_BSPC, + KC_TAB, KC_P7, KC_P8, KC_P9, KC_PDOT, KC_RGUI, + KC_RSFT, KC_P4, KC_P5, KC_P6, KC_COMMA, KC_RCTL, + KC_P0, KC_P1, KC_P2, KC_P3, KC_PENT, KC_RALT, + + _______, _______, _______ + ), + +NOTE: VIA is enabled, but it will show it in the normal orientation until I build a landscape layout version + +Special Features + - FN1 layer has encoder selectable key codes and displayed on OLED + + Change these in keymap.c to assign your desired key selection + + static const keycodedescType PROGMEM keyselection[] = { + // list of key codes that will be scrollled through by encoder and description + {"TASK", KC_TASK}, + {"INS", KC_INS}, + {"DEL", KC_DEL}, + {"PrtSc", KC_PSCR}, + {"ScrLk", KC_SCLN}, + {"Break", KC_PAUS}, + {"C-A-D", KC_CAD}, // Ctrl-Alt-Del + {"AltF4", KC_AF4}, + {"PLAY", KC_MEDIA_PLAY_PAUSE}, + {"RESET", RESET}, // firmware flash mode + }; + + - Additional encoder functionality + - While holding R Shift, changes layers + - While holding R Ctrl, navigates next or previous word + - While holding R Alt, media next track or previous track + - Otherwise change volume up/dn + + +rules.mk OPTIONS - Active features from userspace + + - STARTUP_NUMLOCK_ON = yes + - turns on NUMLOCK by default + +DEFAULT MAPPING + +![image](https://user-images.githubusercontent.com/71780717/131718965-b20afef6-3bc5-49e4-952f-5755a9d6d539.png) + + +FN1 Layer 1 + +![image](https://user-images.githubusercontent.com/71780717/131719025-d41cbcd9-80b1-4a0a-abb5-55d878752dc6.png) + + +RGB Layer 5 - Use Shift+Encoder to get to RGB layer 5 + +![image](https://user-images.githubusercontent.com/71780717/131719492-e2d05a75-3a7a-48ca-94a3-faa3ff891914.png) + diff --git a/keyboards/mechwild/murphpad/keymaps/jonavin/rules.mk b/keyboards/mechwild/murphpad/keymaps/jonavin/rules.mk new file mode 100644 index 000000000..4887fb1bd --- /dev/null +++ b/keyboards/mechwild/murphpad/keymaps/jonavin/rules.mk @@ -0,0 +1,5 @@ +VIA_ENABLE = yes +LTO_ENABLE = yes + +STARTUP_NUMLOCK_ON = yes +ENCODER_DEFAULTACTIONS_ENABLE = no