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


C# Device.SetCooperativeLevel方法代码示例

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


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

示例1: CreateInputDevices

        protected void CreateInputDevices(Control target)
        {
            // create keyboard device.
            keyboard = new Device(SystemGuid.Keyboard);
            if (keyboard == null)
            {
                throw new Exception("No keyboard found.");
            }

            // create mouse device.
            mouse = new Device(SystemGuid.Mouse);
            if (mouse == null)
            {
                throw new Exception("No mouse found.");
            }

            // set cooperative level.
            keyboard.SetCooperativeLevel(target, CooperativeLevelFlags.NonExclusive | CooperativeLevelFlags.Background);

            mouse.SetCooperativeLevel(target, CooperativeLevelFlags.NonExclusive | CooperativeLevelFlags.Background);

            // Acquire devices for capturing.
            keyboard.Acquire();
            mouse.Acquire();
        }
开发者ID:sakseichek,项目名称:homm,代码行数:25,代码来源:Poller.cs

示例2: initiate

    private void initiate()

        {

             DeviceList gameControllerList = Manager.GetDevices(DeviceClass.GameControl, EnumDevicesFlags.AttachedOnly); //get a list of attached game controllers

             if (gameControllerList.Count > 0) //if there is a game controller then enter
             {
                 // Move to the first device

                 gameControllerList.MoveNext();
                 DeviceInstance deviceInstance = (DeviceInstance) //picks the first controller
                     gameControllerList.Current;

                 // create a device from this controller.

                 joystickDevice = new Device(deviceInstance.InstanceGuid);
                 joystickDevice.SetCooperativeLevel(this,CooperativeLevelFlags.Background |CooperativeLevelFlags.NonExclusive);

                 joystickDevice.SetDataFormat(DeviceDataFormat.Joystick);

                 // Finally, acquire the device.

                 joystickDevice.Acquire();


             }


       }
开发者ID:d3bd33p,项目名称:drone_2014,代码行数:30,代码来源:Form1.cs

示例3: SetupJoystick

		private void SetupJoystick()
		{
			DeviceList list = Manager.GetDevices(Microsoft.DirectX.DirectInput.DeviceType.Joystick, EnumDevicesFlags.AttachedOnly);
			System.Diagnostics.Debug.WriteLine(String.Format("Joystick list count: {0}", list.Count));
			if (list.Count > 0)
			{
				while (list.MoveNext())
				{
					// Move to the first device
					DeviceInstance deviceInstance = (DeviceInstance)list.Current;
					try
					{						
						// create a device from this controller.
						Device = new Device(deviceInstance.InstanceGuid);
						System.Diagnostics.Debug.WriteLine(String.Format("Device: {0} / {1}", Device.DeviceInformation.InstanceName, Device.DeviceInformation.ProductName));
						Device.SetCooperativeLevel(Game.Window.Handle, CooperativeLevelFlags.Background | CooperativeLevelFlags.Exclusive);
						// Tell DirectX that this is a Joystick.
						Device.SetDataFormat(DeviceDataFormat.Joystick);
						// Finally, acquire the device.	
						Device.Acquire();
						System.Diagnostics.Debug.WriteLine(String.Format("Device acquired"));
						break;
					}
					catch
					{						
						Device = null;
						System.Diagnostics.Debug.WriteLine(String.Format("Device acquire or data format setup failed"));
					}
				}
			}
		}
开发者ID:jairov4,项目名称:WingZero,代码行数:31,代码来源:JoystickController.cs

示例4: Input

        public Input(Control parentWindow)
        {
            // detect all available devices
            foreach (DeviceInstance di in Manager.GetDevices(DeviceClass.All, EnumDevicesFlags.AllDevices))
            {
                if (di.DeviceType == DeviceType.Keyboard)
                {
                    Keyboard = new Device(di.InstanceGuid);
                    Keyboard.SetDataFormat(DeviceDataFormat.Keyboard);
                    Keyboard.SetCooperativeLevel(parentWindow, CooperativeLevelFlags.Foreground | CooperativeLevelFlags.NonExclusive);
                }
                else if (di.DeviceType == DeviceType.Mouse)
                {
                    Mouse = new Device(di.InstanceGuid);
                    Mouse.SetDataFormat(DeviceDataFormat.Mouse);
                    Mouse.SetCooperativeLevel(parentWindow, CooperativeLevelFlags.Foreground | CooperativeLevelFlags.NonExclusive);
                }
                else if (di.DeviceType == DeviceType.Joystick)
                {
                    Joystick = new Device(di.InstanceGuid);
                    Joystick.SetDataFormat(DeviceDataFormat.Joystick);
                    Joystick.SetCooperativeLevel(parentWindow, CooperativeLevelFlags.Foreground | CooperativeLevelFlags.NonExclusive);
                }
                //else if (di.DeviceType == DeviceType.Gamepad)
                //{
                //    Gamepad = new Device(di.InstanceGuid);

                //    // must manually specify a format when working with different gamepads...i think ;x
                //    DataFormat customFormat;

                //    Gamepad.SetDataFormat(customFormat);
                //    Gamepad.SetCooperativeLevel(parentWindow, CooperativeLevelFlags.Foreground | CooperativeLevelFlags.NonExclusive);
                //}
            }
        }
