Exemple #1
0
 public override void Dispose()
 {
     if (Device != null)
     {
         Device.Dispose();
         Device = null;
     }
     GC.SuppressFinalize(this);
 }
Exemple #2
0
 public GamePad(int lever, int padNumber, DirectInput directInput)
 {
     Config = PadConfig.GetDefault();
     StickBorder = lever;
     try
     {
         Device = new GamePadDevice(padNumber, directInput);
     }
     catch
     {
         throw new NoDeviceException(padNumber + "番パッドの生成に失敗");
     }
 }
Exemple #3
0
        public override void Update()
        {
            if (Device == null)
            {
                CurrentValue = 0;
                return;
            }
            State = null;
            try
            {
                State = Device.GetState();
            }
            catch (Exception)
            {
                Device = null;
                CurrentValue = 0;
                return;
            }
            if (State == null)
            {
                CurrentValue = 0;
                return;
            }

            CurrentValue = ProcessState(State);
        }
Exemple #4
0
 /// <summary>
 /// 複数のゲームパッドのボタン入力の和を取る
 /// </summary>
 /// <param name="pads"></param>
 /// <returns>各ボタンが押されている/いないの配列。状態をとれるパッドが存在しない場合はnull</returns>
 public static bool[] ZipPadsStates(GamePadDevice[] pads)
 {
     var states = pads.Select(p => p.GetState()).Where(s => s != null);
     if (states.Any())
     {
         bool[] bt = states.Select(s => s.Buttons)
             .Aggregate((a, b) => a.Zip(b, (x, y) => x || y).ToArray()).ToArray();//複数パッドを合成
         return bt;
     }
     else return null;
 }