示例#1
0
        /// <summary>
        /// Configures this instance.
        /// </summary>
        private static void Configure()
        {
            IMouseEvents GlobalHook = Hook.GlobalEvents();

            GlobalHook.MouseDownExt += OnMouseClick;
            GlobalHook.MouseUpExt   += OnMouseClick;
        }
示例#2
0
        public void ListenToDevice(bool reversedAxis, GameProfile gameProfile)
        {
            _reverseAxis = reversedAxis;
            _gameProfile = gameProfile;

            if (_gameProfile.EmulationProfile == EmulationProfile.LuigisMansion)
            {
                _isLuigisMansion = true;
            }
            if (_gameProfile.EmulationProfile == EmulationProfile.StarTrekVoyager)
            {
                _isStarTrek = true;
            }

            _minX = _gameProfile.xAxisMin;
            _maxX = _gameProfile.xAxisMax;
            _minY = _gameProfile.yAxisMin;
            _maxY = _gameProfile.yAxisMax;

            _isFullScreen = _gameProfile.ConfigValues.Any(x => x.FieldName == "Windowed" && x.FieldValue == "0");
            _killListen   = false;
            _listenThread = new Thread(ListenThread);
            _listenThread.Start();
            _findWindowThread = new Thread(FindWindowThread);
            _findWindowThread.Start();
            _mGlobalHook            = Hook.GlobalEvents();
            _mGlobalHook.KeyDown   += MGlobalHookOnKeyDown;
            _mGlobalHook.KeyUp     += MGlobalHookOnKeyUp;
            _mouseEvents            = Hook.GlobalEvents();
            _mouseEvents.MouseMove += MouseEventsOnMouseMove;
            _mouseEvents.MouseDown += MouseEventOnMouseDown;
            _mouseEvents.MouseUp   += MouseEventsOnMouseUp;
        }
示例#3
0
        public TitleScene(GraphicsDevice graphicsDevice,
                          IContentProvider content,
                          IMouseEvents mouse,
                          IGameStateFactory gameStateFactory,
                          CImage img,
                          CSound snd,
                          WorldCollection worlds,
                          HighscoreCollection highscores,
                          BBXConfig config)
        {
            this.graphicsDevice   = graphicsDevice;
            this.content          = content;
            this.gameStateFactory = gameStateFactory;
            this.img         = img;
            this.snd         = snd;
            this.config      = config;
            this.spriteBatch = new SpriteBatch(graphicsDevice);

            this.random = new Random();

            this.worlds     = worlds;
            this.highscores = highscores;
            this.worlds.LoadWorlds(content);

            this.mouse = mouse;

            mouse.MouseMove += Mouse_MouseMove;
            mouse.MouseUp   += Mouse_MouseUp;

            keyboard          = new KeyboardEvents();
            keyboard.KeyDown += Keyboard_KeyDown;
            font              = new Font(img.Fonts.Default);
        }
示例#4
0
        public virtual MouseDownCommand CreateMouseDownCommand(IMouseEvents element)
        {
            MouseDownCommand command = new MouseDownCommand(element);

            OnCreateCommand(command);
            return(command);
        }
示例#5
0
 private void InitMouseHook()
 {
     globalHook            = Hook.GlobalEvents();
     globalHook.MouseMove += GlobalHook_MouseMove;
     appHook            = Hook.AppEvents();
     appHook.MouseDown += AppHook_MouseDown;
     appHook.MouseUp   += AppHook_MouseUp;
 }
示例#6
0
 private void UnregisterHookHandlers(IMouseEvents hook)
 {
     hook.MouseMoveExt         -= hook_MouseMove;
     hook.MouseClick           -= hook_MouseClick;
     hook.MouseDoubleClick     -= hook_MouseDoubleClick;
     hook.MouseDownExt         -= hook_MouseDown;
     hook.MouseUpExt           -= hook_MouseUp;
     hook.MouseWheelExt        -= hook_MouseWheel;
     hook.MouseDragStartedExt  -= hook_MouseDragStarted;
     hook.MouseDragFinishedExt -= hook_MouseDragFinished;
 }
示例#7
0
 public void MouseExit()
 {
     IsOver     = false;
     IsLeftDown = false;
     OnMouseExit();
     if (currentOver != null)
     {
         currentOver.MouseExit();
         currentOver = null;
     }
     current = null;
 }
