diff options
-rw-r--r-- | keyboards/ergodox/keymaps/narze/config.h | 21 | ||||
-rw-r--r-- | keyboards/ergodox/keymaps/narze/default.png.md | 1 | ||||
-rw-r--r-- | keyboards/ergodox/keymaps/narze/default_highres.png.md | 1 | ||||
-rw-r--r-- | keyboards/ergodox/keymaps/narze/keymap.c | 852 | ||||
-rw-r--r-- | keyboards/ergodox/keymaps/narze/readme.md | 45 | ||||
-rw-r--r-- | keyboards/ergodox/keymaps/narze/rules.mk | 24 | ||||
-rw-r--r-- | keyboards/ergodox/keymaps/narze/visualizer.c | 94 | ||||
-rw-r--r-- | keyboards/planck/keymaps/narze/config.h | 42 | ||||
-rw-r--r-- | keyboards/planck/keymaps/narze/keymap.c | 524 | ||||
-rw-r--r-- | keyboards/planck/keymaps/narze/readme.md | 31 | ||||
-rw-r--r-- | keyboards/planck/keymaps/narze/rules.mk | 23 |
11 files changed, 1658 insertions, 0 deletions
diff --git a/keyboards/ergodox/keymaps/narze/config.h b/keyboards/ergodox/keymaps/narze/config.h new file mode 100644 index 000000000..8174edd35 --- /dev/null +++ b/keyboards/ergodox/keymaps/narze/config.h @@ -0,0 +1,21 @@ +#ifndef CONFIG_H_ +#define CONFIG_H_ + +#include "../../config.h" + +#undef TAPPING_TERM +#define TAPPING_TERM 150 + +// Combos not working yet +// #define COMBO_TERM 20 +// #define COMBO_COUNT 1 +// #define COMBO_ALLOW_ACTION_KEYS + +#define IGNORE_MOD_TAP_INTERRUPT +#define PERMISSIVE_HOLD +#define PREVENT_STUCK_MODIFIERS + +#undef MOUSEKEY_DELAY +#define MOUSEKEY_DELAY 100 + +#endif diff --git a/keyboards/ergodox/keymaps/narze/default.png.md b/keyboards/ergodox/keymaps/narze/default.png.md new file mode 100644 index 000000000..744e7d172 --- /dev/null +++ b/keyboards/ergodox/keymaps/narze/default.png.md @@ -0,0 +1 @@ +https://i.imgur.com/fKX0Zbs.png diff --git a/keyboards/ergodox/keymaps/narze/default_highres.png.md b/keyboards/ergodox/keymaps/narze/default_highres.png.md new file mode 100644 index 000000000..074e0634d --- /dev/null +++ b/keyboards/ergodox/keymaps/narze/default_highres.png.md @@ -0,0 +1 @@ +https://i.imgur.com/giAc3M9.jpg diff --git a/keyboards/ergodox/keymaps/narze/keymap.c b/keyboards/ergodox/keymaps/narze/keymap.c new file mode 100644 index 000000000..5871c221a --- /dev/null +++ b/keyboards/ergodox/keymaps/narze/keymap.c @@ -0,0 +1,852 @@ +#include "ergodox.h" +// #include "debug.h" +#include "action_layer.h" +#include "version.h" +#include "eeconfig.h" +#include "eeprom.h" +#include "keymap_colemak.h" + +extern keymap_config_t keymap_config; + +enum ergodox_layers { + _QWERTY, + _COLEMAK, + _QWOC, + _LOWER, + _RAISE, + _PLOVER, +// Intermediate layers for SuperDuper (Combo keys does not work on Infinity yet) + _SUPER, + _DUPER, + _SUPERDUPER, + _MOUSE, + _ADJUST, + _MDIA, + _SYMB, +}; + +enum ergodox_keycodes { + QWERTY = SAFE_RANGE, + COLEMAK, + QWOC, + PLOVER, + SUPER, + DUPER, + SUPERDUPER, + MOUSE, + LOWER, + RAISE, + BACKLIT, + EXT_PLV, + SDTOGG, // Toggle SuperDuper + EPRM, + VRSN, + RGB_SLD +}; + +enum functions { + M_GUI_UNDS, // Simulate GUI_T(KC_UNDS) + M_SFT_PO, // SFT_T(KC_LPRN) + M_SFT_PC, // SFT_T(KC_RPRN) +}; + +// Timer for custom mod tap +static uint16_t m_gui_unds_timer; +static uint16_t m_sft_po_timer; +static uint16_t m_sft_pc_timer; + +// Fillers to make layering more clear +#define _______ KC_TRNS +#define XXXXXXX KC_NO + +// Narze : Custom Macros +#define HPR_ESC ALL_T(KC_ESC) +#define From 372b138a6bc43b0fdff4e46ae4c799fd1b1f2785 Mon Sep 17 00:00:00 2001
From: Naushir Patuck <naush@raspberrypi.com>
Date: Thu, 12 Mar 2020 14:09:38 +0000
Subject: [PATCH] media: imx219: Advertise embedded data node on media
pad 1
This commit updates the imx219 driver to adverise support for embedded
data streams. This can then be used by the bcm2835-unicam driver, which
has recently been updated to expose the embedded data stream to
userland.
The imx219 sensor subdevice overloads the media pad to differentiate
between image stream (pad 0) and embedded data stream (pad 1) when
performing the v4l2_subdev_pad_ops functions.
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
---
drivers/media/i2c/imx219.c | 226 +++++++++++++++++++++++++------------
1 file changed, 155 insertions(+), 71 deletions(-)
--- a/drivers/media/i2c/imx219.c
+++ b/drivers/media/i2c/imx219.c
@@ -112,6 +112,16 @@
#define IMX219_TESTP_BLUE_DEFAULT 0
#define IMX219_TESTP_GREENB_DEFAULT 0
+/* Embedded metadata stream structure */
+#define IMX219_EMBEDDED_LINE_WIDTH 16384
+#define IMX219_NUM_EMBEDDED_LINES 1
+
+enum pad_types {
+ IMAGE_PAD,
+ METADATA_PAD,
+ NUM_PADS
+};
+
struct imx219_reg {
u16 address;
u8 val;
@@ -503,7 +513,7 @@ static const struct imx219_mode supporte
struct imx219 {
struct v4l2_subdev sd;
- struct media_pad pad;
+ struct media_pad pad[NUM_PADS];
struct v4l2_mbus_framefmt fmt;
@@ -652,17 +662,25 @@ static void imx219_set_default_format(st
static int imx219_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
{
struct imx219 *imx219 = to_imx219(sd);
- struct v4l2_mbus_framefmt *try_fmt =
- v4l2_subdev_get_try_format(sd, fh->pad, 0);
+ struct v4l2_mbus_framefmt *try_fmt_img =
+ v4l2_subdev_get_try_format(sd, fh->pad, IMAGE_PAD);
+ struct v4l2_mbus_framefmt *try_fmt_meta =
+ v4l2_subdev_get_try_format(sd, fh->pad, METADATA_PAD);
mutex_lock(&imx219->mutex);
- /* Initialize try_fmt */
- try_fmt->width = supported_modes[0].width;
- try_fmt->height = supported_modes[0].height;
- try_fmt->code = imx219_get_format_code(imx219,
- MEDIA_BUS_FMT_SRGGB10_1X10);
- try_fmt->field = V4L2_FIELD_NONE;
+ /* Initialize try_fmt for the image pad */
+ try_fmt_img->width = supported_modes[0].width;
+ try_fmt_img->height = supported_modes[0].height;
+ try_fmt_img->code = imx219_get_format_code(imx219,
+ MEDIA_BUS_FMT_SRGGB10_1X10);
+ try_fmt_img->field = V4L2_FIELD_NONE;
+
+ /* Initialize try_fmt for the embedded metadata pad */
+ try_fmt_meta->width = IMX219_EMBEDDED_LINE_WIDTH;
+ try_fmt_meta->height = IMX219_NUM_EMBEDDED_LINES;
+ try_fmt_meta->code = MEDIA_BUS_FMT_SENSOR_DATA;
+ try_fmt_meta->field = V4L2_FIELD_NONE;
mutex_unlock(&imx219->mutex);
@@ -764,10 +782,21 @@ static int imx219_enum_mbus_code(struct
{
struct imx219 *imx219 = to_imx219(sd);
- if (code->index >= (ARRAY_SIZE(codes) / 4))
+ if (code->pad >= NUM_PADS)
return -EINVAL;
- code->code = imx219_get_format_code(imx219, codes[code->index * 4]);
+ if (code->pad == IMAGE_PAD) {
+ if (code->index >= (ARRAY_SIZE(codes) / 4))
+ return -EINVAL;
+
+ code->code = imx219_get_format_code(imx219,
+ codes[code->index * 4]);
+ } else {
+ if (code->index > 0)
+ return -EINVAL;
+
+ code->code = MEDIA_BUS_FMT_SENSOR_DATA;
+ }
return 0;
}
@@ -778,16 +807,29 @@ static int imx219_enum_frame_size(struct
{
struct imx219 *imx219 = to_imx219(sd);
- if (fse->index >= ARRAY_SIZE(supported_modes))
+ if (fse->pad >= NUM_PADS)
return -EINVAL;
- if (fse->code != imx219_get_format_code(imx219, fse->code))
- return -EINVAL;
+ if (fse->pad == IMAGE_PAD) {
+ if (fse->index >= ARRAY_SIZE(supported_modes))
+ return -EINVAL;
+
+ if (fse->code != imx219_get_format_code(imx219, fse->code))
+ return -EINVAL;
+
+ fse->min_width = supported_modes[fse->index].width;
+ fse->max_width = fse->min_width;
+ fse->min_height = supported_modes[fse->index].height;
+ fse->max_height = fse->min_height;
+ } else {
+ if (fse->code != MEDIA_BUS_FMT_SENSOR_DATA || fse->index > 0)
+ return -EINVAL;
- fse->min_width = supported_modes[fse->index].width;
- fse->max_width = fse->min_width;
- fse->min_height = supported_modes[fse->index].height;
- fse->max_height = fse->min_height;
+ fse->min_width = IMX219_EMBEDDED_LINE_WIDTH;
+ fse->max_width = fse->min_width;
+ fse->min_height = IMX219_NUM_EMBEDDED_LINES;
+ fse->max_height = fse->min_height;
+ }
return 0;
}
@@ -802,9 +844,9 @@ static void imx219_reset_colorspace(stru
fmt->xfer_func = V4L2_MAP_XFER_FUNC_DEFAULT(fmt->colorspace);
}
-static void imx219_update_pad_format(struct imx219 *imx219,
- const struct imx219_mode *mode,
- struct v4l2_subdev_format *fmt)
+static void imx219_update_image_pad_format(struct imx219 *imx219,
+ const struct imx219_mode *mode,
+ struct v4l2_subdev_format *fmt)
{
fmt->format.width = mode->width;
fmt->format.height = mode->height;
@@ -812,20 +854,38 @@ static void imx219_update_pad_format(str
imx219_reset_colorspace(&fmt->format);
}
+static void imx219_update_metadata_pad_format(struct v4l2_subdev_format *fmt)
+{
+ fmt->format.width = IMX219_EMBEDDED_LINE_WIDTH;
+ fmt->format.height = IMX219_NUM_EMBEDDED_LINES;
+ fmt->format.code = MEDIA_BUS_FMT_SENSOR_DATA;
+ fmt->format.field = V4L2_FIELD_NONE;
+}
+
static int __imx219_get_pad_format(struct imx219 *imx219,
struct v4l2_subdev_pad_config *cfg,
struct v4l2_subdev_format *fmt)
{
+ if (fmt->pad >= NUM_PADS)
+ return -EINVAL;
+
if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
struct v4l2_mbus_framefmt *try_fmt =
v4l2_subdev_get_try_format(&imx219->sd, cfg, fmt->pad);
/* update the code which could change due to vflip or hflip: */
- try_fmt->code = imx219_get_format_code(imx219, try_fmt->code);
+ try_fmt->code = fmt->pad == IMAGE_PAD ?
+ imx219_get_format_code(imx219, try_fmt->code) :
+ MEDIA_BUS_FMT_SENSOR_DATA;
fmt->format = *try_fmt;
} else {
- imx219_update_pad_format(imx219, imx219->mode, fmt);
- fmt->format.code = imx219_get_format_code(imx219,
- imx219->fmt.code);
+ if (fmt->pad == IMAGE_PAD) {
+ imx219_update_image_pad_format(imx219, imx219->mode,
+ fmt);
+ fmt->format.code = imx219_get_format_code(imx219,
+ imx219->fmt.code);
+ } else {
+ imx219_update_metadata_pad_format(fmt);
+ }
}
return 0;
@@ -855,51 +915,74 @@ static int imx219_set_pad_format(struct
int exposure_max, exposure_def, hblank;
unsigned int i;
- mutex_lock(&imx219->mutex);
-
- for (i = 0; i < ARRAY_SIZE(codes); i++)
- if (codes[i] == fmt->format.code)
- break;
- if (i >= ARRAY_SIZE(codes))
- i = 0;
+ if (fmt->pad >= NUM_PADS)
+ return -EINVAL;
- /* Bayer order varies with flips */
- fmt->format.code = imx219_get_format_code(imx219, codes[i]);
+ mutex_lock(&imx219->mutex);
- mode = v4l2_find_nearest_size(supported_modes,
- ARRAY_SIZE(supported_modes),
- width, height,
- fmt->format.width, fmt->format.height);
- imx219_update_pad_format(imx219, mode, fmt);
- if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
- framefmt = v4l2_subdev_get_try_format(sd, cfg, fmt->pad);
- *framefmt = fmt->format;
- } else if (imx219->mode != mode ||
- imx219->fmt.code != fmt->format.code) {
- imx219->fmt = fmt->format;
- imx219->mode = mode;
- /* Update limits and set FPS to default */
- __v4l2_ctrl_modify_range(imx219->vblank, IMX219_VBLANK_MIN,
- IMX219_VTS_MAX - mode->height, 1,
- mode->vts_def - mode->height);
- __v4l2_ctrl_s_ctrl(imx219->vblank,
- mode->vts_def - mode->height);
- /* Update max exposure while meeting expected vblanking */
- exposure_max = mode->vts_def - 4;
- exposure_def = (exposure_max < IMX219_EXPOSURE_DEFAULT) ?
- exposure_max : IMX219_EXPOSURE_DEFAULT;
- __v4l2_ctrl_modify_range(imx219->exposure,
- imx219->exposure->minimum,
- exposure_max, imx219->exposure->step,
- exposure_def);
- /*
- * Currently PPL is fixed to IMX219_PPL_DEFAULT, so hblank
- * depends on mode->width only, and is not changeble in any
- * way other than changing the mode.
- */
- hblank = IMX219_PPL_DEFAULT - mode->width;
- __v4l2_ctrl_modify_range(imx219->hblank, hblank, hblank, 1,
- hblank);
+ if (fmt->pad == IMAGE_PAD) {
+ for (i = 0; i < ARRAY_SIZE(codes); i++)
+ if (codes[i] == fmt->format.code)
+ break;
+ if (i >= ARRAY_SIZE(codes))
+ i = 0;
+
+ /* Bayer order varies with flips */
+ fmt->format.code = imx219_get_format_code(imx219, codes[i]);
+
+ mode = v4l2_find_nearest_size(supported_modes,
+ ARRAY_SIZE(supported_modes),
+ width, height,
+ fmt->format.width,
+ fmt->format.height);
+ imx219_update_image_pad_format(imx219, mode, fmt);
+ if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
+ framefmt = v4l2_subdev_get_try_format(sd, cfg,
+ fmt->pad);
+ *framefmt = fmt->format;
+ } else if (imx219->mode != mode ||
+ imx219->fmt.code != fmt->format.code) {
+ imx219->fmt = fmt->format;
+ imx219->mode = mode;
+ /* Update limits and set FPS to default */
+ __v4l2_ctrl_modify_range(imx219->vblank,
+ IMX219_VBLANK_MIN,
+ IMX219_VTS_MAX - mode->height,
+ 1,
+ mode->vts_def - mode->height);
+ __v4l2_ctrl_s_ctrl(imx219->vblank,
+ mode->vts_def - mode->height);
+ /*
+ * Update max exposure while meeting
+ * expected vblanking
+ */
+ exposure_max = mode->vts_def - 4;
+ exposure_def =
+ (exposure_max < IMX219_EXPOSURE_DEFAULT) ?
+ exposure_max : IMX219_EXPOSURE_DEFAULT;
+ __v4l2_ctrl_modify_range(imx219->exposure,
+ imx219->exposure->minimum,
+ exposure_max,
+ imx219->exposure->step,
+ exposure_def);
+ /*
+ * Currently PPL is fixed to IMX219_PPL_DEFAULT, so
+ * hblank depends on mode->width only, and is not
+ * changeble in any way other than changing the mode.
+ */
+ hblank = IMX219_PPL_DEFAULT - mode->width;
+ __v4l2_ctrl_modify_range(imx219->hblank, hblank, hblank,
+ 1, hblank);
+ }
+ } else {
+ if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
+ framefmt = v4l2_subdev_get_try_format(sd, cfg,
+ fmt->pad);
+ *framefmt = fmt->format;
+ } else {
+ /* Only one embedded data mode is supported */
+ imx219_update_metadata_pad_format(fmt);
+ }
}
mutex_unlock(&imx219->mutex);
@@ -1399,13 +1482,14 @@ static int imx219_probe(struct i2c_clien
imx219->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
imx219->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
- /* Initialize source pad */
- imx219->pad.flags = MEDIA_PAD_FL_SOURCE;
+ /* Initialize source pads */
+ imx219->pad[IMAGE_PAD].flags = MEDIA_PAD_FL_SOURCE;
+ imx219->pad[METADATA_PAD].flags = MEDIA_PAD_FL_SOURCE;
/* Initialize default format */
imx219_set_default_format(imx219);
- ret = media_entity_pads_init(&imx219->sd.entity, 1, &imx219->pad);
+ ret = media_entity_pads_init(&imx219->sd.entity, NUM_PADS, imx219->pad);
if (ret) {
dev_err(dev, "failed to init entity pads: %d\n", ret);
goto error_handler_free;
+ XXXXXXX, KC_1, KC_1, KC_1, KC_1, KC_1, XXXXXXX, + XXXXXXX, KC_1, KC_1, KC_1, KC_1, KC_1, XXXXXXX, + KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSLS, + XXXXXXX, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, + KC_N, KC_M,XXXXXXX,XXXXXXX, XXXXXXX, + KC_LALT, CTL_T(KC_ESC), + KC_PGUP, + KC_PGDN,KC_BSPC, KC_ENT + ), + +/* SuperDuper : https://gist.github.com/narze/861e2167784842d38771 + * + * ,--------------------------------------------------. ,--------------------------------------------------. + * | | | | | | | | | | | | | | | | + * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------| + * | | | | | | | | | | | | T← | T→ | | | + * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------| + * | | A | [SuperDuper]| Bksp | Gui |------| |------| ← | ↓ | ↑ | → | Del | | + * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------| + * | | | | | | | | | | | | | | | | + * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------' + * | | | | | | | | | | | | + * `----------------------------------' `----------------------------------' + * ,-------------. ,-------------. + * | | | | | | + * ,------|------|------| |------+--------+------. + * | | | | | | | | + * | Shift| |------| |------| |Shift | + * | | | | | | | | + * `--------------------' `----------------------' + */ +[_SUPERDUPER] = KEYMAP( + // left hand + _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, + _______, KC_LALT, _______, _______, KC_BSPC, KC_LGUI, + _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, + _______, _______, + _______, + KC_LSFT,_______,_______, + // right hand + _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, S(LGUI(KC_LBRC)), S(LGUI(KC_RBRC)), _______, _______, + KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_DEL, _______, + _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, + _______, _______, + _______, + _______,_______, KC_LSFT + ), +// Intermediate keymaps for SuperDuper (Combo keys does not work on Infinity yet) +[_SUPER] = KEYMAP( + // left hand + _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, DUPER, _______, _______, + _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, + _______, _______, + _______, + _______,_______,_______, + // right hand + _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, + _______, _______, + _______, + _______,_______, _______ + ), +[_DUPER] = KEYMAP( + // left hand + _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, + _______, _______, SUPER, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, + _______, _______, + _______, + _______,_______,_______, + // right hand + _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, + _______, _______, + _______, + _______,_______, _______ + ), + +/* Mouse + * + * ,--------------------------------------------------. ,--------------------------------------------------. + * | | | | | | | | | | | | | | | | + * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------| + * | | | S↑ | M↑ | S↓ | | | | | | | S↑ | S↓ | | | + * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------| + * | | | M← | M↓ | M→ | |------| |------| M← | M↓ | M↑ | M→ | | | + * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------| + * | |[Mouse| | | | M3 | | | | M3 | | | | | | + * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------' + * | | | | | M2 | | M2 | | | | | + * `----------------------------------' `----------------------------------' + * ,-------------. ,-------------. + * | | | | | | + * ,------|------|------| |------+--------+------. + * | | | | | | | | + * | Left | |------| |------| | Left | + * | Click| | | | | | Click| + * `--------------------' `----------------------' + */ +[_MOUSE] = KEYMAP( + // left hand + _______, _______, _______, _______, _______, _______, _______, + _______, _______, KC_WH_U, KC_MS_U, KC_WH_D, _______, _______, + _______, _______, KC_MS_L, KC_MS_D, KC_MS_R, _______, + _______, _______, _______, _______, _______, KC_BTN3, _______, + _______, _______, _______, _______, KC_BTN2, + _______, _______, + _______, + KC_BTN1,_______,_______, + // right hand + _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, KC_WH_U, KC_WH_D, _______, _______, + KC_MS_L, KC_MS_D, KC_MS_U, KC_MS_R, _______, _______, + _______, KC_BTN3, _______, _______, _______, _______, _______, + KC_BTN2, _______, _______, _______, _______, + _______, _______, + _______, + _______,_______, KC_BTN1 + ), + +/* Adjust (Lower + Raise) + * + * ,--------------------------------------------------. ,--------------------------------------------------. + * | | | | | | | | | | | | | | | | + * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------| + * | |Reset | | | | | | | | | | | | | Del | + * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------| + * | | | | | |AGnorm|------| |------|AGswap|Qwerty|Colemk|QwOnCo|Plover| | + * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------| + * | | | | | | | | | |SDTogg| | | | | | + * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------' + * | | | | | | | | | | | | + * `----------------------------------' `----------------------------------' + * ,-------------. ,-------------. + * | | | | | | + * ,------|------|------| |------+--------+------. + * | | | | | | | | + * | | |------| |------| | | + * | | | | | | | | + * `--------------------' `----------------------' + */ +[_ADJUST] = KEYMAP( + // left hand + _______, _______, _______, _______, _______, _______, _______, + _______, RESET, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, AG_NORM, + _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, + _______, _______, + _______, + _______,_______,_______, + // right hand + _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, KC_DEL, + AG_SWAP, QWERTY, COLEMAK, QWOC, PLOVER, _______, + _______, SDTOGG, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, + _______, _______, + _______, + _______,_______, _______ + ), + +/* Layers below are not actively used but kept for future reference */ + +/* Symbol + * ,---------------------------------------------------. ,--------------------------------------------------. + * |Version | F1 | F2 | F3 | F4 | F5 | | | | F6 | F7 | F8 | F9 | F10 | F11 | + * |---------+------+------+------+------+------+------| |------+------+------+------+------+------+--------| + * | | ! | @ | { | } | | | | | | Up | 7 | 8 | 9 | * | F12 | + * |---------+------+------+------+------+------| | | |------+------+------+------+------+--------| + * | | # | $ | ( | ) | ` |------| |------| Down | 4 | 5 | 6 | + | | + * |---------+------+------+------+------+------| | | |------+------+------+------+------+--------| + * | | % | ^ | [ | ] | ~ | | | | & | 1 | 2 | 3 | \ | | + * `---------+------+------+------+------+-------------' `-------------+------+------+------+------+--------' + * | EPRM | | | | | | | . | 0 | = | | + * `-----------------------------------' `----------------------------------' + * ,-------------. ,-------------. + * |Animat| | |Toggle|Solid | + * ,------|------|------| |------+------+------. + * |Bright|Bright| | | |Hue- |Hue+ | + * |ness- |ness+ |------| |------| | | + * | | | | | | | | + * `--------------------' `--------------------' + */ +// SYMBOLS +[_SYMB] = KEYMAP( + // left hand + VRSN, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_TRNS, + _______,KC_EXLM,KC_AT, KC_LCBR,KC_RCBR,KC_PIPE,_______, + _______,KC_HASH,KC_DLR, KC_LPRN,KC_RPRN,KC_GRV, + _______,KC_PERC,KC_CIRC,KC_LBRC,KC_RBRC,KC_TILD,_______, + EPRM,_______,_______,_______,_______, + RGB_MOD,_______, + _______, + RGB_VAD,RGB_VAI,_______, + // right hand + _______, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, + _______, KC_UP, KC_7, KC_8, KC_9, KC_ASTR, KC_F12, + KC_DOWN, KC_4, KC_5, KC_6, KC_PLUS, _______, + _______, KC_AMPR, KC_1, KC_2, KC_3, KC_BSLS, _______, + _______,KC_DOT, KC_0, KC_EQL, _______, + RGB_TOG, RGB_SLD, + _______, + _______, RGB_HUD, RGB_HUI +), +/* Media and mouse keys + * + * ,--------------------------------------------------. ,--------------------------------------------------. + * | | | | | | | | | | | | | | | | + * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------| + * | | | | MsUp | | | | | | | | | | | | + * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------| + * | | |MsLeft|MsDown|MsRght| |------| |------| | | | | | Play | + * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------| + * | | | | | | | | | | | | Prev | Next | | | + * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------' + * | | | | Lclk | Rclk | |VolUp |VolDn | Mute | | | + * `----------------------------------' `----------------------------------' + * ,-------------. ,-------------. + * | | | | | | + * ,------|------|------| |------+------+------. + * | | | | | | |Brwser| + * | | |------| |------| |Back | + * | | | | | | | | + * `--------------------' `--------------------' + */ +// MEDIA AND MOUSE +[_MDIA] = KEYMAP( + _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, KC_MS_U, _______, _______, _______, + _______, _______, KC_MS_L, KC_MS_D, KC_MS_R, _______, + _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, KC_BTN1, KC_BTN2, + _______, _______, + _______, + _______, _______, _______, + // right hand + _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, KC_MPLY, + _______, _______, _______, KC_MPRV, KC_MNXT, _______, _______, + KC_VOLU, KC_VOLD, KC_MUTE, _______, _______, + _______, _______, + _______, + _______, _______, KC_WBAK +) +}; + +void persistant_default_layer_set(uint16_t default_layer) { + eeconfig_update_default_layer(default_layer); + default_layer_set(default_layer); +} + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + case QWERTY: + if (record->event.pressed) { + persistant_default_layer_set(1UL<<_QWERTY); + + // key_combos[CB_SUPERDUPER].keys = superduper_combos[_QWERTY]; + // eeprom_update_byte(EECONFIG_SUPERDUPER_INDEX, _QWERTY); + } + return false; + break; + case COLEMAK: + if (record->event.pressed) { + persistant_default_layer_set(1UL<<_COLEMAK); + + // key_combos[CB_SUPERDUPER].keys = superduper_combos[_COLEMAK]; + // eeprom_update_byte(EECONFIG_SUPERDUPER_INDEX, _COLEMAK); + } + return false; + break; + case QWOC: + if (record->event.pressed) { + persistant_default_layer_set(1UL<<_QWOC); + + // key_combos[CB_SUPERDUPER].keys = superduper_combos[_QWOC]; + // eeprom_update_byte(EECONFIG_SUPERDUPER_INDEX, _QWOC); + } + return false; + break; + case LOWER: + if (record->event.pressed) { + layer_on(_LOWER); + update_tri_layer(_LOWER, _RAISE, _ADJUST); + } else { + layer_off(_LOWER); + update_tri_layer(_LOWER, _RAISE, _ADJUST); + } + return false; + break; + case RAISE: + if (record->event.pressed) { + layer_on(_RAISE); + update_tri_layer(_LOWER, _RAISE, _ADJUST); + } else { + layer_off(_RAISE); + update_tri_layer(_LOWER, _RAISE, _ADJUST); + } + return false; + break; + case SUPER: + if (record->event.pressed) { + layer_on(_SUPER); + update_tri_layer(_SUPER, _DUPER, _SUPERDUPER); + } else { + layer_off(_SUPER); + update_tri_layer(_SUPER, _DUPER, _SUPERDUPER); + } + return false; + break; + case DUPER: + if (record->event.pressed) { + layer_on(_DUPER); + update_tri_layer(_SUPER, _DUPER, _SUPERDUPER); + } else { + layer_off(_DUPER); + update_tri_layer(_SUPER, _DUPER, _SUPERDUPER); + } + return false; + break; + case BACKLIT: + if (record->event.pressed) { + register_code(KC_RSFT); + #ifdef BACKLIGHT_ENABLE + backlight_step(); + #endif + } else { + unregister_code(KC_RSFT); + } + return false; + break; + case PLOVER: + if (record->event.pressed) { + layer_off(_RAISE); + layer_off(_LOWER); + layer_off(_ADJUST); + layer_on(_PLOVER); + if (!eeconfig_is_enabled()) { + eeconfig_init(); + } + keymap_config.raw = eeconfig_read_keymap(); + keymap_config.nkro = 1; + eeconfig_update_keymap(keymap_config.raw); + } + return false; + break; + case EXT_PLV: + if (record->event.pressed) { + layer_off(_PLOVER); + } + return false; + break; + case SDTOGG: + if (record->event.pressed) { + // superduper_enabled = !superduper_enabled; + + // if (superduper_enabled) { + // set_superduper_key_combos(); + // } else { + // clear_superduper_key_combos(); + // } + } + return false; + break; + case EPRM: + if (record->event.pressed) { + eeconfig_init(); + } + return false; + break; + case VRSN: + if (record->event.pressed) { + SEND_STRING (QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION); + } + return false; + break; + case RGB_SLD: + if (record->event.pressed) { + #ifdef RGBLIGHT_ENABLE + rgblight_mode(1); + #endif + } + return false; + break; + } + return true; +} + +void matrix_init_user(void) { + +} + +void matrix_setup(void) { + // set_superduper_key_combos(); +} + +// void set_superduper_key_combos(void) { +// uint8_t layer = eeprom_read_byte(EECONFIG_SUPERDUPER_INDEX); + +// switch (layer) { +// case _QWERTY: +// case _COLEMAK: +// case _QWOC: +// key_combos[CB_SUPERDUPER].keys = superduper_combos[layer]; +// break; +// } +// } + +// void clear_superduper_key_combos(void) { +// key_combos[CB_SUPERDUPER].keys = empty_combo; +// } + +void matrix_scan_user(void) { + // uint8_t layer = biton32(layer_state); + + // ergodox_board_led_off(); + // ergodox_right_led_1_off(); + // ergodox_right_led_2_off(); + // ergodox_right_led_3_off(); + // switch (layer) { + // // TODO: Make this relevant to the ErgoDox EZ. + // case 1: + // ergodox_right_led_1_on(); + // break; + // case 2: + // ergodox_right_led_2_on(); + // break; + // default: + // // none + // break; + // } +} + +// Combos + +// void process_combo_event(uint8_t combo_index, bool pressed) { +// if (pressed) { +// switch(combo_index) { +// case CB_SUPERDUPER: +// layer_on(_SUPERDUPER); +// ergodox_board_led_on(); +// break; +// } +// } else { +// layer_off(_SUPERDUPER); +// ergodox_board_led_off(); +// unregister_mods(MOD_BIT(KC_LGUI) | MOD_BIT(KC_LCTL) | MOD_BIT(KC_LALT)); // Sometimes mods are held, unregister them +// } +// } + +// Macros + +const uint16_t PROGMEM fn_actions[] = { + [M_GUI_UNDS] = ACTION_MACRO_TAP(M_GUI_UNDS), + [M_SFT_PO] = ACTION_MACRO_TAP(M_SFT_PO), + [M_SFT_PC] = ACTION_MACRO_TAP(M_SFT_PC), +}; + +const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) +{ + bool tap_not_interrupted = record->tap.count > 0 && !record->tap.interrupted; + + switch(id) { + // Hold for LGUI, tap for Underscore + case M_GUI_UNDS: + if (record->event.pressed) { + m_gui_unds_timer = timer_read(); + + if (!tap_not_interrupted) { + register_mods(MOD_BIT(KC_LGUI)); + } + } else { + if (tap_not_interrupted && timer_elapsed(m_gui_unds_timer) < TAPPING_TERM) { + + add_weak_mods(MOD_BIT(KC_LSFT)); + send_keyboard_report(); + register_code(KC_MINS); + unregister_code(KC_MINS); + del_weak_mods(MOD_BIT(KC_LSFT)); + send_keyboard_report(); + record->tap.count = 0; // ad hoc: cancel tap + } else { + unregister_mods(MOD_BIT(KC_LGUI)); + } + } + break; + // Hold for LSHIFT, tap for Parens open + case M_SFT_PO: + if (record->event.pressed) { + m_sft_po_timer = timer_read(); + + if (!tap_not_interrupted) { + register_mods(MOD_BIT(KC_LSFT)); + } + } else { + if (tap_not_interrupted && timer_elapsed(m_sft_po_timer) < TAPPING_TERM) { + record->tap.count = 0; + return MACRO(D(RSFT), T(9), U(RSFT), END); + } else { + unregister_mods(MOD_BIT(KC_LSFT)); + } + } + break; + // Hold for RSHIFT, tap for Parens close + case M_SFT_PC: + if (record->event.pressed) { + m_sft_pc_timer = timer_read(); + + if (!tap_not_interrupted) { + register_mods(MOD_BIT(KC_RSFT)); + } + } else { + if (tap_not_interrupted && timer_elapsed(m_sft_pc_timer) < TAPPING_TERM) { + record->tap.count = 0; + return MACRO(D(LSFT), T(0), U(LSFT), END); + } else { + unregister_mods(MOD_BIT(KC_RSFT)); + } + } + break; + } + return MACRO_NONE; +}; diff --git a/keyboards/ergodox/keymaps/narze/readme.md b/keyboards/ergodox/keymaps/narze/readme.md new file mode 100644 index 000000000..03a72f1ac --- /dev/null +++ b/keyboards/ergodox/keymaps/narze/readme.md @@ -0,0 +1,45 @@ +# narze's layout + +## Notes +- SuperDuper mode for Ergodox is still under development, since combo keys does not work very well on Ergodox firmware. + Now it is using multiple layers as a workaround. Actual implementation using combos are on my Planck layout. + +## Key features +- Qwerty + [Colemak](https://colemak.com) layouts, and you can type Qwerty on software-level Colemak as well. Very useful for gaming or when your friend wanna type something but don't use Colemak. +- [(S)uper (D)uper Mode](https://github.com/jasonrudolph/keyboard#super-duper-mode) inspired by [jasonrudolph](https://github.com/jasonrudolph), with [some extensions](https://gist.github.com/narze/861e2167784842d38771) such as backspace & forward delete. +- Mouse keys with Z + +## (S)uper (D)uper Mode +Press `S+D` simultaneously and hold, then... +- `H/J/K/L` for Vim-like movement +- `I/O` to move between browser tabs (Not working on Windows yet) +- `A` for `Option (Alt)` +- `F/;` for `Backspace/Forward delete` +- `A` with `H/L` to move to previous/next word +- `A` with `G/;` to delete to previous/next word +- `G` for `Cmd` (Gui/Windows) +- Available for all layouts (but plover) using physical S & D keys position in qwerty +- `Spacebar` for `Shift` (it's easier when already holding A with your pinky) +- Disable with `Raise+Lower+M` +- You can edit or add more useful keys in SUPERDUPER layer +- It can be activated by holding `/` as well, but it's slower since `LT()` uses `TAPPING_TERM` of 200ms but `S+D` uses `COMBO_TERM` of only 20ms (Can be changed within config.h) + +## Build instructions +- `cd /path/to/qmk_firmware` + +#### Left side + ``` +docker run -e keymap=narze -e subproject=infinity -e keyboard=ergodox --rm -v $('pwd'):/qmk:rw edasque/qmk_firmware +avr-objcopy -Iihex -Obinary .build/ergodox_infinity_narze.hex .build/ergodox_infinity_narze_left.bin +dfu-util --device 1c11:b007 -D .build/ergodox_infinity_narze_left.bin +``` + +#### Right side +``` +docker run -e keymap=narze -e subproject=infinity -e keyboard=ergodox -e MASTER=right --rm -v $('pwd'):/qmk:rw edasque/qmk_firmware +avr-objcopy -Iihex -Obinary .build/ergodox_infinity_narze.hex .build/ergodox_infinity_narze_right.bin +dfu-util --device 1c11:b007 -D .build/ergodox_infinity_narze_right.bin +``` + +## TODO +- [ ] Make SuperDuper mode fully-compatible in Windows by swapping GUI with Ctrl diff --git a/keyboards/ergodox/keymaps/narze/rules.mk b/keyboards/ergodox/keymaps/narze/rules.mk new file mode 100644 index 000000000..7d2e00d0e --- /dev/null +++ b/keyboards/ergodox/keymaps/narze/rules.mk @@ -0,0 +1,24 @@ + + +# Build Options +# change to "no" to disable the options, or define them in the Makefile in +# the appropriate keymap folder that will get included automatically +# +BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) +MOUSEKEY_ENABLE = yes # Mouse keys(+4700) +EXTRAKEY_ENABLE = yes # Audio control and System control(+450) +CONSOLE_ENABLE = no # Console for debug(+400) +COMMAND_ENABLE = yes # Commands for debug and configuration +NKRO_ENABLE = yes # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work +BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality +MIDI_ENABLE = no # MIDI controls +AUDIO_ENABLE = no # Audio output on port C6 +UNICODE_ENABLE = no # Unicode +BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID +RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time. + +# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE +SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend + +# Combos not working yet +COMBO_ENABLE = no diff --git a/keyboards/ergodox/keymaps/narze/visualizer.c b/keyboards/ergodox/keymaps/narze/visualizer.c new file mode 100644 index 000000000..88f658d6b --- /dev/null +++ b/keyboards/ergodox/keymaps/narze/visualizer.c @@ -0,0 +1,94 @@ +/* +Copyright 2017 Fred Sundvik + +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 "simple_visualizer.h" +#include "util.h" + +// Copied from keymap.c +enum ergodox_layers { + _QWERTY, + _COLEMAK, + _QWOC, + _LOWER, + _RAISE, + _PLOVER, +// Intermediate layers for SuperDuper (Combo keys does not work on Infinity yet) + _SUPER, + _DUPER, + _SUPERDUPER, + _MOUSE, + _ADJUST, + _MDIA, + _SYMB, +}; + +// This function should be implemented by the keymap visualizer +// Don't change anything else than state->target_lcd_color and state->layer_text as that's the only thing +// that the simple_visualizer assumes that you are updating +// Also make sure that the buffer passed to state->layer_text remains valid until the previous animation is +// stopped. This can be done by either double buffering it or by using constant strings +static void get_visualizer_layer_and_color(visualizer_state_t* state) { + uint8_t saturation = 255; + + uint8_t layer = biton32(state->status.layer); + state->target_lcd_color = LCD_COLOR(layer << 2, saturation, 0xFF); + + switch(layer) { + case _QWERTY: + state->layer_text = "QWERTY"; + break; + case _COLEMAK: + state->layer_text = "COLEMAK"; + break; + case _QWOC: + state->layer_text = "QWERTY on COLEMAK"; + break; + case _LOWER: + state->layer_text = "LOWER"; + break; + case _RAISE: + state->layer_text = "RAISE"; + break; + case _PLOVER: + state->layer_text = "PLOVER"; + break; + case _SUPERDUPER: + state->layer_text = "SUPERDUPER"; + break; + case _SUPER: + state->layer_text = "SUPER"; + break; + case _DUPER: + state->layer_text = "DUPER"; + break; + case _MOUSE: + state->layer_text = "MOUSE"; + break; + case _ADJUST: + state->layer_text = "ADJUST"; + break; + case _MDIA: + state->layer_text = "MDIA"; + break; + case _SYMB: + state->layer_text = "SYMB"; + break; + default: + state->layer_text = "NONE"; + break; + } +} diff --git a/keyboards/planck/keymaps/narze/config.h b/keyboards/planck/keymaps/narze/config.h new file mode 100644 index 000000000..e081a93b5 --- /dev/null +++ b/keyboards/planck/keymaps/narze/config.h @@ -0,0 +1,42 @@ +#ifndef CONFIG_USER_H +#define CONFIG_USER_H + +#include "../../config.h" + +/* + * 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 + +#define TAPPING_TERM 200 + +#define COMBO_TERM 20 +#define COMBO_COUNT 1 + +#define IGNORE_MOD_TAP_INTERRUPT +#define PERMISSIVE_HOLD +#define PREVENT_STUCK_MODIFIERS + +#define SUPER_DUPER_SOUND S__NOTE(_B1) + +#define MOUSEKEY_DELAY 100 + +#endif
\ No newline at end of file diff --git a/keyboards/planck/keymaps/narze/keymap.c b/keyboards/planck/keymaps/narze/keymap.c new file mode 100644 index 000000000..c5703f58d --- /dev/null +++ b/keyboards/planck/keymaps/narze/keymap.c @@ -0,0 +1,524 @@ +// This is the canonical layout file for the Quantum project. If you want to add another keyboard, +// this is the style you want to emulate. + +#include "planck.h" +#include "action_layer.h" +#ifdef AUDIO_ENABLE + #include "audio.h" +#endif +#include "eeconfig.h" +#include "keymap_colemak.h" + +extern keymap_config_t keymap_config; + +// Each layer gets a name for readability, which is then used in the keymap matrix below. +// The underscores don't mean anything - you can have a layer called STUFF or any other name. +// Layer names don't all need to be of the same length, obviously, and you can also skip them +// entirely and just use numbers. + +enum planck_layers { + _QWERTY, + _COLEMAK, + _QWOC, + _LOWER, + _RAISE, + _PLOVER, + _SUPERDUPER, + _MOUSE, + _ADJUST +}; + +enum planck_keycodes { + QWERTY = SAFE_RANGE, + COLEMAK, + QWOC, + PLOVER, + SUPERDUPER, + MOUSE, + LOWER, + RAISE, + BACKLIT, + EXT_PLV, + SDTOGG, // Toggle SuperDuper +}; + +enum functions { + M_GUI_UNDS, // Simulate GUI_T(KC_UNDS) + M_SFT_PO, // SFT_T(KC_LPRN) +}; + +// Timer for custom mod tap +static uint16_t m_gui_unds_timer; +static uint16_t m_sft_po_timer; + +// Fillers to make layering more clear +#define _______ KC_TRNS +#define XXXXXXX KC_NO + +// Narze : Custom Macros +#define HPR_ESC ALL_T(KC_ESC) +#define SFT_ENT SFT_T(KC_ENT) +#define SFT_PO F(M_SFT_PO) +#define GUI_MINS GUI_T(KC_MINS) +#define GUI_UNDS F(M_GUI_UNDS) + +// Combo : SuperDuper layer from S+D (R+S in Colemak) +#define SUPERDUPER_COMBO_COUNT 3 +#define EECONFIG_SUPERDUPER_INDEX (uint8_t *) 19 + +enum process_combo_event { + CB_SUPERDUPER, +}; + +const uint16_t PROGMEM superduper_combos[SUPERDUPER_COMBO_COUNT][3] = { + [_QWERTY] = {KC_S, KC_D, COMBO_END}, + [_COLEMAK] = {KC_R, KC_S, COMBO_END}, + [_QWOC] = {CM_S, CM_D, COMBO_END}, +}; + +combo_t key_combos[COMBO_COUNT] = { + [CB_SUPERDUPER] = COMBO_ACTION(superduper_combos[_QWERTY]), +}; + +volatile bool superduper_enabled = true; + +const uint16_t empty_combo[] = {COMBO_END}; + +void set_superduper_key_combos(void); +void clear_superduper_key_combos(void); + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + +/* Qwerty + * ,-----------------------------------------------------------------------------------. + * | Tab | Q | W | E | R | T | Y | U | I | O | P | Bksp | + * |------+------+------+------+------+-------------+------+------+------+------+------| + * | Hp/Ec| A | S | D | F | G | H | J | K | L | ; | ' | + * |------+------+------+------+------+------|------+------+------+------+------+------| + * | Sft/(| Z/Mo | X | C | V | B | N | M | , | . | SD-/ |Sft/Ent| + * |------+------+------+------+------+------+------+------+------+------+------+------| + * | Rse/[| Ctrl | Alt | GUI/_|Lower | Space |Raise | GUI/-| Alt | Ctrl | Low/]| + * `-----------------------------------------------------------------------------------' + */ +[_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}, + {HPR_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT}, + {SFT_PO, LT(_MOUSE, KC_Z), KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, LT(_SUPERDUPER, KC_SLSH), SFT_ENT}, + {LT(_RAISE, KC_LBRC), KC_LCTL, KC_LALT, GUI_UNDS, LOWER, KC_SPC, KC_SPC, RAISE, GUI_MINS, KC_RALT, KC_RCTL, LT(_LOWER, KC_RBRC)} +}, + +/* Colemak + * ,-----------------------------------------------------------------------------------. + * | Tab | Q | W | F | P | G | J | L | U | Y | ; | Bksp | + * |------+------+------+------+------+-------------+------+------+------+------+------| + * | Hp/Ec| A | R | S | T | D | H | N | E | I | O | ' | + * |------+------+------+------+------+------|------+------+------+------+------+------| + * | Sft/(| Z/Mo | X | C | V | B | K | M | , | . | SD-/ |Sft/Ent| + * |------+------+------+------+------+------+------+------+------+------+------+------| + * | Brite| Ctrl | Alt | GUI/_|Lower | Space |Raise | GUI/-| Alt | Ctrl | Low/]| + * `-----------------------------------------------------------------------------------' + */ +[_COLEMAK] = { + {KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC}, + {HPR_ESC, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT}, + {SFT_PO, LT(_MOUSE, KC_Z), KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, LT(_SUPERDUPER, KC_SLSH), SFT_ENT}, + {LT(_RAISE, KC_LBRC), KC_LCTL, KC_LALT, GUI_UNDS, LOWER, KC_SPC, KC_SPC, RAISE, GUI_MINS, KC_RALT, KC_RCTL, LT(_LOWER, KC_RBRC)} +}, + +/* Qwerty on software Colemak : Useful for gaming with qwerty keymaps! */ +[_QWOC] = { + {KC_TAB, CM_Q, CM_W, CM_E, CM_R, CM_T, CM_Y, CM_U, CM_I, CM_O, CM_P, KC_BSPC}, + {HPR_ESC, CM_A, CM_S, CM_D, CM_F, CM_G, CM_H, CM_J, CM_K, CM_L, CM_SCLN, KC_QUOT}, + {SFT_PO, LT(_MOUSE, CM_Z), CM_X, CM_C, CM_V, CM_B, CM_N, CM_M, CM_COMM, CM_DOT, LT(_SUPERDUPER, CM_SLSH), SFT_ENT}, + {LT(_RAISE, KC_LBRC), KC_LCTL, KC_LALT, GUI_UNDS, LOWER, KC_SPC, KC_SPC, RAISE, GUI_MINS, KC_RALT, KC_RCTL, LT(_LOWER, KC_RBRC)} +}, + +/* Lower + * ,-----------------------------------------------------------------------------------. + * | ` | ! | @ | # | $ | % | ^ | & | * | ( | ) | Bksp | + * |------+------+------+------+------+-------------+------+------+------+------+------| + * | Del | F1 | F2 | F3 | F4 | F5 | F6 | _ | + | { | } | | | + * |------+------+------+------+------+------|------+------+------+------+------+------| + * | | F7 | F8 | F9 | F10 | F11 | F12 |ISO ~ |ISO | | | |Sft/Ent| + * |------+------+------+------+------+------+------+------+------+------+------+------| + * | | | | | | | | Next | Vol- | Vol+ | Play | + * `-----------------------------------------------------------------------------------' + */ +[_LOWER] = { + {KC_GRV, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC}, + {KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE}, + {_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12,S(KC_NUHS),S(KC_NUBS),_______, _______, _______}, + {_______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY} +}, + +/* Raise + * ,-----------------------------------------------------------------------------------. + * | ~ | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp | + * |------+------+------+------+------+-------------+------+------+------+------+------| + * | Del | F1 | F2 | F3 | F4 | F5 | F6 | - | = | [ | ] | \ | + * |------+------+------+------+------+------|------+------+------+------+------+------| + * | | F7 | F8 | F9 | F10 | F11 | F12 |ISO # |ISO / | | |Sft/Ent| + * |------+------+------+------+------+------+------+------+------+------+------+------| + * | | | | | | | | Next | Vol- | Vol+ | Play | + * `-----------------------------------------------------------------------------------' + */ +[_RAISE] = { + {KC_TILD, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC}, + {KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS}, + {_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_NUHS, KC_NUBS, _______, _______, _______}, + {_______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY} +}, + +/* Plover layer (http://opensteno.org) + * ,-----------------------------------------------------------------------------------. + * | # | # | # | # | # | # | # | # | # | # | # | # | + * |------+------+------+------+------+-------------+------+------+------+------+------| + * | | S | T | P | H | * | * | F | P | L | T | D | + * |------+------+------+------+------+------|------+------+------+------+------+------| + * |TogOut| S | K | W | R | * | * | R | B | G | S | Z | + * |------+------+------+------+------+------+------+------+------+------+------+------| + * | Exit | | | A | O | | E | U | | | | + * `-----------------------------------------------------------------------------------' + */ + +[_PLOVER] = { + {KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1 }, + {XXXXXXX, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC}, + {XXXXXXX, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT}, + {EXT_PLV, XXXXXXX, XXXXXXX, KC_C, KC_V, XXXXXXX, XXXXXXX, KC_N, KC_M, XXXXXXX, XXXXXXX, XXXXXXX} +}, + +/* SuperDuper : https://gist.github.com/narze/861e2167784842d38771 + * /-----------------------------------------------------------------------------------\ + * | | | | | | | | | T← | T→ | | | + * |------+------+------+------+------+-------------+------+------+------+------+------| + * | | Alt | [SuperDuper]| Bksp | Gui | ← | ↓ | ↑ | → | Del | | + * |------+------+------+------+------+------|------+------+------+------+------+------| + * | | | | | | | | | | | | | + * |------+------+------+------+------+-------------+------+------+------+------+------| + * | | | | | | Shift | | | | | | + * \-----------------------------------------------------------------------------------/ + */ +[_SUPERDUPER] = { + {_______, _______, _______, _______, _______, _______, _______, _______, S(LGUI(KC_LBRC)), S(LGUI(KC_RBRC)), _______, _______}, + {_______, KC_LALT, _______, _______, KC_BSPC, KC_LGUI, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_DEL, _______}, + {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______}, + {_______, _______, _______, _______, _______, KC_LSFT, KC_LSFT, _______, _______, _______, _______, _______} +}, + +/* Mouse + * /-----------------------------------------------------------------------------------\ + * | | | S↑ | M↑ | S↓ | | | | S↑ | S↓ | | | + * |------+------+------+------+------+-------------+------+------+------+------+------| + * | | | M← | M↓ | M→ | | M← | M↓ | M↑ | M→ | | | + * |------+------+------+------+------+------|------+------+------+------+------+------| + * | |[Mouse| | | | M3 | M3 | | | | | | + * |------+------+------+------+------+-------------+------+------+------+------+------| + * | | | | | M2 | LeftClick | M2 | | | | | + * \-----------------------------------------------------------------------------------/ + */ +[_MOUSE] = { + {_______, _______, KC_WH_U, KC_MS_U, KC_WH_D, _______, _______, _______, KC_WH_U, KC_WH_D, _______, _______}, + {_______, _______, KC_MS_L, KC_MS_D, KC_MS_R, _______, KC_MS_L, KC_MS_D, KC_MS_U, KC_MS_R, _______, _______}, + {_______, _______, _______, _______, _______, KC_BTN3, KC_BTN3, _______, _______, _______, _______, _______}, + {_______, _______, _______, _______, KC_BTN2, KC_BTN1, KC_BTN1, KC_BTN2, _______, _______, _______, _______} +}, + +/* Adjust (Lower + Raise) + * ,-----------------------------------------------------------------------------------. + * | | Reset| | | | | | | | | | Del | + * |------+------+------+------+------+-------------+------+------+------+------+------| + * | | | |Aud on|Audoff|AGnorm|AGswap|Qwerty|Colemk|QwOnCo|Plover| | + * |------+------+------+------+------+------|------+------+------+------+------+------| + * | |Voice-|Voice+|Mus on|Musoff|MIDIon|MIDIof|SDtogg| | | | | + * |------+------+------+------+------+------+------+------+------+------+------+------| + * | | | | | | | | | | | | + * `-----------------------------------------------------------------------------------' + */ +[_ADJUST] = { + {_______, RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL}, + {_______, _______, _______, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, QWOC, PLOVER, _______}, + {_______, MUV_DE, MUV_IN, MU_ON, MU_OFF, MI_ON, MI_OFF, SDTOGG, _______, _______, _______, _______}, + {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______} +} + +}; + +#ifdef AUDIO_ENABLE + float tone_startup[][2] = SONG(STARTUP_SOUND); + float tone_qwerty[][2] = SONG(QWERTY_SOUND); + float tone_qwoc[][2] = SONG(DVORAK_SOUND); + float tone_colemak[][2] = SONG(COLEMAK_SOUND); + float tone_plover[][2] = SONG(PLOVER_SOUND); + float tone_plover_gb[][2] = SONG(PLOVER_GOODBYE_SOUND); + float music_scale[][2] = SONG(MUSIC_SCALE_SOUND); + float tone_coin[][2] = SONG(COIN_SOUND); + float tone_sonic_ring[][2] = SONG(SONIC_RING); + + float tone_goodbye[][2] = SONG(GOODBYE_SOUND); + float tone_superduper[][2] = SONG(SUPER_DUPER_SOUND); +#endif + +void persistant_default_layer_set(uint16_t default_layer) { + eeconfig_update_default_layer(default_layer); + default_layer_set(default_layer); +} + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + case QWERTY: + if (record->event.pressed) { + #ifdef AUDIO_ENABLE + PLAY_NOTE_ARRAY(tone_qwerty, false, 0); + #endif + persistant_default_layer_set(1UL<<_QWERTY); + + key_combos[CB_SUPERDUPER].keys = superduper_combos[_QWERTY]; + eeprom_update_byte(EECONFIG_SUPERDUPER_INDEX, _QWERTY); + } + return false; + break; + case COLEMAK: + if (record->event.pressed) { + #ifdef AUDIO_ENABLE + PLAY_NOTE_ARRAY(tone_colemak, false, 0); + #endif + persistant_default_layer_set(1UL<<_COLEMAK); + + key_combos[CB_SUPERDUPER].keys = superduper_combos[_COLEMAK]; + eeprom_update_byte(EECONFIG_SUPERDUPER_INDEX, _COLEMAK); + } + return false; + break; + case QWOC: + if (record->event.pressed) { + #ifdef AUDIO_ENABLE + PLAY_NOTE_ARRAY(tone_qwoc, false, 0); + #endif + persistant_default_layer_set(1UL<<_QWOC); + + key_combos[CB_SUPERDUPER].keys = superduper_combos[_QWOC]; + eeprom_update_byte(EECONFIG_SUPERDUPER_INDEX, _QWOC); + } + return false; + break; + case LOWER: + if (record->event.pressed) { + layer_on(_LOWER); + update_tri_layer(_LOWER, _RAISE, _ADJUST); + } else { + layer_off(_LOWER); + update_tri_layer(_LOWER, _RAISE, _ADJUST); + } + return false; + break; + case RAISE: + if (record->event.pressed) { + layer_on(_RAISE); + update_tri_layer(_LOWER, _RAISE, _ADJUST); + } else { + layer_off(_RAISE); + update_tri_layer(_LOWER, _RAISE, _ADJUST); + } + return false; + break; + case BACKLIT: + if (record->event.pressed) { + register_code(KC_RSFT); + #ifdef BACKLIGHT_ENABLE + backlight_step(); + #endif + } else { + unregister_code(KC_RSFT); + } + return false; + break; + case PLOVER: + if (record->event.pressed) { + #ifdef AUDIO_ENABLE + stop_all_notes(); + PLAY_NOTE_ARRAY(tone_plover, false, 0); + #endif + layer_off(_RAISE); + layer_off(_LOWER); + layer_off(_ADJUST); + layer_on(_PLOVER); + if (!eeconfig_is_enabled()) { + eeconfig_init(); + } + keymap_config.raw = eeconfig_read_keymap(); + keymap_config.nkro = 1; + eeconfig_update_keymap(keymap_config.raw); + } + return false; + break; + case EXT_PLV: + if (record->event.pressed) { + #ifdef AUDIO_ENABLE + PLAY_NOTE_ARRAY(tone_plover_gb, false, 0); + #endif + layer_off(_PLOVER); + } + return false; + break; + case SDTOGG: + if (record->event.pressed) { + superduper_enabled = !superduper_enabled; + + if (superduper_enabled) { + set_superduper_key_combos(); + + #ifdef AUDIO_ENABLE + PLAY_NOTE_ARRAY(tone_sonic_ring, false, 0); + #endif + } else { + clear_superduper_key_combos(); + + #ifdef AUDIO_ENABLE + PLAY_NOTE_ARRAY(tone_coin, false, 0); + #endif + } + } + return false; + break; + } + return true; +} + +void matrix_init_user(void) { + #ifdef AUDIO_ENABLE + startup_user(); + #endif +} + +void matrix_setup(void) { + set_superduper_key_combos(); +} + +void set_superduper_key_combos(void) { + uint8_t layer = eeprom_read_byte(EECONFIG_SUPERDUPER_INDEX); + + switch (layer) { + case _QWERTY: + case _COLEMAK: + case _QWOC: + key_combos[CB_SUPERDUPER].keys = superduper_combos[layer]; + break; + } +} + +void clear_superduper_key_combos(void) { + key_combos[CB_SUPERDUPER].keys = empty_combo; +} + +void matrix_scan_user(void) { +} + +#ifdef AUDIO_ENABLE + +void startup_user() +{ + _delay_ms(20); // gets rid of tick + PLAY_NOTE_ARRAY(tone_startup, false, 0); +} + +void shutdown_user() +{ + PLAY_NOTE_ARRAY(tone_goodbye, false, 0); + _delay_ms(150); + stop_all_notes(); +} + +void music_on_user(void) +{ + music_scale_user(); +} + +void music_scale_user(void) +{ + PLAY_NOTE_ARRAY(music_scale, false, 0); +} + +#endif + +// Combos + +void process_combo_event(uint8_t combo_index, bool pressed) { + if (pressed) { + switch(combo_index) { + case CB_SUPERDUPER: + layer_on(_SUPERDUPER); + + #ifdef AUDIO_ENABLE + PLAY_NOTE_ARRAY(tone_superduper, false, 0); + #endif + break; + } + } else { + layer_off(_SUPERDUPER); + unregister_mods(MOD_BIT(KC_LGUI) | MOD_BIT(KC_LCTL) | MOD_BIT(KC_LALT)); // Sometimes mods are held, unregister them + } +} + +// Macros + +const uint16_t PROGMEM fn_actions[] = { + [M_GUI_UNDS] = ACTION_MACRO_TAP(M_GUI_UNDS), + [M_SFT_PO] = ACTION_MACRO_TAP(M_SFT_PO), +}; + +const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) +{ + bool tap_not_interrupted = record->tap.count > 0 && !record->tap.interrupted; + + switch(id) { + // Hold for LGUI, tap for Underscore + case M_GUI_UNDS: + if (record->event.pressed) { + m_gui_unds_timer = timer_read(); + + if (!tap_not_interrupted) { + register_mods(MOD_BIT(KC_LGUI)); + } + } else { + if (tap_not_interrupted && timer_elapsed(m_gui_unds_timer) < TAPPING_TERM) { + #ifdef AUDIO_ENABLE + PLAY_NOTE_ARRAY(tone_superduper, false, 0); + #endif + + add_weak_mods(MOD_BIT(KC_LSFT)); + send_keyboard_report(); + register_code(KC_MINS); + unregister_code(KC_MINS); + del_weak_mods(MOD_BIT(KC_LSFT)); + send_keyboard_report(); + record->tap.count = 0; // ad hoc: cancel tap + } else { + unregister_mods(MOD_BIT(KC_LGUI)); + } + } + break; + // Hold for LSHIFT, tap for Parens open + case M_SFT_PO: + if (record->event.pressed) { + m_sft_po_timer = timer_read(); + + if (!tap_not_interrupted) { + register_mods(MOD_BIT(KC_LSFT)); + } + } else { + if (tap_not_interrupted && timer_elapsed(m_sft_po_timer) < TAPPING_TERM) { + #ifdef AUDIO_ENABLE + PLAY_NOTE_ARRAY(tone_superduper, false, 0); + #endif + + record->tap.count = 0; + return MACRO(D(RSFT), T(9), U(RSFT), END); + } else { + unregister_mods(MOD_BIT(KC_LSFT)); + } + } + break; + } + return MACRO_NONE; +}; diff --git a/keyboards/planck/keymaps/narze/readme.md b/keyboards/planck/keymaps/narze/readme.md new file mode 100644 index 000000000..6824251e8 --- /dev/null +++ b/keyboards/planck/keymaps/narze/readme.md @@ -0,0 +1,31 @@ +# narze's layout + +## Key features +- Qwerty + [Colemak](https://colemak.com) layouts, and you can type Qwerty on software-level Colemak as well. Very useful for gaming or when your friend wanna type something but don't use Colemak. +- [(S)uper (D)uper Mode](https://github.com/jasonrudolph/keyboard#super-duper-mode) inspired by [jasonrudolph](https://github.com/jasonrudolph), with [some extensions](https://gist.github.com/narze/861e2167784842d38771) such as backspace & forward delete. +- Mouse keys with Z + +## (S)uper (D)uper Mode +Press `S+D` simultaneously and hold, then... +- `H/J/K/L` for Vim-like movement +- `I/O` to move between browser tabs (Not working on Windows yet) +- `A` for `Option (Alt)` +- `F/;` for `Backspace/Forward delete` +- `A` with `H/L` to move to previous/next word +- `A` with `G/;` to delete to previous/next word +- `G` for `Cmd` (Gui/Windows) +- Available for all layouts (but plover) using physical S & D keys position in qwerty +- `Spacebar` for `Shift` (it's easier when already holding A with your pinky) +- Disable with `Raise+Lower+M` +- You can edit or add more useful keys in SUPERDUPER layer +- It can be activated by holding `/` as well, but it's slower since `LT()` uses `TAPPING_TERM` of 200ms but `S+D` uses `COMBO_TERM` of only 20ms (Can be changed within config.h) + +## Build instructions +- `cd /path/to/qmk_firmware` +- `docker run -e keymap=narze -e subproject=rev4 -e keyboard=planck --rm -v $('pwd'):/qmk:rw edasque/qmk_firmware` +- `dfu-programmer atmega32u4 erase && dfu-programmer atmega32u4 flash .build/planck_rev4_narze.hex` + +## TODO +- [] Make SuperDuper mode fully-compatible in Windows by swapping GUI with Ctrl + + diff --git a/keyboards/planck/keymaps/narze/rules.mk b/keyboards/planck/keymaps/narze/rules.mk new file mode 100644 index 000000000..05c2ce455 --- /dev/null +++ b/keyboards/planck/keymaps/narze/rules.mk @@ -0,0 +1,23 @@ + + +# Build Options +# change to "no" to disable the options, or define them in the Makefile in +# the appropriate keymap folder that will get included automatically +# +BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) +MOUSEKEY_ENABLE = yes # Mouse keys(+4700) +EXTRAKEY_ENABLE = yes # Audio control and System control(+450) +CONSOLE_ENABLE = no # Console for debug(+400) +COMMAND_ENABLE = yes # Commands for debug and configuration +NKRO_ENABLE = yes # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work +BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality +MIDI_ENABLE = no # MIDI controls +AUDIO_ENABLE = no # Audio output on port C6 +UNICODE_ENABLE = no # Unicode +BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID +RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time. + +# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE +SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend + +COMBO_ENABLE = yes |