Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chocofi #275

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions keyboards/chocofi/chocofi.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#pragma once
#include "quantum.h"

#define LAYOUT_split_3x5_3( \
L00, L01, L02, L03, L04, R00, R01, R02, R03, R04, \
L10, L11, L12, L13, L14, R10, R11, R12, R13, R14, \
L20, L21, L22, L23, L24, R20, R21, R22, R23, R24, \
L30, L31, L32, R30, R31, R32 \
) \
{ \
{ KC_NO, L00, L01, L02, L03, L04 }, \
{ KC_NO, L10, L11, L12, L13, L14 }, \
{ KC_NO, L20, L21, L22, L23, L24 }, \
{ KC_NO, KC_NO, KC_NO, L30, L31, L32 }, \
{ KC_NO, R04, R03, R02, R01, R00 }, \
{ KC_NO, R14, R13, R12, R11, R10 }, \
{ KC_NO, R24, R23, R22, R21, R20 }, \
{ KC_NO, KC_NO, KC_NO, R32, R31, R30 } \
}
13 changes: 13 additions & 0 deletions keyboards/chocofi/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright 2022 Pavel Glushkov (@pashutk)
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#define MATRIX_ROWS 8
#define MATRIX_COLS 6

#define USE_SERIAL
#define SOFT_SERIAL_PIN D2

#define TAPPING_TERM 175
#define TAPPING_TERM_PER_KEY
71 changes: 71 additions & 0 deletions keyboards/chocofi/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"manufacturer": "Pavel Glushkov",
"keyboard_name": "chocofi",
"maintainer": "pashutk",
"bootloader": "caterina",
"diode_direction": "COL2ROW",
"features": {
"magic": false,
"bootmagic": false,
"space_cadet": false,
"grave_esc": false,
"command": false,
"console": false,
"extrakey": false,
"mousekey": false,
"nkro": true
},
"matrix_pins": {
"cols": ["F4", "F5", "F6", "F7", "B1", "B3"],
"rows": ["D4", "C6", "D7", "E6"]
},
"processor": "atmega32u4",
"url": "https://github.com/pashutk/chocofi",
"usb": {
"device_version": "1.0.0",
"pid": "0x0000",
"vid": "0xFEED"
},
"layouts": {
"LAYOUT_split_3x5_3": {
"layout": [
{ "x": 0, "y": 0.25 },
{ "x": 1, "y": 0.125 },
{ "x": 2, "y": 0 },
{ "x": 3, "y": 0.125 },
{ "x": 4, "y": 0.25 },
{ "x": 7, "y": 0.25 },
{ "x": 8, "y": 0.125 },
{ "x": 9, "y": 0 },
{ "x": 10, "y": 0.125 },
{ "x": 11, "y": 0.25 },
{ "x": 0, "y": 1.25 },
{ "x": 1, "y": 1.125 },
{ "x": 2, "y": 1 },
{ "x": 3, "y": 1.125 },
{ "x": 4, "y": 1.25 },
{ "x": 7, "y": 1.25 },
{ "x": 8, "y": 1.125 },
{ "x": 9, "y": 1 },
{ "x": 10, "y": 1.125 },
{ "x": 11, "y": 1.25 },
{ "x": 0, "y": 2.25 },
{ "x": 1, "y": 2.125 },
{ "x": 2, "y": 2 },
{ "x": 3, "y": 2.125 },
{ "x": 4, "y": 2.25 },
{ "x": 7, "y": 2.25 },
{ "x": 8, "y": 2.125 },
{ "x": 9, "y": 2 },
{ "x": 10, "y": 2.125 },
{ "x": 11, "y": 2.25 },
{ "x": 2.5, "y": 3.25 },
{ "x": 3.5, "y": 3.5 },
{ "x": 4.5, "y": 3.75 },
{ "x": 6.5, "y": 3.75 },
{ "x": 7.5, "y": 3.5 },
{ "x": 8.5, "y": 3.25 }
]
}
}
}
25 changes: 25 additions & 0 deletions keyboards/chocofi/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include QMK_KEYBOARD_H
#include <stdio.h>

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/*
* ┌───┬───┬───┬───┬───┐ ┌───┬───┬───┬───┬───┐
* │ Q │ W │ E │ R │ T │ │ Y │ U │ I │ O │ P │
* ├───┼───┼───┼───┼───┤ ├───┼───┼───┼───┼───┤
* │ A │ S │ D │ F │ G │ │ H │ J │ K │ L │ ; │
* ├───┼───┼───┼───┼───┤ ├───┼───┼───┼───┼───┤
* │ Z │ X │ C │ V │ B │ │ N │ M │ , │ . │ / │
* └───┴───┴───┴───┴───┘ └───┴───┴───┴───┴───┘
* ┌───┐ ┌───┐
* │GUI├───┐ ┌───┤Alt│
* └───┤Bsp├───┐ ┌───┤Ent├───┘
* └───┤ │ │ ├───┘
* └───┘ └───┘
*/
[0] = LAYOUT_split_3x5_3(
KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P,
KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN,
KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH,
KC_LGUI, KC_BSPC, KC_SPC, KC_SPC, KC_ENT, KC_RALT
)
};
8 changes: 8 additions & 0 deletions keyboards/chocofi/keymaps/dtk35/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#undef NO_ACTION_LAYER
#undef NO_ACTION_TAPPING