开发者ID:CodeAsm,项目名称:open-sauce,代码行数:35,代码来源:Input.cs

示例5: InitDevices

        //Function of initialize device
        public static void InitDevices()
        {
            //create joystick device.
            foreach (DeviceInstance di in Manager.GetDevices(
                DeviceClass.GameControl,
                EnumDevicesFlags.AttachedOnly))
            {
                joystick = new Device(di.InstanceGuid);
                break;
            }
            if (joystick == null)
            {
                //Throw exception if joystick not found.
            }
            //Set joystick axis ranges.
            else {
                foreach (DeviceObjectInstance doi in joystick.Objects)
                {
                    if ((doi.ObjectId & (int)DeviceObjectTypeFlags.Axis) != 0)
                    {
                        joystick.Properties.SetRange(
                            ParameterHow.ById,
                            doi.ObjectId,
                            new InputRange(-5000, 5000));
                    }

                }
                joystick.Properties.AxisModeAbsolute = true;

                joystick.SetCooperativeLevel(null,CooperativeLevelFlags.NonExclusive | CooperativeLevelFlags.Background);
                //Acquire devices for capturing.
                joystick.Acquire();
                state = joystick.CurrentJoystickState;
            }
        }
开发者ID:eserozvataf,项目名称:itec316,代码行数:36,代码来源:joystick.cs

示例6: InputSystem

        public InputSystem(IntPtr hwnd)
        {
            try
            {
                // create the keyboard and mouse(very non-exclusively)
                keyboard = new Device(SystemGuid.Keyboard);
                keyboard.SetCooperativeLevel(hwnd, CooperativeLevelFlags.Background |
                    CooperativeLevelFlags.NonExclusive);

                mouse = new Device(SystemGuid.Mouse);
                mouse.SetCooperativeLevel(hwnd,  CooperativeLevelFlags.Background |
                    CooperativeLevelFlags.NonExclusive);
                mouse.SetDataFormat(DeviceDataFormat.Mouse);

                // attempt to acquire
                Acquire();

                // allocate space for device state
                keyboardState = new State[KEYBOARD_END + 1];
                mouseButtonState = new State[mouse.CurrentMouseState.GetMouseButtons().Length];
            }
            catch (InputException e)
            {
                Ymfas.Util.RecordException(e);
                throw;
            }
        }
开发者ID:andyhebear,项目名称:ymfas,代码行数:27,代码来源:InputSystem.cs

示例7: Load

		/// <summary>
		/// Plugin entry point 
		/// </summary>
		public override void Load() 
		{
			drawArgs = ParentApplication.WorldWindow.DrawArgs;
			DeviceList dl = Manager.GetDevices(DeviceClass.GameControl, EnumDevicesFlags.AttachedOnly);
			dl.MoveNext();
			if(dl.Current==null)
			{
				throw new ApplicationException("No joystick detected.  Please check your connections and verify your device appears in Control panel -> Game Controllers.");
			}
			DeviceInstance di = (DeviceInstance) dl.Current;
			joystick = new Device( di.InstanceGuid );
			joystick.SetDataFormat(DeviceDataFormat.Joystick);
			joystick.SetCooperativeLevel(ParentApplication,  
				CooperativeLevelFlags.NonExclusive | CooperativeLevelFlags.Background);
			foreach(DeviceObjectInstance d in joystick.Objects) 
			{
				// For axes that are returned, set the DIPROP_RANGE property for the
				// enumerated axis in order to scale min/max values.
				if((d.ObjectId & (int)DeviceObjectTypeFlags.Axis)!=0) 
				{
					// Set the AxisRange for the axis.
					joystick.Properties.SetRange(ParameterHow.ById, d.ObjectId, new InputRange(-AxisRange, AxisRange));
					joystick.Properties.SetDeadZone(ParameterHow.ById, d.ObjectId, 1000); // 10%
				}
			}

			joystick.Acquire();

			// Start a new thread to poll the joystick
			// TODO: The Device supports events, use them
			joyThread = new Thread( new ThreadStart(JoystickLoop) );
			joyThread.IsBackground = true;
			joyThread.Start();
		}
