private async void RawInputHandler(object sender, RawKeyPressEventArgs e) { if (IsSettingKeyboard && e.KeyState == KeyPressState.Up) { Data.Types.Keyboard kbd = new Data.Types.Keyboard(); var kbdInfo = Helper.GetKeyboardInfo(e.Keyboard.HWID); kbd.Description = kbdInfo.Item1; kbd.HWID = e.Keyboard.HWID; kbd.Name = e.Keyboard.Name; kbd.Layout = kbdInfo.Item2; Variables.Config.TargetKeyboard = kbd; selectKeyboardBtn.Content = "Select"; selectKeyboardBtn.IsHitTestVisible = true; //enable button click handler currentKeyboardLbl.Content = "Keyboard: " + e.Keyboard.Name; currentKeyboardLbl.Foreground = Helper.GetFromResources <SolidColorBrush>("PrimaryForegroundAccent"); kbdInfoBtn.IsEnabled = true; IsSettingKeyboard = false; await NEHSubprocess.KillAllProcesses(); _ = StartSubprocesses(kbd); ConfigManager.StoreObject(Variables.Config, Constants.ConfigPath); } }
private async Task StartSubprocesses(Data.Types.Keyboard kbd) { UserSubprocess = new NEHSubprocess(false, kbd.HWID, PIPENAME); if (IsStartedAsAdmin) { AdminSubprocess = new NEHSubprocess(true, kbd.HWID, PIPENAME_ADMIN); AdminSubprocess.KeyEventRecieved += new NEHSubprocess.KeyEventRecievedHandler(KeyPressRecieved); _ = AdminSubprocess.StartProcess(); } UserSubprocess.KeyEventRecieved += new NEHSubprocess.KeyEventRecievedHandler(KeyPressRecieved); await UserSubprocess.StartProcess(); }