private static void Main(string[] args) { SlimDX.DirectInput.DirectInput dinput = new SlimDX.DirectInput.DirectInput(); foreach (SlimDX.DirectInput.DeviceInstance device in dinput.GetDevices(SlimDX.DirectInput.DeviceClass.GameController, SlimDX.DirectInput.DeviceEnumerationFlags.AttachedOnly)) { DirectX.Joystick.onLog = logMessages; DirectX.Joystick.debug = false; joystick = new DirectX.Joystick(dinput, device); joystick.axisX.min = 1; joystick.axisX.max = 99; joystick.axisX.deadZone = 1800; joystick.axisX.saturation = 10000; joystick.axisY.min = 101; joystick.axisY.max = 199; joystick.axisY.deadZone = 1800; joystick.axisY.saturation = 10000; joystick.axisZ.min = 201; joystick.axisZ.max = 299; joystick.axisZ.deadZone = 1800; joystick.axisZ.saturation = 10000; joystick.axisRx.min = 301; joystick.axisRx.max = 399; joystick.axisRx.deadZone = 2000; joystick.axisRx.saturation = 10000; joystick.axisRy.min = 401; joystick.axisRy.max = 499; joystick.axisRy.deadZone = 2000; joystick.axisRy.saturation = 10000; joystick.axisRz.min = 501; joystick.axisRz.max = 599; joystick.axisRz.deadZone = 2000; joystick.axisRz.saturation = 10000; joystick.axisExtra.min = 601; joystick.axisExtra.max = 699; joystick.axisExtra.deadZone = 2000; joystick.axisExtra.saturation = 10000; joystick.setJoystickValues(); controlHelper = new controllHelper(joystick); joystick.start(); break; } Console.WriteLine("Press any key to exit"); Console.ReadKey(); }
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 ); }
/// <summary> /// キーボードを使用したい場合は実行してください /// その後GetKeyBoardでKeyboardを取得してください /// </summary> public static void SetupKeyboard() { if (IsUseKeyboard) { return; } // 参考サイト // http://io-fia.blogspot.com/2011/03/slimdxdirect2d.html _dxKeyboardInput = new SlimDX.DirectInput.DirectInput(); _keyboard = new SlimDX.DirectInput.Keyboard(_dxKeyboardInput); _keyboard.SetCooperativeLevel( SlimDXSketch.Instance.Handle, SlimDX.DirectInput.CooperativeLevel.Foreground | SlimDX.DirectInput.CooperativeLevel.Nonexclusive ); _keyboard.Properties.BufferSize = 4; }
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(); } }