当前位置: 首页>>代码示例>>C#>>正文


C# MouseState.GetMouseButtons方法代码示例

本文整理汇总了C#中MouseState.GetMouseButtons方法的典型用法代码示例。如果您正苦于以下问题:C# MouseState.GetMouseButtons方法的具体用法?C# MouseState.GetMouseButtons怎么用?C# MouseState.GetMouseButtons使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MouseState的用法示例。


在下文中一共展示了MouseState.GetMouseButtons方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FrameMoveMouse

        private void FrameMoveMouse()
        {
            _mouseState = _mouse.CurrentMouseState;

            byte[] buttons = _mouseState.GetMouseButtons();
        }
开发者ID:dandonahoe,项目名称:galaxy-smash,代码行数:6,代码来源:Input.cs

示例2: Poll

        public void Poll()
        {
            LockMouse = false;
            try
            {
                CurrentMouseState = Device.CurrentMouseState;
                ButtonState = CurrentMouseState.GetMouseButtons();

                for (int i = 0; i < ButtonState.Length; i++)
                {
                    if (ButtonsHeld[i])
                        ButtonsPressed[i] = false;
                    else
                        ButtonsPressed[i] = (ButtonState[i] & 128) > 0;

                    ButtonsHeld[i] = (ButtonState[i] & 128) > 0;
                }
            }
            catch (NotAcquiredException)
            {
                try { _Device.Acquire(); }
                catch (Exception) { }
            }
            catch (InputException) { }
            catch (NullReferenceException) { }
        }
开发者ID:DJSymBiotiX,项目名称:MX-Engine,代码行数:26,代码来源:Input.cs

示例3: Update

            internal void Update(MouseState state)
            {
                m_x += state.X;
                m_y += state.Y;

                m_b = 0;
                byte[] buttonState = state.GetMouseButtons();
                if ((buttonState[0] & 0x80) != 0) m_b |= 1;
                if ((buttonState[1] & 0x80) != 0) m_b |= 2;
                if ((buttonState[2] & 0x80) != 0) m_b |= 4;
                if ((buttonState[3] & 0x80) != 0) m_b |= 8;
                if ((buttonState[4] & 0x80) != 0) m_b |= 16;
                if ((buttonState[5] & 0x80) != 0) m_b |= 32;
            }
开发者ID:bobsummerwill,项目名称:ZXMAK2,代码行数:14,代码来源:DirectMouse.cs

示例4: CaptureImmediateMouse

        /// <summary>
        ///		Takes a snapshot of the mouse state for immediate input checking.
        /// </summary>
        private void CaptureImmediateMouse()
        {
            // throw away the collection of buffered data
            if (useMouseEvents)
                mouseDevice.GetBufferedData();

            // capture the current mouse state
            mouseState = mouseDevice.CurrentMouseState;

            // store the updated absolute values
            mouseAbsX += mouseState.X;
            mouseAbsY += mouseState.Y;
            mouseAbsZ += mouseState.Z;

            // calc relative deviance from center
            mouseRelX = mouseState.X;
            mouseRelY = mouseState.Y;
            mouseRelZ = mouseState.Z;

            byte[] buttons = mouseState.GetMouseButtons();

            // clear the flags
            mouseButtons = 0;

            for(int i = 0; i < buttons.Length; i++) {
                if((buttons[i] & 0x80) != 0) {
                    mouseButtons |= (1 << i);
                }
            }
        }
开发者ID:ufosky-server,项目名称:MultiversePlatform,代码行数:33,代码来源:Win32InputReader.cs

示例5: Update

        public void Update()
        {
            do
            {
                // Try to get the current state
                try
                {
                    state = mouse.CurrentMouseState;

                    // if fetching the state is successful -> exit loop
                    break;
                }
                catch (InputException)
                {
                    // let the application handle Windows messages
                    Application.DoEvents();

                    // Try to get reacquire the keyboard
                    // and don't care about exceptions
                    try
                    {
                        mouse.Acquire();
                    }
                    catch (InputLostException)
                    {
                        continue;
                    }
                    catch(OtherApplicationHasPriorityException)
                    {
                        continue;
                    }
                }
            }
            while(true); // Do this until it's successful

            if(m_bWindowed)
            {
                m_XPos = Cursor.Position.X -  m_Owner.Left;
                m_YPos = Cursor.Position.Y - (m_Owner.Top + 23);
            }
            else
            {
                m_XPos += XDelta;
                m_YPos += YDelta;
            }

            byte[] btns = state.GetMouseButtons();
            for(int i = 0; i < btns.Length; i++)
            {
                if(btns[i] != 0)
                {
                    buttons[i] = true;
                }
                else
                {
                    buttons[i] = false;
                }
            }

            m_ObjectSpace = Vector3.Unproject(
                new Vector3(m_XPos, m_YPos, 0f),
                d3ddevice.Viewport, d3ddevice.Transform.Projection,
                d3ddevice.Transform.View, d3ddevice.Transform.World);

            m_ObjectSpace2 = Vector3.Unproject(
                new Vector3(m_XPos, m_YPos, 1f),
                d3ddevice.Viewport, d3ddevice.Transform.Projection,
                d3ddevice.Transform.View, d3ddevice.Transform.World);
        }
开发者ID:andrewgbliss,项目名称:CS_DXMAN,代码行数:69,代码来源:xMouse.cs


注:本文中的MouseState.GetMouseButtons方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。