Skip to content

Commit

Permalink
Reverting back to keycodes
Browse files Browse the repository at this point in the history
  • Loading branch information
XScorpion2 committed Apr 29, 2019
1 parent d74cc25 commit 9357514
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 33 deletions.
26 changes: 13 additions & 13 deletions docs/feature_space_cadet.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,28 @@ COMMAND_ENABLE = no

## Configuration

By default Space Cadet assumes a US ANSI layout, but if your layout uses different keys for parentheses, you can redefine them in your `config.h`. In addition, you can redefine the modifier to send on tap, or even send no modifier at all. The new configuration defines bundle all options up into a single define of 3 key codes in this order: the `Modifier` when held or when used with other keys, the `Tap Modifer` sent when tapped (no modifier if `MOD_NONE`), finally the `Keycode` sent when tapped. Now keep in mind, mods from other keys will still apply to the `Keycode` if say `KC_RSFT` is held while tapping `KC_LSPO` key with `MOD_NONE` as the `Tap Modifer`.
By default Space Cadet assumes a US ANSI layout, but if your layout uses different keys for parentheses, you can redefine them in your `config.h`. In addition, you can redefine the modifier to send on tap, or even send no modifier at all. The new configuration defines bundle all options up into a single define of 3 key codes in this order: the `Modifier` when held or when used with other keys, the `Tap Modifer` sent when tapped (no modifier if `KC_TRNS`), finally the `Keycode` sent when tapped. Now keep in mind, mods from other keys will still apply to the `Keycode` if say `KC_RSFT` is held while tapping `KC_LSPO` key with `KC_TRNS` as the `Tap Modifer`.

|Define |Default |Description |
|----------------|--------------------------------|----------------------------------------------------------------------------------|
|`LSPO_KEYS` |`MOD_LSFT, LSPO_MOD, LSPO_KEY` |Send `MOD_LSFT` when held, the mod and key defined by `LSPO_MOD` and `LSPO_KEY`. |
|`RSPC_KEYS` |`MOD_RSFT, RSPC_MOD, RSPC_KEY` |Send `MOD_RSFT` when held, the mod and key defined by `RSPC_MOD` and `RSPC_KEY`. |
|`LCPO_KEYS` |`MOD_LCTL, MOD_LCTL, KC_9` |Send `MOD_LCTL` when held, the mod `MOD_LCTL` with the key `KC_9` when tapped. |
|`RCPO_KEYS` |`MOD_RCTL, MOD_RCTL, KC_0` |Send `MOD_RCTL` when held, the mod `MOD_RCTL` with the key `KC_0` when tapped. |
|`LAPO_KEYS` |`MOD_LALT, MOD_LALT, KC_9` |Send `MOD_LALT` when held, the mod `MOD_LALT` with the key `KC_9` when tapped. |
|`RAPO_KEYS` |`MOD_RALT, MOD_RALT, KC_0` |Send `MOD_RALT` when held, the mod `MOD_RALT` with the key `KC_0` when tapped. |
|`SFTENT_KEYS` |`MOD_RSFT, MOD_NONE, SFTENT_KEY`|Send `MOD_RSFT` when held, no mod with the key `SFTENT_KEY` when tapped. |
|Define |Default |Description |
|----------------|-------------------------------|---------------------------------------------------------------------------------|
|`LSPO_KEYS` |`KC_LSFT, LSPO_MOD, LSPO_KEY` |Send `KC_LSFT` when held, the mod and key defined by `LSPO_MOD` and `LSPO_KEY`. |
|`RSPC_KEYS` |`KC_RSFT, RSPC_MOD, RSPC_KEY` |Send `KC_RSFT` when held, the mod and key defined by `RSPC_MOD` and `RSPC_KEY`. |
|`LCPO_KEYS` |`KC_LCTL, KC_LCTL, KC_9` |Send `KC_LCTL` when held, the mod `KC_LCTL` with the key `KC_9` when tapped. |
|`RCPO_KEYS` |`KC_RCTL, KC_RCTL, KC_0` |Send `KC_RCTL` when held, the mod `KC_RCTL` with the key `KC_0` when tapped. |
|`LAPO_KEYS` |`KC_LALT, KC_LALT, KC_9` |Send `KC_LALT` when held, the mod `KC_LALT` with the key `KC_9` when tapped. |
|`RAPO_KEYS` |`KC_RALT, KC_RALT, KC_0` |Send `KC_RALT` when held, the mod `KC_RALT` with the key `KC_0` when tapped. |
|`SFTENT_KEYS` |`KC_RSFT, KC_TRNS, SFTENT_KEY` |Send `KC_RSFT` when held, no mod with the key `SFTENT_KEY` when tapped. |


## Obsolete Configuration

These defines are used in the above defines internally to support backwards compatibility, so you may continue to use them, however the above defines open up a larger range of flexibility than before. As an example, say you want to not send any modifier when you tap just `KC_LSPO`, with the old defines you had an all or nothing choice of using the `DISABLE_SPACE_CADET_MODIFIER` define. Now you can define that key as: `#define LSPO_KEYS MOD_LSFT, MOD_NONE, KC_9`. This tells the system to set Left Shift if held or used with other keys, then on tap send no modifier (transparent) with the `KC_9`
These defines are used in the above defines internally to support backwards compatibility, so you may continue to use them, however the above defines open up a larger range of flexibility than before. As an example, say you want to not send any modifier when you tap just `KC_LSPO`, with the old defines you had an all or nothing choice of using the `DISABLE_SPACE_CADET_MODIFIER` define. Now you can define that key as: `#define KC_LSPO_KEYS KC_LSFT, KC_TRNS, KC_9`. This tells the system to set Left Shift if held or used with other keys, then on tap send no modifier (transparent) with the `KC_9`

