public void Dispose() { keysDev.Unacquire(); keysDev.Dispose(); mouseDev.Unacquire(); mouseDev.Dispose(); }
internal void destroy() { keyboardDevice.Unacquire(); keyboardDevice.Dispose(); mouseDevice.Unacquire(); mouseDevice.Dispose(); }
protected void FreeDirectInput() { if (p_DInputDevice != null) { p_DInputDevice.Unacquire(); p_DInputDevice.Dispose(); p_DInputDevice = null; } }
static void FreeDirectInput() { if (null != mInputDevice) { mInputDevice.Unacquire(); mInputDevice.Dispose(); mInputDevice = null; } }
public void Release() { if (joystick != null) { joystick.Unacquire(); joystick.Dispose(); } joystick = null; isInitialized = false; // buttonMap.Clear(); }
private void FreeDirectInput() { if (this.mouse != null) { mouse.Unacquire(); mouse.Dispose(); mouse = null; } if (this.keyboard != null) { keyboard.Unacquire(); keyboard.Dispose(); keyboard = null; } }
protected void ProcessInputState() { foreach (Key k in kbd.GetPressedKeys()) { if (k == Key.Left) { //Turn counterclockwise angle -= spinRate; } if (k == Key.Right) { //turn clockwise angle += spinRate; } if (k == Key.Escape) { kbd.Unacquire(); //release the keyboard device kbd.Dispose(); Application.Exit(); } } }
protected void ProcessInputState(float delta) { foreach (Key k in kbd.GetPressedKeys()) { if (k == Key.Space && ship.Visible) { //Fire guns lastBullet += delta; if (lastBullet > bulletSpacing) { BulletSprite bullet = new BulletSprite(bulletTileSet); //Calculate bullet start position, outside ship boundaries float radAngle = Geometry.DegreeToRadian(ship.Angle); int yOffset = (int)(bulletFireRadius * Math.Sin((double)radAngle)); int xOffset = (int)(bulletFireRadius * Math.Cos((double)radAngle)); bullet.PositionY = (ship.PositionY) + shipTileSet.ExtentY + yOffset; //the -4 below is a small nudge to center up the bullets bullet.PositionX = (ship.PositionX) + shipTileSet.ExtentX + xOffset - 4; bullet.Angle = ship.Angle; bullet.Velocity = 150f; bullet.AnimationSpeed = 0f; bullet.CanCollide = true; bullet.LimitLifespan(2f); //only 2 seconds to live sm.AddSprite(bullet); lastBullet = 0f; if (totalScore > 0) { totalScore--; //lose a point for each bullet } shipSounds |= Sounds.ShipFire; } } if (k == Key.Left) { ship.PrevFrame(); } if (k == Key.Right) { ship.NextFrame(); } if (k == Key.Up) { ship.Thrust(); shipSounds |= Sounds.ShipThrust; } if (k == Key.Down) { //Put on the brakes! ship.VelocityX = 0f; ship.VelocityY = 0f; shipSounds |= Sounds.ShipBrake; } if (k == Key.Escape) { kbd.Unacquire(); //release the keyboard device kbd.Dispose(); Application.Exit(); } if (k == Key.Home) { //resets ship to starting position ship.PositionY = (float)this.Height / 2; ship.PositionX = (float)this.Width / 2; ship.VelocityX = 0f; ship.VelocityY = 0f; ship.Angle = 0.0f; ship.Frame = 10; } //if (k == Key.D) sm.ShowList(); } }
private void InitInputDevices() { //keyboard keyboard = new Device(SystemGuid.Keyboard); if (keyboard == null) { System.Windows.Forms.MessageBox.Show("No keyboard found.!"); throw new Exception("No keyboard found."); } //mouse mouse = new Device(SystemGuid.Mouse); if (mouse == null) { System.Windows.Forms.MessageBox.Show("No mouse found.!"); throw new Exception("No mouse found."); } //mouse.Properties.AxisModeAbsolute = true; //set cooperation keyboard.SetCooperativeLevel( this.windowControl, flags); mouse.SetCooperativeLevel( this.windowControl, flags); mouse.SetDataFormat(DeviceDataFormat.Mouse); keyboard.SetDataFormat(DeviceDataFormat.Keyboard); try { keyboard.Properties.BufferSize = BUFFER_SIZE; } catch (Exception ex) { Logging.Logger.AddWarning("CHYBA V INPUTU! Nepodarilo se nastavit velikost bufferu. " + ex.ToString()); throw; } //ziskat mys a klavesnici try { keyboard.Acquire(); mouse.Acquire(); } catch (InputException ex) { Logging.Logger.AddWarning("CHYBA V INPUTU! \nZkusim znovu ziskat input device jako sdileny\n" + ex.ToString()); try { keyboard.Unacquire(); mouse.Unacquire(); keyboard.SetCooperativeLevel( this.windowControl, CooperativeLevelFlags.NonExclusive | CooperativeLevelFlags.Background); mouse.SetCooperativeLevel( this.windowControl, CooperativeLevelFlags.NonExclusive | CooperativeLevelFlags.Background); keyboard.Acquire(); mouse.Acquire(); } catch (InputException iex) { Logging.Logger.AddError(" KRITICKA CHYBA V INPUTU!" + iex.ToString()); throw iex; } } }