static void SetupMouse() { _dxMouseInput = new SlimDX.DirectInput.DirectInput(); _mouse = new SlimDX.DirectInput.Mouse(_dxMouseInput); _mouse.Properties.BufferSize = 100; _mouse.SetCooperativeLevel(SlimDXSketch.Instance.Handle, SlimDX.DirectInput.CooperativeLevel.Foreground | SlimDX.DirectInput.CooperativeLevel.Nonexclusive ); }
public DMouse(SlimDX.DirectInput.Mouse mouse) { umouse = mouse; mouse.Acquire(); System.Threading.Thread mthread = new System.Threading.Thread(thetar); mthread.Start(); }
void thetar() { try { internform = new RenderForm("DirectX - SlimDX library"); Direct3D my3d = new Direct3D(); presentation = new PresentParameters(); presentation.BackBufferHeight = my3d.Adapters[0].CurrentDisplayMode.Height; presentation.BackBufferWidth = my3d.Adapters[0].CurrentDisplayMode.Width; presentation.DeviceWindowHandle = internform.Handle; presentation.Windowed = false; int adapter = 0; foreach (AdapterInformation et in my3d.Adapters) { if (et.Details.Description.ToLower().Contains("perfhud")) { adapter = et.Adapter; } } if (adapter == 0) { graphicsDevice = new Device(my3d, 0, DeviceType.Hardware, internform.Handle, CreateFlags.HardwareVertexProcessing, presentation); } else { //presentation.Windowed = true; //presentation.BackBufferHeight = internform.Height; //presentation.BackBufferWidth = internform.Width; graphicsDevice = new Device(my3d, adapter, DeviceType.Reference, internform.Handle, CreateFlags.HardwareVertexProcessing, presentation); } SlimDX.DirectInput.DirectInput input = new SlimDX.DirectInput.DirectInput(); SlimDX.DirectInput.Keyboard keyboard = new SlimDX.DirectInput.Keyboard(input); keyboard.SetCooperativeLevel(internform.Handle, SlimDX.DirectInput.CooperativeLevel.Foreground | SlimDX.DirectInput.CooperativeLevel.Exclusive); mboard = new DKeyboard(keyboard); SlimDX.DirectInput.Mouse mouse = new SlimDX.DirectInput.Mouse(input); mouse.SetCooperativeLevel(internform.Handle, SlimDX.DirectInput.CooperativeLevel.Foreground | SlimDX.DirectInput.CooperativeLevel.Nonexclusive); mmouse = new DMouse(mouse); tvent.Set(); MessagePump.Run(internform, messenger); } catch (Exception er) { inception = er; tvent.Set(); } }