Skip to content

Commit

Permalink
Purge and cleanup sequences code
Browse files Browse the repository at this point in the history
  • Loading branch information
xs5871 committed Jun 7, 2024
1 parent e4d41fb commit 78e9715
Show file tree
Hide file tree
Showing 14 changed files with 38 additions and 647 deletions.
148 changes: 21 additions & 127 deletions boards/atreus62/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

from kb import KMKKeyboard

from kmk.handlers.sequences import simple_key_sequence
from kmk.keys import KC
from kmk.modules.encoder import EncoderHandler
from kmk.modules.layers import Layers
from kmk.modules.macros import Delay, Macros, Tap

# local_increment = None
# local_decrement = None
Expand All @@ -27,7 +27,9 @@
encoder = EncoderHandler(
(board.D40, board.D41, None, True),
)
keyboard.modules = [layers, encoder]

macros = Macros()
keyboard.modules = [layers, encoder, macros]

keyboard.tap_time = 250
keyboard.debug_enabled = False
Expand All @@ -43,134 +45,26 @@
LT2_ENT = KC.LT(2, KC.ENT)
SAVE_AS = KC.LCTL(KC.LSFT(KC.S))
PSCR = KC.LGUI(KC.PSCR)
SNIP = simple_key_sequence(
(
KC.LGUI,
KC.MACRO_SLEEP_MS(25),
KC.S,
KC.N,
KC.I,
KC.P,
KC.MACRO_SLEEP_MS(25),
KC.ENT,
)
SNIP = KC.MACRO(
Tap(KC.LGUI),
Delay(25),
'snip',
Delay(25),
Tap(KC.ENT),
)

# programming layer keys
UINT = simple_key_sequence(
(
KC.U,
KC.I,
KC.N,
KC.T,
)
)
INT = simple_key_sequence(
(
KC.I,
KC.N,
KC.T,
)
)
DOUBLE = simple_key_sequence(
(
KC.D,
KC.O,
KC.U,
KC.B,
KC.L,
KC.E,
)
)
BOOL = simple_key_sequence(
(
KC.B,
KC.O,
KC.O,
KC.L,
)
)
BYTE = simple_key_sequence(
(
KC.B,
KC.Y,
KC.T,
KC.E,
)
)
SBYTE = simple_key_sequence(
(
KC.S,
KC.B,
KC.Y,
KC.T,
KC.E,
)
)
CHAR = simple_key_sequence(
(
KC.C,
KC.H,
KC.A,
KC.R,
)
)
GETSET = simple_key_sequence(
(
KC.LBRC,
KC.SPC,
KC.G,
KC.E,
KC.T,
KC.SCLN,
KC.SPC,
KC.S,
KC.E,
KC.T,
KC.SCLN,
KC.SPC,
KC.RBRC,
)
)
PUBLIC = simple_key_sequence(
(
KC.P,
KC.U,
KC.B,
KC.L,
KC.I,
KC.C,
)
)
DEBUGWL = simple_key_sequence(
(
KC.LSFT(KC.D),
KC.E,
KC.B,
KC.U,
KC.G,
KC.DOT,
KC.LSFT(KC.W),
KC.R,
KC.I,
KC.T,
KC.E,
KC.LSFT(KC.L),
KC.I,
KC.N,
KC.E,
KC.LSFT(KC.N9),
)
)
PRINT = simple_key_sequence(
(
KC.P,
KC.R,
KC.I,
KC.N,
KC.T,
)
)
UINT = KC.MACRO('uint')
INT = KC.MACRO('int')
DOUBLE = KC.MACRO('double')
BOOL = KC.MACRO('bool')
BYTE = KC.MACRO('byte')
SBYTE = KC.MACRO('sbyte')
CHAR = KC.MACRO('char')
GETSET = KC.MACRO('getset')
PUBLIC = KC.MACRO('public')
DEBUGWL = KC.MACRO('Debug.WriteLine(')
PRINT = KC.MACRO('print')


# make keymap
Expand Down
10 changes: 6 additions & 4 deletions boards/boardsource/unicorne/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@
OledReactionType,
)
from kmk.extensions.peg_rgb_matrix import Rgb_matrix
from kmk.handlers.sequences import send_string
from kmk.hid import HIDModes
from kmk.keys import KC
from kmk.modules.combos import Chord, Combos
from kmk.modules.holdtap import HoldTapRepeat
from kmk.modules.layers import Layers
from kmk.modules.macros import Macros
from kmk.modules.modtap import ModTap
from kmk.modules.oneshot import OneShot
from kmk.modules.split import Split, SplitSide

supervisor.runtime.autoreload = False
keyboard = KMKKeyboard()
macros = Macros()
modtap = ModTap()
combos = Combos()
oneshot = OneShot()
Expand All @@ -35,6 +36,7 @@
keyboard.modules.append(layers)
keyboard.modules.append(modtap)
keyboard.modules.append(combos)
keyboard.modules.append(macros)