|Define |Default |Description |
|------------------------------|-------------|------------------------------------------------------------------|
|`LSPO_KEY` |`KC_9` |The keycode to send when Left Shift is tapped |
|`RSPC_KEY` |`KC_0` |The keycode to send when Right Shift is tapped |
|`LSPO_MOD` |`MOD_LSFT` |The modifier to apply to `LSPO_KEY` |
|`RSPC_MOD` |`MOD_RSFT` |The modifier to apply to `RSPC_KEY` |
|`LSPO_MOD` |`KC_LSFT` |The modifier to apply to `LSPO_KEY` |
|`RSPC_MOD` |`KC_RSFT` |The modifier to apply to `RSPC_KEY` |
|`SFTENT_KEY` |`KC_ENT` |The keycode to send when the Shift key is tapped |
|`DISABLE_SPACE_CADET_MODIFIER`|*Not defined*|If defined, prevent the Space Cadet from applying a modifier |
38 changes: 23 additions & 15 deletions quantum/process_keycode/process_space_cadet.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,48 +35,48 @@

#ifdef DISABLE_SPACE_CADET_MODIFIER
#ifndef LSPO_MOD
#define LSPO_MOD MOD_NONE
#define LSPO_MOD KC_TRNS
#endif
#ifndef RSPC_MOD
#define RSPC_MOD MOD_NONE
#define RSPC_MOD KC_TRNS
#endif
#else
#ifndef LSPO_MOD
#define LSPO_MOD MOD_LSFT
#define LSPO_MOD KC_LSFT
#endif
#ifndef RSPC_MOD
#define RSPC_MOD MOD_RSFT
#define RSPC_MOD KC_RSFT
#endif
#endif
// **********************************************************

// Shift / paren setup
#ifndef LSPO_KEYS
#define LSPO_KEYS MOD_LSFT, LSPO_MOD, LSPO_KEY
#define LSPO_KEYS KC_LSFT, LSPO_MOD, LSPO_KEY
#endif
#ifndef RSPC_KEYS
#define RSPC_KEYS MOD_RSFT, RSPC_MOD, RSPC_KEY
#define RSPC_KEYS KC_RSFT, RSPC_MOD, RSPC_KEY
#endif

// Control / paren setup
#ifndef LCPO_KEYS
#define LCPO_KEYS MOD_LCTL, MOD_LCTL, KC_9
#define LCPO_KEYS KC_LCTL, KC_LCTL, KC_9
#endif
#ifndef RCPO_KEYS
#define RCPO_KEYS MOD_RCTL, MOD_RCTL, KC_0
#define RCPO_KEYS KC_RCTL, KC_RCTL, KC_0
#endif

// Alt / paren setup
#ifndef LAPO_KEYS
#define LAPO_KEYS MOD_LALT, MOD_LALT, KC_9
#define LAPO_KEYS KC_LALT, KC_LALT, KC_9
#endif
#ifndef RAPO_KEYS
#define RAPO_KEYS MOD_RALT, MOD_RALT, KC_0
#define RAPO_KEYS KC_RALT, KC_RALT, KC_0
#endif

// Shift / Enter setup
#ifndef SFTENT_KEYS
#define SFTENT_KEYS MOD_RSFT, MOD_NONE, SFTENT_KEY
#define SFTENT_KEYS KC_RSFT, KC_TRNS, SFTENT_KEY
#endif

static uint8_t sc_last = 0;
Expand All @@ -86,15 +86,23 @@ void perform_space_cadet(keyrecord_t *record, uint8_t normalMod, uint8_t tapMod,
if (record->event.pressed) {
sc_last = normalMod;
sc_timer = timer_read ();
register_mods(normalMod);
if (IS_MOD(normalMod)) {
register_mods(MOD_BIT(normalMod));
}
}
else {
unregister_mods(normalMod);
if (IS_MOD(normalMod)) {
unregister_mods(MOD_BIT(normalMod));
}

if (sc_last == normalMod && timer_elapsed(sc_timer) < TAPPING_TERM) {
register_mods(tapMod);
if (IS_MOD(tapMod)) {
register_mods(MOD_BIT(tapMod));
}
tap_code(keycode);
unregister_mods(tapMod);
if (IS_MOD(tapMod)) {
unregister_mods(MOD_BIT(tapMod));
}
}
}
}
Expand Down
1 change: 0 additions & 1 deletion tmk_core/common/action_code.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ typedef union {
* bit 4 +----- LR flag(Left:0, Right:1)
*/
enum mods_bit {
MOD_NONE = 0x00,
MOD_LCTL = 0x01,
MOD_LSFT = 0x02,
MOD_LALT = 0x04,
Expand Down
8 changes: 4 additions & 4 deletions users/xulkal/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#undef TAPPING_TERM
#define TAPPING_TERM 175

#define LSPO_KEYS MOD_LSFT, MOD_NONE, KC_LBRC
#define RSPC_KEYS MOD_RSFT, MOD_NONE, KC_RBRC
#define LCPO_KEYS MOD_LCTL, MOD_NONE, KC_MINS
#define RCPO_KEYS MOD_RCTL, MOD_NONE, KC_EQL
#define LSPO_KEYS KC_LSFT, KC_TRNS, KC_LBRC
#define RSPC_KEYS KC_RSFT, KC_TRNS, KC_RBRC
#define LCPO_KEYS KC_LCTL, KC_TRNS, KC_MINS
#define RCPO_KEYS KC_RCTL, KC_TRNS, KC_EQL

0 comments on commit 9357514

Please sign in to comment.