public ScriptKeyboard(KeyboardPlugin plugin, ref int[] scan, ref SharpDX.DirectInput.KeyboardState keystate)
 {
     this.plugin   = plugin;
     this.scan     = scan;
     dico          = new Dictionary <int, bool>();
     this.keystate = keystate;
 }
        protected override void KeyKontroller(float time, SharpDX.DirectInput.KeyboardState kState)
        {
            float speed    = 0.001f;
            var   rotation = Matrix.Identity;
            var   scale    = Matrix.Identity;

            if (kState.IsPressed(SharpDX.DirectInput.Key.D))
            {
                rotation = Matrix.RotationY(speed * time);
            }
            if (kState.IsPressed(SharpDX.DirectInput.Key.A))
            {
                rotation = Matrix.RotationY(-speed * time);
            }
            if (kState.IsPressed(SharpDX.DirectInput.Key.W))
            {
                rotation = Matrix.RotationX(speed * time);
            }
            if (kState.IsPressed(SharpDX.DirectInput.Key.S))
            {
                rotation = Matrix.RotationX(-speed * time);
            }

            if (kState.IsPressed(SharpDX.DirectInput.Key.Up))
            {
                scale = Matrix.Scaling(System.Math.Max(0.1f, 1 - speed * time));
            }
            if (kState.IsPressed(SharpDX.DirectInput.Key.Down))
            {
                scale = Matrix.Scaling(1 + speed * time);
            }

            worldMatrix = worldMatrix * scale * rotation;
            m.World     = worldMatrix;
            game.DeviceContext.UpdateSubresource(ref m, _perFrame);
        }
Esempio n. 3
0
 public void CreateDevice()
 {
     SharpDX.DirectInput.DirectInput dinput = new SharpDX.DirectInput.DirectInput();
     SharpDX.DirectInput.CooperativeLevel cooperativeLevel;
     cooperativeLevel = SharpDX.DirectInput.CooperativeLevel.NonExclusive;
     cooperativeLevel |= SharpDX.DirectInput.CooperativeLevel.Background;
     mouse = new SharpDX.DirectInput.Mouse(dinput);
     mouse.SetCooperativeLevel(Window, cooperativeLevel);
     mouse.Acquire();
     keyboard = new SharpDX.DirectInput.Keyboard(dinput);
     cooperativeLevel = SharpDX.DirectInput.CooperativeLevel.NonExclusive;
     cooperativeLevel |= SharpDX.DirectInput.CooperativeLevel.Foreground;
     keyboard.SetCooperativeLevel(Window, cooperativeLevel);
     keyboard.Acquire();
     Point startPoint = System.Windows.Forms.Cursor.Position;
     mouseCoord.X = Window.PointToClient(startPoint).X;
     mouseCoord.Y = Window.PointToClient(startPoint).Y;
     mouseState = new SharpDX.DirectInput.MouseState();
     keyboardState = new SharpDX.DirectInput.KeyboardState();
 }