Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Pointing] Add uart based SpaceMouse Module support #22519

Draft
wants to merge 10 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
More docs
  • Loading branch information
drashna committed Jun 10, 2024
commit a3cd5e6879cd93caa88e2a979242896e4412ba95
9 changes: 8 additions & 1 deletion docs/features/pointing_device.md
Original file line number Diff line number Diff line change
Expand Up @@ -378,14 +378,21 @@ POINTING_DEVICE_DRIVER = spacemouse_module

The SpaceMouse Module is a UART driven sensor, with 6 axises of motion.

While there isn't a whole lot to configure here, only the X and Y movement is enabled by default. The Z axis and the twist and turn axises are not supported out of box. These can be handled with a custom function:
| Setting (`config.h`) | Description | Default |
| ---------------------------- | ------------------------------------------------------------------------------------------- | ------------- |
| `SPACEMOUSE_USE_TILT_AXIS` | Uses the tilt axises for movement rather than the shift axises. | _not_defined_ |


By default, not all of the axises are utilized. If you would like to use more of them, you can do so by using this custom function, which translates the data from the SpaceMouse Module to the pointing device report.

```c
void spacemouse_module_handle_axises(spacemouse_data_t *spacemouse_data, report_mouse_t* mouse_report) {
mouse_report->x = CONSTRAIN_HID_XY(spacemouse_data->x);
mouse_report->y = CONSTRAIN_HID_XY(spacemouse_data->y);
mouse_report->h = CONSTRAIN_HID(spacemouse_data->b);
mouse_report->v = CONSTRAIN_HID(spacemouse_data->c);

mouse_report->buttons = pointing_device_handle_buttons(mouse_report->buttons, (space_mouse_data->z < -10), KC_BTN1);
}
```

Expand Down
5 changes: 5 additions & 0 deletions quantum/pointing_device/pointing_device_drivers.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,8 +497,13 @@ const pointing_device_driver_t pointing_device_driver = {
static bool spacemouse_present = false;

__attribute__((weak)) void spacemouse_module_handle_axises(spacemouse_data_t *spacemouse_data, report_mouse_t* mouse_report) {
#ifdef SPACEMOUSE_USE_TILT_AXIS
mouse_report->x = CONSTRAIN_HID_XY(spacemouse_data->tilt_x);
mouse_report->y = CONSTRAIN_HID_XY(spacemouse_data->tilt_y);
#else
mouse_report->x = CONSTRAIN_HID_XY(spacemouse_data->x);
mouse_report->y = CONSTRAIN_HID_XY(spacemouse_data->y);
#endif
}

static report_mouse_t spacemouse_get_report(report_mouse_t mouse_report) {
Expand Down