/// <summary> /// Creates a new mouse input device instance using an existing <see cref="OpenTK.GameWindow"/>. /// </summary> /// <param name="gameWindow">The game window providing mouse input.</param> public MouseDeviceImp(GameWindow gameWindow) { _gameWindow = gameWindow; _gameWindow.Mouse.ButtonDown += OnGameWinMouseDown; _gameWindow.Mouse.ButtonUp += OnGameWinMouseUp; _btnLeftDesc = new ButtonImpDescription { ButtonDesc = new ButtonDescription { Name = "Left", Id = (int)MouseButtons.Left }, PollButton = false }; _btnMiddleDesc = new ButtonImpDescription { ButtonDesc = new ButtonDescription { Name = "Middle", Id = (int)MouseButtons.Middle }, PollButton = false }; _btnRightDesc = new ButtonImpDescription { ButtonDesc = new ButtonDescription { Name = "Right", Id = (int)MouseButtons.Right }, PollButton = false }; }
/// <summary> /// Creates a new mouse input device instance using an existing <see cref="OpenTK.GameWindow"/>. /// </summary> /// <param name="gameWindow">The game window providing mouse input.</param> public WinFormsMouseDeviceImp(Control gameWindow) { _form = gameWindow; _form.MouseDown += OnGameWinMouseDown; _form.MouseUp += OnGameWinMouseUp; _form.MouseWheel += OnMouseWheel; _currentWheel = 0; _btnLeftDesc = new ButtonImpDescription { ButtonDesc = new ButtonDescription { Name = "Left", Id = (int)Fusee.Engine.Common.MouseButtons.Left }, PollButton = false }; _btnMiddleDesc = new ButtonImpDescription { ButtonDesc = new ButtonDescription { Name = "Middle", Id = (int)Fusee.Engine.Common.MouseButtons.Middle }, PollButton = false }; _btnRightDesc = new ButtonImpDescription { ButtonDesc = new ButtonDescription { Name = "Right", Id = (int)Fusee.Engine.Common.MouseButtons.Right }, PollButton = false }; _wheelAxisDescription = new AxisImpDescription { AxisDesc = new AxisDescription { Name = "Wheel", Id = (int)MouseAxes.Wheel, Direction = AxisDirection.Z, Nature = AxisNature.Position, Bounded = AxisBoundedType.Unbound, MinValueOrAxis = float.NaN, MaxValueOrAxis = float.NaN }, // PollAxis = true PollAxis = false }; }
/// <summary> /// Creates a new mouse input device instance using an existing <see cref="View"/>. /// </summary> /// <param name="View">The game window providing mouse input.</param> public MouseDeviceImp(View view) { _view = (AndroidGameView)view; /* TODO * _View.Mouse.ButtonDown += OnGameWinMouseDown; * _View.Mouse.ButtonUp += OnGameWinMouseUp; */ _btnLeftDesc = new ButtonImpDescription { ButtonDesc = new ButtonDescription { Name = "Left", Id = (int)MouseButtons.Left }, PollButton = false }; _btnMiddleDesc = new ButtonImpDescription { ButtonDesc = new ButtonDescription { Name = "Middle", Id = (int)MouseButtons.Middle }, PollButton = false }; _btnRightDesc = new ButtonImpDescription { ButtonDesc = new ButtonDescription { Name = "Right", Id = (int)MouseButtons.Right }, PollButton = false }; }
/// <summary> /// Implements a touch device for windows. /// </summary> /// <param name="canvas"></param> public TouchDeviceImp(object canvas) { _canvas = canvas; ConnectCanvasEvents(); _tpAxisDescs = new Dictionary <int, AxisImpDescription>(_nTouchPointsSupported * 2 + 5); _activeTouchpoints = new Dictionary <int, int>(_nTouchPointsSupported); _tpAxisDescs[(int)TouchAxes.ActiveTouchpoints] = new AxisImpDescription { AxisDesc = new AxisDescription { Name = $"Active Touchpoints", Id = (int)TouchAxes.ActiveTouchpoints, Direction = AxisDirection.Unknown, Nature = AxisNature.Unknown, Bounded = AxisBoundedType.Unbound }, PollAxis = true }; _tpAxisDescs[(int)TouchAxes.MinX] = new AxisImpDescription { AxisDesc = new AxisDescription { Name = "MinX", Id = (int)TouchAxes.MinX, Direction = AxisDirection.X, Nature = AxisNature.Position, Bounded = AxisBoundedType.Unbound, MinValueOrAxis = float.NaN, MaxValueOrAxis = float.NaN }, PollAxis = true }; _tpAxisDescs[(int)TouchAxes.MaxX] = new AxisImpDescription { AxisDesc = new AxisDescription { Name = "MaxX", Id = (int)TouchAxes.MaxX, Direction = AxisDirection.X, Nature = AxisNature.Position, Bounded = AxisBoundedType.Unbound, MinValueOrAxis = float.NaN, MaxValueOrAxis = float.NaN }, PollAxis = true }; _tpAxisDescs[(int)TouchAxes.MinY] = new AxisImpDescription { AxisDesc = new AxisDescription { Name = "MinY", Id = (int)TouchAxes.MinY, Direction = AxisDirection.Y, Nature = AxisNature.Position, Bounded = AxisBoundedType.Unbound, MinValueOrAxis = float.NaN, MaxValueOrAxis = float.NaN }, PollAxis = true }; _tpAxisDescs[(int)TouchAxes.MaxY] = new AxisImpDescription { AxisDesc = new AxisDescription { Name = "MaxY", Id = (int)TouchAxes.MaxY, Direction = AxisDirection.Y, Nature = AxisNature.Position, Bounded = AxisBoundedType.Unbound, MinValueOrAxis = float.NaN, MaxValueOrAxis = float.NaN }, PollAxis = true }; for (var i = 0; i < _nTouchPointsSupported; i++) { int id = 2 * i + (int)TouchAxes.Touchpoint_0_X; _tpAxisDescs[id] = new AxisImpDescription { AxisDesc = new AxisDescription { Name = $"Touchpoint {id} X", Id = id, Direction = AxisDirection.X, Nature = AxisNature.Position, Bounded = AxisBoundedType.OtherAxis, MinValueOrAxis = (int)TouchAxes.MinX, MaxValueOrAxis = (int)TouchAxes.MaxX }, PollAxis = false }; id++; _tpAxisDescs[id] = new AxisImpDescription { AxisDesc = new AxisDescription { Name = $"Touchpoint {id} Y", Id = id, Direction = AxisDirection.Y, Nature = AxisNature.Position, Bounded = AxisBoundedType.OtherAxis, MinValueOrAxis = (int)TouchAxes.MinY, MaxValueOrAxis = (int)TouchAxes.MaxY }, PollAxis = false }; } _tpButtonDescs = new Dictionary <int, ButtonImpDescription>(_nTouchPointsSupported); for (var i = 0; i < _nTouchPointsSupported; i++) { int id = i + (int)TouchPoints.Touchpoint_0; _tpButtonDescs[id] = new ButtonImpDescription { ButtonDesc = new ButtonDescription() { Name = $"Touchpoint {i} Active", Id = id, }, PollButton = false }; } }
/// <summary> /// Initializes a new instance of the <see cref="MouseDeviceImp" /> class. /// </summary> /// <param name="canvas">The (javascript) canvas object.</param> public MouseDeviceImp(object canvas) { _currentMouseWheel = 0; _canvas = canvas; ConnectCanvasEvents(); _btnLeftDesc = new ButtonImpDescription { ButtonDesc = new ButtonDescription { Name = "Left", Id = (int)MouseButtons.Left }, PollButton = false }; _btnMiddleDesc = new ButtonImpDescription { ButtonDesc = new ButtonDescription { Name = "Middle", Id = (int)MouseButtons.Middle }, PollButton = false }; _btnRightDesc = new ButtonImpDescription { ButtonDesc = new ButtonDescription { Name = "Right", Id = (int)MouseButtons.Right }, PollButton = false }; _mouseXDesc = new AxisImpDescription { AxisDesc = new AxisDescription { Name = "X", Id = (int)MouseAxes.X, Direction = AxisDirection.X, Nature = AxisNature.Position, Bounded = AxisBoundedType.OtherAxis, MinValueOrAxis = (int)MouseAxes.MinX, MaxValueOrAxis = (int)MouseAxes.MaxX }, PollAxis = false }; _mouseYDesc = new AxisImpDescription { AxisDesc = new AxisDescription { Name = "Y", Id = (int)MouseAxes.Y, Direction = AxisDirection.Y, Nature = AxisNature.Position, Bounded = AxisBoundedType.OtherAxis, MinValueOrAxis = (int)MouseAxes.MinY, MaxValueOrAxis = (int)MouseAxes.MaxY }, PollAxis = false }; }
internal GamePadDeviceImp(GameWindow window, int deviceID = 0) { _gameWindow = window; DeviceID = deviceID; _btnADesc = new ButtonImpDescription { ButtonDesc = new ButtonDescription { Name = "GP A", Id = 0 }, PollButton = true }; _btnXDesc = new ButtonImpDescription { ButtonDesc = new ButtonDescription { Name = "GP X", Id = 1 }, PollButton = true }; _btnYDesc = new ButtonImpDescription { ButtonDesc = new ButtonDescription { Name = "GP Y", Id = 2 }, PollButton = true }; _btnBDesc = new ButtonImpDescription { ButtonDesc = new ButtonDescription { Name = "GP B", Id = 3 }, PollButton = true }; _btnStartDesc = new ButtonImpDescription { ButtonDesc = new ButtonDescription { Name = "GP Start", Id = 4 }, PollButton = true }; _btnSelectDesc = new ButtonImpDescription { ButtonDesc = new ButtonDescription { Name = "GP Back", Id = 5 }, PollButton = true }; _btnLeftDesc = new ButtonImpDescription { ButtonDesc = new ButtonDescription { Name = "GP left button", Id = 6 }, PollButton = true }; _btnRightDesc = new ButtonImpDescription { ButtonDesc = new ButtonDescription { Name = "GP right button", Id = 7 }, PollButton = true }; _btnL3Desc = new ButtonImpDescription { ButtonDesc = new ButtonDescription { Name = "GP L3 button", Id = 8 }, PollButton = true }; _btnR3Desc = new ButtonImpDescription { ButtonDesc = new ButtonDescription { Name = "GP R3 button", Id = 9 }, PollButton = true }; _dpadUpDesc = new ButtonImpDescription { ButtonDesc = new ButtonDescription { Name = "GP Dpad up", Id = 10 }, PollButton = true }; _dpadDownDesc = new ButtonImpDescription { ButtonDesc = new ButtonDescription { Name = "GP Dpad Down", Id = 11 }, PollButton = true }; _dpadLeftDesc = new ButtonImpDescription { ButtonDesc = new ButtonDescription { Name = "GP Dpad Left", Id = 12 }, PollButton = true }; _dpadRightDesc = new ButtonImpDescription { ButtonDesc = new ButtonDescription { Name = "GP Dpad Right", Id = 13 }, PollButton = true }; }