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


C# Mouse.Acquire方法代码示例

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


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

示例1: Init

 public static void Init(Form mainWindow)
 {
     var dinput = new DirectInput();
     _keyboard = new Keyboard(dinput);
     _keyboard.Acquire();
     _mouse = new Mouse(dinput);
     _mouse.Acquire();
     dinput.Dispose();
     dinput = null;
 }
开发者ID:ericrrichards,项目名称:rts,代码行数:10,代码来源:Input.cs

示例2: Input

        public Input()
        {
            _directInput = new DirectInput();

            try
            {
                Result result;

                _keyboard = new Keyboard(_directInput);

                IntPtr handle = Engine.GameEngine.Window;

                if ((result = _keyboard.SetCooperativeLevel(handle, CooperativeLevel.Nonexclusive | CooperativeLevel.Background)) != ResultCode.Success)
                {
                    Engine.GameEngine.Exception.Exceptions.Add(new ExceptionData(result.Description,
                        result.Name, "keyboard cooperation"));
                }

                _mouse = new Mouse(_directInput);

                if ((result = _mouse.SetCooperativeLevel(handle, CooperativeLevel.Foreground | CooperativeLevel.Nonexclusive)) != ResultCode.Success)
                {
                    Engine.GameEngine.Exception.Exceptions.Add(new ExceptionData(result.Description,
                        result.Name, "mouse cooperation"));
                }

                if ((result = _keyboard.Acquire()) != ResultCode.Success)
                {
                    Engine.GameEngine.Exception.Exceptions.Add(new ExceptionData(result.Description,
                        result.Name, "keyboard acquire"));
                }

                if ((result = _mouse.Acquire()) != ResultCode.Success)
                {
                    Engine.GameEngine.Exception.Exceptions.Add(new ExceptionData(result.Description,
                        result.Name, "mouse acquire"));
                }

                Engine.GameEngine.Exception.Exceptions.Add(new ExceptionData("worked", "worked", "worked"));
            }
            catch (DirectInputException e)
            {
                Engine.GameEngine.Exception.Exceptions.Add(new ExceptionData(e.Message, e.Source, e.StackTrace));
            }
            catch (Exception e)
            {
                Engine.GameEngine.Exception.Exceptions.Add(new ExceptionData(e.Message, e.Source, e.StackTrace));
            }
            finally
            {
                Dispose();
            }
        }
开发者ID:senbeiwabaka,项目名称:MY3DEngine,代码行数:53,代码来源:Input.cs

示例3: CreateDevice

        void CreateDevice()
        {
            // make sure that DirectInput has been initialized
            DirectInput dinput = new DirectInput();

            // build up cooperative flags
            CooperativeLevel cooperativeLevel;

            if (exclusiveRadio.Checked)
                cooperativeLevel = CooperativeLevel.Exclusive;
            else
                cooperativeLevel = CooperativeLevel.Nonexclusive;

            if (foregroundRadio.Checked)
                cooperativeLevel |= CooperativeLevel.Foreground;
            else
                cooperativeLevel |= CooperativeLevel.Background;

            // create the device
            try
            {
                mouse = new Mouse(dinput);
                mouse.SetCooperativeLevel(this, cooperativeLevel);
            }
            catch (DirectInputException e)
            {
                MessageBox.Show(e.Message);
                return;
            }

            if (!immediateRadio.Checked)
            {
                // since we want to use buffered data, we need to tell DirectInput
                // to set up a buffer for the data
                mouse.Properties.BufferSize = 8;
            }

            // acquire the device
            mouse.Acquire();

            // set the timer to go off 12 times a second to read input
            // NOTE: Normally applications would read this much faster.
            // This rate is for demonstration purposes only.
            timer.Interval = 1000 / 12;
            timer.Start();
        }
开发者ID:zhandb,项目名称:slimdx,代码行数:46,代码来源:MainForm.cs

示例4: Input

        public Input(Form window)
        {
            _window = window;
            _di = new DirectInput();

            _keyboard = new Keyboard(_di);
            //_keyboard.SetCooperativeLevel(_window.Handle, CooperativeLevel.Background | CooperativeLevel.Nonexclusive);
            _keyboard.Acquire();
            Log.Info("Keyboard aquired");

            _mouse = new Mouse(_di);
            //_mouse.SetCooperativeLevel(_window.Handle, CooperativeLevel.Background | CooperativeLevel.Nonexclusive);
            _mouse.Acquire();
            Log.Info("Mouse aquired");

            _pressStamp = 0;
        }
