Skip to content

Commit

Permalink
parent c6ab70e
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Alabastard-64 committed Jan 23, 2023
1 parent 8ca3f0f commit 612ff48
Show file tree
Hide file tree
Showing 10 changed files with 1,260 additions and 15 deletions.
1 change: 1 addition & 0 deletions builddefs/common_features.mk
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ ifeq ($(strip $(POINTING_DEVICE_ENABLE)), yes)
SRC += $(QUANTUM_DIR)/pointing_device/pointing_device.c
SRC += $(QUANTUM_DIR)/pointing_device/pointing_device_drivers.c
SRC += $(QUANTUM_DIR)/pointing_device/pointing_device_auto_mouse.c
SRC += $(QUANTUM_DIR)/pointing_device/pointing_device_modes.c
ifneq ($(strip $(POINTING_DEVICE_DRIVER)), custom)
SRC += drivers/sensors/$(strip $(POINTING_DEVICE_DRIVER)).c
OPT_DEFS += -DPOINTING_DEVICE_DRIVER_$(strip $(shell echo $(POINTING_DEVICE_DRIVER) | tr '[:lower:]' '[:upper:]'))
Expand Down
4 changes: 3 additions & 1 deletion data/constants/keycodes/keycodes_0.0.1.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
"0x52C0/0x001F": {
"define": "QK_LAYER_TAP_TOGGLE"
},
// 0x52E0/0x001F - UNUSED
"0x52E0/0x001F": {
"define": "QK_POINTING_MODE"
},
// 0x5300/0x02FF - UNUSED
"0x5600/0x00FF": {
"define": "QK_SWAP_HANDS"
Expand Down
504 changes: 497 additions & 7 deletions docs/feature_pointing_device.md

Large diffs are not rendered by default.

45 changes: 39 additions & 6 deletions quantum/pointing_device/pointing_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,11 @@ __attribute__((weak)) void pointing_device_send(void) {
host_mouse_send(&local_mouse_report);
}
// send it and 0 it out except for buttons, so those stay until they are explicity over-ridden using update_pointing_device
uint8_t buttons = local_mouse_report.buttons;
memset(&local_mouse_report, 0, sizeof(local_mouse_report));
local_mouse_report.buttons = buttons;
local_mouse_report.x = 0;
local_mouse_report.y = 0;
local_mouse_report.v = 0;
local_mouse_report.h = 0;

memcpy(&old_report, &local_mouse_report, sizeof(local_mouse_report));
}

Expand Down Expand Up @@ -272,14 +274,22 @@ __attribute__((weak)) void pointing_device_task(void) {
local_mouse_report = pointing_device_adjust_by_defines_right(local_mouse_report);
shared_mouse_report = pointing_device_adjust_by_defines(shared_mouse_report);
}
local_mouse_report = is_keyboard_left() ? pointing_device_task_combined_kb(local_mouse_report, shared_mouse_report) : pointing_device_task_combined_kb(shared_mouse_report, local_mouse_report);
local_mouse_report = is_keyboard_left() ? pointing_device_task_combined(local_mouse_report, shared_mouse_report) : pointing_device_task_combined(shared_mouse_report, local_mouse_report);
#else
local_mouse_report = pointing_device_adjust_by_defines(local_mouse_report);
local_mouse_report = pointing_device_task_kb(local_mouse_report);
#endif
// automatic mouse layer function
#ifdef POINTING_DEVICE_AUTO_MOUSE_ENABLE
pointing_device_task_auto_mouse(local_mouse_report);
#endif
// pointing device modes handling for single pointing device
#if defined(POINTING_DEVICE_MODES_ENABLE) && !(defined(SPLIT_POINTING_ENABLE) && defined(POINTING_DEVICE_COMBINED))
local_mouse_report = pointing_device_modes_task(local_mouse_report);
#endif
// automatic mouse layer function
#ifdef POINTING_DEVICE_AUTO_MOUSE_ENABLE
pointing_device_task_auto_mouse(local_mouse_report);
#endif
// combine with mouse report to ensure that the combined is sent correctly
#ifdef MOUSEKEY_ENABLE
Expand Down Expand Up @@ -378,7 +388,7 @@ static inline int8_t pointing_device_hv_clamp(int16_t value) {
}