# oled
oled = Oled(
Expand Down Expand Up @@ -231,9 +233,9 @@
# fmt:on

combos.combos = [
Chord((KC.QUOT, KC.COMM), send_string('>_>')),
Chord((KC.COMM, KC.DOT), send_string('><')),
Chord((KC.C, KC.L), send_string("C'est la vie")),
Chord((KC.QUOT, KC.COMM), KC.MACRO('>_>')),
Chord((KC.COMM, KC.DOT), KC.MACRO('><')),
Chord((KC.C, KC.L), KC.MACRO("C'est la vie")),
Chord((KC.BKSP, KC.L), KC.LCTL(KC.BKSP)),
Chord((KC.R, KC.L), KC.LCTL(KC.V)),
Chord((KC.V, KC.Z), KC.LCTL(KC.Z)),
Expand Down
46 changes: 0 additions & 46 deletions boards/keebio/iris/main.py
Original file line number Diff line number Diff line change
@@ -1,63 +1,17 @@
from kb import KMKKeyboard

from kmk.consts import UnicodeMode
from kmk.extensions.rgb import RGB
from kmk.handlers.sequences import compile_unicode_string_sequences as cuss
from kmk.handlers.sequences import send_string
from kmk.keys import KC
from kmk.modules.layers import Layers
from kmk.modules.split import Split, SplitSide, SplitType

keyboard = KMKKeyboard()

keyboard.debug_enabled = False
keyboard.unicode_mode = UnicodeMode.LINUX
keyboard.tap_time = 750

emoticons = cuss(
{
# Emojis
'BEER': r'🍺',
'BEER_TOAST': r'🍻',
'FACE_CUTE_SMILE': r'😊',
'FACE_HEART_EYES': r'😍',
'FACE_JOY': r'😂',
'FACE_SWEAT_SMILE': r'😅',
'FACE_THINKING': r'🤔',
'FIRE': r'🔥',
'FLAG_CA': r'🇨🇦',
'FLAG_US': r'🇺🇸',
'HAND_CLAP': r'👏',
'HAND_HORNS': r'🤘',
'HAND_OK': r'👌',
'HAND_THUMB_DOWN': r'👎',
'HAND_THUMB_UP': r'👍',
'HAND_WAVE': r'👋',
'HEART': r'❤️',
'MAPLE_LEAF': r'🍁',
'POOP': r'💩',
'TADA': r'🎉',
'SHRUG_EMOJI': r'🤷',
# Emoticons, but fancier
'ANGRY_TABLE_FLIP': r'(ノಠ痊ಠ)ノ彡┻━┻',
'CELEBRATORY_GLITTER': r'+。:.゚ヽ(´∀。)ノ゚.:。+゚゚+。:.゚ヽ(*´∀)ノ゚.:。+゚',
'SHRUGGIE': r'¯\_(ツ)_/¯',
'TABLE_FLIP': r'(╯°□°)╯︵ ┻━┻',
}
)

WPM = send_string(
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Bibendum arcu vitae elementum curabitur vitae nunc sed. Facilisis sed odio morbi quis.'
)

_______ = KC.TRNS
xxxxxxx = KC.NO
HELLA_TD = KC.TD(
KC.A,
KC.B,
send_string('macros in a tap dance? I think yes'),
KC.TG(1),
)

rgb = RGB(pixel_pin=keyboard.rgb_pixel_pin, num_pixels=keyboard.rgb_num_pixels)
layers = Layers()
Expand Down
5 changes: 0 additions & 5 deletions docs/en/keycodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,6 @@
| `KC.ANY` | Any key between `A` and `/` |
| `KC.GESC` | Escape when tapped, <code>&#96;</code> when pressed with Shift or GUI |
| `KC.BKDL` | Backspace when tapped, Delete when pressed with GUI |
| `KC.UC_MODE_NOOP` | Sets UnicodeMode to NOOP |
| `KC.UC_MODE_LINUX` | Sets UnicodeMode to Linux |
| `KC.UC_MODE_MACOS` | Sets UnicodeMode to macOS |
| `KC.UC_MODE_WINC` | Sets UnicodeMode to WinCompose |
| `KC.MACRO_SLEEP_MS(ms)` | Sleeps in a macro. See [SEQUENCES](sequences.md) for more information. |


## [Modifiers]
Expand Down
16 changes: 2 additions & 14 deletions docs/en/keys.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,14 @@ objects have a few core pieces of information:

- Their attached modifiers (to implement things like shifted keys or `KC.HYPR`,
which are single key presses sending along more than one key in a single HID
report. This is a distinct concept from Sequences, which are a KMK feature
documented in [`sequences.md`](sequences.md)). For almost all purposes outside of KMK core,
report. For almost all purposes outside of KMK core,
this field should be ignored - it can be safely populated through far more
sane means than futzing with it by hand.

- Some data on whether the key should actually be pressed or released - this is
mostly an implementation detail of how Sequences work, where, for example,
`KC.RALT` may need to be held down for the entirety of a sequence, rather than
being released immediately before moving to the next character. Usually end
users shouldn't need to mess with this, but the fields are called `no_press`
and `no_release` and are referenced in a few places in the codebase if you
need examples.

- Handlers for "press" (sometimes known as "keydown") and "release" (sometimes
known as "keyup") events. KMK provides handlers for standard keyboard
functions and some special override keys (like `KC.GESC`, which is an enhanced
form of existing ANSI keys) in [`kmk/handlers/stock.py`](/kmk/handlers/stock.py), for layer switching in
[`kmk/modules/layers.py`](/kmk/modules/layers.py), and for everything related to Sequences (see
[`sequences.md`](sequences.md) again) in [`kmk/handlers/sequences.py`](/kmk/handlers/sequences.py). We'll discuss these more
shortly.
form of existing ANSI keys) in [`kmk/handlers/stock.py`](/kmk/handlers/stock.py).

- Optional callbacks to be run before and/or after the above handlers. More on
that soon.
Expand Down
Loading

0 comments on commit 78e9715

Please sign in to comment.