From e66f9aab6f5ba05f518a80bee83de604ca2af2de Mon Sep 17 00:00:00 2001 From: Sadek Baroudi Date: Fri, 16 Jun 2023 00:04:19 -0700 Subject: [PATCH] for combined pointing devices, you can now specify sniping mode as the default on either half, also fixed small pointing dpi bug --- keyboards/fingerpunch/README.md | 14 ++++----- keyboards/fingerpunch/src/fp_pointing.c | 30 +++++++++++++++---- keyboards/fingerpunch/src/fp_pointing.h | 15 +++++++--- .../ximi/keymaps/sadekbaroudi/config.h | 2 ++ 4 files changed, 45 insertions(+), 16 deletions(-) create mode 100644 keyboards/fingerpunch/ximi/keymaps/sadekbaroudi/config.h diff --git a/keyboards/fingerpunch/README.md b/keyboards/fingerpunch/README.md index a53952ff30..160b3b71c3 100644 --- a/keyboards/fingerpunch/README.md +++ b/keyboards/fingerpunch/README.md @@ -29,21 +29,21 @@ For general firmware build walkthrough and instructions, please see: | ------------------------------ | -------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `FP_ACCEL_TOG` | Pointing Device | Toggle pointing device acceleration (default is enabled on keyboard startup) | | `FP_POINT_DPI_UP` | Pointing Device | Increase the pointing DPI (increments of 1, maximum `FP_POINTING_MAX_DPI`) | -| `FP_POINT_DPI_DN` | Pointing Device | Decrease the pointing DPI (increments of 1, maximum `FP_POINTING_MAX_DPI`) | +| `FP_POINT_DPI_DN` | Pointing Device | Decrease the pointing DPI (increments of 1, minimum `FP_POINTING_MIN_DPI`) | | `FP_POINT_DPI_RESET` | Pointing Device | Reset the pointing DPI back to the default (defined as value of `FP_POINTING_DEFAULT_DPI`) | | `FP_SCROLL_TOG` | Pointing Device | Toggle scrolling mode | | `FP_SCROLL_ON` | Pointing Device | Turn on scrolling mode | | `FP_SCROLL_OFF` | Pointing Device | Turn off scrolling mode | | `FP_SCROLL_MOMENT` | Pointing Device | Activate scrolling mode while holding this key | | `FP_SCROLL_DPI_UP` | Pointing Device | Increase the scrolling DPI (increments of 1, maximum `FP_POINTING_SCROLLING_MAX_DPI`) | -| `FP_SCROLL_DPI_DN` | Pointing Device | Decrease the scrolling DPI (increments of 1, maximum `FP_POINTING_SCROLLING_MAX_DPI`) | +| `FP_SCROLL_DPI_DN` | Pointing Device | Decrease the scrolling DPI (increments of 1, minimum `FP_POINTING_SCROLLING_MIN_DPI`) | | `FP_SCROLL_DPI_RESET` | Pointing Device | Reset the scrolling DPI back to the default (defined as value of `FP_POINTING_SCROLLING_DPI`) | | `FP_SNIPE_TOG` | Pointing Device | Toggle sniping mode | | `FP_SNIPE_ON` | Pointing Device | Turn on sniping mode | | `FP_SNIPE_OFF` | Pointing Device | Turn off sniping mode | | `FP_SNIPE_MOMENT` | Pointing Device | Activate sniping mode while holding this key | | `FP_SNIPE_DPI_UP` | Pointing Device | Increase the sniping DPI (increments of 1, maximum `FP_POINTING_SNIPING_MAX_DPI`) | -| `FP_SNIPE_DPI_DN` | Pointing Device | Decrease the sniping DPI (increments of 1, maximum `FP_POINTING_SNIPING_MAX_DPI`) | +| `FP_SNIPE_DPI_DN` | Pointing Device | Decrease the sniping DPI (increments of 1, minimum `FP_POINTING_SNIPING_MIN_DPI`) | | `FP_SNIPE_DPI_RESET` | Pointing Device | Reset the sniping DPI back to the default (defined as value of `FP_POINTING_SNIPING_DPI`) | | `FP_ZOOM_TOG` | Pointing Device | Toggle zooming mode | | `FP_ZOOM_ON` | Pointing Device | Turn on zooming mode | @@ -180,7 +180,7 @@ bool encoder_update_kb(uint8_t index, bool clockwise) { | `FP_POINTING_SCROLLING_LAYER` | (Required) Defines the layer used to enable scrolling | `3` | | `FP_POINTING_SNIPING_DPI` | (Required) Sets the default DPI for sniping | `2` | | `FP_POINTING_SNIPING_MIN_DPI` | (Required) Sets the minimum DPI for sniping | `2` | -| `FP_POINTING_SNIPING_MAX_DPI` | (Required) Sets the maximum DPI for sniping | `10` | +| `FP_POINTING_SNIPING_MAX_DPI` | (Required) Sets the maximum DPI for sniping | `5` | | `FP_POINTING_SNIPING_LAYER_ENABLE` | (Required) Enables sniping mode for the layer `FP_POINTING_SNIPING_LAYER` | `undefined` | | `FP_POINTING_SNIPING_LAYER` | (Required) Defines the layer used to enable sniping | `2` | | `FP_POINTING_ZOOMING_LAYER_ENABLE` | (Required) Enables zooming mode for the layer `FP_POINTING_ZOOMING_LAYER` | `undefined` | @@ -191,14 +191,14 @@ bool encoder_update_kb(uint8_t index, bool clockwise) { ### Combined Pointing Devices -This only applies if you are using a split fingerpunch keyboard with two pointing devices. The default is for the left one to be scrolling, and the right one to act as the mouse, but this is configurable via `FP_POINTING_COMBINED_SCROLLING_LEFT` and `FP_POINTING_COMBINED_SCROLLING_RIGHT` - -Also note that all layer and keycode toggles for combined pointing devices only applies to the primary side (the side that's plugged into the computer). For instance, if you have `FP_POINTING_SCROLLING_LAYER` set to layer 1, activating that layer will only affect the pointing device on the primary side of the keyboard. +This only applies if you are using a split fingerpunch keyboard with two pointing devices. The default is for the left one to be scrolling, and the right one to act as the mouse, but this is configurable via the settings below. The compiler will error out if you specify both scrolling and sniping on the same side. For example, setting `FP_POINTING_COMBINED_SCROLLING_LEFT` and `FP_POINTING_COMBINED_SNIPING_LEFT` will fail. | Setting | Description | Default | | --------------------------------------- | ------------------------------------------------------------------- | -------------------------- | | `FP_POINTING_COMBINED_SCROLLING_LEFT` | (Required) Sets default behavior to scrolling on the left half | `true` | | `FP_POINTING_COMBINED_SCROLLING_RIGHT` | (Required) Sets default behavior to scrolling on the right half | `false` | +| `FP_POINTING_COMBINED_SNIPING_LEFT` | (Required) Sets default behavior to sniping on the left half | `false` | +| `FP_POINTING_COMBINED_SNIPING_RIGHT` | (Required) Sets default behavior to sniping on the right half | `false` | ### Auto mouse layer diff --git a/keyboards/fingerpunch/src/fp_pointing.c b/keyboards/fingerpunch/src/fp_pointing.c index cc912c5449..baab7aa57b 100644 --- a/keyboards/fingerpunch/src/fp_pointing.c +++ b/keyboards/fingerpunch/src/fp_pointing.c @@ -32,6 +32,15 @@ static bool zooming_keycode_enabled = false; static bool zooming_layer_enabled = false; static bool zooming_hold = false; +#ifdef POINTING_DEVICE_COMBINED +void fp_compile_check_combined_default_modes(void) { + // assert that either both LEFT values are false or only one of them is true + static_assert( ((FP_POINTING_COMBINED_SCROLLING_LEFT || FP_POINTING_COMBINED_SNIPING_LEFT) && (FP_POINTING_COMBINED_SCROLLING_LEFT != FP_POINTING_COMBINED_SNIPING_LEFT)) || (!FP_POINTING_COMBINED_SCROLLING_LEFT && !FP_POINTING_COMBINED_SNIPING_LEFT), "Cannot specify both FP_POINTING_COMBINED_SCROLLING_LEFT and FP_POINTING_COMBINED_SNIPING_LEFT"); + // assert that either both RIGHT values are false or only one of them is true + static_assert( ((FP_POINTING_COMBINED_SCROLLING_RIGHT || FP_POINTING_COMBINED_SNIPING_RIGHT) && (FP_POINTING_COMBINED_SCROLLING_RIGHT != FP_POINTING_COMBINED_SNIPING_RIGHT)) || (!FP_POINTING_COMBINED_SCROLLING_RIGHT && !FP_POINTING_COMBINED_SNIPING_RIGHT), "Cannot specify both FP_POINTING_COMBINED_SCROLLING_RIGHT and FP_POINTING_COMBINED_SNIPING_RIGHT"); +} +#endif + uint8_t fp_get_cpi_value_from_mode(uint8_t mode_index) { switch (mode_index) { case FP_POINTING_MODE: @@ -164,13 +173,24 @@ void fp_snipe_dpi_update(uint8_t action) { void fp_apply_dpi_defaults(void) { #ifdef POINTING_DEVICE_COMBINED + uint8_t left_mode = FP_POINTING_MODE; + uint8_t right_mode = FP_POINTING_MODE; + if (FP_POINTING_COMBINED_SCROLLING_LEFT) { - fp_set_cpi_combined_by_mode(FP_SCROLLING_MODE, FP_POINTING_MODE); - } else if (FP_POINTING_COMBINED_SCROLLING_RIGHT) { - fp_set_cpi_combined_by_mode(FP_POINTING_MODE, FP_SCROLLING_MODE); - } else { - fp_set_cpi_combined_by_mode(FP_POINTING_MODE, FP_POINTING_MODE); + left_mode = FP_SCROLLING_MODE; } + if (FP_POINTING_COMBINED_SNIPING_LEFT) { + left_mode = FP_SNIPING_MODE; + } + + if (FP_POINTING_COMBINED_SCROLLING_RIGHT) { + right_mode = FP_SCROLLING_MODE; + } + if (FP_POINTING_COMBINED_SNIPING_RIGHT) { + right_mode = FP_SNIPING_MODE; + } + + fp_set_cpi_combined_by_mode(left_mode, right_mode); #else fp_set_cpi_by_mode(FP_POINTING_MODE); #endif diff --git a/keyboards/fingerpunch/src/fp_pointing.h b/keyboards/fingerpunch/src/fp_pointing.h index bf65430e0b..f48a4a0d16 100644 --- a/keyboards/fingerpunch/src/fp_pointing.h +++ b/keyboards/fingerpunch/src/fp_pointing.h @@ -88,12 +88,12 @@ bool fp_process_record_pointing(uint16_t keycode, keyrecord_t *record); # define FP_POINTING_SNIPING_LAYER 2 # endif -# ifndef FP_POINTING_SNIPING_MAX_DPI -# define FP_POINTING_SNIPING_MAX_DPI 2 +# ifndef FP_POINTING_SNIPING_MIN_DPI +# define FP_POINTING_SNIPING_MIN_DPI 2 # endif -# ifndef FP_POINTING_SNIPING_MIN_DPI -# define FP_POINTING_SNIPING_MIN_DPI 10 +# ifndef FP_POINTING_SNIPING_MAX_DPI +# define FP_POINTING_SNIPING_MAX_DPI 5 # endif # ifndef FP_POINTING_SCROLLING_DPI @@ -131,4 +131,11 @@ bool fp_process_record_pointing(uint16_t keycode, keyrecord_t *record); # define FP_POINTING_COMBINED_SCROLLING_RIGHT false # endif +# ifndef FP_POINTING_COMBINED_SNIPING_LEFT +# define FP_POINTING_COMBINED_SNIPING_LEFT false +# endif + +# ifndef FP_POINTING_COMBINED_SNIPING_RIGHT +# define FP_POINTING_COMBINED_SNIPING_RIGHT false +# endif #endif diff --git a/keyboards/fingerpunch/ximi/keymaps/sadekbaroudi/config.h b/keyboards/fingerpunch/ximi/keymaps/sadekbaroudi/config.h new file mode 100644 index 0000000000..cce0b10c3d --- /dev/null +++ b/keyboards/fingerpunch/ximi/keymaps/sadekbaroudi/config.h @@ -0,0 +1,2 @@ +#define FP_POINTING_COMBINED_SCROLLING_LEFT false +#define FP_POINTING_COMBINED_SNIPING_LEFT true \ No newline at end of file