diff --git a/boards/atreus62/main.py b/boards/atreus62/main.py
index a35115f93..0820dc30e 100644
--- a/boards/atreus62/main.py
+++ b/boards/atreus62/main.py
@@ -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
@@ -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
@@ -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
diff --git a/boards/boardsource/unicorne/main.py b/boards/boardsource/unicorne/main.py
index 23f76869b..52f58fbec 100644
--- a/boards/boardsource/unicorne/main.py
+++ b/boards/boardsource/unicorne/main.py
@@ -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()
@@ -35,6 +36,7 @@
keyboard.modules.append(layers)
keyboard.modules.append(modtap)
keyboard.modules.append(combos)
+keyboard.modules.append(macros)
# oled
oled = Oled(
@@ -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)),
diff --git a/boards/keebio/iris/main.py b/boards/keebio/iris/main.py
index 6de3651e9..c94bcf42d 100644
--- a/boards/keebio/iris/main.py
+++ b/boards/keebio/iris/main.py
@@ -1,9 +1,6 @@
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
@@ -11,53 +8,10 @@
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'+q:.οΎγ½(Β΄βq)οΎοΎ.:q+οΎοΎ+q:.οΎγ½(*Β΄β)οΎοΎ.:q+οΎ',
- '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()
diff --git a/docs/en/keycodes.md b/docs/en/keycodes.md
index 0f9657153..fb4d1a050 100644
--- a/docs/en/keycodes.md
+++ b/docs/en/keycodes.md
@@ -191,11 +191,6 @@
| `KC.ANY` | Any key between `A` and `/` |
| `KC.GESC` | Escape when tapped, `
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]
diff --git a/docs/en/keys.md b/docs/en/keys.md
index b151a315d..84da6b698 100644
--- a/docs/en/keys.md
+++ b/docs/en/keys.md
@@ -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.
diff --git a/docs/en/sequences.md b/docs/en/sequences.md
deleted file mode 100644
index c6a47fb09..000000000
--- a/docs/en/sequences.md
+++ /dev/null
@@ -1,173 +0,0 @@
-# Sequences
-
-Sequences are used for sending multiple keystrokes in a single action, and can
-be used for things like Unicode characters (even emojis! π¨π¦), _Lorem ipsum_
-generators, triggering side effects (think lighting, speakers,
-microcontroller-optimized cryptocurrency miners, whatever). If you are still
-unsure of what this is, most other vendors call these "Macros", but can do much
-more if you wish.
-
-## Sending strings
-The most basic sequence is `send_string`. It can be used to send any standard
-English alphabet character, and an assortment of other "standard" keyboard keys
-(return, space, exclamation points, etc.)
-
-```python
-from kmk.handlers.sequences import send_string
-
-WOW = send_string("Wow, KMK is awesome!")
-
-keyboard.keymap = [, WOW, ]
-```
-
-## Key sequences
-If you need to add modifier keys to your sequence, instead of `send_string` use
-`simple_key_sequence`. While it's not as visually clean as `send_string`, you can
-use it to add things like copying/pasting, tabbing between fields, etc.
-
-```python
-from kmk.handlers.sequences import simple_key_sequence
-
-PASTE_WITH_COMMENTARY = simple_key_sequence(
- (
- KC.L,
- KC.O,
- KC.O,
- KC.K,
- KC.SPC,
- KC.A,
- KC.T,
- KC.SPC,
- KC.T,
- KC.H,
- KC.I,
- KC.S,
- KC.COLN,
- KC.SPC,
- KC.LCTL(KC.V),
- )
-)
-
-keyboard.keymap = [, PASTE_WITH_COMMENTARY, ]
-```
-
-The above example will type out "look at this: " and then paste the contents of your
-clipboard.
-
-
-### Sleeping within a sequence
-
-If you need to wait during a sequence, you can use `KC.MACRO_SLEEP_MS(ms)` to wait a
-length of time, in milliseconds.
-
-```python
-from kmk.handlers.sequences import simple_key_sequence
-
-COUNTDOWN_TO_PASTE = simple_key_sequence(
- (
- KC.N3,
- KC.ENTER,
- KC.MACRO_SLEEP_MS(1000),
- KC.N2,
- KC.ENTER,
- KC.MACRO_SLEEP_MS(1000),
- KC.N1,
- KC.ENTER,
- KC.MACRO_SLEEP(1000),
- KC.LCTL(KC.V),
- )
-)
-
-keyboard.keymap = [, COUNTDOWN_TO_PASTE, ]
-```
-
-This example will type out the following, waiting one second (1000 ms) between numbers:
-
- 3
- 2
- 1
-
-and then paste the contents of your clipboard.
-
-### Alt Tab with delay
-
-If alt tab isn't working because it requires a delay, adding a delay and triggering
-down and up on ALT manually may fix the issue.
-
-``` python
-from kmk.handlers.sequences import simple_key_sequence
-
-NEXT = simple_key_sequence(
- (
- KC.LALT(no_release=True),
- KC.MACRO_SLEEP_MS(30),
- KC.TAB,
- KC.MACRO_SLEEP_MS(30),
- KC.LALT(no_press=True),
- )
-)
-```
-
-## Unicode
-Before trying to send Unicode sequences, make sure you set your `UnicodeMode`.
-You can set an initial value in your keymap by setting `keyboard.unicode_mode`.
-
-Keys are provided to change this mode at runtime - for example, `KC.UC_MODE_LINUX`.
-
-
-### Unicode Modes:
-On Linux, Unicode uses `Ctrl-Shift-U`, which is supported by `ibus` and GTK+3.
-`ibus` users will need to add `IBUS_ENABLE_CTRL_SHIFT_U=1` to their environment
-(`~/profile`, `~/.bashrc`, `~/.zshrc`, or through your desktop environment's
-configurator).
-
-On Windows, [WinCompose](https://github.com/samhocevar/wincompose) is required.
-
-- Linux : `UnicodeMode.LINUX` or `UnicodeMode.IBUS`
-- Mac: `UnicodeMode.MACOS` or `UnicodeMode.OSX` or `UnicodeMode.RALT`
-- Windows: `UnicodeMode.WINC`
-
-
-### Unicode Examples
-
-To send a simple Unicode symbol
-```python
-from kmk.handlers.sequences import unicode_string_sequence
-
-FLIP = unicode_string_sequence('(γΰ² ηΰ² )γ彑β»ββ»')
-
-keyboard.keymap = [, FLIP, ]
-```
-
-If you'd rather keep a lookup table of your sequences (perhaps to bind emojis to
-keys), that's supported too, through an obnoxiously long-winded method:
-
-```python
-from kmk.handlers.sequences import compile_unicode_string_sequences as cuss
-
-emoticons = cuss({
- 'BEER': r'πΊ',
- 'HAND_WAVE': r'π',
-})
-
-keymap = [, emoticons.BEER, emoticons.HAND_WAVE, ]
-```
-
-> The observant will notice dot-notation is supported here despite feeding in a
-> dictionary - the return of `compile_unicode_string_sequences` is a
-> `kmk.types.AttrDict`, which you can think of as a read-only view over a
-> dictionary adding attribute-based (dot-notation) access.
-
-Finally, if you need to send arbitrary Unicode codepoints in raw form, that's
-supported too, through `unicode_codepoint_sequence`.
-
-```python
-from kmk.handlers.sequences import unicode_codepoint_sequence
-
-TABLE_FLIP = unicode_codepoint_sequence([
- "28", "30ce", "ca0", "75ca","ca0", "29",
- "30ce", "5f61", "253b", "2501", "253b",
-])
-
-keyboard.keymap = [, TABLE_FLIP, ]
-```
diff --git a/docs/en/tapdance.md b/docs/en/tapdance.md
index 953d06ef2..f3b0599d2 100644
--- a/docs/en/tapdance.md
+++ b/docs/en/tapdance.md
@@ -33,7 +33,7 @@ Here's an example of all this in action:
```python
from kmk.keycodes import KC
-from kmk.handlers.sequences import send_string
+from kmk.modules.macros import Macros
from kmk.modules.tapdance import TapDance
keyboard = KMKKeyboard()
@@ -41,6 +41,7 @@ keyboard = KMKKeyboard()
tapdance = TapDance()
tapdance.tap_time = 750
keyboard.modules.append(tapdance)
+keyboard.modules.append(Macros())
EXAMPLE_TD = KC.TD(
# Tap once for "a"
@@ -48,7 +49,7 @@ EXAMPLE_TD = KC.TD(
# Tap twice for "b", or tap and hold for "left control"
KC.HT(KC.B, KC.LCTL, prefer_hold=False),
# Tap three times to send a raw string via macro
- send_string('macros in a tap dance? I think yes'),
+ KC.MACRO('macros in a tap dance? I think yes'),
# Tap four times to toggle layer index 1, tap 3 times and hold for 3s to
# momentary toggle layer index 1.
KC.TT(1, tap_time=3000),
diff --git a/kmk/consts.py b/kmk/consts.py
deleted file mode 100644
index 164d02b74..000000000
--- a/kmk/consts.py
+++ /dev/null
@@ -1,8 +0,0 @@
-from micropython import const
-
-
-class UnicodeMode:
- NOOP = const(0)
- LINUX = IBUS = const(1)
- MACOS = OSX = RALT = const(2)
- WINC = const(3)
diff --git a/kmk/handlers/sequences.py b/kmk/handlers/sequences.py
deleted file mode 100644
index 2f71dbfd6..000000000
--- a/kmk/handlers/sequences.py
+++ /dev/null
@@ -1,153 +0,0 @@
-import gc
-
-from kmk.consts import UnicodeMode
-from kmk.handlers.stock import passthrough
-from kmk.keys import KC, make_key
-from kmk.types import AttrDict, KeySequenceMeta
-
-
-def get_wide_ordinal(char):
- if len(char) != 2:
- return ord(char)
-
- return 0x10000 + (ord(char[0]) - 0xD800) * 0x400 + (ord(char[1]) - 0xDC00)
-
-
-def sequence_press_handler(key, keyboard, KC, *args, **kwargs):
- for ikey in key.meta.seq:
- if not getattr(ikey, 'no_press', None):
- keyboard.add_key(ikey)
- keyboard._send_hid()
- if not getattr(ikey, 'no_release', None):
- keyboard.remove_key(ikey)
- keyboard._send_hid()
- else:
- keyboard.tap_key(ikey)
- keyboard._send_hid()
-
- return keyboard
-
-
-def simple_key_sequence(seq):
- return make_key(
- meta=KeySequenceMeta(seq),
- on_press=sequence_press_handler,
- on_release=passthrough,
- )
-
-
-def send_string(message):
- seq = []
-
- for char in message:
- kc = getattr(KC, char.upper())
-
- if char.isupper():
- kc = KC.LSHIFT(kc)
-
- seq.append(kc)
-
- return simple_key_sequence(seq)
-
-
-IBUS_KEY_COMBO = simple_key_sequence((KC.LCTRL(KC.LSHIFT(KC.U)),))
-RALT_KEY = simple_key_sequence((KC.RALT,))
-U_KEY = simple_key_sequence((KC.U,))
-ENTER_KEY = simple_key_sequence((KC.ENTER,))
-RALT_DOWN_NO_RELEASE = simple_key_sequence((KC.RALT(no_release=True),))
-RALT_UP_NO_PRESS = simple_key_sequence((KC.RALT(no_press=True),))
-
-
-def compile_unicode_string_sequences(string_table):
- '''
- Destructively convert ("compile") unicode strings into key sequences. This
- will, for RAM saving reasons, empty the input dictionary and trigger
- garbage collection.
- '''
- target = AttrDict()
-
- for k, v in string_table.items():
- target[k] = unicode_string_sequence(v)
-
- # now loop through and kill the input dictionary to save RAM
- for k in target.keys():
- del string_table[k]
-
- gc.collect()
-
- return target
-
-
-def unicode_string_sequence(unistring):
- '''
- Allows sending things like (β―Β°β‘Β°οΌβ―οΈ΅ β»ββ» directly, without
- manual conversion to Unicode codepoints.
- '''
- return unicode_codepoint_sequence([hex(get_wide_ordinal(s))[2:] for s in unistring])
-
-
-def generate_codepoint_keysym_seq(codepoint, expected_length=4):
- # To make MacOS and Windows happy, always try to send
- # sequences that are of length 4 at a minimum
- # On Linux systems, we can happily send longer strings.
- # They will almost certainly break on MacOS and Windows,
- # but this is a documentation problem more than anything.
- # Not sure how to send emojis on Mac/Windows like that,
- # though, since (for example) the Canadian flag is assembled
- # from two five-character codepoints, 1f1e8 and 1f1e6
- seq = [KC.N0 for _ in range(max(len(codepoint), expected_length))]
-
- for idx, codepoint_fragment in enumerate(reversed(codepoint)):
- seq[-(idx + 1)] = KC.__getattr__(codepoint_fragment.upper())
-
- return seq
-
-
-def unicode_codepoint_sequence(codepoints):
- kc_seqs = (generate_codepoint_keysym_seq(codepoint) for codepoint in codepoints)
-
- kc_macros = [simple_key_sequence(kc_seq) for kc_seq in kc_seqs]
-
- def _unicode_sequence(key, keyboard, *args, **kwargs):
- if keyboard.unicode_mode == UnicodeMode.IBUS:
- keyboard.process_key(
- simple_key_sequence(_ibus_unicode_sequence(kc_macros, keyboard)), True
- )
- elif keyboard.unicode_mode == UnicodeMode.RALT:
- keyboard.process_key(
- simple_key_sequence(_ralt_unicode_sequence(kc_macros, keyboard)), True
- )
- elif keyboard.unicode_mode == UnicodeMode.WINC:
- keyboard.process_key(
- simple_key_sequence(_winc_unicode_sequence(kc_macros, keyboard)), True
- )
-
- return make_key(on_press=_unicode_sequence)
-
-
-def _ralt_unicode_sequence(kc_macros, keyboard):
- for kc_macro in kc_macros:
- yield RALT_DOWN_NO_RELEASE
- yield kc_macro
- yield RALT_UP_NO_PRESS
-
-
-def _ibus_unicode_sequence(kc_macros, keyboard):
- for kc_macro in kc_macros:
- yield IBUS_KEY_COMBO
- yield kc_macro
- yield ENTER_KEY
-
-
-def _winc_unicode_sequence(kc_macros, keyboard):
- '''
- Send unicode sequence using WinCompose:
-
- http://wincompose.info/
- https://github.com/SamHocevar/wincompose
- '''
- for kc_macro in kc_macros:
- yield RALT_KEY
- yield U_KEY
- yield kc_macro
- yield ENTER_KEY
diff --git a/kmk/key_validators.py b/kmk/key_validators.py
deleted file mode 100644
index 676f22162..000000000
--- a/kmk/key_validators.py
+++ /dev/null
@@ -1,9 +0,0 @@
-from kmk.types import KeySeqSleepMeta, UnicodeModeKeyMeta
-
-
-def key_seq_sleep_validator(ms):
- return KeySeqSleepMeta(ms)
-
-
-def unicode_mode_key_validator(mode):
- return UnicodeModeKeyMeta(mode)
diff --git a/kmk/keys.py b/kmk/keys.py
index 926882329..79684860a 100644
--- a/kmk/keys.py
+++ b/kmk/keys.py
@@ -6,9 +6,6 @@
from micropython import const
import kmk.handlers.stock as handlers
-from kmk.consts import UnicodeMode
-from kmk.key_validators import key_seq_sleep_validator, unicode_mode_key_validator
-from kmk.types import UnicodeModeKeyMeta
from kmk.utils import Debug
# Type aliases / forward declaration; can't use the proper types because of circular imports.
@@ -329,42 +326,6 @@ def maybe_make_international_key(candidate: str) -> Optional[Key]:
return make_key(code=code, names=names)
-def maybe_make_unicode_key(candidate: str) -> Optional[Key]:
- keys = (
- (
- ('UC_MODE_NOOP', 'UC_DISABLE'),
- handlers.uc_mode_pressed,
- UnicodeModeKeyMeta(UnicodeMode.NOOP),
- ),
- (
- ('UC_MODE_LINUX', 'UC_MODE_IBUS'),
- handlers.uc_mode_pressed,
- UnicodeModeKeyMeta(UnicodeMode.IBUS),
- ),
- (
- ('UC_MODE_MACOS', 'UC_MODE_OSX', 'US_MODE_RALT'),
- handlers.uc_mode_pressed,
- UnicodeModeKeyMeta(UnicodeMode.RALT),
- ),
- (
- ('UC_MODE_WINC',),
- handlers.uc_mode_pressed,
- UnicodeModeKeyMeta(UnicodeMode.WINC),
- ),
- )
-
- for names, handler, meta in keys:
- if candidate in names:
- return make_key(names=names, on_press=handler, meta=meta)
-
- if candidate in ('UC_MODE',):
- return make_argumented_key(
- names=('UC_MODE',),
- validator=unicode_mode_key_validator,
- on_press=handlers.uc_mode_pressed,
- )
-
-
def maybe_make_firmware_key(candidate: str) -> Optional[Key]:
keys = (
((('BLE_REFRESH',), handlers.ble_refresh)),
@@ -399,13 +360,6 @@ def maybe_make_firmware_key(candidate: str) -> Optional[Key]:
on_press=handlers.gesc_pressed,
on_release=handlers.gesc_released,
),
- # A dummy key to trigger a sleep_ms call in a sequence of other keys in a
- # simple sequence macro.
- maybe_make_argumented_key(
- key_seq_sleep_validator,
- ('MACRO_SLEEP_MS', 'SLEEP_IN_SEQ'),
- on_press=handlers.sleep_pressed,
- ),
maybe_make_mod_key,
# More ASCII standard keys
maybe_make_more_ascii,
@@ -425,7 +379,6 @@ def maybe_make_firmware_key(candidate: str) -> Optional[Key]:
maybe_make_shifted_key,
# International
maybe_make_international_key,
- maybe_make_unicode_key,
)
@@ -500,8 +453,6 @@ def __init__(
self,
code: int,
has_modifiers: Optional[list[Key, ...]] = None,
- no_press: bool = False,
- no_release: bool = False,
on_press: Callable[
[object, Key, Keyboard, ...], None
] = handlers.default_pressed,
@@ -513,28 +464,13 @@ def __init__(
self.code = code
self.has_modifiers = has_modifiers
# cast to bool() in case we get a None value
- self.no_press = bool(no_press)
- self.no_release = bool(no_release)
self._handle_press = on_press
self._handle_release = on_release
self.meta = meta
- def __call__(
- self, no_press: Optional[bool] = None, no_release: Optional[bool] = None
- ) -> Key:
- if no_press is None and no_release is None:
- return self
-
- return type(self)(
- code=self.code,
- has_modifiers=self.has_modifiers,
- no_press=no_press,
- no_release=no_release,
- on_press=self._handle_press,
- on_release=self._handle_release,
- meta=self.meta,
- )
+ def __call__(self) -> Key:
+ return self
def __repr__(self):
return f'Key(code={self.code}, has_modifiers={self.has_modifiers})'
@@ -573,8 +509,6 @@ def clone(self) -> Key:
return type(self)(
code=self.code,
has_modifiers=self.has_modifiers,
- no_press=self.no_press,
- no_release=self.no_release,
on_press=self._handle_press,
on_release=self._handle_release,
meta=self.meta,
@@ -681,11 +615,9 @@ class ModifierKey(Key):
def __call__(
self,
modified_key: Optional[Key] = None,
- no_press: Optional[bool] = None,
- no_release: Optional[bool] = None,
) -> Key:
if modified_key is None:
- return super().__call__(no_press=no_press, no_release=no_release)
+ return super().__call__()
modifiers = set()
code = modified_key.code
@@ -705,8 +637,6 @@ def __call__(
return type(modified_key)(
code=code,
has_modifiers=modifiers,
- no_press=no_press,
- no_release=no_release,
on_press=modified_key._handle_press,
on_release=modified_key._handle_release,
meta=modified_key.meta,
diff --git a/kmk/kmk_keyboard.py b/kmk/kmk_keyboard.py
index f8daca7af..dbd86676f 100644
--- a/kmk/kmk_keyboard.py
+++ b/kmk/kmk_keyboard.py
@@ -6,7 +6,6 @@
from collections import namedtuple
from keypad import Event as KeyEvent
-from kmk.consts import UnicodeMode
from kmk.hid import BLEHID, USBHID, AbstractHID, HIDModes
from kmk.keys import KC, Key
from kmk.modules import Module
@@ -45,8 +44,6 @@ class KMKKeyboard:
diode_orientation = None
matrix = None
- unicode_mode = UnicodeMode.NOOP
-
modules = []
extensions = []
sandbox = Sandbox()
@@ -488,7 +485,6 @@ def _init(
if debug.enabled:
debug('Initialising ', self)
- debug('unicode_mode=', self.unicode_mode)
self._init_hid()
self._init_matrix()
diff --git a/kmk/types.py b/kmk/types.py
deleted file mode 100644
index 4d05158fa..000000000
--- a/kmk/types.py
+++ /dev/null
@@ -1,26 +0,0 @@
-class AttrDict(dict):
- '''
- Primitive support for accessing dictionary entries in dot notation.
- Mostly for user-facing stuff (allows for `k.KC_ESC` rather than
- `k['KC_ESC']`, which gets a bit obnoxious).
-
- This is read-only on purpose.
- '''
-
- def __getattr__(self, key):
- return self[key]
-
-
-class KeySequenceMeta:
- def __init__(self, seq):
- self.seq = seq
-
-
-class KeySeqSleepMeta:
- def __init__(self, ms):
- self.ms = ms
-
-
-class UnicodeModeKeyMeta:
- def __init__(self, mode):
- self.mode = mode
diff --git a/tests/test_kmk_keys.py b/tests/test_kmk_keys.py
index ae664e259..599ea4e26 100644
--- a/tests/test_kmk_keys.py
+++ b/tests/test_kmk_keys.py
@@ -97,10 +97,10 @@ def test_basic_kmk_keyboard(self):
)
self.assertEqual(keyboard.keyboard._coordkeys_pressed, {6: KC.TRNS})
- assert isinstance(KC.RGUI(no_press=True), ModifierKey)
+ assert isinstance(KC.RGUI, ModifierKey)
assert isinstance(KC.RALT(KC.RGUI), ModifierKey)
- assert isinstance(KC.Q(no_press=True), Key)
- assert not isinstance(KC.Q(no_press=True), ModifierKey)
+ assert isinstance(KC.Q, Key)
+ assert not isinstance(KC.Q, ModifierKey)
assert isinstance(KC.RALT(KC.Q), Key)
assert not isinstance(KC.RALT(KC.Q), ModifierKey)