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

Chaining OSL and MO #23065

Open
wants to merge 15 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
4 changes: 4 additions & 0 deletions quantum/action.c
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,10 @@ void process_action(keyrecord_t *record, action_t action) {
case ACT_LAYER_TAP_EXT:
# endif
led_set(host_keyboard_leds());
# ifndef NO_ACTION_ONESHOT
// don't release the key
do_release_oneshot = false;
# endif
break;
default:
break;
Expand Down
94 changes: 93 additions & 1 deletion tests/basic/test_one_shot_keys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ TEST_F(OneShot, OSMChainingTwoOSMs) {
run_one_scan_loop();
VERIFY_AND_CLEAR(driver);

/* Press and relesea OSM2 */
/* Press and release OSM2 */
EXPECT_NO_REPORT(driver);
osm_key2.press();
run_one_scan_loop();
Expand Down Expand Up @@ -383,3 +383,95 @@ TEST_F(OneShot, OSLWithOsmAndAdditionalKeypress) {
run_one_scan_loop();
VERIFY_AND_CLEAR(driver);
}

TEST_F(OneShot, OSLWithMoAndAdditionalKeypress) {
drashna marked this conversation as resolved.
Show resolved Hide resolved
TestDriver driver;
InSequence s;
KeymapKey osl_key = KeymapKey{0, 0, 0, OSL(1)};
KeymapKey mo_key = KeymapKey{1, 1, 0, MO(2)};
KeymapKey regular_key = KeymapKey{2, 1, 1, KC_A};

set_keymap({osl_key, mo_key, regular_key});

/* Press OSL key */
EXPECT_NO_REPORT(driver);
osl_key.press();
run_one_scan_loop();
VERIFY_AND_CLEAR(driver);

/* Release OSL key */
EXPECT_NO_REPORT(driver);
osl_key.release();
run_one_scan_loop();
EXPECT_TRUE(layer_state_is(1));
VERIFY_AND_CLEAR(driver);

/* Press MO */
EXPECT_NO_REPORT(driver);
mo_key.press();
run_one_scan_loop();
EXPECT_TRUE(layer_state_is(2));
VERIFY_AND_CLEAR(driver);

/* Press regular key */
EXPECT_REPORT(driver, (regular_key.report_code)).Times(1);
regular_key.press();
run_one_scan_loop();
EXPECT_TRUE(layer_state_is(2));
VERIFY_AND_CLEAR(driver);

/* Release regular key */
EXPECT_EMPTY_REPORT(driver);
regular_key.release();
run_one_scan_loop();
VERIFY_AND_CLEAR(driver);

/* Release MO */
EXPECT_NO_REPORT(driver);
mo_key.release();
run_one_scan_loop();
EXPECT_TRUE(layer_state_is(0));
VERIFY_AND_CLEAR(driver);
}

TEST_F(OneShot, OSLChainingTwoOSLsAndAdditionalKeypress) {
TestDriver driver;
InSequence s;
KeymapKey osl1_key = KeymapKey{0, 0, 0, OSL(1)};
KeymapKey osl2_key = KeymapKey{1, 1, 0, OSL(2)};
KeymapKey regular_key = KeymapKey{2, 1, 1, KC_A};

set_keymap({osl1_key, osl2_key, regular_key});

/* Press and release first OSL key */
EXPECT_NO_REPORT(driver);
osl1_key.press();
run_one_scan_loop();
osl1_key.release();
run_one_scan_loop();
EXPECT_TRUE(layer_state_is(1));
VERIFY_AND_CLEAR(driver);

/* Press and release second OSL */
EXPECT_NO_REPORT(driver);
osl2_key.press();
run_one_scan_loop();
osl2_key.release();
run_one_scan_loop();
EXPECT_TRUE(layer_state_is(2));
VERIFY_AND_CLEAR(driver);

/* Press regular key */
EXPECT_REPORT(driver, (regular_key.report_code)).Times(1);
EXPECT_EMPTY_REPORT(driver);
regular_key.press();
run_one_scan_loop();
VERIFY_AND_CLEAR(driver);

/* Release regular key */
EXPECT_NO_REPORT(driver);
regular_key.release();
run_one_scan_loop();
EXPECT_TRUE(layer_state_is(0));
VERIFY_AND_CLEAR(driver);
}
Loading