mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-07-28 11:59:21 +00:00
macos fallback for highres scrolling
This commit is contained in:
parent
fa24602e74
commit
85770691d8
@ -15,7 +15,8 @@
|
|||||||
"mousekey": true,
|
"mousekey": true,
|
||||||
"nkro": true,
|
"nkro": true,
|
||||||
"pointing_device": true,
|
"pointing_device": true,
|
||||||
"console": true
|
"console": true,
|
||||||
|
"os_detection": true
|
||||||
},
|
},
|
||||||
"layouts": {
|
"layouts": {
|
||||||
"LAYOUT": {
|
"LAYOUT": {
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
#include "analog.h"
|
#include "analog.h"
|
||||||
#include "opt_encoder.h"
|
#include "opt_encoder.h"
|
||||||
#include "as5600.h"
|
#include "as5600.h"
|
||||||
#include "print.h"
|
|
||||||
|
|
||||||
// for legacy support
|
// for legacy support
|
||||||
#if defined(OPT_DEBOUNCE) && !defined(PLOOPY_SCROLL_DEBOUNCE)
|
#if defined(OPT_DEBOUNCE) && !defined(PLOOPY_SCROLL_DEBOUNCE)
|
||||||
@ -61,10 +60,8 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef POINTING_DEVICE_AS5600_ENABLE
|
#ifdef POINTING_DEVICE_AS5600_ENABLE
|
||||||
// Variables specific to the Dial
|
|
||||||
uint16_t current_position = 0;
|
uint16_t current_position = 0;
|
||||||
// Dial will have 16 positions
|
os_variant_t d_os = OS_UNSURE;
|
||||||
const uint16_t SCROLL_DISTANCE = 64;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
keyboard_config_t keyboard_config;
|
keyboard_config_t keyboard_config;
|
||||||
@ -184,7 +181,7 @@ report_mouse_t pointing_device_task_kb(report_mouse_t mouse_report) {
|
|||||||
delta += 4096;
|
delta += 4096;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_hires_scroll_on()) {
|
if (d_os == OS_WINDOWS || d_os == OS_LINUX) {
|
||||||
// Establish a deadzone to prevent spurious inputs
|
// Establish a deadzone to prevent spurious inputs
|
||||||
// 4 was found to be a good number experimentally
|
// 4 was found to be a good number experimentally
|
||||||
if (delta > 4 || delta < -4) {
|
if (delta > 4 || delta < -4) {
|
||||||
@ -196,20 +193,14 @@ report_mouse_t pointing_device_task_kb(report_mouse_t mouse_report) {
|
|||||||
// high-res scrolling implementation. For more details, see:
|
// high-res scrolling implementation. For more details, see:
|
||||||
// https://github.com/qmk/qmk_firmware/issues/17585#issuecomment-2325248167
|
// https://github.com/qmk/qmk_firmware/issues/17585#issuecomment-2325248167
|
||||||
// 128 gives the scroll wheels "ticks".
|
// 128 gives the scroll wheels "ticks".
|
||||||
if (delta > 128) {
|
if (delta >= 128) {
|
||||||
current_position = ra;
|
current_position = ra;
|
||||||
mouse_report.v = 1;
|
mouse_report.v = 1;
|
||||||
} else if (delta < 128) {
|
} else if (delta <= -128) {
|
||||||
current_position = ra;
|
current_position = ra;
|
||||||
mouse_report.v = -1;
|
mouse_report.v = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
*/
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return pointing_device_task_user(mouse_report);
|
return pointing_device_task_user(mouse_report);
|
||||||
@ -290,22 +281,12 @@ void pointing_device_init_kb(void) {
|
|||||||
void keyboard_post_init_kb(void) {
|
void keyboard_post_init_kb(void) {
|
||||||
// Init the AS5600 controlling the Dial
|
// Init the AS5600 controlling the Dial
|
||||||
as5600_init();
|
as5600_init();
|
||||||
|
current_position = get_rawangle();
|
||||||
|
}
|
||||||
|
|
||||||
uint16_t ra = get_rawangle();
|
bool process_detected_host_os_kb(os_variant_t detected_os) {
|
||||||
|
d_os = detected_os;
|
||||||
int closest = 0;
|
return true;
|
||||||
int min_dist = 4096;
|
|
||||||
|
|
||||||
for (int i = 0; i < 4096; i += SCROLL_DISTANCE) {
|
|
||||||
int diff = abs((int) ra - i);
|
|
||||||
int dist = diff < (4096 - diff) ? diff : (4096 - diff);
|
|
||||||
if (dist < min_dist) {
|
|
||||||
min_dist = dist;
|
|
||||||
closest = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
current_position = closest;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user