Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 0804a5c00d6f8d4b8131ad020c64c17e41c2633d
Author: Alabastard-64 <snipac+github@gmail.com>
Date:   Sun Jan 29 14:56:37 2023 -0700

    optimizations and cleanup some function argument changes

commit 42bbfa78b9fa08ef3307b9b48a31719170ada3d7
Author: Alabastard-64 <snipac+github@gmail.com>
Date:   Sun Jan 29 11:45:04 2023 -0700

    update keycodes.h

commit 136928de249a8829d2b5b5e01d4b4473e0be661a
Author: Alabastard-64 <snipac+github@gmail.com>
Date:   Sun Jan 29 11:34:09 2023 -0700

    update keycodes hjson version

commit 1cf695e7344afe3907fded4ba375aec0b2d3110e
Author: Alabastard-64 <snipac+github@gmail.com>
Date:   Tue Jan 24 08:16:17 2023 -0700

    linting

commit fa1430468982acd943b4bd75bffff8859f242421
Author: Alabastard-64 <snipac+github@gmail.com>
Date:   Tue Jan 24 08:13:49 2023 -0700

    fixup documentation

commit 2b1d787cc8b4d4c3793545816703827d6bc99cc0
Author: Alabastard-64 <snipac+github@gmail.com>
Date:   Tue Jan 24 07:42:33 2023 -0700

    fix bug with fastcalc and update doc

commit 941df07ba3035ae808b243754c9534f5d81e19f3
Author: Alabastard-64 <snipac+github@gmail.com>
Date:   Mon Jan 23 23:04:54 2023 -0700

    doc cleanup

commit 77889c64a8b23d36ac4809ae945ac9273640884d
Author: Alabastard-64 <snipac+github@gmail.com>
Date:   Mon Jan 23 23:01:57 2023 -0700

    doc cleanup

commit 531706ad04e49e701d7e2ba289430943bc43a7eb
Author: Alabastard-64 <snipac+github@gmail.com>
Date:   Mon Jan 23 22:45:11 2023 -0700

    linting

commit 7eda19b499c1ffe75d9316d592390e55465fb3e8
Author: Alabastard-64 <snipac+github@gmail.com>
Date:   Mon Jan 23 22:25:50 2023 -0700

    fix issues

commit f7bb9f1ef91510e92420c025b66dacd7eb0b38ae
Author: Alabastard-64 <snipac+github@gmail.com>
Date:   Mon Jan 23 16:39:58 2023 -0700

    add FASTCALC option and streamline a few things

commit f4f6f1455d5ce51060299280f786d4744e420b9d
Author: Alabastard-64 <snipac+github@gmail.com>
Date:   Fri Dec 23 14:58:39 2022 -0700

    doc update

commit dd5917ae16dd66774fcd03b67cb87fb61743276d
Author: Alabastard-64 <snipac+github@gmail.com>
Date:   Fri Dec 23 14:51:37 2022 -0700

    linting

commit f2099df8287bc714ee48e8fb71b169e3e03e8a9e
Author: Alabastard-64 <snipac+github@gmail.com>
Date:   Thu Dec 22 19:13:24 2022 -0700

    fixes and doc improvements

commit e0a3b4cc18d8873246d6e95ad442a85c320205e9
Author: Alabastard-64 <snipac+github@gmail.com>
Date:   Wed Dec 21 23:07:52 2022 -0700

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

commit b929e9f083d48fb4c43574ab8d601b3a782b5196
Author: Alabastard-64 <snipac+github@gmail.com>
Date:   Wed Dec 21 20:29:11 2022 -0700

    doc update and precision changes

commit 9b28bfa5f5d57768376c12e0548d15c4f027f5c1
Author: Alabastard-64 <snipac+github@gmail.com>
Date:   Tue Dec 13 00:53:47 2022 -0700

    more doc updates/code cleanup

commit 99fd1eab922a2b3e17c4240f516fe5a15e9f298f
Author: Alabastard-64 <snipac+github@gmail.com>
Date:   Tue Dec 13 00:20:15 2022 -0700

    code and doc fixup

commit dbe83eae871f23a9cdfef57d3f3cd3044dd14a80
Author: Alabastard-64 <snipac+github@gmail.com>
Date:   Mon Dec 12 23:10:19 2022 -0700

    update and linting

