forked from zmkfirmware/zmk
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(mouse): Lots of mouse refactors.
* Dedicated mouse source directory. * Split mouse HID into dedicated USB endpoint and HoG service. * Enable composite USB device automatically, tweak the various default sizes.
- Loading branch information
1 parent
4ea55c3
commit 0ce1b89
Showing
20 changed files
with
652 additions
and
335 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
* Copyright (c) 2020 The ZMK Contributors | ||
* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <zephyr/usb/usb_device.h> | ||
#include <zephyr/usb/class/usb_hid.h> | ||
|
||
#include <zmk/keys.h> | ||
#include <zmk/hid.h> | ||
|
||
#include <zmk/mouse/types.h> | ||
|
||
#include <dt-bindings/zmk/hid_usage.h> | ||
#include <dt-bindings/zmk/hid_usage_pages.h> | ||
|
||
#define ZMK_MOUSE_HID_NUM_BUTTONS 0x05 | ||
|
||
#define ZMK_MOUSE_HID_REPORT_ID_MOUSE 0x01 | ||
|
||
static const uint8_t zmk_mouse_hid_report_desc[] = { | ||
HID_USAGE_PAGE(HID_USAGE_GD), | ||
HID_USAGE(HID_USAGE_GD_MOUSE), | ||
HID_COLLECTION(HID_COLLECTION_APPLICATION), | ||
HID_REPORT_ID(ZMK_MOUSE_HID_REPORT_ID_MOUSE), | ||
HID_USAGE(HID_USAGE_GD_POINTER), | ||
HID_COLLECTION(HID_COLLECTION_PHYSICAL), | ||
HID_USAGE_PAGE(HID_USAGE_BUTTON), | ||
HID_USAGE_MIN8(0x1), | ||
HID_USAGE_MAX8(ZMK_MOUSE_HID_NUM_BUTTONS), | ||
HID_LOGICAL_MIN8(0x00), | ||
HID_LOGICAL_MAX8(0x01), | ||
HID_REPORT_SIZE(0x01), | ||
HID_REPORT_COUNT(0x5), | ||
HID_INPUT(ZMK_HID_MAIN_VAL_DATA | ZMK_HID_MAIN_VAL_VAR | ZMK_HID_MAIN_VAL_ABS), | ||
// Constant padding for the last 3 bits. | ||
HID_REPORT_SIZE(0x03), | ||
HID_REPORT_COUNT(0x01), | ||
HID_INPUT(ZMK_HID_MAIN_VAL_CONST | ZMK_HID_MAIN_VAL_VAR | ZMK_HID_MAIN_VAL_ABS), | ||
// Some OSes ignore pointer devices without X/Y data. | ||
HID_USAGE_PAGE(HID_USAGE_GEN_DESKTOP), | ||
HID_USAGE(HID_USAGE_GD_X), | ||
HID_USAGE(HID_USAGE_GD_Y), | ||
HID_USAGE(HID_USAGE_GD_WHEEL), | ||
HID_LOGICAL_MIN16(0xFF, -0x7F), | ||
HID_LOGICAL_MAX16(0xFF, 0x7F), | ||
HID_REPORT_SIZE(0x10), | ||
HID_REPORT_COUNT(0x03), | ||
HID_INPUT(ZMK_HID_MAIN_VAL_DATA | ZMK_HID_MAIN_VAL_VAR | ZMK_HID_MAIN_VAL_REL), | ||
HID_USAGE_PAGE(HID_USAGE_CONSUMER), | ||
HID_USAGE16(HID_USAGE_CONSUMER_AC_PAN), | ||
HID_REPORT_COUNT(0x01), | ||
HID_INPUT(ZMK_HID_MAIN_VAL_DATA | ZMK_HID_MAIN_VAL_VAR | ZMK_HID_MAIN_VAL_REL), | ||
HID_END_COLLECTION, | ||
HID_END_COLLECTION, | ||
}; | ||
|
||
struct zmk_hid_mouse_report_body { | ||
zmk_mouse_button_flags_t buttons; | ||
int16_t d_x; | ||
int16_t d_y; | ||
int16_t d_scroll_y; | ||
int16_t d_scroll_x; | ||
} __packed; | ||
|
||
struct zmk_hid_mouse_report { | ||
uint8_t report_id; | ||
struct zmk_hid_mouse_report_body body; | ||
} __packed; | ||
|
||
int zmk_hid_mouse_button_press(zmk_mouse_button_t button); | ||
int zmk_hid_mouse_button_release(zmk_mouse_button_t button); | ||
int zmk_hid_mouse_buttons_press(zmk_mouse_button_flags_t buttons); | ||
int zmk_hid_mouse_buttons_release(zmk_mouse_button_flags_t buttons); | ||
void zmk_hid_mouse_movement_set(int16_t x, int16_t y); | ||
void zmk_hid_mouse_scroll_set(int8_t x, int8_t y); | ||
void zmk_hid_mouse_movement_update(int16_t x, int16_t y); | ||
void zmk_hid_mouse_scroll_update(int8_t x, int8_t y); | ||
void zmk_hid_mouse_clear(void); | ||
|
||
struct zmk_hid_mouse_report *zmk_mouse_hid_get_mouse_report(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* Copyright (c) 2020 The ZMK Contributors | ||
* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <zmk/mouse/hid.h> | ||
|
||
#if IS_ENABLED(CONFIG_ZMK_MOUSE) | ||
int zmk_mouse_hog_send_mouse_report(struct zmk_hid_mouse_report_body *body); | ||
#endif // IS_ENABLED(CONFIG_ZMK_MOUSE) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* Copyright (c) 2020 The ZMK Contributors | ||
* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <stdint.h> | ||
|
||
#if IS_ENABLED(CONFIG_ZMK_MOUSE) | ||
int zmk_mouse_usb_hid_send_mouse_report(void); | ||
#endif // IS_ENABLED(CONFIG_ZMK_MOUSE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.