开发者ID:ericrrichards,项目名称:fps,代码行数:17,代码来源:Input.cs

示例5: Start

        public override Action Start()
        {
            IntPtr handle = Process.GetCurrentProcess().MainWindowHandle;

            mouseDevice = new Mouse(directInputInstance);
            if (mouseDevice == null)
                throw new Exception("Failed to create mouse device");

            mouseDevice.SetCooperativeLevel(handle, CooperativeLevel.Background | CooperativeLevel.Nonexclusive);
            mouseDevice.Properties.AxisMode = DeviceAxisMode.Relative;   // Get delta values
            mouseDevice.Acquire();

            getButtonPressedStrategy = new GetPressedStrategy<int>(IsButtonDown);
            setButtonPressedStrategy = new SetPressedStrategy(SetButtonDown, SetButtonUp);
          
            OnStarted(this, new EventArgs());
            return null;
        }
开发者ID:tagaf,项目名称:FreePIE,代码行数:18,代码来源:MousePlugin.cs

示例6: Start

        //-----------------------------------------------------------------------
        public override System.Action Start()
        {
            IntPtr handle = Process.GetCurrentProcess().MainWindowHandle;

            MouseDevice = new Mouse(DirectInputInstance);
            if (MouseDevice == null)
                throw new Exception("Failed to create mouse device");

            MouseDevice.SetCooperativeLevel(handle, CooperativeLevel.Background | CooperativeLevel.Nonexclusive);
            MouseDevice.Properties.AxisMode = DeviceAxisMode.Relative;   // Get delta values
            MouseDevice.Acquire();

            OnStarted(this, new EventArgs());
            return null;
        }
开发者ID:zdam,项目名称:FreePIE,代码行数:16,代码来源:MousePlugin.cs

示例7: ModuleInit

        /// <summary>
        /// Initialize the input.
        /// </summary>
        public static void ModuleInit()
        {
            directInput = new DirectInput();
            keyboard = new Keyboard(directInput);
            keyboard.SetCooperativeLevel(Scene.Instance.GraphicsEngine.Form, CooperativeLevel.Nonexclusive | CooperativeLevel.Background);
            keyboard.Acquire();
            mouse = new Mouse(directInput);
            mouse.SetCooperativeLevel(Scene.Instance.GraphicsEngine.Form, CooperativeLevel.Nonexclusive | CooperativeLevel.Background);
            mouse.Acquire();

            s_lastFrameState = keyboard.GetCurrentState();
            s_thisState = s_lastFrameState;
            s_lastFrameMouseState = mouse.GetCurrentState();
            s_thisMouseState = s_lastFrameMouseState;
        }
开发者ID:crissian,项目名称:planets,代码行数:18,代码来源:Input.cs

示例8: Camera

        public Camera(Device device, float aspectRatio)
        {
            _globals = new Constants();
            _aspect = aspectRatio;
            _fov = 1.3f;
            View = Matrix.LookAtLH(new Vector3(0, 0, -20f), Vector3.Zero, Vector3.UnitY);
            SetPerspective();

            _device = device;
            //Projection = Matrix.PerspectiveFovLH(_fov, aspectRatio, 0.0001f, 100000);
            //Projection = Matrix.OrthoLH(10 * _aspect, 10, 0.0001f, 100000);

            var data = new DataStream(Marshal.SizeOf(typeof(Constants)), true, true);
            data.Write(_globals);
            data.Position = 0;

            _globalConstants = new Buffer(device, //Device
                data, //Stream
                Marshal.SizeOf(typeof(Constants)), // Size
                ResourceUsage.Default,
                BindFlags.ConstantBuffer,
                CpuAccessFlags.None,
                ResourceOptionFlags.None,
                64);

            device.ImmediateContext.PixelShader.SetConstantBuffer(_globalConstants, 0);

            DirectInput input = new DirectInput();
            keyboard = new Keyboard(input);
            mouse = new Mouse(input);
            keyboard.Acquire();
            mouse.Acquire();
            lastMouseX = Cursor.Position.X;
            lastMouseY = Cursor.Position.Y;

            ResetCamera();
        }
开发者ID:AnkeAnke,项目名称:FlowSharp,代码行数:37,代码来源:Camera.cs


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