示例#8
0
 public bool ConnectToDevice()
 {
     try
     {
         _hook = Hook.GlobalEvents();
         return(true);
     }
     catch (Exception ex)
     {
         Log?.Invoke(this, new Core.LogMessage(Core.LogLevel.Error, LogTags.Connection, "Failed to connect to device", ex));
         ConnectionError?.Invoke(this, ex);
     }
     return(false);
 }
示例#9
0
 public void ListenToDevice(bool reversedAxis)
 {
     _reverseAxis           = reversedAxis;
     _mGlobalHook           = Hook.GlobalEvents();
     _mGlobalHook.KeyDown  += MGlobalHookOnKeyDown;
     _mGlobalHook.KeyUp    += MGlobalHookOnKeyUp;
     mouseEvents            = Hook.GlobalEvents();
     mouseEvents.MouseMove += MouseEventsOnMouseMove;
     mouseEvents.MouseDown += MouseEventOnMouseDown;
     mouseEvents.MouseUp   += MouseEventsOnMouseUp;
     _killListen            = false;
     _listenThread          = new Thread(ListenThread);
     _listenThread.Start();
 }
示例#10
0
        public void StopListening()
        {
            if (_mouseEvents != null)
            {
                _mouseEvents.MouseMove -= MouseEventsOnMouseMove;
                _mouseEvents.MouseDown -= MouseEventOnMouseDown;
                _mouseEvents.MouseUp   -= MouseEventsOnMouseUp;
                _mouseEvents            = null;
            }

            if (_mGlobalHook != null)
            {
                _mGlobalHook.KeyDown -= MGlobalHookOnKeyDown;
                _mGlobalHook.KeyUp   -= MGlobalHookOnKeyUp;
                _mGlobalHook.Dispose();
                _mGlobalHook = null;
            }

            ReleaseCapture();
            _killListen = true;
        }
示例#11
0
        public void MouseMove(MouseButtons buttons, Vector2 mouse)
        {
            Position = mouse;
            var raycast = RayCast(mouse);

            if (raycast != null)
            {
                var mouseEvents = raycast.Object.GetService <IMouseEvents>();

                if (current != null && raycast != current)
                {
                    currentOver.MouseExit();
                    current = raycast;
                }

                if (mouseEvents != null)
                {
                    mouseEvents.MouseMove(buttons, (mouse - raycast.TopLeftPoint) / raycast.Scale);
                    if (currentOver != mouseEvents)
                    {
                        mouseEvents.MouseEnter();
                    }
                    currentOver = mouseEvents;
                    current     = raycast;
                }
            }
            else
            {
                if (currentOver != null)
                {
                    currentOver.MouseExit();
                    currentOver = null;
                }
                current = null;
            }

            OnMouseMove(buttons, mouse);
        }
示例#12
0
        public GameScene(GraphicsDevice graphicsDevice,
                         GameState gameState,
                         IMouseEvents mouse,
                         CImage img,
                         CSound snd,
                         BBXConfig config)
        {
            this.gameState      = gameState;
            this.graphicsDevice = graphicsDevice;
            this.mouse          = mouse;
            this.img            = img;
            this.snd            = snd;
            this.config         = config;
            this.spriteBatch    = new SpriteBatch(graphicsDevice);

            mouse.MouseMove += Mouse_MouseMove;
            mouse.MouseDown += Mouse_MouseDown;

            keyboard        = new KeyboardEvents();
            keyboard.KeyUp += Keyboard_KeyUp;

            InitializeLevel(true);
        }
示例#13
0
        /************************
        * Initializes the form *
        ************************/
        public Smiley()
        {
            // Load all of the frames for the animation
            loadFrames(120, 120);
            frame = startFrame;

            // Start up the form
            InitializeComponent();
            HandleCreated += Form1_HandleCreated;

            // Set up the hook
            hook            = Hook.GlobalEvents();
            hook.MouseMove += hook_MouseMove;

            // Update the region of the form every tick
            frameTimer.Interval = frameTickLength;
            frameTimer.Enabled  = true;
            frameTimer.Tick    += frameTick;

            // Update the game every tick
            tickTimer.Interval = gameTickLength;
            tickTimer.Enabled  = true;
            tickTimer.Tick    += gameTick;
        }
示例#14
0
 public MouseUpCommand(IMouseEvents element) : base(element)
 {
 }
示例#15
0
 public MouseCommand(IMouseEvents element)
 {
     Element = element;
 }