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


C# Device.SetDataFormat方法代码示例

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


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

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

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

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

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

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

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

示例8: xKeyboard

 public xKeyboard(Control Owner)
 {
     keyboard = new Device(SystemGuid.Keyboard);
     keyboard.SetDataFormat(DeviceDataFormat.Keyboard);
     keyboard.SetCooperativeLevel(Owner,
         CooperativeLevelFlags.Foreground |
         CooperativeLevelFlags.NonExclusive |
         CooperativeLevelFlags.NoWindowsKey);
     //keyboard.Acquire();
 }
开发者ID:andrewgbliss,项目名称:CS_DXMAN,代码行数:10,代码来源:xKeyboard.cs

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

示例10: _createDevice

        /// <summary>
        /// Creates the DIKeyboard device.
        /// </summary>
        protected override void _createDevice()
        {
            _device = new Device(SystemGuid.Keyboard);

            _device.SetDataFormat(DeviceDataFormat.Keyboard);
            _device.SetCooperativeLevel(
                _window,
                CooperativeLevelFlags.NonExclusive |
                CooperativeLevelFlags.NoWindowsKey |
                CooperativeLevelFlags.Foreground
                );
        }
开发者ID:soeminnminn,项目名称:BattleCity,代码行数:15,代码来源:DIKeyboard.cs

示例11: InputToolBox

        public InputToolBox(GraphicEngine GE)
        {
            GE_object = GE;
            try
            {
                KeyBoardDevice = new Microsoft.DirectX.DirectInput.Device(SystemGuid.Keyboard);
                KeyBoardDevice.SetDataFormat(DeviceDataFormat.Keyboard);
                KeyBoardDevice.Acquire();

                MouseDevice = new Device(SystemGuid.Mouse);
                MouseDevice.SetDataFormat(DeviceDataFormat.Mouse);
                MouseDevice.Acquire();
            }
            catch (DirectXException ex)
            {
                MessageBox.Show(ex.Message, ex.Source);
            }
        }
开发者ID:Behzadkhosravifar,项目名称:Museum-3D,代码行数:18,代码来源:InputToolBox.cs

示例12: DirectInputGamePad

 public DirectInputGamePad(Guid gamePadGuid)
 {
     Device = new Device(gamePadGuid);
     Device.SetDataFormat(DeviceDataFormat.Joystick);
     Device.Acquire();
 }
开发者ID:TryCatch22,项目名称:JoystickTest,代码行数:6,代码来源:DirectInputGamePad.cs

示例13: AddJoystickDevices

        private void AddJoystickDevices(IntPtr windowHandle)
        {
            DeviceList gameControllerList = Manager.GetDevices(DeviceClass.GameControl, EnumDevicesFlags.AttachedOnly);
            for (int i = 0; i < gameControllerList.Count; i++)
            {
                gameControllerList.MoveNext();
                DeviceInstance deviceInstance = (DeviceInstance)gameControllerList.Current;

                Device device = new Device(deviceInstance.InstanceGuid);

                if (device.DeviceInformation.ProductGuid != new Guid("0306057e-0000-0000-0000-504944564944") &&       // Wiimotes are excluded
                    !CheckIfDirectInputDeviceExists(device))
                {
                    device.SetCooperativeLevel(windowHandle, CooperativeLevelFlags.Background | CooperativeLevelFlags.NonExclusive);
                    device.SetDataFormat(DeviceDataFormat.Joystick);
                    device.Acquire();

                    JoystickInput input = new JoystickInput(device);
                    AddInputDevice(input);
                    input.InitCurrentlyInvokedInput();

                    InvokeNewInputDeviceEvent(input.DeviceInstanceId, input);
                }
            }
        }
开发者ID:ILOVEPIE,项目名称:AR.MinWin.Freeflight,代码行数:25,代码来源:InputManager.cs

示例14: AddKeyboardDevices

        private void AddKeyboardDevices(IntPtr windowHandle)
        {
            DeviceList keyboardControllerList = Manager.GetDevices(DeviceClass.Keyboard, EnumDevicesFlags.AttachedOnly);
            for (int i = 0; i < keyboardControllerList.Count; i++)
            {
                keyboardControllerList.MoveNext();
                DeviceInstance deviceInstance = (DeviceInstance)keyboardControllerList.Current;

                Device device = new Device(deviceInstance.InstanceGuid);

                if (!CheckIfDirectInputDeviceExists(device))
                {
                    device.SetCooperativeLevel(windowHandle, CooperativeLevelFlags.Background | CooperativeLevelFlags.NonExclusive);
                    device.SetDataFormat(DeviceDataFormat.Keyboard);
                    device.Acquire();

                    KeyboardInput input = new KeyboardInput(device);
                    AddInputDevice(input);
                    input.InitCurrentlyInvokedInput();

                    InvokeNewInputDeviceEvent(input.DeviceInstanceId, input);
                }
            }
        }
开发者ID:ILOVEPIE,项目名称:AR.MinWin.Freeflight,代码行数:24,代码来源:InputManager.cs

示例15: Init

        public static void Init(System.Windows.Forms.Control targetControl)
        {
            if (_Mouse == null)
                _Mouse = new Mouse();
            if (_EmptyState == null)
                _EmptyState = new Mouse();
            _Device = new Device(SystemGuid.Mouse);
            _Device.SetCooperativeLevel(targetControl, CooperativeLevelFlags.Foreground | CooperativeLevelFlags.NonExclusive);
            _Device.SetDataFormat(DeviceDataFormat.Mouse);
            targetControl.MouseMove += new MouseEventHandler(targetControl_MouseMove);

            try { _Device.Acquire(); }
            catch (DirectXException e) { Console.WriteLine(e.Message); }
        }
开发者ID:DJSymBiotiX,项目名称:MX-Engine,代码行数:14,代码来源:Input.cs


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