Пример #1
0
 internal void UpdateAndDispatchMouseButton(eMouseButton button, bool isDown)
 {
     foreach (var receiver in _mouseButtonReceivers)
     {
         receiver.Invoke(button, isDown);
     }
 }
Пример #2
0
        private void HandleMouseButtonEvent(SDL.SDL_Event e)
        {
            bool         isDown = false;
            eMouseButton button = eMouseButton.Any;

            if (e.type == SDL.SDL_EventType.SDL_MOUSEBUTTONDOWN)
            {
                isDown = true;
            }

            if (e.button.button == SDL.SDL_BUTTON_LEFT)
            {
                button = eMouseButton.Left;
            }
            else if (e.button.button == SDL.SDL_BUTTON_MIDDLE)
            {
                button = eMouseButton.Middle;
            }
            else if (e.button.button == SDL.SDL_BUTTON_RIGHT)
            {
                button = eMouseButton.Right;
            }

            _input.MouseBindings.UpdateAndDispatchMouseButton(button, isDown);
        }
Пример #3
0
        public MacroEvent_Mouse(MouseEvent _event, eMouseButton _button)
        {
            Event = _event;
            Button = _button;

            INPUT keyInput = new INPUT();
            keyInput.type = 0;
            MOUSEINPUT mInput = new MOUSEINPUT();

            eMouseCommand command = eMouseCommand.Move;
            if (Button == eMouseButton.LDOWN) command = eMouseCommand.LDown;
            if (Button == eMouseButton.LUP) command = eMouseCommand.LUp;
            if (Button == eMouseButton.RDOWN) command = eMouseCommand.RDown;
            if (Button == eMouseButton.RUP) command = eMouseCommand.RUp;
            if (Button == eMouseButton.MWheel) command = eMouseCommand.MWheel;
            if (Button == eMouseButton.MHWheel) command = eMouseCommand.HWHeel;

            mInput.dx = 0;
            mInput.dy = 0;
            mInput.mouseData = Event.mouseData;
            mInput.time = 0;
            mInput.dwExtraInfo = Event.extraInfo;
            mInput.dwFlags = (uint)command;

            keyInput.iUinion.mi = mInput;

            InputList[0] = keyInput;

            inputSize = Marshal.SizeOf(InputList[0]);
        }
Пример #4
0
 void iButtonHandler.buttonUp(CPoint point, eMouseButton button, eMouseButtonsState bs)
 {
     if (button != this.button)
     {
         return;
     }
     prevPoint = null;
 }
Пример #5
0
        static public bool GetMouseButtonDown(eMouseButton button)
        {
            if (mbPaused)
            {
                return(false);
            }

            return(mButtonState[(int)button]);
        }
Пример #6
0
    //======================
    // AddInputHandler
    // Adds a hander for mouse button input
    //======================
    public static void AddInputHandler(eDeviceType dt, eMouseButton mouseButton,
                                       OnKeyDown onDown, OnKeyHeld onHeld, OnKeyUp onUp, int joystickNum = 0, bool exc = false)
    {
        KeyInfo k = new KeyInfo(dt, mouseButton, onDown, onHeld, onUp);

        k.WasDown   = GetMouseButton(mouseButton);
        k.exclusive = exc;

        InputMap[joystickNum].KeyInfos.Add(k);
    }
Пример #7
0
 void iButtonHandler.buttonDown(CPoint pos, eMouseButton changedButtons, eMouseButtonsState bs)
 {
     if (changedButtons == eMouseButton.Left)
     {
         anim.cancelDelta(this);
         prevMouse = pos;
         mouseVelocity.reset();
         mouseVelocity.add(pos, timeSource.messageTime);
     }
 }
Пример #8
0
        void iButtonHandler.buttonDown(CPoint point, eMouseButton button, eMouseButtonsState bs)
        {
            switch (button)
            {
            case eMouseButton.Left:
                playPause();
                return;

            case eMouseButton.Middle:
                mediaEngine.muted = !mediaEngine.muted;
                return;
            }
        }
