Ejemplo n.º 1
0
        public GameWindow()
        {
            InitializeComponent();
            Instance = this;
            Cursor.Hide();

            // Multi mouse input init
            InputDevice = new MultiDeviceInput.InputDevice(Handle);
            InputDevice.EnumerateDevices();
            InputDevice.MouseDown += new MultiDeviceInput.InputDevice.MouseEventHandler(_MouseDown);
            InputDevice.MouseMove += new MultiDeviceInput.InputDevice.MouseEventHandler(_MouseMove);
            InputDevice.MouseUp += new MultiDeviceInput.InputDevice.MouseEventHandler(_MouseUp);
            InputDevice.MouseWheel += new MultiDeviceInput.InputDevice.MouseEventHandler(_MouseWheel);

            foreach (var KvP in InputDevice.DeviceList)
            {
                MouseData NewMouse = new MouseData();
                NewMouse.PosX = Canvas.Width / 2;
                NewMouse.PosY = Canvas.Height / 2;
                NewMouse.Data = KvP.Value;
                Mouses.Add(KvP.Value.Info.deviceHandle, NewMouse);
            }
        }
Ejemplo n.º 2
0
        private void _MouseWheel(object sender, InputDevice.MouseControlEventArgs e)
        {
            if (Mouses.ContainsKey(e.DeviceData.Info.deviceHandle))
            {
                if (e.Wheel > 0)
                {
                    MouseEventWheelUp(this, Mouses[e.DeviceData.Info.deviceHandle]);
                }
                else if (e.Wheel < 0)
                {
                    MouseEventWheelDown(this, Mouses[e.DeviceData.Info.deviceHandle]);
                }

            }
        }
Ejemplo n.º 3
0
        private void _MouseMove(object sender, InputDevice.MouseControlEventArgs e)
        {
            if(Focused)Cursor.Position = new Point(Location.X + Width / 2, Location.Y + Height / 2);

            if (Mouses.ContainsKey(e.DeviceData.Info.deviceHandle))
            {
                // convert to absolute mouse cooridnates
                MouseData Current = Mouses[e.DeviceData.Info.deviceHandle];
                Current.PosX += e.DeltaX;
                Current.PosY += e.DeltaY;

                if (Current.PosX < 0) Current.PosX = 0;
                if (Current.PosY < 0) Current.PosY = 0;
                if (Current.PosX >= Canvas.Width) Current.PosX = Canvas.Width-1;
                if (Current.PosY >= Canvas.Height) Current.PosY = Canvas.Height - 1;
            }
        }
Ejemplo n.º 4
0
        private void _MouseUp(object sender, InputDevice.MouseControlEventArgs e)
        {
            if (!Mouses.ContainsKey(e.DeviceData.Info.deviceHandle))
            {
                MouseData NewMouse = new MouseData();
                NewMouse.PosX = Canvas.Width / 2;
                NewMouse.PosY = Canvas.Height / 2;
                NewMouse.Data = e.DeviceData;
                Mouses.Add(e.DeviceData.Info.deviceHandle, NewMouse);
            }

            if (Mouses.ContainsKey(e.DeviceData.Info.deviceHandle) && e.LeftButton)
            {
                MouseEventButtonUpLeft(this, Mouses[e.DeviceData.Info.deviceHandle]);
            }
            else if (e.RightButton)
            {
                MouseEventButtonUpRight(this, Mouses[e.DeviceData.Info.deviceHandle]);
            }
        }
Ejemplo n.º 5
0
 private void _MouseDown(object sender, InputDevice.MouseControlEventArgs e)
 {
     if (e.LeftButton)
     {
         MouseEventButtonDownLeft(this, Mouses[e.DeviceData.Info.deviceHandle]);
     }
     else if (e.RightButton)
     {
         MouseEventButtonDownRight(this, Mouses[e.DeviceData.Info.deviceHandle]);
     }
 }