mirror of
https://github.com/qmk/qmk_firmware.git
synced 2024-11-22 03:19:24 +00:00
[Core] Don't send keyboard reports that propagate no changes to the host (#14065)
This commit is contained in:
parent
ce5a2a7367
commit
8b865a9d64
@ -21,6 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#include "action_layer.h"
|
#include "action_layer.h"
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
#include "keycode_config.h"
|
#include "keycode_config.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
extern keymap_config_t keymap_config;
|
extern keymap_config_t keymap_config;
|
||||||
|
|
||||||
@ -247,7 +248,13 @@ void send_keyboard_report(void) {
|
|||||||
keyboard_report->mods |= weak_override_mods;
|
keyboard_report->mods |= weak_override_mods;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
host_keyboard_send(keyboard_report);
|
static report_keyboard_t last_report;
|
||||||
|
|
||||||
|
/* Only send the report if there are changes to propagate to the host. */
|
||||||
|
if (memcmp(keyboard_report, &last_report, sizeof(report_keyboard_t)) != 0) {
|
||||||
|
memcpy(&last_report, keyboard_report, sizeof(report_keyboard_t));
|
||||||
|
host_keyboard_send(keyboard_report);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \brief Get mods
|
/** \brief Get mods
|
||||||
|
@ -42,7 +42,6 @@ TEST_F(AutoShift, key_release_before_timeout) {
|
|||||||
/* Release regular key */
|
/* Release regular key */
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_A)));
|
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_A)));
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
|
||||||
regular_key.release();
|
regular_key.release();
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||||
@ -65,8 +64,6 @@ TEST_F(AutoShift, key_release_after_timeout) {
|
|||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_A)));
|
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_A)));
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT)));
|
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT)));
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
|
||||||
regular_key.release();
|
regular_key.release();
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||||
|
@ -131,14 +131,12 @@ TEST_F(ActionLayer, MomentaryLayerDoesNothing) {
|
|||||||
set_keymap({layer_key});
|
set_keymap({layer_key});
|
||||||
|
|
||||||
/* Press and release MO, nothing should happen. */
|
/* Press and release MO, nothing should happen. */
|
||||||
/* TODO: QMK currently sends an empty report even if nothing needs to be reported to the host! */
|
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(1);
|
|
||||||
layer_key.press();
|
layer_key.press();
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||||
|
|
||||||
/* TODO: QMK currently sends an empty report even if nothing needs to be reported to the host! */
|
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(1);
|
|
||||||
layer_key.release();
|
layer_key.release();
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||||
@ -153,8 +151,7 @@ TEST_F(ActionLayer, MomentaryLayerWithKeypress) {
|
|||||||
set_keymap({layer_key, regular_key, KeymapKey{1, 1, 0, KC_B}});
|
set_keymap({layer_key, regular_key, KeymapKey{1, 1, 0, KC_B}});
|
||||||
|
|
||||||
/* Press MO. */
|
/* Press MO. */
|
||||||
/* TODO: QMK currently sends an empty report even if nothing needs to be reported to the host! */
|
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(1);
|
|
||||||
layer_key.press();
|
layer_key.press();
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
EXPECT_TRUE(layer_state_is(1));
|
EXPECT_TRUE(layer_state_is(1));
|
||||||
@ -175,8 +172,7 @@ TEST_F(ActionLayer, MomentaryLayerWithKeypress) {
|
|||||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||||
|
|
||||||
/* Release MO */
|
/* Release MO */
|
||||||
/* TODO: QMK currently sends an empty report even if nothing needs to be reported to the host! */
|
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(1);
|
|
||||||
layer_key.release();
|
layer_key.release();
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
EXPECT_TRUE(layer_state_is(0));
|
EXPECT_TRUE(layer_state_is(0));
|
||||||
@ -199,8 +195,7 @@ TEST_F(ActionLayer, ToggleLayerDoesNothing) {
|
|||||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||||
|
|
||||||
/* Release TG. */
|
/* Release TG. */
|
||||||
/* TODO: QMK currently sends an empty report even if nothing needs to be reported to the host! */
|
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(1);
|
|
||||||
layer_key.release();
|
layer_key.release();
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
EXPECT_TRUE(layer_state_is(1));
|
EXPECT_TRUE(layer_state_is(1));
|
||||||
@ -223,8 +218,7 @@ TEST_F(ActionLayer, ToggleLayerUpAndDown) {
|
|||||||
EXPECT_TRUE(layer_state_is(1));
|
EXPECT_TRUE(layer_state_is(1));
|
||||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||||
|
|
||||||
/* TODO: QMK currently sends an empty report even if nothing needs to be reported to the host! */
|
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(1);
|
|
||||||
toggle_layer_1_on_layer_0.release();
|
toggle_layer_1_on_layer_0.release();
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
EXPECT_TRUE(layer_state_is(1));
|
EXPECT_TRUE(layer_state_is(1));
|
||||||
@ -237,8 +231,7 @@ TEST_F(ActionLayer, ToggleLayerUpAndDown) {
|
|||||||
EXPECT_TRUE(layer_state_is(0));
|
EXPECT_TRUE(layer_state_is(0));
|
||||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||||
|
|
||||||
/* TODO: QMK currently sends an empty report even if nothing needs to be reported to the host! */
|
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(1);
|
|
||||||
toggle_layer_0_on_layer_1.release();
|
toggle_layer_0_on_layer_1.release();
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
EXPECT_TRUE(layer_state_is(0));
|
EXPECT_TRUE(layer_state_is(0));
|
||||||
@ -254,14 +247,13 @@ TEST_F(ActionLayer, LayerTapToggleDoesNothing) {
|
|||||||
set_keymap({layer_key});
|
set_keymap({layer_key});
|
||||||
|
|
||||||
/* Press and release TT. */
|
/* Press and release TT. */
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(0);
|
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||||
layer_key.press();
|
layer_key.press();
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
EXPECT_TRUE(layer_state_is(1));
|
EXPECT_TRUE(layer_state_is(1));
|
||||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||||
|
|
||||||
/* TODO: QMK currently sends an empty report even if nothing needs to be reported to the host! */
|
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(2);
|
|
||||||
layer_key.release();
|
layer_key.release();
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
EXPECT_TRUE(layer_state_is(0));
|
EXPECT_TRUE(layer_state_is(0));
|
||||||
@ -279,7 +271,6 @@ TEST_F(ActionLayer, LayerTapToggleWithKeypress) {
|
|||||||
set_keymap({layer_key, regular_key, KeymapKey{1, 1, 0, KC_B}});
|
set_keymap({layer_key, regular_key, KeymapKey{1, 1, 0, KC_B}});
|
||||||
|
|
||||||
/* Press TT. */
|
/* Press TT. */
|
||||||
/* TODO: QMK currently sends an empty report even if nothing needs to be reported to the host! */
|
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(0);
|
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(0);
|
||||||
layer_key.press();
|
layer_key.press();
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
@ -298,8 +289,7 @@ TEST_F(ActionLayer, LayerTapToggleWithKeypress) {
|
|||||||
EXPECT_TRUE(layer_state_is(1));
|
EXPECT_TRUE(layer_state_is(1));
|
||||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||||
|
|
||||||
/* TODO: QMK currently sends an empty report even if nothing needs to be reported to the host! */
|
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(1);
|
|
||||||
layer_key.release();
|
layer_key.release();
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
EXPECT_TRUE(layer_state_is(0));
|
EXPECT_TRUE(layer_state_is(0));
|
||||||
@ -317,8 +307,7 @@ TEST_F(ActionLayer, LayerTapToggleWithToggleWithKeypress) {
|
|||||||
set_keymap({layer_key, regular_key, KeymapKey{1, 1, 0, KC_B}});
|
set_keymap({layer_key, regular_key, KeymapKey{1, 1, 0, KC_B}});
|
||||||
|
|
||||||
/* Tap TT five times . */
|
/* Tap TT five times . */
|
||||||
/* TODO: QMK currently sends an empty report even if nothing needs to be reported to the host! */
|
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(9);
|
|
||||||
|
|
||||||
layer_key.press();
|
layer_key.press();
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
|
@ -85,7 +85,7 @@ TEST_F(KeyPress, CorrectKeysAreReportedWhenTwoKeysArePressed) {
|
|||||||
TEST_F(KeyPress, LeftShiftIsReportedCorrectly) {
|
TEST_F(KeyPress, LeftShiftIsReportedCorrectly) {
|
||||||
TestDriver driver;
|
TestDriver driver;
|
||||||
auto key_a = KeymapKey(0, 0, 0, KC_A);
|
auto key_a = KeymapKey(0, 0, 0, KC_A);
|
||||||
auto key_lsft = KeymapKey(0, 3, 0, KC_LSFT);
|
auto key_lsft = KeymapKey(0, 3, 0, KC_LEFT_SHIFT);
|
||||||
|
|
||||||
set_keymap({key_a, key_lsft});
|
set_keymap({key_a, key_lsft});
|
||||||
|
|
||||||
@ -110,8 +110,8 @@ TEST_F(KeyPress, LeftShiftIsReportedCorrectly) {
|
|||||||
|
|
||||||
TEST_F(KeyPress, PressLeftShiftAndControl) {
|
TEST_F(KeyPress, PressLeftShiftAndControl) {
|
||||||
TestDriver driver;
|
TestDriver driver;
|
||||||
auto key_lsft = KeymapKey(0, 3, 0, KC_LSFT);
|
auto key_lsft = KeymapKey(0, 3, 0, KC_LEFT_SHIFT);
|
||||||
auto key_lctrl = KeymapKey(0, 5, 0, KC_LCTRL);
|
auto key_lctrl = KeymapKey(0, 5, 0, KC_LEFT_CTRL);
|
||||||
|
|
||||||
set_keymap({key_lctrl, key_lsft});
|
set_keymap({key_lctrl, key_lsft});
|
||||||
|
|
||||||
@ -138,8 +138,8 @@ TEST_F(KeyPress, PressLeftShiftAndControl) {
|
|||||||
|
|
||||||
TEST_F(KeyPress, LeftAndRightShiftCanBePressedAtTheSameTime) {
|
TEST_F(KeyPress, LeftAndRightShiftCanBePressedAtTheSameTime) {
|
||||||
TestDriver driver;
|
TestDriver driver;
|
||||||
auto key_lsft = KeymapKey(0, 3, 0, KC_LSFT);
|
auto key_lsft = KeymapKey(0, 3, 0, KC_LEFT_SHIFT);
|
||||||
auto key_rsft = KeymapKey(0, 4, 0, KC_RSFT);
|
auto key_rsft = KeymapKey(0, 4, 0, KC_RIGHT_SHIFT);
|
||||||
|
|
||||||
set_keymap({key_rsft, key_lsft});
|
set_keymap({key_rsft, key_lsft});
|
||||||
|
|
||||||
@ -175,12 +175,12 @@ TEST_F(KeyPress, RightShiftLeftControlAndCharWithTheSameKey) {
|
|||||||
// The underlying cause is that we use only one bit to represent the right hand
|
// The underlying cause is that we use only one bit to represent the right hand
|
||||||
// modifiers.
|
// modifiers.
|
||||||
combo_key.press();
|
combo_key.press();
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_RSFT, KC_RCTRL)));
|
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_RIGHT_SHIFT, KC_RIGHT_CTRL)));
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_RSFT, KC_RCTRL, KC_O)));
|
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_RIGHT_SHIFT, KC_RIGHT_CTRL, KC_O)));
|
||||||
keyboard_task();
|
keyboard_task();
|
||||||
|
|
||||||
combo_key.release();
|
combo_key.release();
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_RSFT, KC_RCTRL)));
|
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_RIGHT_SHIFT, KC_RIGHT_CTRL)));
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
||||||
keyboard_task();
|
keyboard_task();
|
||||||
}
|
}
|
||||||
@ -189,18 +189,18 @@ TEST_F(KeyPress, PressPlusEqualReleaseBeforePress) {
|
|||||||
TestDriver driver;
|
TestDriver driver;
|
||||||
InSequence s;
|
InSequence s;
|
||||||
auto key_plus = KeymapKey(0, 1, 1, KC_PLUS);
|
auto key_plus = KeymapKey(0, 1, 1, KC_PLUS);
|
||||||
auto key_eql = KeymapKey(0, 0, 1, KC_EQL);
|
auto key_eql = KeymapKey(0, 0, 1, KC_EQUAL);
|
||||||
|
|
||||||
set_keymap({key_plus, key_eql});
|
set_keymap({key_plus, key_eql});
|
||||||
|
|
||||||
key_plus.press();
|
key_plus.press();
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT)));
|
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT)));
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_EQL)));
|
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT, KC_EQUAL)));
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||||
|
|
||||||
key_plus.release();
|
key_plus.release();
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT)));
|
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT)));
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||||
@ -220,13 +220,13 @@ TEST_F(KeyPress, PressPlusEqualDontReleaseBeforePress) {
|
|||||||
TestDriver driver;
|
TestDriver driver;
|
||||||
InSequence s;
|
InSequence s;
|
||||||
auto key_plus = KeymapKey(0, 1, 1, KC_PLUS);
|
auto key_plus = KeymapKey(0, 1, 1, KC_PLUS);
|
||||||
auto key_eql = KeymapKey(0, 0, 1, KC_EQL);
|
auto key_eql = KeymapKey(0, 0, 1, KC_EQUAL);
|
||||||
|
|
||||||
set_keymap({key_plus, key_eql});
|
set_keymap({key_plus, key_eql});
|
||||||
|
|
||||||
key_plus.press();
|
key_plus.press();
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT)));
|
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT)));
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_EQL)));
|
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT, KC_EQUAL)));
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||||
|
|
||||||
@ -237,14 +237,13 @@ TEST_F(KeyPress, PressPlusEqualDontReleaseBeforePress) {
|
|||||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||||
|
|
||||||
key_plus.release();
|
key_plus.release();
|
||||||
// BUG: Should really still return KC_EQL, but this is fine too
|
// BUG: Should really still return KC_EQUAL, but this is fine too
|
||||||
// It's also called twice for some reason
|
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(1);
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(2);
|
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||||
|
|
||||||
key_eql.release();
|
key_eql.release();
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||||
}
|
}
|
||||||
@ -253,12 +252,12 @@ TEST_F(KeyPress, PressEqualPlusReleaseBeforePress) {
|
|||||||
TestDriver driver;
|
TestDriver driver;
|
||||||
InSequence s;
|
InSequence s;
|
||||||
auto key_plus = KeymapKey(0, 1, 1, KC_PLUS);
|
auto key_plus = KeymapKey(0, 1, 1, KC_PLUS);
|
||||||
auto key_eql = KeymapKey(0, 0, 1, KC_EQL);
|
auto key_eql = KeymapKey(0, 0, 1, KC_EQUAL);
|
||||||
|
|
||||||
set_keymap({key_plus, key_eql});
|
set_keymap({key_plus, key_eql});
|
||||||
|
|
||||||
key_eql.press();
|
key_eql.press();
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_EQL)));
|
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_EQUAL)));
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||||
|
|
||||||
@ -268,13 +267,13 @@ TEST_F(KeyPress, PressEqualPlusReleaseBeforePress) {
|
|||||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||||
|
|
||||||
key_plus.press();
|
key_plus.press();
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT)));
|
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT)));
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_EQL)));
|
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT, KC_EQUAL)));
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||||
|
|
||||||
key_plus.release();
|
key_plus.release();
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT)));
|
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT)));
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||||
@ -284,12 +283,12 @@ TEST_F(KeyPress, PressEqualPlusDontReleaseBeforePress) {
|
|||||||
TestDriver driver;
|
TestDriver driver;
|
||||||
InSequence s;
|
InSequence s;
|
||||||
auto key_plus = KeymapKey(0, 1, 1, KC_PLUS);
|
auto key_plus = KeymapKey(0, 1, 1, KC_PLUS);
|
||||||
auto key_eql = KeymapKey(0, 0, 1, KC_EQL);
|
auto key_eql = KeymapKey(0, 0, 1, KC_EQUAL);
|
||||||
|
|
||||||
set_keymap({key_plus, key_eql});
|
set_keymap({key_plus, key_eql});
|
||||||
|
|
||||||
key_eql.press();
|
key_eql.press();
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_EQL)));
|
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_EQUAL)));
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||||
|
|
||||||
@ -309,9 +308,7 @@ TEST_F(KeyPress, PressEqualPlusDontReleaseBeforePress) {
|
|||||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||||
|
|
||||||
key_plus.release();
|
key_plus.release();
|
||||||
// This report is not needed
|
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT)));
|
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||||
}
|
}
|
||||||
|
@ -175,22 +175,20 @@ TEST_F(OneShot, OSLWithAdditionalKeypress) {
|
|||||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||||
|
|
||||||
/* Release OSL key */
|
/* Release OSL key */
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(2);
|
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||||
osl_key.release();
|
osl_key.release();
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||||
|
|
||||||
/* Press regular key */
|
/* Press regular key */
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(regular_key.report_code))).Times(1);
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(regular_key.report_code))).Times(2);
|
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
||||||
regular_key.press();
|
regular_key.press();
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||||
|
|
||||||
/* Release regular key */
|
/* Release regular key */
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||||
regular_key.release();
|
regular_key.release();
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||||
|
@ -117,7 +117,6 @@ TEST_F(PermissiveHold, tap_regular_key_while_layer_tap_key_is_held) {
|
|||||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||||
|
|
||||||
/* Release regular key */
|
/* Release regular key */
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(layer_key.report_code)));
|
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(layer_key.report_code)));
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
||||||
regular_key.release();
|
regular_key.release();
|
||||||
@ -125,7 +124,7 @@ TEST_F(PermissiveHold, tap_regular_key_while_layer_tap_key_is_held) {
|
|||||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||||
|
|
||||||
/* Release layer-tap-hold key */
|
/* Release layer-tap-hold key */
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||||
layer_tap_hold_key.release();
|
layer_tap_hold_key.release();
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||||
|
@ -119,7 +119,6 @@ TEST_F(PermissiveHold_IgnoreModTapInterrupt, tap_regular_key_while_layer_tap_key
|
|||||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||||
|
|
||||||
/* Release regular key */
|
/* Release regular key */
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_B)));
|
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_B)));
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
||||||
regular_key.release();
|
regular_key.release();
|
||||||
@ -127,7 +126,7 @@ TEST_F(PermissiveHold_IgnoreModTapInterrupt, tap_regular_key_while_layer_tap_key
|
|||||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||||
|
|
||||||
/* Release layer-tap-hold key */
|
/* Release layer-tap-hold key */
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||||
layer_tap_hold_key.release();
|
layer_tap_hold_key.release();
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||||
|
@ -31,9 +31,8 @@ TEST_F(ActionLayer, LayerTapToggleWithToggleWithKeypress) {
|
|||||||
set_keymap({layer_key, regular_key, KeymapKey{1, 1, 0, KC_B}});
|
set_keymap({layer_key, regular_key, KeymapKey{1, 1, 0, KC_B}});
|
||||||
|
|
||||||
/* Tap TT five times . */
|
/* Tap TT five times . */
|
||||||
/* TODO: QMK currently sends an empty report even if nothing needs to be reported to the host! */
|
|
||||||
/* TODO: Tapping Force Hold breaks TT */
|
/* TODO: Tapping Force Hold breaks TT */
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(10);
|
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||||
|
|
||||||
layer_key.press();
|
layer_key.press();
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
|
@ -60,7 +60,6 @@ TEST_F(TappingForceHold, tap_regular_key_while_mod_tap_key_is_held) {
|
|||||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||||
|
|
||||||
/* Idle for tapping term of mod tap hold key. */
|
/* Idle for tapping term of mod tap hold key. */
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT)));
|
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_A)));
|
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_A)));
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT)));
|
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT)));
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
||||||
@ -101,7 +100,6 @@ TEST_F(TappingForceHold, tap_mod_tap_key_while_mod_tap_key_is_held) {
|
|||||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||||
|
|
||||||
/* Idle for tapping term of first mod tap hold key. */
|
/* Idle for tapping term of first mod tap hold key. */
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT)));
|
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_A)));
|
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_A)));
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT)));
|
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT)));
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
||||||
|
@ -48,7 +48,6 @@ void TestFixture::SetUpTestCase() {
|
|||||||
eeconfig_update_debug(debug_config.raw);
|
eeconfig_update_debug(debug_config.raw);
|
||||||
|
|
||||||
TestDriver driver;
|
TestDriver driver;
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(_));
|
|
||||||
keyboard_init();
|
keyboard_init();
|
||||||
|
|
||||||
test_logger.info() << "TestFixture setup-up end." << std::endl;
|
test_logger.info() << "TestFixture setup-up end." << std::endl;
|
||||||
@ -62,8 +61,6 @@ TestFixture::~TestFixture() {
|
|||||||
test_logger.info() << "TestFixture clean-up start." << std::endl;
|
test_logger.info() << "TestFixture clean-up start." << std::endl;
|
||||||
TestDriver driver;
|
TestDriver driver;
|
||||||
|
|
||||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(2);
|
|
||||||
|
|
||||||
/* Reset keyboard state. */
|
/* Reset keyboard state. */
|
||||||
clear_all_keys();
|
clear_all_keys();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user