本文整理汇总了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();
}
示例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();
}
}
示例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"));
}
}
}
}
示例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);
//}
}
}
示例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;
}
}
示例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;
}
}
示例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();
}
示例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);
}
示例9: Create
public static void Create()
{
if (Program.Form == null || Program.Form.IsDisposed) return;
Device = new Device();
Device.SetCooperativeLevel(Program.Form, CooperativeLevel.Normal);
LoadSoundList();
}
示例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);
}
示例11: DxBeemEmitter
public DxBeemEmitter(Form parent)
{
if (device == null)
{
device = new Device();
device.SetCooperativeLevel(parent, CooperativeLevel.Priority);
}
}
示例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();
}
示例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);
}
示例14: getDev
public static Device getDev()
{
if (dev == null)
{
dev = new Device();
dev.SetCooperativeLevel(MainForm.me, CooperativeLevel.Priority);
}
return dev;
}
示例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();
}