diff options
| author | Fred Sundvik <fsundvik@gmail.com> | 2017-07-01 02:00:30 +0300 |
|---|---|---|
| committer | Jack Humbert <jack.humb@gmail.com> | 2017-07-08 21:59:51 -0400 |
| commit | cae7a9c3ec3834f08dfd56b0f094dc6afaf2ccaa (patch) | |
| tree | c4249ba5748420175cc02d4b56ac45c5e74789d9 /tests/test_common | |
| parent | 1985f43bad9fd51101467bea994e000c6c295f00 (diff) | |
| download | qmk_firmware-cae7a9c3ec3834f08dfd56b0f094dc6afaf2ccaa.tar.gz qmk_firmware-cae7a9c3ec3834f08dfd56b0f094dc6afaf2ccaa.zip | |
Add simple modifier test
Diffstat (limited to 'tests/test_common')
| -rw-r--r-- | tests/test_common/keyboard_report_util.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/tests/test_common/keyboard_report_util.cpp b/tests/test_common/keyboard_report_util.cpp index aca4433dd..aa096e416 100644 --- a/tests/test_common/keyboard_report_util.cpp +++ b/tests/test_common/keyboard_report_util.cpp | |||
| @@ -47,19 +47,25 @@ bool operator==(const report_keyboard_t& lhs, const report_keyboard_t& rhs) { | |||
| 47 | 47 | ||
| 48 | std::ostream& operator<<(std::ostream& stream, const report_keyboard_t& value) { | 48 | std::ostream& operator<<(std::ostream& stream, const report_keyboard_t& value) { |
| 49 | stream << "Keyboard report:" << std::endl; | 49 | stream << "Keyboard report:" << std::endl; |
| 50 | stream << "Mods: " << value.mods << std::endl; | 50 | stream << "Mods: " << (uint32_t)value.mods << std::endl; |
| 51 | stream << "Keys: "; | ||
| 51 | // TODO: This should probably print friendly names for the keys | 52 | // TODO: This should probably print friendly names for the keys |
| 52 | for (uint32_t k: get_keys(value)) { | 53 | for (uint32_t k: get_keys(value)) { |
| 53 | stream << k << std::endl; | 54 | stream << k << " "; |
| 54 | } | 55 | } |
| 56 | stream << std::endl; | ||
| 55 | return stream; | 57 | return stream; |
| 56 | } | 58 | } |
| 57 | 59 | ||
| 58 | KeyboardReportMatcher::KeyboardReportMatcher(const std::vector<uint8_t>& keys) { | 60 | KeyboardReportMatcher::KeyboardReportMatcher(const std::vector<uint8_t>& keys) { |
| 59 | // TODO: Support modifiers | ||
| 60 | memset(m_report.raw, 0, sizeof(m_report.raw)); | 61 | memset(m_report.raw, 0, sizeof(m_report.raw)); |
| 61 | for (auto k: keys) { | 62 | for (auto k: keys) { |
| 62 | add_key_to_report(&m_report, k); | 63 | if (IS_MOD(k)) { |
| 64 | m_report.mods |= MOD_BIT(k); | ||
| 65 | } | ||
| 66 | else { | ||
| 67 | add_key_to_report(&m_report, k); | ||
| 68 | } | ||
| 63 | } | 69 | } |
| 64 | } | 70 | } |
| 65 | 71 | ||
