Skip to content

Commit

Permalink
Merge branch 'maccel-scaledowncurve+roundingcarry' of https://github.…
Browse files Browse the repository at this point in the history
…com/finrod09/qmk_userspace_features into maccel-scaledowncurve+roundingcarry
  • Loading branch information
Wimads committed Mar 12, 2024
2 parents c183e9f + ef443f6 commit be1a705
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
8 changes: 6 additions & 2 deletions maccel/maccel.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,12 @@ static inline float get_mod_step(float step) {
return step;
}

bool process_record_maccel(uint16_t keycode, keyrecord_t *record, uint16_t takeoff, uint16_t growth_rate, uint16_t offset, uint16_t limit) {
bool process_record_maccel(uint16_t keycode, keyrecord_t *record, uint16_t toggle, uint16_t takeoff, uint16_t growth_rate, uint16_t offset, uint16_t limit) {
if (record->event.pressed) {
if (keycode == toggle) {
maccel_toggle_enabled();
return false;
}
if (keycode == takeoff) {
maccel_set_takeoff(maccel_get_takeoff() + get_mod_step(MACCEL_TAKEOFF_STEP));
printf("MACCEL:keycode: TKO: %.3f gro: %.3f ofs: %.3f lmt: %.3f\n", g_maccel_config.takeoff, g_maccel_config.growth_rate, g_maccel_config.offset, g_maccel_config.limit);
Expand All @@ -197,7 +201,7 @@ bool process_record_maccel(uint16_t keycode, keyrecord_t *record, uint16_t takeo
return true;
}
#else
bool process_record_maccel(uint16_t keycode, keyrecord_t *record, uint16_t takeoff, uint16_t growth_rate, uint16_t offset, uint16_t limit) {
bool process_record_maccel(uint16_t keycode, keyrecord_t *record, uint16_t toggle, uint16_t takeoff, uint16_t growth_rate, uint16_t offset, uint16_t limit) {
// provide a do-nothing keyrecord function so a user doesn't need to un-shim when disabling the keycodes
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion maccel/maccel.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "report.h"

report_mouse_t pointing_device_task_maccel(report_mouse_t mouse_report);
bool process_record_maccel(uint16_t keycode, keyrecord_t *record, uint16_t takeoff, uint16_t growth_rate, uint16_t offset, uint16_t limit);
bool process_record_maccel(uint16_t keycode, keyrecord_t *record, uint16_t toggle, uint16_t takeoff, uint16_t growth_rate, uint16_t offset, uint16_t limit);

typedef struct _maccel_config_t {
float growth_rate;
Expand Down
30 changes: 14 additions & 16 deletions maccel/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,23 +113,16 @@ A good starting point for tweaking your settings, is to set your default DPI sli
#define PRINTF_SUPPORT_DECIMAL_SPECIFIERS 1
```

Finally, linearity across different user-CPI settings works better when pointer task throttling is enforced, ie. add something like this in your `config.h`:

```c
// Fixed pointer-task frequency needed for consistent acceleration across different user CPIs.
#undef POINTING_DEVICE_TASK_THROTTLE_MS
#define POINTING_DEVICE_TASK_THROTTLE_MS 5
```
## Runtime adjusting of curve parameters by keycodes (optional)

### Additional required installation steps

To use keycodes to adjust the parameters without recompiling, two more build steps are required.
First, add four keycodes to your keycode enum. You may choose different names, as long as you use the same names in the following step. If you are not yet using custom keycodes, add the following snippet to `keymap.c`:
First, add five keycodes to your keycode enum. You may choose different names, as long as you use the same names in the following step. If you are not yet using custom keycodes, add the following snippet to `keymap.c`:
```c
enum my_keycodes {
MA_TAKEOFF = QK_USER, // mouse acceleration curve takeoff (initial acceleration) step key
MA_TOGGLE = QK_USER, // toggle mouse acceleration
MA_TAKEOFF, // mouse acceleration curve takeoff (initial acceleration) step key
MA_GROWTH_RATE, // mouse acceleration curve growth rate step key
MA_OFFSET, // mouse acceleration curve offset step key
MA_LIMIT, // mouse acceleration curve limit step key
Expand All @@ -138,7 +131,7 @@ enum my_keycodes {
Next, add another shim, this time to `process_record_user`. If you have not previously implemented this function, simply place the following snippet in your `keymap.c`:
```c
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if (!process_record_maccel(keycode, record, MA_TAKEOFF, MA_GROWTH_RATE, MA_OFFSET, MA_LIMIT)) {
if (!process_record_maccel(keycode, record, MA_TOGGLE, MA_TAKEOFF, MA_GROWTH_RATE, MA_OFFSET, MA_LIMIT)) {
return false;
}
/* insert your own macros here */
Expand Down Expand Up @@ -229,7 +222,7 @@ Finally, after flashing the firmware to your board, load the custom via definiti
- Add configuration defines for parameters and optionally debugging
- Optional: Config keycodes:
- Enable keycode support by define
- Create four keycodes in the keycode enum
- Create five keycodes in the keycode enum
- Shim `process_record_user`
- Optional: VIA support:
- Enable in `rules.mk`
Expand Down Expand Up @@ -258,17 +251,21 @@ It is currently unknown how the un-throttled polling when used with `POINTING_DE
## Breaking changes
### 2024 March 08
### 2024 March 12
This new release changes the acceleration curve from a up-scaling curve to a down-scaling curve, to match how other acceleration tools work, and to avoid forcing users to set a very low DPI setting - this had been the goal from the start, but it took until now to overcome the technical challenges to make this work smoothly.
See the configuration bit of this readme for an explanation of how the new curve works. This change means that you will have to readjust your variables; but do not worry, it is fairly easy to get this dialed in to *exactly* to how you had it set before:
* First, change your default DPI: $DPI_{new} = DPI_{old} * limit_{old}$
* Second, change your LIMIT variable (which is now lower instead of upper limit): $limit_{new} = \dfrac{DPI_{old}}{DPI_{new}}$
* First, change your default DPI: ${DPI}_{new} = {DPI}_{old} * \text{limit}_{old}$
* Second, change your LIMIT variable (which is now lower instead of upper limit): $\text{limit}_{new} = \dfrac{{DPI}_{old}}{{DPI}_{new}}$
* Your other variables can remain the same.
* If using via, make sure to clear EEPROM for the new settings to take effect.
### 2024 March 10
A keycode for toggling mouse acceleration was added: If you enabled maccel keycodes, you must add a fifth keycode to your enum and add it to the shim between the record and takeoff arguments. Don't forget to place it on your keymap!
### 2024 March 1
If you're updating from a previous version, you will have to make manual adjustments to your integration. Refer to the instructions for details on what the current version expects:
Expand All @@ -281,7 +278,8 @@ If you're updating from a previous version, you will have to make manual adjustm
If you set GROWTH_RATE to your previous value of `STEEPNESS` and keep `TAKEOFF` at a high value (eg. `10`), the behavior will be similar to previous versions.
## Release history
- //2024 ?? WIP - Release of improved down scaling accel curve
- 2024 March 12 - Release of improved down scaling accel curve
- 2024 March 10 - Addition of toggle keycode
- 2024 March 1 - Release of new four-parameter acceleration curve
- 2024 February 23 - New four-parameter acceleration curve and improved documentation
- 2024 February 07 - Experimental new DPI correction to achieve consistent acceleration behavior across different user DPI settings.
Expand Down

0 comments on commit be1a705

Please sign in to comment.