mirror of https://github.com/zmkfirmware/zmk.git
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:
parent
7292df02d4
commit
342d838913
|
|
@ -208,7 +208,7 @@ static const uint8_t zmk_hid_report_desc[] = {
|
|||
HID_USAGE_PAGE(HID_USAGE_GEN_DESKTOP),
|
||||
HID_USAGE(HID_USAGE_GD_X),
|
||||
HID_USAGE(HID_USAGE_GD_Y),
|
||||
HID_LOGICAL_MIN16(0xFF, -0x7F),
|
||||
HID_LOGICAL_MIN16(0x00, 0x80),
|
||||
HID_LOGICAL_MAX16(0xFF, 0x7F),
|
||||
HID_REPORT_SIZE(0x10),
|
||||
HID_REPORT_COUNT(0x02),
|
||||
|
|
@ -226,7 +226,7 @@ static const uint8_t zmk_hid_report_desc[] = {
|
|||
HID_FEATURE(ZMK_HID_MAIN_VAL_DATA | ZMK_HID_MAIN_VAL_VAR | ZMK_HID_MAIN_VAL_ABS),
|
||||
#endif // IS_ENABLED(CONFIG_ZMK_POINTING_SMOOTH_SCROLLING)
|
||||
HID_USAGE(HID_USAGE_GD_WHEEL),
|
||||
HID_LOGICAL_MIN16(0xFF, -0x7F),
|
||||
HID_LOGICAL_MIN16(0x00, 0x80),
|
||||
HID_LOGICAL_MAX16(0xFF, 0x7F),
|
||||
HID_PHYSICAL_MIN8(0x00),
|
||||
HID_PHYSICAL_MAX8(0x00),
|
||||
|
|
@ -242,7 +242,7 @@ static const uint8_t zmk_hid_report_desc[] = {
|
|||
#endif // IS_ENABLED(CONFIG_ZMK_POINTING_SMOOTH_SCROLLING)
|
||||
HID_USAGE_PAGE(HID_USAGE_CONSUMER),
|
||||
HID_USAGE16_SINGLE(HID_USAGE_CONSUMER_AC_PAN),
|
||||
HID_LOGICAL_MIN16(0xFF, -0x7F),
|
||||
HID_LOGICAL_MIN16(0x00, 0x80),
|
||||
HID_LOGICAL_MAX16(0xFF, 0x7F),
|
||||
HID_PHYSICAL_MIN8(0x00),
|
||||
HID_PHYSICAL_MAX8(0x00),
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue