1 // 2 // Copyright (c) 2010-2018 Antmicro 3 // Copyright (c) 2011-2015 Realtime Embedded 4 // 5 // This file is licensed under the MIT License. 6 // Full license text is available in 'licenses/MIT.txt'. 7 // 8 using Antmicro.Renode.Peripherals.Input; 9 using Xwt; 10 11 namespace Antmicro.Renode.Extensions.Analyzers.Video.Handlers 12 { 13 internal abstract class PointerHandler 14 { PointerHandler(IPointerInput input)15 protected PointerHandler(IPointerInput input) 16 { 17 this.input = input; 18 } 19 Init()20 public virtual void Init() 21 { 22 } 23 ButtonPressed(int button)24 public virtual void ButtonPressed(int button) 25 { 26 input.Press(ToMouseButton((PointerButton)button)); 27 } 28 ButtonReleased(int button)29 public virtual void ButtonReleased(int button) 30 { 31 input.Release(ToMouseButton((PointerButton)button)); 32 } 33 PointerMoved(int x, int y, int dx, int dy)34 public abstract void PointerMoved(int x, int y, int dx, int dy); 35 ToMouseButton(PointerButton button)36 private MouseButton ToMouseButton(PointerButton button) 37 { 38 switch(button) 39 { 40 case PointerButton.Left: 41 return MouseButton.Left; 42 case PointerButton.Right: 43 return MouseButton.Right; 44 case PointerButton.Middle: 45 return MouseButton.Middle; 46 } 47 48 return MouseButton.Extra; 49 } 50 51 protected IPointerInput input; 52 } 53 } 54 55