Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 5a2991b
Author: Alabastard-64 <[email protected]>
Date:   Tue Jan 24 08:16:17 2023 -0700

    linting

commit 4c686b6
Author: Alabastard-64 <[email protected]>
Date:   Tue Jan 24 08:13:49 2023 -0700

    fixup documentation

commit abf5a2b
Author: Alabastard-64 <[email protected]>
Date:   Tue Jan 24 07:42:33 2023 -0700

    fix bug with fastcalc and update doc

commit e7b6e11
Author: Alabastard-64 <[email protected]>
Date:   Mon Jan 23 23:04:54 2023 -0700

    doc cleanup

commit 1624f4c
Author: Alabastard-64 <[email protected]>
Date:   Mon Jan 23 23:01:57 2023 -0700

    doc cleanup

commit 9ac04e9
Author: Alabastard-64 <[email protected]>
Date:   Mon Jan 23 22:45:11 2023 -0700

    linting

commit ade01f0
Author: Alabastard-64 <[email protected]>
Date:   Mon Jan 23 22:25:50 2023 -0700

    fix issues

commit 3dcf006
Author: Alabastard-64 <[email protected]>
Date:   Mon Jan 23 16:39:58 2023 -0700

    add FASTCALC option and streamline a few things

commit 88c62ae
Author: Alabastard-64 <[email protected]>
Date:   Fri Dec 23 14:58:39 2022 -0700

    doc update

commit 7735757
Author: Alabastard-64 <[email protected]>
Date:   Fri Dec 23 14:51:37 2022 -0700

    linting

commit b4d6446
Author: Alabastard-64 <[email protected]>
Date:   Thu Dec 22 19:13:24 2022 -0700

    fixes and doc improvements

commit 0243dce
Author: Alabastard-64 <[email protected]>
Date:   Wed Dec 21 23:07:52 2022 -0700

    fix previous changes to precision mode now working as intended additional mode fixes

commit 02e35b8
Author: Alabastard-64 <[email protected]>
Date:   Wed Dec 21 20:29:11 2022 -0700

    doc update and precision changes

commit b6bd521
Author: Alabastard-64 <[email protected]>
Date:   Tue Dec 13 00:53:47 2022 -0700

    more doc updates/code cleanup

commit 47337bd
Author: Alabastard-64 <[email protected]>
Date:   Tue Dec 13 00:20:15 2022 -0700

    code and doc fixup

commit 2633968
Author: Alabastard-64 <[email protected]>
Date:   Mon Dec 12 23:10:19 2022 -0700

    update and linting

commit b028e01
Author: Alabastard-64 <[email protected]>
Date:   Sun Dec 11 21:08:08 2022 -0700

    post rebase/squash cleanup

commit 612ff48
Author: Alabastard-64 <[email protected]>
Date:   Tue Aug 30 01:23:41 2022 -0600

    parent c6ab70e
    author Alabastard-64 <[email protected]> 1661844221 -0600
    committer Alabastard-64 <[email protected]> 1670816485 -0700

    parent c6ab70e
    author Alabastard-64 <[email protected]> 1661844221 -0600
    committer Alabastard-64 <[email protected]> 1670813789 -0700

    parent c6ab70e
    author Alabastard-64 <[email protected]> 1661844221 -0600
    committer Alabastard-64 <[email protected]> 1670812067 -0700

    Squashed all previous Commits

