Skip to content

Commit

Permalink
zigotica userspace add raw_hid_receive (#14869)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
zigotica and fauxpark authored Dec 27, 2021
1 parent 6ec9cd5 commit 07465c0
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 48 deletions.
12 changes: 4 additions & 8 deletions keyboards/z12/keymaps/zigotica/encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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.
Expand Down
116 changes: 82 additions & 34 deletions keyboards/z12/keymaps/zigotica/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
* FIGMA Layer
*
* ,-----------------------------.
* | | TERM | FIGM | |
* | | BASE | FIGM | |
* |-------+------+------+-------|
* |BUFFER | BROW | VIM | SCROLL|
* | TABS | BROW | VIM | ZOOM |
* |-------+------+------+-------|
* |-------+-------+-------|
* |SEARCH | o | o |
* |ZOOMFIT| GRIDS | FULL |
* |-------+-------+-------|
* | o | o | o |
* |ZOOM100| NEXT | COLOR |
* |-------+-------+-------|
*/
[_VIM] = LAYOUT(
[_FIGMA] = LAYOUT(
_______, _______,
_______, _______, _______, _______,
VIM_SIP, _______, _______,
_______, _______, _______
LSFT(KC_1), LCTL(KC_G), LGUI(KC_BSLS),
LSFT(KC_0), KC_N, LCTL(KC_C)
),
/*
* FIGMA Layer
* BROWSER Layer
*
* ,-----------------------------.
* | | TERM | FIGM | |
* | | BASE | FIGM | |
* |-------+------+------+-------|
* | VOL | BROW | VIM | ZOOM |
* | TABS | BROW | VIM | SCROLL|
* |-------+------+------+-------|
* |-------+-------+-------|
* | ZOOM | GRIDS | FULL |
* |SEARCH | BOOKM | DEVTL |
* |-------+-------+-------|
* | o | o | o |
* |ZOOM100| MUTE | READ |
* |-------+-------+-------|
*/
[_FIGMA] = LAYOUT(
[_BROWSER] = LAYOUT(
_______, _______,
_______, _______, _______, _______,
LSFT(KC_1), LCTL(KC_G), LGUI(KC_BSLS),
_______, _______, _______
G(KC_F), G(KC_D), G(A(KC_I)),
G(KC_0), C(KC_M), G(A(KC_R))
),
/*
* BROWSER Layer
* VIM Layer
*
* ,-----------------------------.
* | | TERM | FIGM | |
* | | BASE | FIGM | |
* |-------+------+------+-------|
* | TABS | BROW | VIM | SCROLL|
* |BUFFER | BROW | VIM | SCROLL|
* |-------+------+------+-------|
* |-------+-------+-------|
* |SEARCH | BOOKM | DEVTL |
* |SRCH FL|REPL FL|NEW BUF|
* |-------+-------+-------|
* | o | o | o |
* |SRCH PR|REPL PR| o |
* |-------+-------+-------|
*/
[_BROWSER] = LAYOUT(
[_VIM] = LAYOUT(
_______, _______,
_______, _______, _______, _______,
G(KC_F), G(KC_D), G(A(KC_I)),
_______, _______, _______
VIM_SIF, VIM_RIF, VIM_NEW,
VIM_SIP, VIM_RIP, _______
),
};
10 changes: 5 additions & 5 deletions keyboards/z12/keymaps/zigotica/oled.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions keyboards/z12/keymaps/zigotica/readme.md
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 1 addition & 1 deletion users/zigotica/zigotica.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ enum userspace_layers {
};
#else
enum userspace_layers {
_TERMINAL = 0,
_BASE = 0,
_FIGMA,
_BROWSER,
_VIM,
Expand Down

0 comments on commit 07465c0

Please sign in to comment.