1
0
Fork 0

zigotica userspace add raw_hid_receive (#14869)

* zigotica userspace add raw_hid_receive

* add 3 keys to figma keymap

* add 2 keys to vim keymap

* improve vim keys

* add 3 keys to browser keymap

* comment typo

* shorten SEND_STRING

Co-authored-by: Ryan <fauxpark@gmail.com>

Co-authored-by: Ryan <fauxpark@gmail.com>
This commit is contained in:
Sergi Meseguer 2021-12-27 11:24:14 +01:00 committed by GitHub
parent 6ec9cd511d
commit 07465c0ebb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 100 additions and 53 deletions

View file

@ -48,12 +48,8 @@ bool encoder_update_user(uint8_t index, bool clockwise) {
// Cycle through Tabs
if (clockwise) {
tap_code16(C(KC_TAB));
/* register_code16(G(KC_RCBR)); */
/* unregister_code16(G(KC_RCBR)); */
} else {
tap_code16(S(C(KC_TAB)));
/* register_code16(G(KC_LCBR)); */
/* unregister_code16(G(KC_LCBR)); */
}
} else { // RIGHT
// Scroll up/down
@ -68,11 +64,11 @@ bool encoder_update_user(uint8_t index, bool clockwise) {
break;
case _FIGMA:
if (index == 0) { // LEFT
// Volume control.
// Cycle through Tabs
if (clockwise) {
tap_code(KC_VOLU);
tap_code16(C(KC_TAB));
} else {
tap_code(KC_VOLD);
tap_code16(S(C(KC_TAB)));
}
} else { // RIGHT
// Zoom in/out
@ -89,7 +85,7 @@ bool encoder_update_user(uint8_t index, bool clockwise) {
}
}
break;
case _TERMINAL:
case _BASE:
default:
if (index == 0) { // LEFT
// Volume control.

View file

@ -16,25 +16,73 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "zigotica.h"
#include "raw_hid.h"
#ifdef RAW_ENABLE
void raw_hid_receive(uint8_t* data, uint8_t length) {
layer_clear();
if (data[0] == 99) {
layer_on(_BASE);
}
else {
layer_on(data[0]);
}
}
#endif
// Custom Keycodes
#define MODE_1 TO(_TERMINAL)
#define MODE_1 TO(_BASE)
#define MODE_2 TO(_FIGMA)
#define MODE_3 TO(_BROWSER)
#define MODE_4 TO(_VIM)
enum custom_keycodes {
VIM_SIP = SAFE_RANGE
VIM_SIF = SAFE_RANGE,
VIM_SIP,
VIM_RIF,
VIM_RIP,
VIM_NEW
};
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case VIM_SIP:
case VIM_SIF:// Search in File
if (record->event.pressed) {
register_code(KC_ESC);
tap_code(KC_SLASH);
} else { // released
unregister_code(KC_ESC);
}
break;
case VIM_SIP:// Search in Project
if (record->event.pressed) {
register_code(KC_ESC);
SEND_STRING(":Ag ");
} else {
// released
} else { // released
unregister_code(KC_ESC);
}
break;
case VIM_RIF:// Replace in File
if (record->event.pressed) {
register_code(KC_ESC);
SEND_STRING(":%s/a/b/g");
} else { // released
unregister_code(KC_ESC);
}
break;
case VIM_RIP:// Replace in Project
if (record->event.pressed) {
register_code(KC_ESC);
SEND_STRING(":cdo %s/a/b/g");
} else { // released
unregister_code(KC_ESC);
}
break;
case VIM_NEW:// New buffer
if (record->event.pressed) {
SEND_STRING("\e:vnew\n");
} else { // released
unregister_code(KC_ENT);
unregister_code(KC_ESC);
}
break;
@ -44,83 +92,83 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/*
* TERMINAL Layer
* BASE Layer
*
* ,-----------------------------.
* | | TERM | FIGM | |
* | | BASE | FIGM | |
* |-------+------+------+-------|
* | VOL | BROW | VIM | SCROLL|
* |VOL/PLY| BROW | VIM | SCROLL|
* |-------+------+------+-------|
* |-------+-------+-------|
* | MEDIA | o | o |
* | o | o | o |
* |-------+-------+-------|
* | o | o | o |
* |-------+-------+-------|
*/
[_TERMINAL] = LAYOUT(
[_BASE] = LAYOUT(
MODE_1, MODE_2,
ZK_MEDIA, MODE_3, MODE_4, _______,
_______, _______, _______,
_______, _______, _______
),
/*
* VIM Layer
*
* ,-----------------------------.
* | | TERM | FIGM | |
* |-------+------+------+-------|
* |BUFFER | BROW | VIM | SCROLL|
* |-------+------+------+-------|
* |-------+-------+-------|
* |SEARCH | o | o |
* |-------+-------+-------|
* | o | o | o |
* |-------+-------+-------|
*/
[_VIM] = LAYOUT(
_______, _______,
_______, _______, _______, _______,
VIM_SIP, _______, _______,
_______, _______, _______
),
/*
* FIGMA Layer
*
* ,-----------------------------.
* | | TERM | FIGM | |
* | | BASE | FIGM | |
* |-------+------+------+-------|
* | VOL | BROW | VIM | ZOOM |
* | TABS | BROW | VIM | ZOOM |
* |-------+------+------+-------|
* |-------+-------+-------|
* | ZOOM | GRIDS | FULL |
* |ZOOMFIT| GRIDS | FULL |
* |-------+-------+-------|
* | o | o | o |
* |ZOOM100| NEXT | COLOR |
* |-------+-------+-------|
*/
[_FIGMA] = LAYOUT(
_______, _______,
_______, _______, _______, _______,
LSFT(KC_1), LCTL(KC_G), LGUI(KC_BSLS),
_______, _______, _______
LSFT(KC_0), KC_N, LCTL(KC_C)
),
/*
* BROWSER Layer
*
* ,-----------------------------.
* | | TERM | FIGM | |
* | | BASE | FIGM | |
* |-------+------+------+-------|
* | TABS | BROW | VIM | SCROLL|
* |-------+------+------+-------|
* |-------+-------+-------|
* |SEARCH | BOOKM | DEVTL |
* |-------+-------+-------|
* | o | o | o |
* |ZOOM100| MUTE | READ |
* |-------+-------+-------|
*/
[_BROWSER] = LAYOUT(
_______, _______,
_______, _______, _______, _______,
G(KC_F), G(KC_D), G(A(KC_I)),
_______, _______, _______
G(KC_0), C(KC_M), G(A(KC_R))
),
/*
* VIM Layer
*
* ,-----------------------------.
* | | BASE | FIGM | |
* |-------+------+------+-------|
* |BUFFER | BROW | VIM | SCROLL|
* |-------+------+------+-------|
* |-------+-------+-------|
* |SRCH FL|REPL FL|NEW BUF|
* |-------+-------+-------|
* |SRCH PR|REPL PR| o |
* |-------+-------+-------|
*/
[_VIM] = LAYOUT(
_______, _______,
_______, _______, _______, _______,
VIM_SIF, VIM_RIF, VIM_NEW,
VIM_SIP, VIM_RIP, _______
),
};

View file

@ -21,16 +21,16 @@ static void render_status(void) {
oled_write_P(PSTR("Layer: "), false);
switch (get_highest_layer(layer_state)) {
case _VIM:
oled_write_P(PSTR("VIM\n\nBUFFER SCROLL"), false);
oled_write_P(PSTR("VIM \n\nBUFFER SCROLL"), false);
break;
case _FIGMA:
oled_write_P(PSTR("FIGMA\n\nVOLUME ZOOM"), false);
oled_write_P(PSTR("FIGMA \n\nTABS ZOOM"), false);
break;
case _BROWSER:
oled_write_P(PSTR("BROWSER\n\nTABS SCROLL"), false);
oled_write_P(PSTR("BROWSER \n\nTABS SCROLL"), false);
break;
case _TERMINAL:
oled_write_P(PSTR("TERMINAL\n\nVOLUME SCROLL"), false);
case _BASE:
oled_write_P(PSTR("BASE \n\nVOLUME SCROLL"), false);
break;
default:
oled_write_P(PSTR("Undef\n"), false);

View file

@ -0,0 +1,3 @@
# zigotica's z12 Layout
This layout uses `RAW_ENABLE = yes`, and benefits from [active-app-qmk-layer-updater](https://github.com/zigotica/active-app-qmk-layer-updater) node script (run by the host system) to change layers programmatically depending on the current active app.

View file

@ -26,7 +26,7 @@ enum userspace_layers {
};
#else
enum userspace_layers {
_TERMINAL = 0,
_BASE = 0,
_FIGMA,
_BROWSER,
_VIM,