Пример #9
0
        public MacroEvent_Mouse(MouseEvent _event, eMouseButton _button)
        {
            Event  = _event;
            Button = _button;

            INPUT keyInput = new INPUT();

            keyInput.type = 0;
            MOUSEINPUT mInput = new MOUSEINPUT();

            eMouseCommand command = eMouseCommand.Move;

            if (Button == eMouseButton.LDOWN)
            {
                command = eMouseCommand.LDown;
            }
            if (Button == eMouseButton.LUP)
            {
                command = eMouseCommand.LUp;
            }
            if (Button == eMouseButton.RDOWN)
            {
                command = eMouseCommand.RDown;
            }
            if (Button == eMouseButton.RUP)
            {
                command = eMouseCommand.RUp;
            }
            if (Button == eMouseButton.MWheel)
            {
                command = eMouseCommand.MWheel;
            }
            if (Button == eMouseButton.MHWheel)
            {
                command = eMouseCommand.HWHeel;
            }

            mInput.dx          = 0;
            mInput.dy          = 0;
            mInput.mouseData   = Event.mouseData;
            mInput.time        = 0;
            mInput.dwExtraInfo = Event.extraInfo;
            mInput.dwFlags     = (uint)command;

            keyInput.iUinion.mi = mInput;

            InputList[0] = keyInput;

            inputSize = Marshal.SizeOf(InputList[0]);
        }
Пример #10
0
        void upDown(int x, int y, eMouseButton changedButtons, eMouseButtonsState bs, bool down)
        {
            CPoint point = new CPoint(x, y);

            foreach (var kvp in buttonHandlers)
            {
                if (down)
                {
                    kvp.Key.buttonDown(point, changedButtons, bs);
                }
                else
                {
                    kvp.Key.buttonUp(point, changedButtons, bs);
                }
            }
        }
Пример #11
0
 // mouse button constructor
 public KeyInfo(eDeviceType inDeviceType,
                eMouseButton inMouseButton,
                OnKeyDown inDownHandler,
                OnKeyHeld inHeldHandler,
                OnKeyUp inUpHandler)
 {
     DeviceType     = inDeviceType;
     KeyName        = "Mouse Button " + (int)inMouseButton;
     MouseButton    = inMouseButton;
     JoystickButton = OVRGamepadController.Button.None;
     JoystickAxis   = OVRGamepadController.Axis.None;
     Threshold      = 1000.0f;
     WasDown        = false;
     DownHandler    = inDownHandler;
     HeldHandler    = inHeldHandler;
     UpHandler      = inUpHandler;
 }
Пример #12
0
        void iButtonHandler.buttonUp(CPoint pos, eMouseButton changedButtons, eMouseButtonsState bs)
        {
            if (changedButtons == eMouseButton.Left)
            {
                acceleration = Vector3.Zero;
                prevMouse    = null;

                mouseVelocity.add(pos, timeSource.messageTime);
                Vector2?velOrNull = mouseVelocity.compute();
                if (velOrNull.HasValue)
                {
                    Vector2 velocity = velOrNull.Value;
                    velocity     /= new Vector2(content.swapChainSize.cx, content.swapChainSize.cy);
                    this.velocity = new Vector3(-velocity.Y, 0, -velocity.X);
                }
                anim.startDelta(this);
            }
        }
