@@ -357,36 +357,19 @@ report_mouse_t navigator_trackpad_get_report(report_mouse_t mouse_report) {
357357 scroll_inertia .vy -= friction_y ;
358358
359359 // Convert Q8 velocity to scroll value
360+ # ifdef NAVIGATOR_TRACKPAD_MACOS_SCROLLING
361+ // macOS mode: send raw velocity deltas (descriptor tells macOS the resolution)
362+ int16_t scroll_x = scroll_inertia .vx / 256 ;
363+ int16_t scroll_y = scroll_inertia .vy / 256 ;
364+ # else
365+ // Hi-res mode: apply multiplier for Windows/Linux
360366 int16_t scroll_x = (scroll_inertia .vx * NAVIGATOR_TRACKPAD_SCROLL_MULTIPLIER ) / 256 ;
361367 int16_t scroll_y = (scroll_inertia .vy * NAVIGATOR_TRACKPAD_SCROLL_MULTIPLIER ) / 256 ;
368+ # endif
362369
363- # ifdef NAVIGATOR_TRACKPAD_MACOS_SCROLLING
364- // macOS mode: accumulate scroll and only output when threshold is crossed
365- macos_scroll_accumulated_h += (float )scroll_x / NAVIGATOR_TRACKPAD_MACOS_SCROLL_DIVIDER ;
366- macos_scroll_accumulated_v += (float )scroll_y / NAVIGATOR_TRACKPAD_MACOS_SCROLL_DIVIDER ;
367-
368- float abs_h = (macos_scroll_accumulated_h < 0 ) ? - macos_scroll_accumulated_h : macos_scroll_accumulated_h ;
369- float abs_v = (macos_scroll_accumulated_v < 0 ) ? - macos_scroll_accumulated_v : macos_scroll_accumulated_v ;
370-
371- // Only output scroll when accumulated value crosses 1.0
372- if (abs_h >= 1.0f ) {
373- scroll_x = (macos_scroll_accumulated_h > 0 ) ? 1 : -1 ;
374- macos_scroll_accumulated_h -= (macos_scroll_accumulated_h > 0 ) ? 1.0f : -1.0f ;
375- } else {
376- scroll_x = 0 ;
377- }
378-
379- if (abs_v >= 1.0f ) {
380- scroll_y = (macos_scroll_accumulated_v > 0 ) ? 1 : -1 ;
381- macos_scroll_accumulated_v -= (macos_scroll_accumulated_v > 0 ) ? 1.0f : -1.0f ;
382- } else {
383- scroll_y = 0 ;
384- }
385- # else
386- // Hi-res mode: clamp to int8_t range
370+ // Clamp to int8_t range
387371 scroll_x = (scroll_x > 127 ) ? 127 : ((scroll_x < -127 ) ? -127 : scroll_x );
388372 scroll_y = (scroll_y > 127 ) ? 127 : ((scroll_y < -127 ) ? -127 : scroll_y );
389- # endif
390373
391374 // Check if velocity is too low to continue
392375 int16_t abs_vx = scroll_inertia .vx < 0 ? - scroll_inertia .vx : scroll_inertia .vx ;
@@ -604,11 +587,17 @@ report_mouse_t navigator_trackpad_get_report(report_mouse_t mouse_report) {
604587 if (delta_x != 0 || delta_y != 0 ) {
605588# ifdef NAVIGATOR_TRACKPAD_SCROLL_WITH_TWO_FINGERS
606589 if (gesture .state == TP_SCROLLING ) {
607- // Two-finger scroll: output directly to h/v for high-res scrolling
608- // With high-res scrolling enabled, the OS divides by 120 to get ticks
609- // Apply multiplier to adjust scroll speed
590+ # ifdef NAVIGATOR_TRACKPAD_MACOS_SCROLLING
591+ // macOS mode: send raw deltas, macOS handles scaling via HIDScrollResolution
592+ // Apple trackpads report raw sensor deltas and let macOS apply acceleration
593+ int16_t scroll_x = delta_x ;
594+ int16_t scroll_y = delta_y ;
595+ # else
596+ // Hi-res mode: apply multiplier for Windows/Linux
597+ // These OSes divide by the Resolution Multiplier (120)
610598 int16_t scroll_x = delta_x * NAVIGATOR_TRACKPAD_SCROLL_MULTIPLIER ;
611599 int16_t scroll_y = delta_y * NAVIGATOR_TRACKPAD_SCROLL_MULTIPLIER ;
600+ # endif
612601
613602# ifdef NAVIGATOR_TRACKPAD_SCROLL_INERTIA_ENABLE
614603 // Track velocity for inertia using exponential smoothing (Q8 fixed point)
@@ -638,34 +627,9 @@ report_mouse_t navigator_trackpad_get_report(report_mouse_t mouse_report) {
638627 }
639628# endif
640629
641- # ifdef NAVIGATOR_TRACKPAD_MACOS_SCROLLING
642- // macOS mode: accumulate scroll and only output when threshold is crossed
643- // This provides fine-grained speed control via the divider
644- macos_scroll_accumulated_h += (float )scroll_x / NAVIGATOR_TRACKPAD_MACOS_SCROLL_DIVIDER ;
645- macos_scroll_accumulated_v += (float )scroll_y / NAVIGATOR_TRACKPAD_MACOS_SCROLL_DIVIDER ;
646-
647- float abs_h = (macos_scroll_accumulated_h < 0 ) ? - macos_scroll_accumulated_h : macos_scroll_accumulated_h ;
648- float abs_v = (macos_scroll_accumulated_v < 0 ) ? - macos_scroll_accumulated_v : macos_scroll_accumulated_v ;
649-
650- // Only output scroll when accumulated value crosses 1.0
651- if (abs_h >= 1.0f ) {
652- scroll_x = (macos_scroll_accumulated_h > 0 ) ? 1 : -1 ;
653- macos_scroll_accumulated_h -= (macos_scroll_accumulated_h > 0 ) ? 1.0f : -1.0f ;
654- } else {
655- scroll_x = 0 ;
656- }
657-
658- if (abs_v >= 1.0f ) {
659- scroll_y = (macos_scroll_accumulated_v > 0 ) ? 1 : -1 ;
660- macos_scroll_accumulated_v -= (macos_scroll_accumulated_v > 0 ) ? 1.0f : -1.0f ;
661- } else {
662- scroll_y = 0 ;
663- }
664- # else
665- // Hi-res mode: clamp to int8_t range for the report
630+ // Clamp to int8_t range for the report
666631 scroll_x = (scroll_x > 127 ) ? 127 : ((scroll_x < -127 ) ? -127 : scroll_x );
667632 scroll_y = (scroll_y > 127 ) ? 127 : ((scroll_y < -127 ) ? -127 : scroll_y );
668- # endif
669633
670634 // Apply scroll inversion if configured
671635# ifdef NAVIGATOR_SCROLL_INVERT_X
0 commit comments