diff options
author | Drashna Jael're <drashna@live.com> | 2022-01-06 02:01:04 -0800 |
---|---|---|
committer | Drashna Jael're <drashna@live.com> | 2022-01-06 02:01:04 -0800 |
commit | ac466c15716bab9db8d1b69ff557c95efd805e95 (patch) | |
tree | 9d1a74c00ac272da092d9b1f375f10b02903e2f9 /docs/feature_pointing_device.md | |
parent | 8dbc8a802cc07271ba90af05bf57daefe5729b5b (diff) | |
parent | 910a7b92d0c10010153d4e853b634ff49ebcc146 (diff) |
Merge remote-tracking branch 'origin/master' into develop
Diffstat (limited to 'docs/feature_pointing_device.md')
-rw-r--r-- | docs/feature_pointing_device.md | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/docs/feature_pointing_device.md b/docs/feature_pointing_device.md index f8de92f3b4..b1015f3cd3 100644 --- a/docs/feature_pointing_device.md +++ b/docs/feature_pointing_device.md @@ -255,9 +255,11 @@ Additionally, by default, `pointing_device_send()` will only send a report when Also, you use the `has_mouse_report_changed(new, old)` function to check to see if the report has changed. -## Example +## Examples -In the following example, a custom key is used to click the mouse and scroll 127 units vertically and horizontally, then undo all of that when released - because that's a totally useful function. Listen, this is an example: +### Custom Mouse Keycode + +In this example, a custom key is used to click the mouse and scroll 127 units vertically and horizontally, then undo all of that when released - because that's a totally useful function. ```c case MS_SPECIAL: @@ -278,6 +280,36 @@ case MS_SPECIAL: Recall that the mouse report is set to zero (except the buttons) whenever it is sent, so the scrolling would only occur once in each case. +### Drag Scroll or Mouse Scroll + +A very common implementation is to use the mouse movement to scroll instead of moving the cursor on the system. This uses the `pointing_device_task_user` callback to intercept and modify the mouse report before it's sent to the host system. + +```c +enum custom_keycodes { + DRAG_SCROLL = SAFE_RANGE, +}; + +bool set_scrolling = false; + +report_mouse_t pointing_device_task_user(report_mouse_t mouse_report) { + if (set_scrolling) { + mouse_report.h = mouse_report.x; + mouse_report.v = mouse_report.y; + mouse_report.x = mouse_report.y = 0 + } + return mouse_report; +} + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + if (keycode == DRAG_SCROLL && record->event.pressed) { + set_scrolling = !set_scrolling; + } + return true; +} +``` + +This allows you to toggle between scrolling and cursor movement by pressing the DRAG_SCROLL key. + ## Split Examples The following examples make use the `SPLIT_POINTING_ENABLE` functionality and show how to manipulate the mouse report for a scrolling mode. @@ -315,7 +347,6 @@ report_mouse_t pointing_device_task_user(report_mouse_t mouse_report) { } return mouse_report; } - ``` ### Combined Pointing Devices @@ -336,3 +367,4 @@ report_mouse_t pointing_device_task_combined_user(report_mouse_t left_report, re return pointing_device_combine_reports(left_report, right_report); } ``` +======= |