Skip to content

Commit

Permalink
default extended mouse report enabled, and added experimental acceler…
Browse files Browse the repository at this point in the history
…ation feature, inspired by trankillity
  • Loading branch information
sadekbaroudi committed Nov 18, 2022
1 parent f136cd0 commit 2f5017f
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 15 deletions.
27 changes: 15 additions & 12 deletions keyboards/fingerpunch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ For general firmware build walkthrough and instructions, please see:

| Key | Description |
| ------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `FP_ACCEL_TOG` | Pointing Device: Toggle pointing device acceleration (default is enabled on keyboard startup) |
| `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 |
Expand Down Expand Up @@ -78,18 +79,20 @@ enum userspace_custom_keycodes {

### General Settings

| Setting | Description | Default |
| --------------------------------------- | ----------------------------------------------------------------------------------------- | -------------------------------- |
| `FP_POINTING_DEFAULT_DPI` | (Required) Sets the default DPI for your pointing device | `1000` |
| `FP_POINTING_SCROLLING_DPI` | (Required) Sets the default DPI for scrolling | `50` |
| `FP_POINTING_SCROLLING_LAYER_ENABLE` | (Optional) Enables scrolling mode for the layer `FP_POINTING_SCROLLING_LAYER` | `undefined` |
| `FP_POINTING_SCROLLING_LAYER` | (Required) Defines the layer used to enable scrolling | `3` |
| `FP_POINTING_SNIPING_DPI` | (Required) Sets the default DPI for scrolling | `50` |
| `FP_POINTING_SNIPING_LAYER_ENABLE` | (Required) Enables scrolling 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` |
| `FP_POINTING_ZOOMING_LAYER` | (Required) Defines the layer used to enable zooming | `1` |

| Setting | Description | Default |
| -------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | -------------------------------- |
| `FP_POINTING_EXTENDED_MOUSE_REPORT_DISABLE` | (Optional) Disable extended mouse report, enabled by default when pointing devices is enabled, saves a tiny bit of memory | `undefined` |
| `FP_POINTING_DEFAULT_DPI` | (Required) Sets the default DPI for your pointing device | `1000` |
| `FP_POINTING_SCROLLING_DPI` | (Required) Sets the default DPI for scrolling | `50` |
| `FP_POINTING_SCROLLING_LAYER_ENABLE` | (Optional) Enables scrolling mode for the layer `FP_POINTING_SCROLLING_LAYER` | `undefined` |
| `FP_POINTING_SCROLLING_LAYER` | (Required) Defines the layer used to enable scrolling | `3` |
| `FP_POINTING_SNIPING_DPI` | (Required) Sets the default DPI for scrolling | `50` |
| `FP_POINTING_SNIPING_LAYER_ENABLE` | (Required) Enables scrolling 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` |
| `FP_POINTING_ZOOMING_LAYER` | (Required) Defines the layer used to enable zooming | `1` |
| `FP_POINTING_ACCELERATION_ENABLE` | (Optional) (EXPERIMENTAL) Enable pointing device acceleration | `undefined` |


### Combined Pointing Devices
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
K33, K34, K35, K36, K37, K38 \
) \
LAYOUT_wrapper( \
FP_SCROLL_TOG, K01, K02, K03, LT(_FUNCTION, K04), K05, K06, LT(_FUNCTION, K07), K08, K09, K0A, KC_BSLS, \
KC_MS_BTN1, LCTL_T(K11), LGUI_T(K12), LALT_T(K13), LSFT_T(K14), K15, LT(_MOUSE, K16), RSFT_T(K17), RALT_T(K18), RGUI_T(K19), RCTL_T(K1A), FP_ZOOM_MOMENT, \
FP_SNIPE_TOG, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, FP_SUPER_TAB, \
FP_SCROLL_TOG, K01, K02, K03, LT(_FUNCTION, K04), K05, K06, LT(_FUNCTION, K07), K08, K09, K0A, FP_ACCEL_TOG, \
KC_MS_BTN1, LCTL_T(K11), LGUI_T(K12), LALT_T(K13), LSFT_T(K14), K15, LT(_MOUSE, K16), RSFT_T(K17), RALT_T(K18), RGUI_T(K19), RCTL_T(K1A), FP_SNIPE_TOG, \
KC_MS_BTN2, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, FP_ZOOM_TOG, \
KC_MUTE, K33, LT(_NAVIGATION,K34), LT(_FUNCTION,K35), LT(_MEDIA,K36), LT(_SYMBOLS,K37), K38, LCTL(KC_BSPC) \
)

Expand Down
1 change: 1 addition & 0 deletions keyboards/fingerpunch/fp_keyhandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ enum fp_keycodes {
# else
FP_SCROLL_TOG = SAFE_RANGE,
# endif // VIA_ENABLE
FP_ACCEL_TOG,
FP_SCROLL_ON,
FP_SCROLL_OFF,
FP_SCROLL_MOMENT,
Expand Down
21 changes: 21 additions & 0 deletions keyboards/fingerpunch/fp_pointing.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@

#ifdef POINTING_DEVICE_ENABLE

#ifdef FP_POINTING_ACCELERATION_ENABLE
static bool acceleration_enabled = true;
#endif
static bool scrolling_enabled = false;
static bool scrolling_layer_enabled = false;
static bool sniping_enabled = false;
Expand Down Expand Up @@ -152,7 +155,20 @@ report_mouse_t pointing_device_task_kb(report_mouse_t mouse_report) {
mouse_report.y = 0;

}
#ifdef FP_POINTING_ACCELERATION_ENABLE
// Don't run acceleration unless you're in regular mousing mode, and acceleration is explicitly enabled
if (!fp_scroll_get() && !fp_snipe_get() && !fp_zoom_get() && acceleration_enabled) {
mouse_xy_report_t x = mouse_report.x, y = mouse_report.y;
mouse_report.x = 0;
mouse_report.y = 0;

x = (mouse_xy_report_t)(x > 0 ? x * x / 16 + x : -x * x / 16 + x);
y = (mouse_xy_report_t)(y > 0 ? y * y / 16 + y : -y * y / 16 + y);

mouse_report.x = x;
mouse_report.y = y;
}
#endif
mouse_report = pointing_device_task_user(mouse_report);
return mouse_report;
}
Expand Down Expand Up @@ -256,6 +272,11 @@ bool auto_mouse_activation(report_mouse_t mouse_report) {
bool fp_process_record_pointing(uint16_t keycode, keyrecord_t *record) {
# ifndef FP_DISABLE_CUSTOM_KEYCODES
switch (keycode) {
case FP_ACCEL_TOG:
# ifdef FP_POINTING_ACCELERATION_ENABLE
acceleration_enabled = !acceleration_enabled;
# endif
break;
case FP_SCROLL_MOMENT:
if (record->event.pressed) {
fp_scroll_keycode_set(true);
Expand Down
5 changes: 5 additions & 0 deletions keyboards/fingerpunch/fp_pointing.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ bool fp_zoom_get(void);
uint32_t fp_zoom_unset_hold(uint32_t triger_time, void *cb_arg);

#ifdef POINTING_DEVICE_ENABLE
// Add MOUSE_EXTENDED_REPORT by default
# ifndef FP_POINTING_EXTENDED_MOUSE_REPORT_DISABLE
# define MOUSE_EXTENDED_REPORT
# endif

# ifndef FP_POINTING_DEFAULT_DPI
# define FP_POINTING_DEFAULT_DPI 1000
# endif
Expand Down

0 comments on commit 2f5017f

Please sign in to comment.