开发者ID:jpespartero,项目名称:WorldWind,代码行数:37,代码来源:Joystick.cs

示例8: InputClass

        public InputClass(Control owner)
        {
            this.owner = owner;

            localDevice = new Device(SystemGuid.Keyboard);
            localDevice.SetDataFormat(DeviceDataFormat.Keyboard);
            localDevice.SetCooperativeLevel(owner, CooperativeLevelFlags.Foreground | CooperativeLevelFlags.NonExclusive);
        }
开发者ID:timdetering,项目名称:BeginningNetGameProgramming,代码行数:8,代码来源:dinput.cs

示例9: Create

        public static void Create()
        {
            if (Program.Form == null || Program.Form.IsDisposed) return;

            Device = new Device();
            Device.SetCooperativeLevel(Program.Form, CooperativeLevel.Normal);
            LoadSoundList();
        }
开发者ID:Pete107,项目名称:Mir2,代码行数:8,代码来源:SoundManager.cs

示例10: InputDevices

 public InputDevices(Control parent)
 {
     parentWindow = parent;
     keyboard = new Device(SystemGuid.Keyboard);
     keyboard.SetCooperativeLevel(parent, CooperativeLevelFlags.Foreground | CooperativeLevelFlags.NonExclusive);
     mouse = new Device(SystemGuid.Mouse);
     mouse.SetCooperativeLevel(parent, CooperativeLevelFlags.Foreground | CooperativeLevelFlags.NonExclusive);
 }
开发者ID:DnikitaA,项目名称:Engine,代码行数:8,代码来源:InputDevices.cs

示例11: DxBeemEmitter

 public DxBeemEmitter(Form parent)
 {
     if (device == null)
     {
         device = new Device();
         device.SetCooperativeLevel(parent, CooperativeLevel.Priority);
     }
 }
开发者ID:tmokmss,项目名称:Morusu,代码行数:8,代码来源:DxBeemEmitter.cs

示例12: MouseInput

 public MouseInput(Control parent)
 {
     // Create our mouse device
     device = new Device(SystemGuid.Mouse);
     device.SetCooperativeLevel(parent, CooperativeLevelFlags.Background | CooperativeLevelFlags.NonExclusive);
     device.Properties.AxisModeAbsolute = false;
     device.Acquire();
 }
开发者ID:timdetering,项目名称:BeginningNetGameProgramming,代码行数:8,代码来源:MouseInput.cs

示例13: GameSound

 public GameSound(System.Windows.Forms.Control Owner)
 {
     _bufferDesc = new BufferDescription();
     _bufferDesc.GlobalFocus = true;
     _bufferDesc.Control3D = true;
     _soundDevice = new Device();
     _soundDevice.SetCooperativeLevel(Owner, CooperativeLevel.Normal);
 }
开发者ID:hassanmaher,项目名称:Pacman,代码行数:8,代码来源:GameSound.cs

示例14: getDev

 public static Device getDev()
 {
     if (dev == null)
     {
         dev = new Device();
         dev.SetCooperativeLevel(MainForm.me, CooperativeLevel.Priority);
     }
     return dev;
 }
开发者ID:winterheart,项目名称:game-utilities,代码行数:9,代码来源:SoundView.cs

示例15: KeyboardDevice

        /// <summary>
        /// Initializes a new instance of KeyboardDevice.
        /// </summary>
        public KeyboardDevice( Form form )
        {
            keyboard = new Device( SystemGuid.Keyboard );

            keyboard.SetCooperativeLevel( form, CooperativeLevelFlags.Background |
                CooperativeLevelFlags.NonExclusive );

            keyboard.Acquire();
        }
开发者ID:zpconn,项目名称:Gas,代码行数:12,代码来源:KeyboardDevice.cs


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