/**
* @brief clamps int16_t to int8_t
* @brief clamps clamp_range_t to mouse_xy_report_t
*
* @param[in] clamp_range_t value
* @return mouse_xy_report_t clamped value
Expand Down Expand Up @@ -450,6 +460,28 @@ report_mouse_t pointing_device_adjust_by_defines_right(report_mouse_t mouse_repo
return mouse_report;
}

/**
* @brief Handle core combined pointing device tasks
*
* Takes 2 report_mouse_t structs allowing individual modification of either side and then returns pointing_device_task_combined_kb.
*
* NOTE: Only available when using both SPLIT_POINTING_ENABLE and POINTING_DEVICE_COMBINED
*
* @param[in] left_report report_mouse_t
* @param[in] right_report report_mouse_t
* @return pointing_device_task_combined_kb(left_report, right_report) by default
*/
report_mouse_t pointing_device_task_combined(report_mouse_t left_report, report_mouse_t right_report) {
# ifdef POINTING_DEVICE_MODES_ENABLE
if (is_pointing_mode_on_left()) {
left_report = pointing_device_modes_task(left_report);
} else {
right_report = pointing_device_modes_task(right_report);
}
# endif
return pointing_device_task_combined_kb(left_report, right_report);
}

/**
* @brief Weak function allowing for keyboard level mouse report modification
*
Expand Down Expand Up @@ -479,11 +511,12 @@ __attribute__((weak)) report_mouse_t pointing_device_task_combined_kb(report_mou
__attribute__((weak)) report_mouse_t pointing_device_task_combined_user(report_mouse_t left_report, report_mouse_t right_report) {
return pointing_device_combine_reports(left_report, right_report);
}
#endif

__attribute__((weak)) void pointing_device_keycode_handler(uint16_t keycode, bool pressed) {
if IS_MOUSEKEY_BUTTON (keycode) {
local_mouse_report.buttons = pointing_device_handle_buttons(local_mouse_report.buttons, pressed, keycode - KC_MS_BTN1);
pointing_device_send();
}
}

#endif // defined(SPLIT_POINTING_ENABLE) && defined(POINTING_DEVICE_COMBINED)
4 changes: 4 additions & 0 deletions quantum/pointing_device/pointing_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifdef POINTING_DEVICE_AUTO_MOUSE_ENABLE
# include "pointing_device_auto_mouse.h"
#endif
#ifdef POINTING_DEVICE_MODES_ENABLE
# include "pointing_device_modes.h"
#endif

#if defined(POINTING_DEVICE_DRIVER_adns5050)
# include "drivers/sensors/adns5050.h"
Expand Down Expand Up @@ -121,6 +124,7 @@ uint16_t pointing_device_get_shared_cpi(void);
# if defined(POINTING_DEVICE_COMBINED)
void pointing_device_set_cpi_on_side(bool left, uint16_t cpi);
report_mouse_t pointing_device_combine_reports(report_mouse_t left_report, report_mouse_t right_report);
report_mouse_t pointing_device_task_combined(report_mouse_t left_report, report_mouse_t right_report);
report_mouse_t pointing_device_task_combined_kb(report_mouse_t left_report, report_mouse_t right_report);
report_mouse_t pointing_device_task_combined_user(report_mouse_t left_report, report_mouse_t right_report);
report_mouse_t pointing_device_adjust_by_defines_right(report_mouse_t mouse_report);
Expand Down
7 changes: 6 additions & 1 deletion quantum/pointing_device/pointing_device_auto_mouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,12 @@ bool process_auto_mouse(uint16_t keycode, keyrecord_t* record) {
*/
static bool is_mouse_record(uint16_t keycode, keyrecord_t* record) {
// allow for keyboard to hook in and override if need be
if (is_mouse_record_kb(keycode, record) || IS_MOUSEKEY(keycode)) return true;
if (is_mouse_record_kb(keycode, record) || IS_MOUSEKEY(keycode) ||
# ifdef POINTING_DEVICE_MODES_ENABLE
IS_QK_POINTING_MODE(keycode) ||
# endif
false)
return true;
return false;
}

Expand Down
Loading

0 comments on commit 612ff48

Please sign in to comment.