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


C# Device.Acquire方法代码示例

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


在下文中一共展示了Device.Acquire方法的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: 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

示例3: Init_Joystick_Device

        public void Init_Joystick_Device()
        {
            //create joystick device.
            foreach (DeviceInstance di in Manager.GetDevices(DeviceClass.GameControl, EnumDevicesFlags.AttachedOnly))
            {
                Joystick        = new Device(di.InstanceGuid);
                break;
            }

            if (Joystick != null)
            {
                joystickStatus  = true;
            }

            //Set joystick axis ranges.
            foreach (DeviceObjectInstance doi in Joystick.Objects)
            {
                if ((doi.ObjectId & (int)DeviceObjectTypeFlags.Axis) != 0)
                {
                    Joystick.Properties.SetRange(ParameterHow.ById, doi.ObjectId, new InputRange(1, 126));
                }
            }

            //Set joystick axis mode absolute.
            Joystick.Properties.AxisModeAbsolute = true;
            //Joystick.SetCooperativeLevel(this, CooperativeLevelFlags.NonExclusive | CooperativeLevelFlags.Background);

            //Acquire devices for capturing.
            Joystick.Acquire();
        }
开发者ID:salih18200,项目名称:orcs,代码行数:30,代码来源:JoystickDevice.cs

示例4: Paddle

		public Paddle()
		{

			foreach(DeviceInstance di in Manager.GetDevices(DeviceClass.GameControl, EnumDevicesFlags.AttachedOnly))
			{
				paddleDevice = new Device(di.InstanceGuid);
				break;
			}

			if(paddleDevice != null)
			{
				try
				{
					paddleDevice.SetDataFormat(DeviceDataFormat.Joystick);
					paddleDevice.Acquire();
				}
				catch(InputException)
				{
					
				}
			}

			pollTimer = new System.Timers.Timer(1);
			pollTimer.Enabled = false;
			pollTimer.Elapsed += new System.Timers.ElapsedEventHandler(pollTimer_Elapsed);
			
		}
开发者ID:HosokawaKenchi,项目名称:powersdr-if-stage,代码行数:27,代码来源:paddle.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: 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

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

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

示例9: SlimDXKeyboard

        /// <summary>
        /// Initializes a new instance of the <see cref="SlimDXKeyboard"/> class.
        /// </summary>
        /// <param name="control">The control.</param>
        public SlimDXKeyboard(Control control)
        {
            var directInput = DirectInput.FromPointer(control.Handle);

            mKeyboard = new Device<KeyboardState>(directInput, SystemGuid.Keyboard);
            mKeyboard.SetCooperativeLevel(control,
                CooperativeLevel.Foreground | CooperativeLevel.Exclusive | CooperativeLevel.NoWinKey);

            mKeyboard.Acquire();
        }
开发者ID:Christof,项目名称:afterglow,代码行数:14,代码来源:SlimDXKeyboard.cs

示例10: MafiaInput

 public MafiaInput(Form form)
 {
     this.form = form;
     device = new Device(SystemGuid.Keyboard);
     device.Acquire();
     prevLeft = prevUp = prevRight = prevDown = false;
     prevEnter = prevSpace = false;
     prevAlt = false;
     prevEsc = false;
 }
开发者ID:sinshu,项目名称:mafia,代码行数:10,代码来源:MafiaInput.cs

示例11: SlimDXMouse

        /// <summary>
        /// Initializes a new instance of the <see cref="SlimDXMouse"/> class.
        /// </summary>
        /// <param name="control">The control.</param>
        public SlimDXMouse(Control control)
        {
            mAxesActions = new Dictionary<Axis, AxisAction>(3);
            var directInput = DirectInput.FromPointer(control.Handle);

            mMouse = new Device<MouseState>(directInput, SystemGuid.Mouse);
            mMouse.SetCooperativeLevel(control,
                CooperativeLevel.Foreground | CooperativeLevel.Exclusive);

            mMouse.Acquire();
        }
开发者ID:Christof,项目名称:afterglow,代码行数:15,代码来源:SlimDXMouse.cs

示例12: gamePad

 public gamePad(Guid gamepadInstanceGuid, bool autoPoll)
 {
     device = new Device(gamepadInstanceGuid);
     device.SetDataFormat(DeviceDataFormat.Joystick);
     if (autoPoll == true)//If autopoll is on then continuous poll the pad in a seperate thread and return the results every change
     {
         new Thread(new ThreadStart(PollPad)).Start();//Start polling gamepad for buttons
         device.SetEventNotification(gamePadUpdate);
     }
     device.Acquire();
 }
开发者ID:Tricon2-Elf,项目名称:DirectInputMapping,代码行数:11,代码来源:Gamepad.cs

示例13: Init

        public void Init(Control parent)
        {
            _keyboard = new Microsoft.DirectX.DirectInput.Device(SystemGuid.Keyboard);
            _keyboard.SetCooperativeLevel(parent, CooperativeLevelFlags.Background | CooperativeLevelFlags.NonExclusive);
            _keyboard.Acquire();

            _mouse = new Device(SystemGuid.Mouse);
            _mouse.SetCooperativeLevel(parent,
                CooperativeLevelFlags.NonExclusive |
                CooperativeLevelFlags.Background);

            _mouse.Acquire();
        }
开发者ID:dandonahoe,项目名称:galaxy-smash,代码行数:13,代码来源:Input.cs

示例14: DInputHook

        public DInputHook(IntPtr hWnd)
        {
            this.hWnd = hWnd;
            keyboard = new Device(SystemGuid.Keyboard);
            keyboardUpdated = new AutoResetEvent(false);
            keyboard.SetCooperativeLevel(hWnd, CooperativeLevelFlags.NonExclusive | CooperativeLevelFlags.Background);
            keyboard.SetEventNotification(keyboardUpdated);

            appShutdown = new ManualResetEvent(false);

            threadloop = new Thread(new ThreadStart(ThreadFunction));
            keyboard.Acquire();
            threadloop.Start();
        }
开发者ID:asuahsahua,项目名称:Google-Code-Clone,代码行数:14,代码来源:DInputHook.cs

示例15: Gamepad

		public Gamepad(Window wnd) {
			foreach (DeviceInstance instance in Manager.GetDevices(DeviceClass.GameControl, EnumDevicesFlags.AttachedOnly)) {
				_joystick = new Device(instance.InstanceGuid);
				break;
			}
			if (_joystick == null) {
				Tools.ShowMessage("No gamepad found!", MessageType.Error);
			}
			else {
				var helper = new WindowInteropHelper(wnd);
				_joystick.SetCooperativeLevel(helper.Handle, CooperativeLevelFlags.Background | CooperativeLevelFlags.NonExclusive);
				_joystick.Properties.BufferSize = 0x80;
				_joystick.Acquire();
				IsValid = true;
			}
		}
开发者ID:CyberFoxHax,项目名称:PCSXBonus,代码行数:16,代码来源:Gamepad.cs


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