Пример #13
0
        private IntPtr MouseEventCallback(int nCode, IntPtr wParam, IntPtr lParam)
        {
            if (!(nCode < 0))
            {
                lock (this)
                {
                    eMouseButton button = (eMouseButton)wParam;
                    if (button == eMouseButton.MOVE && !AcceptMouseMovement && mouseDelayEnabled)
                    {
                        return(WinApi.CallNextHookEx(MouseHook, nCode, wParam, lParam));
                    }

                    MouseEvent eventData = (MouseEvent)Marshal.PtrToStructure(lParam, typeof(MouseEvent));
                    DateTime   cTime     = DateTime.Now;
                    int        delay     = (cTime - delayBegin).Milliseconds;

                    MacroEvent_Delay dEvent = new MacroEvent_Delay(delay);
                    MacroEvent_Mouse mEvent = new MacroEvent_Mouse(eventData, button);

                    if (PopulateInternalEventList)
                    {
                        EventList.Add(dEvent);
                        EventList.Add(mEvent);
                    }

                    if (OnEvent != null)
                    {
                        OnEvent(dEvent);
                        OnEvent(mEvent);
                    }


                    AcceptMouseMovement = false;
                    delayBegin          = cTime;
                }
            }
            return(WinApi.CallNextHookEx(MouseHook, nCode, wParam, lParam));
        }
Пример #14
0
 //======================
 // GetMouseButton
 // Returns true if the specified mouse button is pressed.
 //======================
 public static bool GetMouseButton(eMouseButton button)
 {
     return(Input.GetMouseButton((int)button));
 }
Пример #15
0
 //======================
 // AddInputHandler
 // Adds a hander for mouse button input
 //======================
 public static void AddInputHandler(eDeviceType dt, eMouseButton mouseButton,
                                    OnKeyDown onDown, OnKeyHeld onHeld, OnKeyUp onUp)
 {
     KeyInfos.Add(new KeyInfo(dt, mouseButton, onDown, onHeld, onUp));
 }
Пример #16
0
 void iButtonHandler.buttonUp(CPoint point, eMouseButton button, eMouseButtonsState bs)
 {
 }
Пример #17
0
        private void loadAMacroToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string filePath = string.Empty;

            using (OpenFileDialog ofd = new OpenFileDialog())
            {
                ofd.Filter = "Macro File|*.bmr";
                if (ofd.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                {
                    return;
                }
                filePath = ofd.FileName;
            }
            try
            {
                IMacroEvent[] loadedEvents = null;
                using (FileStream fs = new FileStream(filePath, FileMode.Open))
                    using (BinaryReader br = new BinaryReader(fs))
                    {
                        loadedEvents = new IMacroEvent[br.ReadInt32()];
                        int eventIndex = 0;
                        while (fs.Position != fs.Length)
                        {
                            MacroEventType mType = (MacroEventType)br.ReadByte();
                            if (mType == MacroEventType.Delay)
                            {
                                loadedEvents[eventIndex] = new MacroEvent_Delay(br.ReadInt32());
                            }

                            if (mType == MacroEventType.Keyboard)
                            {
                                eKeyboardEvent kbEvent   = (eKeyboardEvent)br.ReadInt32();
                                KeyboardEvent  eventData = new KeyboardEvent();
                                eventData.vKeyCode       = br.ReadUInt32();
                                eventData.scanCode       = br.ReadUInt32();
                                eventData.Flags          = br.ReadUInt32();
                                eventData.Time           = 0;
                                eventData.dwExtraInfo    = WinApi.GetMessageExtraInfo();
                                loadedEvents[eventIndex] = new MacroEvent_Keyboard(kbEvent, eventData);
                            }

                            if (mType == MacroEventType.Mouse)
                            {
                                eMouseButton mButton = (eMouseButton)br.ReadInt32();
                                MouseEvent   mEvent  = new MouseEvent();
                                mEvent.mouseData         = br.ReadUInt32();
                                mEvent.Location          = new mPoint();
                                mEvent.Location.X        = br.ReadInt32();
                                mEvent.Location.Y        = br.ReadInt32();
                                mEvent.Flags             = br.ReadUInt32();
                                loadedEvents[eventIndex] = new MacroEvent_Mouse(mEvent, mButton);
                            }
                            eventIndex++;
                        }
                    }
                ClearCurrent();
                foreach (IMacroEvent lEvent in loadedEvents)
                {
                    AddEvent(lEvent);
                }
                MessageBox.Show("Loaded successfully");
            }
            catch
            {
                MessageBox.Show("Failed to load macro.");
            }
        }
