Skip to content
This repository was archived by the owner on Jun 4, 2026. It is now read-only.

Commit a4078f0

Browse files
committed
c2usb update; revert high-res scrolling workaround for Linux
1 parent a7cc669 commit a4078f0

5 files changed

Lines changed: 10 additions & 41 deletions

File tree

ble-keyboard/prj.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,5 @@ CONFIG_USE_SEGGER_RTT=n
6565
# procedures which results in a procedure collision and disconnection.
6666
CONFIG_BT_GATT_AUTO_SEC_REQ=n
6767
CONFIG_BT_AUTO_PHY_UPDATE=n
68+
69+
CONFIG_SHELL_STACK_SIZE=2048

ble-keyboard/src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ static auto& hog_service()
224224
static const auto security = security::ENCRYPT;
225225
static const auto features = flags::NORMALLY_CONNECTABLE | flags::REMOTE_WAKE;
226226

227-
static service_instance<hid::report_protocol_properties(simple_keyboard<>::report_desc()),
227+
static service_instance<hid::app::keyboard::app_report_descriptor<0>(),
228228
boot_protocol_mode::KEYBOARD>
229229
hog{keyboard_app(), security, features};
230230
return hog;

usb-keyboard/src/main.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@
55

66
#include <port/zephyr/message_queue.hpp>
77
#include <port/zephyr/udc_mac.hpp>
8+
#include <simple_keyboard.hpp>
89
#include <usb/df/class/hid.hpp>
910
#include <usb/df/device.hpp>
1011

1112
LOG_MODULE_REGISTER(main, LOG_LEVEL_INF);
1213

13-
#include "simple_keyboard.hpp"
14-
1514
using namespace magic_enum::bitwise_operators;
1615

1716
auto& kb_msgq()
@@ -63,7 +62,7 @@ int main(void)
6362
{
6463
if (ev == usb::df::device::event::CONFIGURATION_CHANGE)
6564
{
66-
LOG_INF("USB configured: %u, granted current: %uuA", dev.configured(),
65+
LOG_INF("USB configured: %u, granted current: %uuA", (unsigned)dev.configured(),
6766
dev.granted_bus_current_uA());
6867
}
6968
else
@@ -110,14 +109,15 @@ int main(void)
110109
case INPUT_KEY_0:
111110
keyboard_app().send_key(hid::page::keyboard_keypad::KEYBOARD_CAPS_LOCK, msg.value);
112111
break;
113-
#if 0
114112
case INPUT_KEY_1:
115-
keyboard_app().send_key(hid::page::keyboard_keypad::KEYBOARD_ENTER, msg.value);
113+
keyboard_app().send_key(hid::page::keyboard_keypad::KEYBOARD_BACKSLASH_PIPE, msg.value);
116114
break;
117115
case INPUT_KEY_2:
116+
keyboard_app().send_key(hid::page::keyboard_keypad::KEYBOARD_ENTER, msg.value);
117+
break;
118+
case INPUT_KEY_3:
118119
keyboard_app().send_key(hid::page::keyboard_keypad::KEYBOARD_F1, msg.value);
119120
break;
120-
#endif
121121
default:
122122
break;
123123
}

usb-mouse/src/main.cpp

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -68,49 +68,16 @@ int main(void)
6868
[](usb::df::device& dev, usb::df::device::event ev)
6969
{
7070
using event = enum usb::df::device::event;
71-
using namespace std::literals;
72-
static high_resolution_mouse<>::resolution_multiplier_report report_backup{};
73-
static os::zephyr::tick_timer::time_point last_reset_time{};
74-
75-
/* Linux hosts produce erroneous behavior when waking up (on a subset of USB ports):
76-
* 1. L2 -> L0
77-
* 2. USB reset
78-
* 3. L0 -> L2
79-
* 4. L2 -> L0
80-
* 5. USB re-enumeration, this time without negotiating high-resolution scrolling
81-
*/
8271
if (ev == event::CONFIGURATION_CHANGE)
8372
{
8473
LOG_INF("USB configured: %u, granted current: %uuA", (unsigned)dev.configured(),
8574
dev.granted_bus_current_uA());
86-
if (!dev.configured())
87-
{
88-
last_reset_time = os::zephyr::tick_timer::now();
89-
}
9075
}
9176
else
9277
{
9378
LOG_INF("USB power state: %s, granted current: %uuA",
9479
magic_enum::enum_name(dev.power_state()).data(),
9580
dev.granted_bus_current_uA());
96-
if (dev.power_state() == usb::power::state::L2_SUSPEND)
97-
{
98-
if (dev.configured())
99-
{
100-
report_backup = mouse().multiplier_report();
101-
}
102-
else if (std::chrono::duration_cast<std::chrono::milliseconds>(
103-
os::zephyr::tick_timer::now() - last_reset_time) < 20ms)
104-
{
105-
// reset happened recently, restore the last known multiplier
106-
mouse().set_report(
107-
high_resolution_mouse<>::resolution_multiplier_report::type(),
108-
std::span<const uint8_t>(
109-
const_cast<const uint8_t*>(report_backup.data()),
110-
sizeof(report_backup)));
111-
LOG_INF("restored multiplier: %x", report_backup.resolutions);
112-
}
113-
}
11481
}
11582
});
11683

west.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ manifest:
1616
projects:
1717
- name: c2usb
1818
remote: IntergatedCircuits
19-
revision: 5d08c6739c6e17af8fb8099b4edde1507799c417
19+
revision: 84575f528a530b631895d03673e371e6c20de1fa
2020
submodules: true
2121
- name: nrf
2222
repo-path: sdk-nrf

0 commit comments

Comments
 (0)