commit 8ca3f0f
Author: Stefan Kerkmann <[email protected]>
Date:   Mon Jan 23 22:24:21 2023 +0100

    [Bug] rp2040: fix timer wrap deadlock in ws2812 vendor driver (qmk#19652)

    Co-authored-by: Sergey Vlasov <[email protected]>

commit ea05045
Author: Nick Brassel <[email protected]>
Date:   Tue Jan 24 07:10:03 2023 +1100

    Allow overriding of keymap/encodermap layer count. (qmk#19325)

commit aea1194
Author: David Hoelscher <[email protected]>
Date:   Mon Jan 23 14:05:47 2023 -0600

    Corrections to uart driver for Chibios platform (qmk#19075)

commit dfb2833
Merge: 0a51ea2 4e658d4
Author: QMK Bot <[email protected]>
Date:   Mon Jan 23 10:23:39 2023 +0000

    Merge remote-tracking branch 'origin/master' into develop

commit 4e658d4
Author: youturn45 <[email protected]>
Date:   Mon Jan 23 05:23:00 2023 -0500

    [Keymap] Add youturn/yt keymap for think65 (qmk#19300)

    Co-authored-by: jack <[email protected]>
    Co-authored-by: Drashna Jaelre <[email protected]>
    Co-authored-by: Jue Liu <[email protected]>

commit 0a51ea2
Merge: 603c86b 9c7490d
Author: QMK Bot <[email protected]>
Date:   Mon Jan 23 09:39:16 2023 +0000

    Merge remote-tracking branch 'origin/master' into develop

commit 9c7490d
Author: Joe Scotto <[email protected]>
Date:   Mon Jan 23 04:38:22 2023 -0500

    [Keyboard] Add Scotto40 Keyboard (qmk#18453)

    Co-authored-by: Drashna Jaelre <[email protected]>
    Co-authored-by: James Young <[email protected]>
  • Loading branch information
freznel10 committed Jan 25, 2023
1 parent 3bfdb5b commit 16ddced
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
33 changes: 15 additions & 18 deletions docs/feature_pointing_device.md
Original file line number Diff line number Diff line change
Expand Up @@ -807,8 +807,8 @@ Pointing device modes activated by toggle type functions/macros have their mode
| Pointing Device Mode | Alias | Mode Id | Description |
| :-------------------- | --------- | :-----: | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `PM_NONE` | _None_ | 0 | Null pointing mode that will will pass through normal x and y output of pointing device (Cannot be overwritten) |
| `PM_DRAG` | `PM_DRG` | 1 | Change x and y movement of pointing device into h and v axis values `x->h` `y->v` |
| `PM_PRECISION` | `PM_PRE` | 2 | Reduce x and y movement output of pointing device by the divisor which can affect other modes when toggled (_see notes_) |
| `PM_PRECISION` | `PM_PRE` | 1 | Reduce x and y movement output of pointing device by the divisor which can affect other modes when toggled (_see notes_) |
| `PM_DRAG` | `PM_DRG` | 2 | Change x and y movement of pointing device into h and v axis values `x->h` `y->v` |
| `PM_CARET` | `PM_CRT` | 3 | Taps arrow keys based on pointing input `x->(<-, ->)` `y->(^, v)` |
| `PM_HISTORY` | `PM_HST` | 4 | x movement of pointing device to undo and redo macros `x->(C(KC_Z)), C(KC_Y)` `y->ignored` |
| `PM_VOLUME` | `PM_VOL` | 5 | y movement of pointing device to media volume up/down (requires `EXTRAKEY_ENABLED`) `x->ignored` `y->(KC_VOLU, KC_VOLD)` |
Expand All @@ -818,7 +818,7 @@ Pointing device modes activated by toggle type functions/macros have their mode
***Notes:***
-***These modes can all be overwritten with the exception of `PM_NONE`.***
-***The mode id count starts at 0 (e.g. mode id 15 is the 16th mode) and thus mode mode ids 6-15 are free to be used without overwriting a mode (see adding custom modes below)***
-***The `PM_PRECISION` mode has additional behaviour when it is the current toggle mode, all modes will have their divisors multiplied by `POINTING_PRECISION_DIVISOR` (see adding divisors for more detail)***
-***The `PM_PRECISION` mode has additional behaviour when it is toggled, all modes activated as momentary modes will have their divisors multiplied by `POINTING_PRECISION_DIVISOR` until another mode is toggled (see adding divisors for more detail)***

#### Use In A keymap:
```c
Expand All @@ -838,10 +838,10 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
| `POINTING_DEVICE_MODES_ENABLE` | (Required) Enables pointing device pointing device modes feature | `NA` | `None` | _Not defined_ |
| `POINTING_DEVICE_MODES_INVERT_X` | (optional) Inverts stored y axis accumulation (affects all modes) | `NA` | `None` | _Not defined_ |
| `POINTING_DEVICE_MODES_INVERT_Y` | (optional) Inverts stored x axis accumulation (affects all modes) | `NA` | `None` | _Not defined_ |
| `POINTING_DEVICE_MODES_FASTCALC` | (optional) Enables fast calculations for division operations limiting divisors to base 2 | `NA` | `None` | _Not defined_ |
| `POINTING_DEVICE_MODES_FASTCALC` | (optional) Enables fast calculations for division operations limiting divisors to powers of 2 | `NA` | `None` | _Not defined_ |
| `POINTING_MODE_DEFAULT` | (optional) Default pointing device mode | `0-255` | `None` | `PM_NONE` |
| `POINTING_TAP_DELAY` | (optional) Delay between key presses in `pointing_tap_codes` in ms | `0-255` | `ms` | `0` |
| `POINTING_MODE_MAP_COUNT` | (optional) Number of modes defined in `pointing_device_mode_maps` | `0-255` | `None` | `0` |
| `POINTING_MODE_MAP_COUNT` | (optional) Number of modes defined in `pointing_device_mode_maps`(_required if using mode maps_) | `0-255` | `None` | `0` |
| `POINTING_DEFAULT_DIVISOR` | (optional) Default divisor for all modes that do not have a defined divisor | `1-255` | `Varies` | `64` |
| `POINTING_HISTORY_DIVISOR` | (optional) Accumulated stored x/y per key tap in `PM_HISTORY` mode | `1-255` | `(x\|y)/tap` | `64` |
| `POINTING_VOLUME_DIVISOR` | (optional) Accumulated stored x/y per key tap in `PM_VOLUME` mode | `1-255` | `(x\|y)/tap` | `64` |
Expand All @@ -855,10 +855,10 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
***Notes:***
1. `POINTING_DEVICE_MODES_FASTCALC` will force all divisors to powers of two but will enable fast calculation of division.
2. it is recommended that generally powers of 2 are used for divisors **(e.g. 1, 2, 4, 8, 16, 32, 64, 128*)** and using `POINTING_DEVICE_MODES_FASTCALC` as will optimize better, but as long as `POINTING_DEVICE_MODES_FASTCALC` is not used **any positive integer of 255 or less** will work.
2. For processors without hardware supported integer division (Atmel AVR U4, U2, ARM Cortex M0, M0+, M1, and, M2 chips with the exception of the RP2040[M0+] which has additional hardware for it) it is recommended that generally powers of 2 are used for divisors **(e.g. 1, 2, 4, 8, 16, 32, 64, 128*)** or using `POINTING_DEVICE_MODES_FASTCALC` as it will optimize better, but as long as `POINTING_DEVICE_MODES_FASTCALC` is not used **any positive integer of 255 or less** will work but can be slower on chips without hardware division.
3. Drag scroll speed will be effected by OS mouse settings (_there are usually separate settings for scroll "wheel" and "wheel tilt"_)
- The `POINTING_DRAG_DIVISOR` default value of 8 is based on having mouse settings in the OS set to one line per tick of "mouse wheel" or "wheel tilt" (_the minimum_)
4. `POINTING_PRECISION_DIVISOR` default will half cursor speed when active (_divisor of 2_) but a divisor of 4 is fine to use as well but the cursor will be quite a bit slower, however divisors of 8 or greater will likely only work well for high cpi settings.
4. `POINTING_PRECISION_DIVISOR` default will half cursor speed when active (_divisor of 2_) but a divisor of 4 is fine to use as well but the cursor will be quite a bit slower, however divisors of 8 or greater will likely only work well for very high cpi settings.
5. Speed and sensitivity of any pointing device mode will be impacted by the pointing device CPI setting so divisors may need to be adjusted to personal preference and CPI settings typically used.
6. Recommended settings for `POINTING_CARET_DIVISOR_V` and `POINTING_CARET_DIVISOR_H` will give faster horizontal caret movement than vertical and will give even more stability to keeping movement horizontal.
Expand All @@ -877,7 +877,7 @@ const uint16_t pointing_device_mode_maps[][4] = {
<keycode down>
),
//... all other pointing mode maps ...
[<last_map_id>] = POINTING_MODE_LAYOUT(
[<POINTING_MODE_MAP_COUNT - 1>] = POINTING_MODE_LAYOUT(
<keycode up>,
<keycode left>, <keycode right>,
<keycode down>
Expand All @@ -889,8 +889,8 @@ const uint16_t pointing_device_mode_maps[][4] = {
#### Example Mode Maps:
```c
// in config.h:
#define POINTING_DEVICE_MODES_ENABLE // always needed (assumed for future example code)
#define POINTING_MODE_MAP_COUNT 4 // number of modes in map
#define POINTING_DEVICE_MODES_ENABLE // (Required)
#define POINTING_MODE_MAP_COUNT 4 // (Required) number of modes in map
// POINTING_MODE_MAP_START is left at the default value to not overwrite any modes

// in keymap.c
Expand Down Expand Up @@ -936,9 +936,6 @@ const uint16_t pointing_device_mode_maps[][4] = {
-***The modes maps start at 0 and are in the same order as the enum***
-***If mode maps and pointing mode processing callbacks are being used together to define multiple modes care must be taken to ensure that there is no overlap between mode ids (as the callbacks will override the maps) ***

**Note on overriding built in modes using pointing device mode maps:**
if `POINTING_MODE_MAP_START` is set to the `PM_VOLUME` mode id or lower then mode maps will override the built-in modes it overlaps with. Keep in mind that pointing mode maps must be consecutive so modes from `POINTING_MODE_MAP_START` to `POINTING_MODE_MAP_START + POINTING_MODE_MAP_COUNT` will be overridden.

### Adding & Customizing Divisors
All Newly added modes will use `POINTING_DEFAULT_DIVISOR` unless a divisor is defined for the modes in the `get_pointing_mode_divisor` callback functions.
For most keycode tapping modes a divisor of `64` works well, which is the default divisor for `POINTING_DEFAULT_DIVISOR`. The `get_pointing_mode_divisor_*` callbacks have two variables available, `mode_id` which is the current pointing device mode id and `direction` which indicates the primary direction of the stored accumulated h/v values with the largest magnitude (_see table below_). This makes it simple to have a unique divisor for each direction or axis for a particular mode.
Expand Down Expand Up @@ -1279,7 +1276,7 @@ bool process_pointing_mode_kb(pointing_mode_t pointing_mode, report_mouse_t* mou
#else
mouse_report->x = CONSTRAIN_XY(mouse_report->x + temp_mouse_axis);
#endif
// collect residuals
// collect residual
pointing_mode.x -= multiply_divisor_xy(temp_mouse_axis);
// add linear boost to cursor y speed
temp_mouse_axis = apply_divisor_xy(pointing_mode.y);
Expand All @@ -1288,7 +1285,7 @@ bool process_pointing_mode_kb(pointing_mode_t pointing_mode, report_mouse_t* mou
#else
mouse_report->y = CONSTRAIN_XY(mouse_report->y + apply_divisor_xy(pointing_mode.y));
#endif
// collect residuals
// collect residual
pointing_mode.y -= multiply_divisor_xy(temp_mouse_axis);
}
// update pointing_mode with residual stored x & y
Expand Down Expand Up @@ -1354,9 +1351,9 @@ If both `SPLIT_POINTING_ENABLE` and `POINTING_DEVICE_COMBINED` are defined then

#### Relevant Settings

| Define | Description | Default |
| ---------------------------------- | ----------------------------------------------------------- | -------------: |
| `POINTING_MODES_LEFT` | Set left side to default pointing device controlled side | _Not defined_ |
| Define | Description | Default |
| ---------------------------------- | ---------------------------------------------------------------------- | -------------: |
| `POINTING_MODES_LEFT` | (optional) Set left side to default pointing device controlled side | _Not defined_ |

#### Functions when using two pointing devices
These functions are only available when both `SPLIT_POINTING_ENABLE` and `POINTING_DEVICE_COMBINED` are defined and will cause a compiler error if they are not. It is recommended that code that uses them is conditional on both of these settings being defined.
Expand Down
10 changes: 8 additions & 2 deletions quantum/pointing_device/pointing_device_modes.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ static inline int16_t clamp_int_32_to_16(int32_t value) {
}

static inline int16_t divisor_multiply16(int16_t value) {
# ifdef POINTING_DEVICE_MODES_FASTCALC
return clamp_int_32_to_16(value << pointing_mode_context.mode.divisor);
# else
return clamp_int_32_to_16(value * (int16_t)pointing_mode_context.mode.divisor);
# endif

return clamp_int_32_to_16(value * (int16_t)pointing_mode_context.mode.divisor);
}

Expand Down Expand Up @@ -268,11 +274,11 @@ static uint8_t get_pointing_mode_divisor(void) {
divisor = POINTING_HISTORY_DIVISOR;
break;

case PM_VOLUME:
# ifdef EXTRAKEY_ENABLE
case PM_VOLUME:
divisor = POINTING_VOLUME_DIVISOR;
# endif
break;
# endif
}
}
return divisor_postprocess(divisor);
Expand Down

0 comments on commit 16ddced

Please sign in to comment.