Пример #18
0
 void iMouseHandler.buttonDown(int x, int y, eMouseButton changedButtons, eMouseButtonsState bs) =>
 logInfo("{0} button down at {1}, {2}, state {3}", changedButtons, x, y, bs);
Пример #19
0
 //======================
 // GetMouseButton
 // Returns true if the specified mouse button is pressed.
 //======================
 public static bool GetMouseButton( eMouseButton button )
 {
     return Input.GetMouseButton( (int)button );
 }
Пример #20
0
 void iMouseHandler.buttonUp(int x, int y, eMouseButton changedButtons, eMouseButtonsState bs)
 {
     upDown(x, y, changedButtons, bs, false);
 }
Пример #21
0
 /// <summary>Construct for the specified mouse button, unscaled</summary>
 public MouseDragEvent(eMouseButton button) :
     this(button, 1)
 {
 }
Пример #22
0
 void iMouseHandler.buttonDown(int x, int y, eMouseButton changedButtons, eMouseButtonsState bs)
 {
     Console.WriteLine("MousePrinter.buttonDown {0} {1} {2} {3}", x, y, changedButtons, bs);
 }
Пример #23
0
        void clearStateBit(eMouseButton button)
        {
            int bit = (1 << (byte)button);

            buttonsState &= (~(eMouseButtonsState)bit);
        }
Пример #24
0
        void setStateBit(eMouseButton button)
        {
            int bit = (1 << (byte)button);

            buttonsState |= (eMouseButtonsState)bit;
        }
Пример #25
0
 public extern static bool IsMouseButtonPressed(eMouseButton MouseButton);
Пример #26
0
        // mouse button constructor
        public KeyInfo( eDeviceType inDeviceType, 
						eMouseButton inMouseButton,
						OnKeyDown inDownHandler, 
						OnKeyHeld inHeldHandler, 
						OnKeyUp inUpHandler )
        {
            DeviceType = inDeviceType;
                    KeyName = "Mouse Button " + (int)inMouseButton;
                    MouseButton = inMouseButton;
                    JoystickButton = OVRGamepadController.Button.None;
                    JoystickAxis = OVRGamepadController.Axis.None;
                    Threshold = 1000.0f;
                    WasDown = false;
                    DownHandler = inDownHandler;
                    HeldHandler = inHeldHandler;
                    UpHandler = inUpHandler;
        }
Пример #27
0
 MouseDragEvent(eMouseButton button, float scaling)
 {
     this.button = button;
     buttonBit   = (eMouseButtonsState)(1 << (int)button);
     m_scaling   = new Vector2(scaling);
 }
Пример #28
0
        // joystick axis constructor
        public KeyInfo( eDeviceType inDeviceType, 
						OVRGamepadController.Axis inJoystickAxis,
						OnKeyDown inDownHandler, 
						OnKeyHeld inHeldHandler, 
						OnKeyUp inUpHandler )
        {
            DeviceType = inDeviceType;
                    KeyName = OVRGamepadController.AxisNames[(int)inJoystickAxis];
                    MouseButton = eMouseButton.None;
                    JoystickButton = OVRGamepadController.Button.None;
                    JoystickAxis = inJoystickAxis;
                    Threshold = 0.5f;
                    WasDown = false;
                    DownHandler = inDownHandler;
                    HeldHandler = inHeldHandler;
                    UpHandler = inUpHandler;
        }
Пример #29
0
 /// <summary>Construct for the specified mouse button, DPI-scaled</summary>
 public MouseDragEvent(eMouseButton button, double dpiScalingFactor) :
     this(button, (float)(1.0 / dpiScalingFactor))
 {
 }
Пример #30
0
    //======================
    // AddInputHandler
    // Adds a hander for mouse button input
    //======================
    public static void AddInputHandler( eDeviceType dt, eMouseButton mouseButton, 
			OnKeyDown onDown, OnKeyHeld onHeld, OnKeyUp onUp )
    {
        KeyInfos.Add( new KeyInfo( dt, mouseButton, onDown, onHeld, onUp ) );
    }