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