A game framework written with osu! in mind.
at master 1.2 kB view raw
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 position. 12 /// Pointing devices such as mice provide relative positional input. 13 /// </summary> 14 public class MousePositionRelativeInput : IInput 15 { 16 /// <summary> 17 /// The change in position. This will be added to the current position. 18 /// When the current position is not valid, no changes will be made. 19 /// </summary> 20 public Vector2 Delta; 21 22 public void Apply(InputState state, IInputStateChangeHandler handler) 23 { 24 var mouse = state.Mouse; 25 26 if (mouse.IsPositionValid && Delta != Vector2.Zero) 27 { 28 var lastPosition = mouse.Position; 29 mouse.Position += Delta; 30 mouse.LastSource = this; 31 handler.HandleInputStateChange(new MousePositionChangeEvent(state, this, lastPosition)); 32 } 33 } 34 } 35}