fix(ble,hid): Fix smooth scrolling over BLE (#2998)

- Use correct MIN16 value in hid report. -32768 in 2's compliment is 8000(hex)
- Initialize resolution multiplier array
- Properly implement `read_hids_mouse_feature_report`

Fixes: #2957

Co-authored-by: Tobias Adolph <43353209+adolto@users.noreply.github.comgit>
This commit is contained in:
Tobias Adolph
2025-07-20 17:13:18 +02:00
committed by GitHub
parent 7292df02d4
commit 342d838913
3 changed files with 32 additions and 7 deletions

View File

@@ -168,9 +168,28 @@ static ssize_t read_hids_mouse_input_report(struct bt_conn *conn, const struct b
static ssize_t read_hids_mouse_feature_report(struct bt_conn *conn, const struct bt_gatt_attr *attr,
void *buf, uint16_t len, uint16_t offset) {
struct zmk_hid_mouse_report_body *report_body = &zmk_hid_get_mouse_report()->body;
return bt_gatt_attr_read(conn, attr, buf, len, offset, report_body,
sizeof(struct zmk_hid_mouse_report_body));
int profile = zmk_ble_profile_index(bt_conn_get_dst(conn));
if (profile < 0) {
LOG_DBG(" BT_ATT_ERR_UNLIKELY");
return BT_GATT_ERR(BT_ATT_ERR_UNLIKELY);
}
struct zmk_endpoint_instance endpoint = {
.transport = ZMK_TRANSPORT_BLE,
.ble = {.profile_index = profile},
};
struct zmk_pointing_resolution_multipliers mult =
zmk_pointing_resolution_multipliers_get_profile(endpoint);
struct zmk_hid_mouse_resolution_feature_report_body report = {
.wheel_res = mult.wheel,
.hwheel_res = mult.hor_wheel,
};
return bt_gatt_attr_read(conn, attr, buf, len, offset, &report,
sizeof(struct zmk_hid_mouse_resolution_feature_report_body));
}
static ssize_t write_hids_mouse_feature_report(struct bt_conn *conn,

View File

@@ -13,7 +13,13 @@
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
static struct zmk_pointing_resolution_multipliers multipliers[ZMK_ENDPOINT_COUNT];
static struct zmk_pointing_resolution_multipliers multipliers[ZMK_ENDPOINT_COUNT] = {
[0 ... ZMK_ENDPOINT_COUNT - 1] =
{
.wheel = 15,
.hor_wheel = 15,
},
};
struct zmk_pointing_resolution_multipliers
zmk_pointing_resolution_multipliers_get_current_profile(void) {