#define IGNORE_MOD_TAP_INTERRUPT
#define TAPPING_TERM_PER_KEY
#define TAPPING_TERM_SFT 150
#define HOLD_ON_OTHER_KEY_PRESS_PER_KEY
#define RETRO_TAPPING_PER_KEY
158 changes: 158 additions & 0 deletions keyboards/chocofi/keymaps/dtk35/features/caps_word.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
// Copyright 2021-2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//
// For full documentation, see
// https://getreuer.info/posts/keyboards/caps-word

#include "caps_word.h"

static bool caps_word_active = false;

// Many keyboards enable the Command feature, which by default is also activated
// by Left Shift + Right Shift. It can be configured to use a different key
// combination by defining IS_COMMAND(). We make a non-fatal warning if Command
// is enabled but IS_COMMAND() is *not* defined.
#if defined(COMMAND_ENABLE) && !defined(IS_COMMAND)
#pragma message "Caps Word and Command should not be enabled at the same time, since both use the Left Shift + Right Shift key combination. Please disable Command, or ensure that `IS_COMMAND` is not set to (get_mods() == MOD_MASK_SHIFT)."
#endif // defined(COMMAND_ENABLE) && !defined(IS_COMMAND)

#if CAPS_WORD_IDLE_TIMEOUT > 0
#if CAPS_WORD_IDLE_TIMEOUT < 100 || CAPS_WORD_IDLE_TIMEOUT > 30000
// Constrain timeout to a sensible range. With the 16-bit timer, the longest
// representable timeout is 32768 ms, rounded here to 30000 ms = half a minute.
#error "caps_word: CAPS_WORD_IDLE_TIMEOUT must be between 100 and 30000 ms"
#endif

static uint16_t idle_timer = 0;

void caps_word_task(void) {
if (caps_word_active && timer_expired(timer_read(), idle_timer)) {
caps_word_set(false);
}
}
#endif // CAPS_WORD_IDLE_TIMEOUT > 0

bool process_caps_word(uint16_t keycode, keyrecord_t* record) {
#ifndef NO_ACTION_ONESHOT
const uint8_t mods = get_mods() | get_oneshot_mods();
#else
const uint8_t mods = get_mods();
#endif // NO_ACTION_ONESHOT

if (!caps_word_active) {
// Pressing both shift keys at the same time enables caps word.
if (mods == MOD_MASK_SHIFT) {
caps_word_set(true); // Activate Caps Word.
return false;
}
return true;
} else {
#if CAPS_WORD_IDLE_TIMEOUT > 0
idle_timer = record->event.time + CAPS_WORD_IDLE_TIMEOUT;
#endif // CAPS_WORD_IDLE_TIMEOUT > 0
}

if (!record->event.pressed) { return true; }

if (!(mods & ~MOD_MASK_SHIFT)) {
switch (keycode) {
// Ignore MO, TO, TG, TT, and OSL layer switch keys.
case QK_MOMENTARY ... QK_MOMENTARY_MAX:
case QK_TO ... QK_TO_MAX:
case QK_TOGGLE_LAYER ... QK_TOGGLE_LAYER_MAX:
case QK_LAYER_TAP_TOGGLE ... QK_LAYER_TAP_TOGGLE_MAX:
case QK_ONE_SHOT_LAYER ... QK_ONE_SHOT_LAYER_MAX:
return true;

#ifndef NO_ACTION_TAPPING
case QK_MOD_TAP ... QK_MOD_TAP_MAX:
if (record->tap.count == 0) {
// Deactivate if a mod becomes active through holding a mod-tap key.
caps_word_set(false);
return true;
}
keycode &= 0xff;
break;

#ifndef NO_ACTION_LAYER
case QK_LAYER_TAP ... QK_LAYER_TAP_MAX:
#endif // NO_ACTION_LAYER
if (record->tap.count == 0) { return true; }
keycode &= 0xff;
break;
#endif // NO_ACTION_TAPPING

#ifdef SWAP_HANDS_ENABLE
case QK_SWAP_HANDS ... QK_SWAP_HANDS_MAX:
if (keycode > 0x56F0 || record->tap.count == 0) { return true; }
keycode &= 0xff;
break;
#endif // SWAP_HANDS_ENABLE
}

clear_weak_mods();
if (caps_word_press_user(keycode)) {
send_keyboard_report();
return true;
}
}

caps_word_set(false); // Deactivate Caps Word.
return true;
}

void caps_word_set(bool active) {
if (active != caps_word_active) {
if (active) {
clear_mods();
#ifndef NO_ACTION_ONESHOT
clear_oneshot_mods();
#endif // NO_ACTION_ONESHOT
#if CAPS_WORD_IDLE_TIMEOUT > 0
idle_timer = timer_read() + CAPS_WORD_IDLE_TIMEOUT;
#endif // CAPS_WORD_IDLE_TIMEOUT > 0
} else {
// Make sure weak shift is off.
unregister_weak_mods(MOD_BIT(KC_LSFT));
}

caps_word_active = active;
caps_word_set_user(active);
}
}

bool caps_word_get(void) { return caps_word_active; }

__attribute__((weak)) void caps_word_set_user(bool active) {}

__attribute__((weak)) bool caps_word_press_user(uint16_t keycode) {
switch (keycode) {
// Keycodes that continue Caps Word, with shift applied.
case KC_A ... KC_Z:
case KC_MINS:
add_weak_mods(MOD_BIT(KC_LSFT)); // Apply shift to the next key.
return true;

// Keycodes that continue Caps Word, without shifting.
case KC_1 ... KC_0:
case KC_BSPC:
case KC_DEL:
case KC_UNDS:
return true;

default:
return false; // Deactivate Caps Word.
}
}
Loading
Loading