Further OSM improvements:
locking support (double-tap to lock, tap to unlock or use KC_NO) includes word-lock (shift-lock: ' ' -> _)
This commit is contained in:
@@ -13,7 +13,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "keycodes.h"
|
#include "action.h"
|
||||||
#include QMK_KEYBOARD_H
|
#include QMK_KEYBOARD_H
|
||||||
|
|
||||||
enum keycodes {
|
enum keycodes {
|
||||||
@@ -204,6 +204,7 @@ typedef enum {
|
|||||||
os_up_queued,
|
os_up_queued,
|
||||||
os_down_unused,
|
os_down_unused,
|
||||||
os_down_used,
|
os_down_used,
|
||||||
|
os_locked
|
||||||
} oneshot_state_t;
|
} oneshot_state_t;
|
||||||
|
|
||||||
oneshot_state_t oneshot_state[4] = {0};
|
oneshot_state_t oneshot_state[4] = {0};
|
||||||
@@ -227,16 +228,19 @@ bool is_oneshot_ignored_key(uint16_t keycode) {
|
|||||||
|
|
||||||
bool is_oneshot_cancel_key(uint16_t keycode) {
|
bool is_oneshot_cancel_key(uint16_t keycode) {
|
||||||
switch (keycode) {
|
switch (keycode) {
|
||||||
case NAV:
|
// case NAV:
|
||||||
case SYM:
|
// case SYM:
|
||||||
case NUM:
|
// case NUM:
|
||||||
case FUN:
|
// case FUN:
|
||||||
|
// return true;
|
||||||
|
case KC_NO:
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// From https://github.com/qmk/qmk_firmware/blob/user-keymaps-still-present/users/callum/oneshot.c
|
|
||||||
|
// Based on https://github.com/qmk/qmk_firmware/blob/user-keymaps-still-present/users/callum/oneshot.c
|
||||||
void update_oneshot(
|
void update_oneshot(
|
||||||
oneshot_state_t *state,
|
oneshot_state_t *state,
|
||||||
uint16_t mod,
|
uint16_t mod,
|
||||||
@@ -247,10 +251,21 @@ void update_oneshot(
|
|||||||
if (keycode == trigger) {
|
if (keycode == trigger) {
|
||||||
if (record->event.pressed) {
|
if (record->event.pressed) {
|
||||||
// Trigger keydown
|
// Trigger keydown
|
||||||
if (*state == os_up_unqueued) {
|
switch (*state) {
|
||||||
|
case os_up_queued:
|
||||||
|
*state = os_locked;
|
||||||
|
break;
|
||||||
|
case os_up_unqueued:
|
||||||
register_code(mod);
|
register_code(mod);
|
||||||
}
|
|
||||||
*state = os_down_unused;
|
*state = os_down_unused;
|
||||||
|
break;
|
||||||
|
case os_locked:
|
||||||
|
*state = os_down_used;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
*state = os_down_unused;
|
||||||
|
break;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Trigger keyup
|
// Trigger keyup
|
||||||
switch (*state) {
|
switch (*state) {
|
||||||
@@ -299,6 +314,15 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
|||||||
update_oneshot(&oneshot_state[2], mods[2], OS_LALT, keycode, record);
|
update_oneshot(&oneshot_state[2], mods[2], OS_LALT, keycode, record);
|
||||||
update_oneshot(&oneshot_state[3], mods[3], OS_LGUI, keycode, record);
|
update_oneshot(&oneshot_state[3], mods[3], OS_LGUI, keycode, record);
|
||||||
|
|
||||||
|
if (oneshot_state[0] == os_locked && keycode == KC_SPACE) {
|
||||||
|
if (record->event.pressed) {
|
||||||
|
register_code(KC_MINUS);
|
||||||
|
} else {
|
||||||
|
unregister_code(KC_MINUS);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user