Skip to content

Commit

Permalink
Merge pull request qmk#9 from finrod09/maccel-togglekey
Browse files Browse the repository at this point in the history
Add toggle keycode
  • Loading branch information
burkfers authored Mar 10, 2024
2 parents 3deaed6 + 1735806 commit 2fc2a56
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
8 changes: 6 additions & 2 deletions maccel/maccel.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,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 @@ -181,7 +185,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
13 changes: 9 additions & 4 deletions maccel/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,11 @@ Finally, linearity across different user-CPI settings works better when pointer
### 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 @@ -134,7 +135,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 @@ -225,7 +226,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 All @@ -246,6 +247,10 @@ This feature makes extensive use of floating point operations, and as such is no
## Breaking changes
### 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 Down

0 comments on commit 2fc2a56

Please sign in to comment.