示例#1
0
 void CallInitializeEvent()
 {
     if (!initializeEventCalled && GamepadHookInitialized != null)
     {
         GamepadHookInitialized.Invoke(this, null);
         initializeEventCalled = true;
     }
 }
示例#2
0
 public void Poll()
 {
     if (GamepadHook != null)
     {
         if (!hasPolledGamepadHook)
         {
             hasPolledGamepadHook = true;
             GamepadHookInitialized?.Invoke(this, null);
         }
         GamepadHook.Poll();
     }
     KeyboardHook.Poll();
 }
示例#3
0
        void InitializeGamepadHook()
        {
            hasPolledGamepadHook = false;
            Task.Factory.StartNew(() =>
            {
                try
                {
                    GamepadHook = new GamepadHook();
                    GamepadHook.ButtonPressed += GamepadHook_ButtonPressed;
                }
                catch (Exception ex)
                {
                    Log.Error(ex);
                }

                GamepadHookInitialized?.Invoke(this, null);

                if (GamepadHook != null)
                {
                    while (true)
                    {
                        Thread.Sleep(25);
                        try
                        {
                            try
                            {
                                GamepadHook.Poll();
                            }
                            catch (Exception ex)
                            {
                                Log.Error(ex);
                            }
                        }
                        catch { }
                    }
                }
            });
        }