commit d9df7c6dddd6ec5d622cd64ae6102216c4fbfe98
Author: Alabastard-64 <snipac+github@gmail.com>
Date:   Sun Dec 11 21:08:08 2022 -0700

    post rebase/squash cleanup

commit 1e0206067899205fb03a28a4cb90a63cc17b6831
Author: Alabastard-64 <96358682+Alabastard-64@users.noreply.github.com>
Date:   Tue Aug 30 01:23:41 2022 -0600

    parent c6ab70e
    author Alabastard-64 <96358682+Alabastard-64@users.noreply.github.com> 1661844221 -0600
    committer Alabastard-64 <snipac+github@gmail.com> 1670816485 -0700

    parent c6ab70e
    author Alabastard-64 <96358682+Alabastard-64@users.noreply.github.com> 1661844221 -0600
    committer Alabastard-64 <snipac+github@gmail.com> 1670813789 -0700

    parent c6ab70e
    author Alabastard-64 <96358682+Alabastard-64@users.noreply.github.com> 1661844221 -0600
    committer Alabastard-64 <snipac+github@gmail.com> 1670812067 -0700

    Squashed all previous Commits

commit 043d8e1
Author: Ryan <fauxpark@gmail.com>
Date:   Mon Jan 30 03:44:16 2023 +1100

    Remove deprecated Quantum keycodes (qmk#19712)

commit 80cc6ad
Author: Joel Challis <git@zvecr.com>
Date:   Sat Jan 28 21:16:59 2023 +0000

    Fix 19701 merge

commit 8cc2e0e
Author: Joel Challis <git@zvecr.com>
Date:   Sat Jan 28 21:07:51 2023 +0000

    Fix quantum ring_buffer for ChibiOS (qmk#19683)

commit 832479c
Author: Joel Challis <git@zvecr.com>
Date:   Sat Jan 28 20:40:47 2023 +0000

    Split out mcu_selection to platform (qmk#19701)

commit b727434
Author: Ryan <fauxpark@gmail.com>
Date:   Sun Jan 29 02:42:44 2023 +1100

    Remove commented out backlight config & stray "backlight levels" (qmk#19703)

commit f1b5659
Author: wangfuco <46733695+wangfuco@users.noreply.github.com>
Date:   Thu Jan 26 22:11:29 2023 -0800

    fix pegasushoof caps light, add via keymap (qmk#19649)

    Co-authored-by: jack <0x6a73@protonmail.com>
    Co-authored-by: Ryan <fauxpark@gmail.com>
    Co-authored-by: Fucong Wang <wangfuco@Fucongs-Mac-mini.local>

commit ad817a7
Merge: 81ca832 3823046
Author: QMK Bot <hello@qmk.fm>
Date:   Thu Jan 26 16:35:07 2023 +0000

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

commit 3823046
Author: schwarzer-geiger <lalitmistry1407@gmail.com>
Date:   Thu Jan 26 11:34:27 2023 -0500

    new keyboard: edinburgh41 (qmk#19569)

    * added edinburgh41

    Co-authored-by: Joel Challis <git@zvecr.com>
    Co-authored-by: jack <0x6a73@protonmail.com>
    Co-authored-by: Ryan <fauxpark@gmail.com>
    Co-authored-by: Drashna Jaelre <drashna@live.com>

commit 81ca832
Author: Sergey Vlasov <sigprof@gmail.com>
Date:   Wed Jan 25 04:47:55 2023 +0300

    analog.c: Fix `pinToMux()` for STM32F0xx (qmk#19658)

    The `adc_read()` code for STM32F0xx expects to get the 0-based channel
    number in `mux.input`, but the `pinToMux()` code for STM32F0xx was
    attempting to pass the CHSELR bit mask in that field, which resulted in
    selecting a wrong channel, therefore `analogReadPin()` did not work
    properly for the STM32F0xx chips.  Fix `pinToMux()` to put the channel
    number in that field (this matches the behavior for other supported
    chips and also allows selection of channels 16...18, which can be used
    to access the builtin temperature, reference voltage and VBAT sensors).

commit 0edf478
Merge: 019c321 fa132ba
Author: QMK Bot <hello@qmk.fm>
Date:   Wed Jan 25 00:20:11 2023 +0000

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

commit fa132ba
Author: Darkhan <darkhanu@gmail.com>
Date:   Wed Jan 25 00:19:32 2023 +0000

    Decrease LED animation frequency to improve performance (qmk#19677)

commit 019c321
Merge: 7ff55e6 8af8720
Author: QMK Bot <hello@qmk.fm>
Date:   Tue Jan 24 20:03:41 2023 +0000

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

commit 8af8720
Author: Christian Brauner <brauner@kernel.org>
Date:   Tue Jan 24 21:03:05 2023 +0100

    [Keymap] Update brauner preonic layout (qmk#19665)

commit 7ff55e6
Merge: d14863c 419a794
Author: QMK Bot <hello@qmk.fm>
Date:   Tue Jan 24 15:18:09 2023 +0000

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

commit 419a794
Author: arrowj <172841+arrowj@users.noreply.github.com>
Date:   Tue Jan 24 09:17:24 2023 -0600

    Update understanding_qmk.md (qmk#19664)

    Changed "...4 row by 5 column numpad" to "...5 row by 4 column numpad" on line 46.

commit d14863c
Merge: 8767e74 b24fa2f
Author: QMK Bot <hello@qmk.fm>
Date:   Tue Jan 24 14:20:10 2023 +0000

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

commit b24fa2f
Author: Natan-P <npolenec@gmail.com>
Date:   Tue Jan 24 15:19:34 2023 +0100

    escaped stray backslash in bux.py (qmk#19667)

commit 8767e74
Merge: fca6d16 1c69682
Author: QMK Bot <hello@qmk.fm>
Date:   Tue Jan 24 09:20:21 2023 +0000

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

commit 1c69682
Author: MJM <89230047+MATTMCCA@users.noreply.github.com>
Date:   Tue Jan 24 04:19:42 2023 -0500

    [Keyboard] Add the Black Hellebore (qmk#19655)

commit fca6d16
Merge: 025e530 695c4c6
Author: QMK Bot <hello@qmk.fm>
Date:   Tue Jan 24 08:52:36 2023 +0000

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

commit 695c4c6
Author: adophoxia <100170946+adophoxia@users.noreply.github.com>
Date:   Tue Jan 24 00:51:45 2023 -0800

    [Keyboard] Add missing `dip_switch_update_kb` for Keychron V2 (qmk#19674)

commit 025e530
Merge: dd7b244 4d180c9
Author: QMK Bot <hello@qmk.fm>
Date:   Tue Jan 24 08:05:37 2023 +0000

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

commit 4d180c9
Author: jack <0x6A73@pm.me>
Date:   Tue Jan 24 01:04:56 2023 -0700

    fixup splitkb/kyria VIA keymap (qmk#19676)

commit dd7b244
Author: jack <0x6A73@pm.me>
Date:   Mon Jan 23 23:24:56 2023 -0700

    Fixup handwired/jscotto/scotto40 (qmk#19675)

commit 79d5f2f
Merge: 8ca3f0f 4c6415d
Author: QMK Bot <hello@qmk.fm>
Date:   Tue Jan 24 05:43:18 2023 +0000

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

commit 4c6415d
Author: cole smith <38364556+daysgobye@users.noreply.github.com>
Date:   Mon Jan 23 21:42:38 2023 -0800

    [Keyboard] Fix boardsource/lulu/avr encoder pins (qmk#19672)

commit 8ca3f0f
Author: Stefan Kerkmann <karlk90@pm.me>
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 <sigprof@gmail.com>

commit ea05045
Author: Nick Brassel <nick@tzarc.org>
Date:   Tue Jan 24 07:10:03 2023 +1100

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

commit aea1194
Author: David Hoelscher <infinityis@users.noreply.github.com>
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 <hello@qmk.fm>
Date:   Mon Jan 23 10:23:39 2023 +0000

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

commit 4e658d4
Author: youturn45 <youturn45@gmail.com>
Date:   Mon Jan 23 05:23:00 2023 -0500

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

    Co-authored-by: jack <0x6a73@protonmail.com>
    Co-authored-by: Drashna Jaelre <drashna@live.com>
    Co-authored-by: Jue Liu <youturn@Jues-MacBook-Pro.local>

commit 0a51ea2
Merge: 603c86b 9c7490d
Author: QMK Bot <hello@qmk.fm>
Date:   Mon Jan 23 09:39:16 2023 +0000

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

commit 9c7490d
Author: Joe Scotto <me@joescotto.com>
Date:   Mon Jan 23 04:38:22 2023 -0500

    [Keyboard] Add Scotto40 Keyboard (qmk#18453)

    Co-authored-by: Drashna Jaelre <drashna@live.com>
    Co-authored-by: James Young <18669334+noroadsleft@users.noreply.github.com>
  • Loading branch information
freznel10 committed Jan 30, 2023
1 parent d6d31ec commit 0966e0d
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 95 deletions.
5 changes: 1 addition & 4 deletions data/constants/keycodes/keycodes_0.0.1.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@
"0x52C0/0x001F": {
"define": "QK_LAYER_TAP_TOGGLE"
},
"0x52E0/0x001F": {
"define": "QK_POINTING_MODE"
},
// 0x5300/0x02FF - UNUSED
"0x5600/0x00FF": {
"define": "QK_SWAP_HANDS"
Expand Down Expand Up @@ -95,4 +92,4 @@
"key": "SAFE_RANGE"
}
}
}
}
7 changes: 7 additions & 0 deletions data/constants/keycodes/keycodes_0.0.2.hjson
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"ranges": {
"0x52E0/0x001F": {
"define": "QK_POINTING_MODE"
}
}
}
31 changes: 15 additions & 16 deletions docs/feature_pointing_device.md
Original file line number Diff line number Diff line change
Expand Up @@ -952,12 +952,12 @@ For most keycode tapping modes a divisor of `64` works well, which is the defaul
#### Callbacks to set pointing device mode divisors
The following callbacks can be used to overwrite built in mode divisors or to set divisors for new modes. The `get_pointing_mode_divisor` stacks works by checking the functions until a non zero value is reached in order of `user`->`kb`->`built in`->`default_value`. Returning a divisor of `0` will allow processing to continue on to the next stage, However this means that if any of the get divisor callback functions return a default value other than 0 then that will overwrite all subsequent divisors(such as built in modes). These functions allows for overriding and modifying built in divisors by users/keymaps and keyboards and overriding keyboard level divisors by users/keymaps so it is possible to give built in modes the same level of divisor customization as new custom modes.

| Callback | Description |
| ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- |
| `uint8_t get_pointing_mode_divisor_kb(uint8_t mode_id, uint8_t direction);` | Keyboard level callback for setting divisor based on mode id an direction |
| `uint8_t get_pointing_mode_divisor_user(uint8_t mode_id, uint8_t direction);` | Keymap/user level callback for setting divisor |
| `uint8_t pointing_mode_divisor_postprocess_kb(uint8_t mode_id, uint8_t direction);` | keyboard level callback for modifying all divisors before being updated |
| `uint8_t pointing_mode_divisor_postprocess_user(uint8_t mode_id, uint8_t direction);` | Keymap/user level callback for modifying all divisors |
| Callback | Description |
| ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `uint8_t get_pointing_mode_divisor_kb(uint8_t mode_id, uint8_t direction);` | Keyboard level callback for setting divisor based on mode id an direction |
| `uint8_t get_pointing_mode_divisor_user(uint8_t mode_id, uint8_t direction);` | Keymap/user level callback for setting divisor |
| `bool pointing_mode_divisor_postprocess_kb(uint8_t mode_id, uint8_t direction);` | keyboard level callback for modifying all divisors after above callbacks before it is applied (_return `false` to skip subsequent post_processing_) |
| `bool pointing_mode_divisor_postprocess_user(uint8_t mode_id, uint8_t direction);` | Keymap/user level callback for modifying all divisors after above callbacks before it is applied (_return `false` to skip subsequent post_processing_) |

#### Example code of assigning divisors for new modes
```c
Expand Down Expand Up @@ -1050,10 +1050,10 @@ The above alternative method uses a `uint8_t` variable that defaults to zero tha

There are built in functions to simplify the creation of custom keycodes and it is generally recommended to use these in combination with other functions rather than using mode changing functions as they do handle some edge cases to ensure consistent behaviour.

| Function | Description | Return type |
| :------------------------------------------------------------------------------------------ | :---------------------------------------------------------------------------------------------- | :---------: |
| `pointing_mode_key_momentary(uint8_t mode_id, keyrecord_t* record)` | Momentary change of pointing mode while key is held (_for use in custom keycodes_) | _None_ |
| `pointing_mode_key_toggle(uint8_t mode_id, keyrecord_t* record)` | Toggle pointing mode on/off on key release (_for use in custom keycodes_) | _None_ |
| Function | Description | Return type |
| :----------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------- | :---------: |
| `pointing_mode_key_momentary(uint8_t mode_id, bool pressed)` | Momentary change of pointing mode while key is held (_for use in custom keycodes pass `record->event.pressed` for `bool`_) | _None_ |
| `pointing_mode_key_toggle(uint8_t mode_id, bool pressed)` | Toggle pointing mode on/off on key release (_for use in custom keycodes pass `record->event.pressed` for `bool`_) | _None_ |

These can be used to activate pointing device modes outside of the range of the built in keycodes as well as adding custom features to a mode that activate on key press such as registering a keycode and holding it until key release (_see code examples below_).

Expand Down Expand Up @@ -1203,12 +1203,11 @@ There are several functions available to assist with the creation of custom mode
| `set_pointing_mode(pointing_mode_t pointing_mode)` | Set stored pointing mode state to `pointing_mode` | _None_ |
| `pointing_mode_update(void)` | Update stored direction and divisor based on current mode id and h/v values | _None_ |
| `pointing_tap_codes(uint16_t kc_left, uint16_t kc_down, uint16_t kc_up, uint16_t kc_right)` | Convert stored h/v axis value to key taps depending on direction, 1 key tap per current divisor | _None_ |
| `apply_divisor_xy(int16_t value)` | divides value by the current divisor clamped to mouse cursor output | `mouse_xy_t` |
| `apply_divisor_hv(int16_t value)` | divides value by the current divisor clamped to mouse scroll output | `int8_t` |
| `multiply_divisor_xy(mouse_xy_report_t value)` | multiplies cursor value by the current divisor clamped to `int16_t` (_to collect the residual_) | `int16_t` |
| `multiply_divisor_hv(int8_t value)` | multiplies scroll value by the current divisor clamped to `int16_t` (_to collect the residual_) | `int16_t` |
| `multiply_divisor_hv(int8_t value)` | multiplies scroll value by the current divisor clamped to `int16_t` (_to collect the residual_) | `int16_t` |
| `apply_divisor_xy(int16_t value)` | Divides value by the current divisor clamped to mouse cursor output | `mouse_xy_t` |
| `apply_divisor_hv(int16_t value)` | Divides value by the current divisor clamped to mouse scroll output | `int8_t` |
| `multiply_divisor_xy(mouse_xy_report_t value)` | Multiplies cursor value by the current divisor clamped to `int16_t` (_to collect the residual_) | `int16_t` |
| `multiply_divisor_hv(int8_t value)` | Multiplies scroll value by the current divisor clamped to `int16_t` (_to collect the residual_) | `int16_t` |
| `pointing_mode_divisor_override(uint8_t divisor)` | Override current pointing mode divisor and still apply post processing for divisors | _None_ |
#### Creating modes using callback functions:
```c
Expand Down
35 changes: 0 additions & 35 deletions keyboards/zerfstudios/chunky2040/post_config.h

This file was deleted.

3 changes: 3 additions & 0 deletions quantum/keycodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ enum qk_keycode_ranges {
QK_USER_MAX = 0x7FFF,
QK_UNICODE = 0x8000,
QK_UNICODE_MAX = 0xFFFF,
QK_POINTING_MODE = 0x52E0,
QK_POINTING_MODE_MAX = 0x52FF,
};

enum qk_keycode_defines {
Expand Down Expand Up @@ -1304,6 +1306,7 @@ enum qk_keycode_defines {
#define IS_QK_KB(code) ((code) >= QK_KB && (code) <= QK_KB_MAX)
#define IS_QK_USER(code) ((code) >= QK_USER && (code) <= QK_USER_MAX)
#define IS_QK_UNICODE(code) ((code) >= QK_UNICODE && (code) <= QK_UNICODE_MAX)
#define IS_QK_POINTING_MODE(code) ((code) >= QK_POINTING_MODE && (code) <= QK_POINTING_MODE_MAX)

// Group Helpers
#define IS_INTERNAL_KEYCODE(code) ((code) >= KC_NO && (code) <= KC_TRANSPARENT)
Expand Down
66 changes: 30 additions & 36 deletions quantum/pointing_device/pointing_device_modes.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,40 +54,30 @@ static inline int16_t clamp_int_32_to_16(int32_t value) {
}
}

static inline int16_t divisor_multiply16(int16_t value) {
static 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);
}

static inline int8_t divisor_divide8(int16_t value) {
static int8_t divisor_divide8(int16_t value) {
# ifdef POINTING_DEVICE_MODES_FASTCALC
return clamp_int_16_to_8(value >> pointing_mode_context.mode.divisor);
# else
return clamp_int_16_to_8(value / (int16_t)pointing_mode_context.mode.divisor);
# endif
}

static inline int16_t divisor_divide16(int16_t value) {
static int16_t divisor_divide16(int16_t value) {
# ifdef POINTING_DEVICE_MODES_FASTCALC
return value >> pointing_mode_context.mode.divisor;
# else
return value / (int16_t)pointing_mode_context.mode.divisor;
# endif
}

static inline int8_t apply_divisor_count(int16_t value) {
return divisor_divide8(value);
}

static inline int16_t multiply_divisor_count(int8_t value) {
return divisor_multiply16((int16_t)value);
}

/**
* @brief local function to get single direction based on h/v
*
Expand Down Expand Up @@ -133,7 +123,6 @@ void set_pointing_mode(pointing_mode_t pointing_mode) {
// skip if same
if (!memcmp(&pointing_mode_context.mode, &pointing_mode, sizeof(pointing_mode_t))) return;
memcpy(&pointing_mode_context.mode, &pointing_mode, sizeof(pointing_mode_t));
dprintf("PM status saved!");
// Prevent zero divisor
if (!pointing_mode_context.mode.divisor) {
pointing_mode_context.mode.divisor = POINTING_DEFAULT_DIVISOR;
Expand Down Expand Up @@ -223,8 +212,13 @@ __attribute__((weak)) report_mouse_t pointing_modes_axes_conv(pointing_mode_t po
* @return divisor uint8_t
*/
static uint8_t divisor_postprocess(uint8_t divisor) {
divisor = pointing_mode_divisor_postprocess_kb(divisor);
divisor = pointing_mode_divisor_postprocess_user(divisor);
if (!(pointing_mode_divisor_postprocess_kb(&divisor) && pointing_mode_divisor_postprocess_user(&divisor))) {
# ifdef POINTING_DEVICE_MODES_FASTCALC
return biton(divisor);
# else
return divisor;
# endif
}
// Modify divisor if precision is toggled
if (get_toggled_pointing_mode_id() == PM_PRECISION && !(get_pointing_mode_id() == PM_PRECISION)) {
divisor = ((uint16_t)divisor * POINTING_PRECISION_DIVISOR) > UINT8_MAX ? UINT8_MAX : (divisor * POINTING_PRECISION_DIVISOR);
Expand Down Expand Up @@ -307,7 +301,7 @@ void pointing_mode_update(void) {
}

/**
* @brief divides/multipliers cursor value by current divisor
* @brief divides/multiplies cursor value by current divisor
*
* @params value[in] int16_t input to divide
* @params multiply[in] bool multiply when true divide when false
Expand Down Expand Up @@ -394,15 +388,15 @@ void pointing_tap_codes(uint16_t kc_left, uint16_t kc_down, uint16_t kc_up, uint

switch (pointing_mode_context.mode.direction) {
case PD_DOWN ... PD_UP:
count = apply_divisor_count(pointing_mode_context.mode.y);
count = divisor_divide8(pointing_mode_context.mode.y);
if (!count) return;
pointing_mode_context.mode.y -= multiply_divisor_count(count);
pointing_mode_context.mode.y -= divisor_multiply16(count);
pointing_mode_context.mode.x = 0;
break;
case PD_LEFT ... PD_RIGHT:
count = apply_divisor_count(pointing_mode_context.mode.x);
count = divisor_divide8(pointing_mode_context.mode.x);
if (!count) return;
pointing_mode_context.mode.x -= multiply_divisor_count(count);
pointing_mode_context.mode.x -= divisor_multiply16(count);
pointing_mode_context.mode.y = 0;
break;
}
Expand Down Expand Up @@ -516,14 +510,14 @@ static report_mouse_t process_pointing_mode(pointing_mode_t pointing_mode, repor
* NOTE: if pointing mode has changed since key down, reset is skipped
*
* @params mode_id[in] uint8_t
* @params record[in] keyrecord_t* pointer
* @params pressed[in] bool
*/
void pointing_mode_key_momentary(uint8_t mode_id, keyrecord_t* record) {
if (record->event.pressed) {
void pointing_mode_key_momentary(uint8_t mode_id, bool pressed) {
if (pressed) {
set_pointing_mode_id(mode_id);
} else {
} else if (pointing_mode_context.mode.id == mode_id) {
// reset mode only if the current mode matches (in case mode has changed before release)
if (pointing_mode_context.mode.id == mode_id) pointing_mode_reset();
pointing_mode_reset();
}
}

Expand All @@ -535,9 +529,9 @@ void pointing_mode_key_momentary(uint8_t mode_id, keyrecord_t* record) {
* @params mode_id[in] uint8_t
* @params record[in] keyrecord_t* pointer
*/
void pointing_mode_key_toggle(uint8_t mode_id, keyrecord_t* record) {
void pointing_mode_key_toggle(uint8_t mode_id, bool pressed) {
// only attempt to change mode on key release event (matches layer toggle behaviour)
if (!record->event.pressed) toggle_pointing_mode_id(mode_id);
if (!pressed) toggle_pointing_mode_id(mode_id);
}

/**
Expand All @@ -555,11 +549,11 @@ bool process_pointing_mode_records(uint16_t keycode, keyrecord_t* record) {
// handle built in keycods for bottom 16 pointing modes (0-15)
// momentary
case POINTING_MODE_MO ... POINTING_MODE_MO_MAX:
pointing_mode_key_momentary((keycode - POINTING_MODE_MO) & (POINTING_MODE_COUNT - 1), record);
pointing_mode_key_momentary((keycode - POINTING_MODE_MO) & (POINTING_MODE_COUNT - 1), record->event.pressed);
return true; // allow further processing
// toggle
case POINTING_MODE_TG ... POINTING_MODE_TG_MAX:
pointing_mode_key_toggle((keycode - POINTING_MODE_TG) & (POINTING_MODE_COUNT - 1), record);
pointing_mode_key_toggle((keycode - POINTING_MODE_TG) & (POINTING_MODE_COUNT - 1), record->event.pressed);
return true; // allow further processing
// end
default:
Expand Down Expand Up @@ -641,10 +635,10 @@ __attribute__((weak)) uint8_t get_pointing_mode_divisor_kb(uint8_t mode_id, uint
*
* @params[in] divisor uint8_t
*
* @return divisor uint8_t
* @return continue process? bool
*/
__attribute__((weak)) uint8_t pointing_mode_divisor_postprocess_kb(uint8_t divisor) {
return divisor;
__attribute__((weak)) bool pointing_mode_divisor_postprocess_kb(uint8_t* divisor) {
return true;
}

/**
Expand All @@ -656,10 +650,10 @@ __attribute__((weak)) uint8_t pointing_mode_divisor_postprocess_kb(uint8_t divis
* @params pointing_mode[in] uint8_t
* @params direction[in] uint8_t
*
* @return divisor uint8_t
* @return continue process? bool
*/
__attribute__((weak)) uint8_t pointing_mode_divisor_postprocess_user(uint8_t divisor) {
return divisor;
__attribute__((weak)) bool pointing_mode_divisor_postprocess_user(uint8_t* divisor) {
return true;
}

# if defined(SPLIT_POINTING_ENABLE) && defined(POINTING_DEVICE_COMBINED)
Expand Down
Loading

0 comments on commit 0966e0d

Please sign in to comment.