Cirque circular scroll: Support POINTING_DEVICE_COMBINED (#17654)

master
Daniel Kao 2022-07-25 23:19:33 -07:00 committed by GitHub
parent 2456044d5f
commit 1de6811ebe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 13 deletions

View File

@ -20,6 +20,9 @@
#include "pointing_device.h" #include "pointing_device.h"
#include "timer.h" #include "timer.h"
#include "wait.h" #include "wait.h"
#if defined(SPLIT_POINTING_ENABLE) && defined(POINTING_DEVICE_COMBINED)
# include "keyboard.h"
#endif
#if defined(CIRQUE_PINNACLE_TAP_ENABLE) || defined(CIRQUE_PINNACLE_CIRCULAR_SCROLL_ENABLE) #if defined(CIRQUE_PINNACLE_TAP_ENABLE) || defined(CIRQUE_PINNACLE_CIRCULAR_SCROLL_ENABLE)
static cirque_pinnacle_features_t features = {.tap_enable = true, .circular_scroll_enable = true}; static cirque_pinnacle_features_t features = {.tap_enable = true, .circular_scroll_enable = true};
@ -92,18 +95,28 @@ static inline uint16_t atan2_16(int32_t dy, int32_t dx) {
static circular_scroll_t circular_scroll(pinnacle_data_t touchData) { static circular_scroll_t circular_scroll(pinnacle_data_t touchData) {
circular_scroll_t report = {0, 0, false}; circular_scroll_t report = {0, 0, false};
int8_t x, y, wheel_clicks; int8_t x, y, wheel_clicks;
uint8_t center = 256 / 2, mag; uint8_t center = INT8_MAX, mag;
int16_t ang, dot, det, opposite_side, adjacent_side; int16_t ang, dot, det, opposite_side, adjacent_side;
uint16_t scale = cirque_pinnacle_get_scale(); uint16_t scale = cirque_pinnacle_get_scale();
if (touchData.zValue) { if (touchData.zValue) {
/* /*
* Place origin at center of trackpad, treat coordinates as vectors. * Place origin at center of trackpad, treat coordinates as vectors.
* Scale to fixed int8_t size; angles are independent of resolution. * Scale to +/-INT8_MAX; angles are independent of resolution.
*/ */
if (scale) { if (scale) {
x = (int8_t)((int32_t)touchData.xValue * 256 / scale - center); /* Rotate coordinates into a consistent orientation */
y = (int8_t)((int32_t)touchData.yValue * 256 / scale - center); report_mouse_t rot = {.x = (int8_t)((int32_t)touchData.xValue * INT8_MAX * 2 / scale - center), .y = (int8_t)((int32_t)touchData.yValue * INT8_MAX * 2 / scale - center)};
# if defined(SPLIT_POINTING_ENABLE) && defined(POINTING_DEVICE_COMBINED)
if (!is_keyboard_left()) {
rot = pointing_device_adjust_by_defines_right(rot);
} else
# endif
{
rot = pointing_device_adjust_by_defines(rot);
}
x = rot.x;
y = rot.y;
} else { } else {
x = 0; x = 0;
y = 0; y = 0;
@ -125,15 +138,7 @@ static circular_scroll_t circular_scroll(pinnacle_data_t touchData) {
* Horizontal if started from left half * Horizontal if started from left half
* Flipped for left-handed * Flipped for left-handed
*/ */
# if defined(POINTING_DEVICE_ROTATION_90)
scroll.axis = y < 0;
# elif defined(POINTING_DEVICE_ROTATION_180)
scroll.axis = x > 0;
# elif defined(POINTING_DEVICE_ROTATION_270)
scroll.axis = y > 0;
# else
scroll.axis = x < 0; scroll.axis = x < 0;
# endif
} }
} else if (scroll.state == SCROLL_DETECTING) { } else if (scroll.state == SCROLL_DETECTING) {
report.suppress_touch = true; report.suppress_touch = true;

View File

@ -412,7 +412,7 @@ report_mouse_t pointing_device_combine_reports(report_mouse_t left_report, repor
*/ */
report_mouse_t pointing_device_adjust_by_defines_right(report_mouse_t mouse_report) { report_mouse_t pointing_device_adjust_by_defines_right(report_mouse_t mouse_report) {
// Support rotation of the sensor data // Support rotation of the sensor data
# if defined(POINTING_DEVICE_ROTATION_90_RIGHT) || defined(POINTING_DEVICE_ROTATION_RIGHT) || defined(POINTING_DEVICE_ROTATION_RIGHT) # if defined(POINTING_DEVICE_ROTATION_90_RIGHT) || defined(POINTING_DEVICE_ROTATION_180_RIGHT) || defined(POINTING_DEVICE_ROTATION_270_RIGHT)
mouse_xy_report_t x = mouse_report.x; mouse_xy_report_t x = mouse_report.x;
mouse_xy_report_t y = mouse_report.y; mouse_xy_report_t y = mouse_report.y;
# if defined(POINTING_DEVICE_ROTATION_90_RIGHT) # if defined(POINTING_DEVICE_ROTATION_90_RIGHT)