A game framework written with osu! in mind.
1// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
2// See the LICENCE file in the repository root for full licence text.
3
4using osu.Framework.Input.StateChanges.Events;
5using osu.Framework.Input.States;
6using osuTK;
7
8namespace osu.Framework.Input.StateChanges
9{
10 /// <summary>
11 /// Denotes a relative change of mouse scroll.
12 /// Pointing devices such as mice provide relative scroll input.
13 /// </summary>
14 public class MouseScrollRelativeInput : IInput
15 {
16 /// <summary>
17 /// The change in scroll. This is added to the current scroll.
18 /// </summary>
19 public Vector2 Delta;
20
21 /// <summary>
22 /// Whether the change came from a device supporting precision scrolling.
23 /// </summary>
24 /// <remarks>
25 /// In cases this is true, scroll events will generally map 1:1 to user's input, rather than incrementing in large "notches" (as expected of traditional scroll wheels).
26 /// </remarks>
27 public bool IsPrecise;
28
29 public void Apply(InputState state, IInputStateChangeHandler handler)
30 {
31 var mouse = state.Mouse;
32
33 if (Delta != Vector2.Zero)
34 {
35 var lastScroll = mouse.Scroll;
36 mouse.Scroll += Delta;
37 mouse.LastSource = this;
38 handler.HandleInputStateChange(new MouseScrollChangeEvent(state, this, lastScroll, IsPrecise));
39 }
40 }
41 }
42}