public override void Dispose() { if (mouse != null) mouse.Unacquire(); mouse = null; directInput = null; }
public Game() { renderForm = new RenderForm("D3D11 Planets"); renderForm.MouseMove += (object sender, System.Windows.Forms.MouseEventArgs e) => { realMousePos = new Vector2(e.Location.X, e.Location.Y); }; renderForm.WindowState = System.Windows.Forms.FormWindowState.Maximized; renderForm.AllowUserResizing = true; renderForm.ClientSizeChanged += (object sender, EventArgs e) => { resizePending = true; }; DInput.DirectInput directInput = new DInput.DirectInput(); keyboard = new DInput.Keyboard(directInput); mouse = new DInput.Mouse(directInput); keyboard.Acquire(); mouse.Acquire(); renderer = new Renderer(this, renderForm); Shaders.Load(renderer.Device, renderer.Context); Resources.Load(renderer.Device); Initialize(); }
/// <summary> /// ctor and init /// </summary> /// <param name="device">A DXInput device</param> /// <param name="hwnd">The WinHandle of the main window</param> public MouseCls(SharpDX.DirectInput.Mouse device, Control hwnd) { log.DebugFormat("MouseCls cTor - Entry with {0}", device.Information.ProductName); m_device = device; m_hwnd = hwnd; Activated_low = false; m_senseLimit = AppConfiguration.AppConfig.msSenseLimit; // can be changed in the app.config file if it is still too little // Set BufferSize in order to use buffered data. m_device.Properties.BufferSize = 128; log.Debug("Get Mouse Object"); try { // Set the data format to the c_dfDIJoystick pre-defined format. //m_device.SetDataFormat( DeviceDataFormat.Joystick ); // Set the cooperative level for the device. m_device.SetCooperativeLevel(m_hwnd, CooperativeLevel.NonExclusive | CooperativeLevel.Background); // Enumerate all the objects on the device. } catch (Exception ex) { log.Error("Get Mouse Object failed", ex); } MouseCls.RegisteredDevices++; Activated_low = true; }
protected override void Initialize() { MouseState.Clear(); this._mouse = new SharpDX.DirectInput.Mouse(this._directInput); this._mouse.Properties.AxisMode = MDI.DeviceAxisMode.Relative; this._window = ((DirectXInputManager)Creator).WindowHandle; if (this._coopSettings != 0) { this._mouse.SetCooperativeLevel(this._window, this._coopSettings); } if (IsBuffered) { this._mouse.Properties.BufferSize = BufferSize; } try { this._mouse.Acquire(); } catch (Exception e) { throw new Exception("Failed to acquire mouse using DirectInput.", e); } hide(this._hideMouse); }
public SpriteWindow() { Keyboard = new DirectInput.Keyboard(DirectInput); Keyboard.Acquire(); Mouse = new DirectInput.Mouse(DirectInput); Mouse.Acquire(); }
public Mouse(DirectInput DirectInput) { _Mouse = new SharpDX.DirectInput.Mouse(DirectInput); _Mouse.Acquire(); UpdateMouseState(); UpdateMouseState(); }
public void Dispose() { if (mouse != null) { mouse.Unacquire(); mouse.Dispose(); mouse = null; } }
public override void Dispose() { if (mouse != null) { mouse.Unacquire(); } mouse = null; directInput = null; }
public SharpDXMouse(CursorPositionTranslater positionTranslater) { this.positionTranslater = positionTranslater; mouseCounter = new MouseDeviceCounter(); directInput = new DInput.DirectInput(); mouse = new DInput.Mouse(directInput); mouse.Properties.AxisMode = DInput.DeviceAxisMode.Absolute; mouse.Acquire(); currentState = new DInput.MouseState(); }
public SharpDXMouse(Window window) { positionTranslater = new CursorPositionTranslater(window); mouseCounter = new MouseDeviceCounter(); directInput = new DInput.DirectInput(); mouse = new DInput.Mouse(directInput); mouse.Properties.AxisMode = DInput.DeviceAxisMode.Absolute; mouse.Acquire(); currentState = new DInput.MouseState(); }
internal Mouse(Form form, DMouse mouse) { System.Diagnostics.Debug.Assert(form != null); System.Diagnostics.Debug.Assert(mouse != null); _dMouse = mouse; _form = form; _inputState = MouseInput.CreateEmpty(); _currentPressedButtons = new List<MouseButton>(5); _lastPressedButtons = new List<MouseButton>(5); (_timer = new GameTimer()).Start(); _currentState = new MouseState(); }
public override void Stop() { SF = null; if (mouseDevice != null) { mouseDevice.Unacquire(); mouseDevice.Dispose(); mouseDevice = null; } if (directInputInstance != null) { directInputInstance.Dispose(); directInputInstance = null; } }
public InputDeviceMouse(DirectInput di, DeviceInstance d) { // those silly foreign people call mouse something other than it in english, so we need to fix it to english msi = new InputDeviceIdentity() { Instanceguid = d.InstanceGuid, Productguid = d.ProductGuid, Name = "Mouse" }; mouse = new SharpDX.DirectInput.Mouse(di); mouse.SetNotification(eventhandle); mouse.Acquire(); Capabilities c = mouse.Capabilities; butstate = new bool[c.ButtonCount]; }
//*******************************************************// // METHODS // //*******************************************************// public static void Initialize() { if (IsInitialized) return; _DirectInput = new DirectInput(); _Mouse = new SharpDX.DirectInput.Mouse(_DirectInput); _Mouse.Properties.AxisMode = DeviceAxisMode.Relative; try { _Mouse.Acquire(); } catch (SharpDX.SharpDXException) { Console.WriteLine("Error: Failed to aquire mouse !"); return; } IsInitialized = true; }
public override Action Start() { IntPtr handle = Process.GetCurrentProcess().MainWindowHandle; mouseDevice = new SharpDX.DirectInput.Mouse(directInputInstance); if (mouseDevice == null) { throw new Exception("Failed to create mouse device"); } mouseDevice.SetCooperativeLevel(handle, CooperativeLevel.Background | CooperativeLevel.NonExclusive); mouseDevice.Properties.AxisMode = DeviceAxisMode.Relative; // Get delta values mouseDevice.Acquire(); getPressedStrategy = new GetPressedStrategy <int>(IsDown); setPressedStrategy = new SetPressedStrategy <int>(SetButtonDown, SetButtonUp); OnStarted(this, new EventArgs()); return(null); }
protected override void Dispose(bool disposeManagedResources) { if (!IsDisposed) { if (disposeManagedResources) { // Dispose managed resources. if (this._mouse != null) { try { this._mouse.Unacquire(); } catch { // NOTE : This is intentional } finally { this._mouse.Dispose(); this._mouse = null; } } ((DirectXInputManager)Creator).ReleaseDevice <Mouse>(this._msInfo); } // There are no unmanaged resources to release, but // if we add them, they need to be released here. Log.Debug("DirectXMouse device disposed."); } // If it is available, make the call to the // base class's Dispose(Boolean) method base.Dispose(disposeManagedResources); }
private void _initializeInputs() { Console.Write("Initializing inputs... "); _directInput = ToDispose<DirectInput>(new DirectInput()); _dKeyboard = ToDispose<DKeyboard>(new DKeyboard(_directInput)); _dKeyboard.Properties.BufferSize = 256; _dKeyboard.SetCooperativeLevel(_form, CooperativeLevel.Foreground | CooperativeLevel.Exclusive); Keyboard = new Keyboard(_dKeyboard); _dMouse = ToDispose<DMouse>(new DMouse(_directInput)); _dMouse.Properties.AxisMode = DeviceAxisMode.Relative; _dMouse.SetCooperativeLevel(_form, CooperativeLevel.Foreground | CooperativeLevel.NonExclusive); Mouse = new Mouse(_form, _dMouse); Console.WriteLine("done."); }