Example #1
0
 void CallInitializeEvent()
 {
     if (!initializeEventCalled && GamepadHookInitialized != null)
     {
         GamepadHookInitialized.Invoke(this, null);
         initializeEventCalled = true;
     }
 }
Example #2
0
 public void Poll()
 {
     if (GamepadHook != null)
     {
         if (!hasPolledGamepadHook)
         {
             hasPolledGamepadHook = true;
             GamepadHookInitialized?.Invoke(this, null);
         }
         GamepadHook.Poll();
     }
     KeyboardHook.Poll();
 }
Example #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 { }
                    }
                }
            });
        }