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


C# Mouse.SetCooperativeLevel方法代码示例

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


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

示例1: ZapperConnecter

 // TODO: Zapper with "Wild Gun Man" - The Gang Mode is not working !
 public ZapperConnecter(IntPtr handle, int winPosX, int winPosY, int videoW, int videoH)
 {
     this.scanlinesCount = 240;
     this.videoW = videoW;
     this.videoH = videoH;
     this.winPosX = winPosX;
     this.winPosY = winPosY;
     DirectInput di = new DirectInput();
     mouse = new Mouse(di);
     mouse.SetCooperativeLevel(handle, CooperativeLevel.Nonexclusive | CooperativeLevel.Foreground);
 }
开发者ID:ywjno,项目名称:mynes-code,代码行数:12,代码来源:ZapperConnecter.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: 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

示例5: Input

        public Input(Game game, IntPtr handle)
            : base(game, -10000)
        {
            _directInput = new DirectInput();
            _keyboard = new Keyboard(_directInput);
            _keyboard.Properties.BufferSize = 256;
            _keyboard.SetCooperativeLevel(handle, CooperativeLevel.Background | CooperativeLevel.NonExclusive);
            _mouse = new Mouse(_directInput);
            _mouse.Properties.AxisMode = DeviceAxisMode.Relative;
            _mouse.SetCooperativeLevel(handle, CooperativeLevel.Background | CooperativeLevel.NonExclusive);

            var devices  = _directInput.GetDevices(DeviceType.Gamepad, DeviceEnumerationFlags.AllDevices);
            if (devices.Count > 0)
            {
                _joystick = new Joystick(_directInput, devices[0].InstanceGuid);
                _joystick.SetCooperativeLevel(handle, CooperativeLevel.Background | CooperativeLevel.NonExclusive);
            }
        }
开发者ID:ndech,项目名称:PlaneSimulator,代码行数:18,代码来源:Input.cs

示例6: Initialize

 public static void Initialize(IntPtr handle)
 {
     try
     {
         m_directInput = new DirectInput();
         m_mouse = new Mouse(m_directInput);
         try
         {
             m_mouse.SetCooperativeLevel(handle, CooperativeLevel.Foreground | CooperativeLevel.NonExclusive);
         }
         catch
         {
             MyLog.Default.WriteLine("WARNING: DirectInput SetCooperativeLevel failed");
         }
     }
     catch (SharpDXException ex)
     {
         MyLog.Default.WriteLine("DirectInput initialization error: " + ex);
     }
 }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:20,代码来源:MyDirectInput.cs

示例7: 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

示例8: 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

示例9: SetupInput

        /// <summary>
        /// Initialize input methods and
        /// setup it's settings
        /// </summary>
        /// <param name="_control"></param>
        public void SetupInput(Control _control)
        {
            InputControl = _control;
            /// make sure that DirectInput has been initialized
            DirectInput dinput = new DirectInput();
            /// create the device
            try {
                g_keyboard = new Keyboard(dinput);
                g_keyboard.Properties.BufferSize = 256;

                g_keyboard.SetCooperativeLevel( _control,
                                                CooperativeLevel.Foreground |
                                                CooperativeLevel.NonExclusive |
                                                CooperativeLevel.NoWinKey);

                g_keyboard.Acquire();
            } catch (MarshalDirectiveException e) {
                MessageBox.Show(e.Message);
                return;
            }

            /// acquire the device
            Release_KeyBoard();

            /// setup Mouse
            dinput = new DirectInput();
            try {
                g_mouse = new Mouse(dinput);
                g_mouse.SetCooperativeLevel(_control,
                    CooperativeLevel.Exclusive | CooperativeLevel.Foreground);
            } catch (MarshalDirectiveException e) {
                MessageBox.Show(e.Message);
                return;
            }

            /// since we want to use buffered data,
            /// we need to tell DirectInput
            /// to set up a buffer for the data
            g_mouse.Properties.BufferSize = 10;

            /// acquire the device and release to OS
            Release_Mouse();
        }
开发者ID:fxbit,项目名称:FxGraphicsEngine,代码行数:48,代码来源:GraphicsEngine.cs


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