File tree Expand file tree Collapse file tree 1 file changed +41
-15
lines changed Expand file tree Collapse file tree 1 file changed +41
-15
lines changed Original file line number Diff line number Diff line change @@ -318,21 +318,47 @@ fn get_events(
318318 } ) ) )
319319 }
320320 CGEventType :: ScrollWheel => {
321- let v = ev. get_integer_value_field ( EventField :: SCROLL_WHEEL_EVENT_POINT_DELTA_AXIS_1 ) ;
322- let h = ev. get_integer_value_field ( EventField :: SCROLL_WHEEL_EVENT_POINT_DELTA_AXIS_2 ) ;
323- if v != 0 {
324- result. push ( CaptureEvent :: Input ( Event :: Pointer ( PointerEvent :: Axis {
325- time : 0 ,
326- axis : 0 , // Vertical
327- value : v as f64 ,
328- } ) ) ) ;
329- }
330- if h != 0 {
331- result. push ( CaptureEvent :: Input ( Event :: Pointer ( PointerEvent :: Axis {
332- time : 0 ,
333- axis : 1 , // Horizontal
334- value : h as f64 ,
335- } ) ) ) ;
321+ if ev. get_integer_value_field ( EventField :: SCROLL_WHEEL_EVENT_IS_CONTINUOUS ) != 0 {
322+ let v =
323+ ev. get_integer_value_field ( EventField :: SCROLL_WHEEL_EVENT_POINT_DELTA_AXIS_1 ) ;
324+ let h =
325+ ev. get_integer_value_field ( EventField :: SCROLL_WHEEL_EVENT_POINT_DELTA_AXIS_2 ) ;
326+ if v != 0 {
327+ result. push ( CaptureEvent :: Input ( Event :: Pointer ( PointerEvent :: Axis {
328+ time : 0 ,
329+ axis : 0 , // Vertical
330+ value : v as f64 ,
331+ } ) ) ) ;
332+ }
333+ if h != 0 {
334+ result. push ( CaptureEvent :: Input ( Event :: Pointer ( PointerEvent :: Axis {
335+ time : 0 ,
336+ axis : 1 , // Horizontal
337+ value : h as f64 ,
338+ } ) ) ) ;
339+ }
340+ } else {
341+ // line based scrolling
342+ const LINES_PER_STEP : i32 = 3 ;
343+ const V120_STEPS_PER_LINE : i32 = 120 / LINES_PER_STEP ;
344+ let v = ev. get_integer_value_field ( EventField :: SCROLL_WHEEL_EVENT_DELTA_AXIS_1 ) ;
345+ let h = ev. get_integer_value_field ( EventField :: SCROLL_WHEEL_EVENT_DELTA_AXIS_2 ) ;
346+ if v != 0 {
347+ result. push ( CaptureEvent :: Input ( Event :: Pointer (
348+ PointerEvent :: AxisDiscrete120 {
349+ axis : 0 , // Vertical
350+ value : V120_STEPS_PER_LINE * v as i32 ,
351+ } ,
352+ ) ) ) ;
353+ }
354+ if h != 0 {
355+ result. push ( CaptureEvent :: Input ( Event :: Pointer (
356+ PointerEvent :: AxisDiscrete120 {
357+ axis : 1 , // Horizontal
358+ value : V120_STEPS_PER_LINE * h as i32 ,
359+ } ,
360+ ) ) ) ;
361+ }
336362 }
337363 }
338364 _ => ( ) ,
You can’t perform that action at this time.
0 commit comments