private void SaveConfig() { conf.CustomConfig = extConfig; if (simFeedbackLoaded) { facade.IncrementOverallIntensity(); facade.DecrementOverallIntensity(); } else { Thread th = new Thread(new ThreadStart(() => { Thread.Sleep(waitTimeBeforeSimFBInitialized); facade.IncrementOverallIntensity(); facade.DecrementOverallIntensity(); Thread.CurrentThread.Join(); })); th.Start(); } }
private void PushButtons() { try { //TraceButtons(); joystick.GetCurrentState(ref joystickState); bool[] buttons = joystickState.Buttons; //bool isButtonPushed = false; //foreach(bool i in buttons) { // if (i) // { // isButtonPushed = true; // break; // } //} //if (!isButtonPushed) return; // Mouse Click, push the joystick button if (buttons[11]) { if (leftButtonUp) { inputSim.Mouse.LeftButtonDown(); leftButtonDown = true; leftButtonUp = false; } } else { if (leftButtonDown) { inputSim.Mouse.LeftButtonUp(); leftButtonUp = true; leftButtonDown = false; } } // Oben links Grün if (buttons[9]) { inputSim.Keyboard.KeyPress(VirtualKeyCode.ESCAPE); } // Unten links, Blau, Orange if (buttons[6]) { simFeedbackFacade.IncrementOverallIntensity(); } if (buttons[8]) { simFeedbackFacade.DecrementOverallIntensity(); } // unten rechts schwarz if (buttons[4]) { inputSim.Keyboard.KeyDown(VirtualKeyCode.CONTROL); inputSim.Keyboard.KeyPress(VirtualKeyCode.SPACE); System.Threading.Thread.Sleep(100); inputSim.Keyboard.KeyUp(VirtualKeyCode.CONTROL); System.Threading.Thread.Sleep(200); } // unten links schwarz // Assetto Corsa // Toggle ASW with hotkeys: // CTRL+Numpad1: Disable ASW, go back to the original ATW mode // CTRL+Numpad2: Force apps to 45Hz, ASW disabled // CTRL+Numpad3: Force apps to 45Hz, ASW enabled // CTRL+Numpad4: Enable auto-ASW (default, use this first) if (buttons[5]) { inputSim.Keyboard.KeyDown(VirtualKeyCode.CONTROL); if (awsState == AWS.DISABLED) { inputSim.Keyboard.KeyPress(VirtualKeyCode.NUMPAD4); awsState = AWS.ENABLED; } else { inputSim.Keyboard.KeyPress(VirtualKeyCode.NUMPAD1); awsState = AWS.DISABLED; } inputSim.Keyboard.KeyUp(VirtualKeyCode.CONTROL); } } catch (Exception e) { while (e.InnerException != null) { e = e.InnerException; Trace.Write(e.ToString()); } } }
void CheckButtons() { try { //TraceButtons(); joystick.GetCurrentState(ref joystickState); bool[] buttons = joystickState.Buttons; //bool isButtonPushed = false; //foreach(bool i in buttons) { // if (i) // { // isButtonPushed = true; // break; // } //} //if (!isButtonPushed) return; // Mouse Click, push the joystick button ///if (buttons[11]) ///{ /// if (leftButtonUp) /// { /// inputSim.Mouse.LeftButtonDown(); /// leftButtonDown = true; /// leftButtonUp = false; /// } ///} ///else ///{ /// if (leftButtonDown) /// { /// inputSim.Mouse.LeftButtonUp(); /// leftButtonUp = true; /// leftButtonDown = false; /// } ///} // Oben links Grün //if (buttons[9]) //{ // inputSim.Keyboard.KeyPress(VirtualKeyCode.ESCAPE); //} // Unten links, Blau, Orange ///if (buttons[6]) ///{ /// simFeedbackFacade.IncrementOverallIntensity(); ///} ///if (buttons[8]) ///{ /// simFeedbackFacade.DecrementOverallIntensity(); ///} // unten rechts schwarz ///if (buttons[4]) ///{ /// inputSim.Keyboard.KeyDown(VirtualKeyCode.CONTROL); /// inputSim.Keyboard.KeyPress(VirtualKeyCode.SPACE); /// System.Threading.Thread.Sleep(100); /// inputSim.Keyboard.KeyUp(VirtualKeyCode.CONTROL); /// System.Threading.Thread.Sleep(200); ///} // unten links schwarz // Assetto Corsa // Toggle ASW with hotkeys: // CTRL+Numpad1: Disable ASW, go back to the original ATW mode // CTRL+Numpad2: Force apps to 45Hz, ASW disabled // CTRL+Numpad3: Force apps to 45Hz, ASW enabled // CTRL+Numpad4: Enable auto-ASW (default, use this first) ///if (buttons[5]) ///{ /// inputSim.Keyboard.KeyDown(VirtualKeyCode.CONTROL); /// if (awsState == AWS.DISABLED) /// { /// inputSim.Keyboard.KeyPress(VirtualKeyCode.NUMPAD4); /// awsState = AWS.ENABLED; /// } /// else /// { /// inputSim.Keyboard.KeyPress(VirtualKeyCode.NUMPAD1); /// awsState = AWS.DISABLED; /// } /// inputSim.Keyboard.KeyUp(VirtualKeyCode.CONTROL); ///} if (preventSpamClickStartStopStopWatch.ElapsedMilliseconds > (int)startStopDelay) { preventSpamClickStartStopStopWatch.Stop(); } if (userMustSelectStartStopButton) { for (int i = 0; i < buttons.Length; i++) { if (buttons[i]) { startStopButton = i; finishStartStopButton(); extension.SetToggleStartStopButton(i); Thread.Sleep(1000); break; } } } else if (userMustSelectDecreaseIntensity1Button) { for (int i = 0; i < buttons.Length; i++) { if (buttons[i]) { decreaseIntensity1Button = i; finishDecreaseIntensity1Button(); extension.SetToggleDecreaseIntensity1Button(i); Thread.Sleep(1000); break; } } } else if (userMustSelectIncreaseIntensity1Button) { for (int i = 0; i < buttons.Length; i++) { if (buttons[i]) { increaseIntensity1Button = i; finishIncreaseIntensity1Button(); extension.SetToggleIncreaseIntensity1Button(i); Thread.Sleep(1000); break; } } } else if (userMustSelectDecreaseIntensity5Button) { for (int i = 0; i < buttons.Length; i++) { if (buttons[i]) { decreaseIntensity5Button = i; finishDecreaseIntensity5Button(); extension.SetToggleDecreaseIntensity5Button(i); Thread.Sleep(1000); break; } } } else if (userMustSelectIncreaseIntensity5Button) { for (int i = 0; i < buttons.Length; i++) { if (buttons[i]) { increaseIntensity5Button = i; finishIncreaseIntensity5Button(); extension.SetToggleIncreaseIntensity5Button(i); Thread.Sleep(1000); break; } } } else if (userMustSelectDecreaseIntensity10Button) { for (int i = 0; i < buttons.Length; i++) { if (buttons[i]) { decreaseIntensity10Button = i; finishDecreaseIntensity10Button(); extension.SetToggleDecreaseIntensity10Button(i); Thread.Sleep(1000); break; } } } else if (userMustSelectIncreaseIntensity10Button) { for (int i = 0; i < buttons.Length; i++) { if (buttons[i]) { increaseIntensity10Button = i; finishIncreaseIntensity10Button(); extension.SetToggleIncreaseIntensity10Button(i); Thread.Sleep(1000); break; } } } else if (userMustSelectDecreaseIntensity20Button) { for (int i = 0; i < buttons.Length; i++) { if (buttons[i]) { decreaseIntensity20Button = i; finishDecreaseIntensity20Button(); extension.SetToggleDecreaseIntensity20Button(i); Thread.Sleep(1000); break; } } } else if (userMustSelectIncreaseIntensity20Button) { for (int i = 0; i < buttons.Length; i++) { if (buttons[i]) { increaseIntensity20Button = i; finishIncreaseIntensity20Button(); extension.SetToggleIncreaseIntensity20Button(i); Thread.Sleep(1000); break; } } } else { if (IsEnabled && extension.IsActivated) { if (startStopButton >= 0 && startStopButton < buttons.Length) { if (preventSpamClickStartStopStopWatch.ElapsedMilliseconds > (int)startStopDelay || !preventSpamClickStartStopStopWatch.IsRunning) { preventSpamClickStartStopStopWatch.Reset(); if (!buttons[startStopButton] && isStartStopButtonDown) { simFeedbackIsOn = !facade.IsRunning(); if (simFeedbackIsOn) { if (componentsInitialized) { label1.Text = "SimFeedback is turned ON"; } facade.Start(); } else { if (componentsInitialized) { label1.Text = "SimFeedback is turned OFF"; } facade.Stop(); } preventSpamClickStartStopStopWatch.Start(); } isStartStopButtonDown = buttons[startStopButton]; } } if (decreaseIntensity1Button >= 0 && decreaseIntensity1Button < buttons.Length) { if (!buttons[decreaseIntensity1Button] && isDecreaseIntensity1ButtonDown) { facade.DecrementOverallIntensity(); } isDecreaseIntensity1ButtonDown = buttons[decreaseIntensity1Button]; } if (increaseIntensity1Button >= 0 && increaseIntensity1Button < buttons.Length) { if (!buttons[increaseIntensity1Button] && isIncreaseIntensity1ButtonDown) { facade.IncrementOverallIntensity(); } isIncreaseIntensity1ButtonDown = buttons[increaseIntensity1Button]; } if (decreaseIntensity5Button >= 0 && decreaseIntensity5Button < buttons.Length) { if (!buttons[decreaseIntensity5Button] && isDecreaseIntensity5ButtonDown) { for (int i = 0; i < 5; i++) { facade.DecrementOverallIntensity(); } } isDecreaseIntensity5ButtonDown = buttons[decreaseIntensity5Button]; } if (increaseIntensity5Button >= 0 && increaseIntensity5Button < buttons.Length) { if (!buttons[increaseIntensity5Button] && isIncreaseIntensity5ButtonDown) { for (int i = 0; i < 5; i++) { facade.IncrementOverallIntensity(); } } isIncreaseIntensity5ButtonDown = buttons[increaseIntensity5Button]; } if (decreaseIntensity10Button >= 0 && decreaseIntensity10Button < buttons.Length) { if (!buttons[decreaseIntensity10Button] && isDecreaseIntensity10ButtonDown) { for (int i = 0; i < 10; i++) { facade.DecrementOverallIntensity(); } } isDecreaseIntensity10ButtonDown = buttons[decreaseIntensity10Button]; } if (increaseIntensity10Button >= 0 && increaseIntensity10Button < buttons.Length) { if (!buttons[increaseIntensity10Button] && isIncreaseIntensity10ButtonDown) { for (int i = 0; i < 10; i++) { facade.IncrementOverallIntensity(); } } isIncreaseIntensity10ButtonDown = buttons[increaseIntensity10Button]; } if (decreaseIntensity20Button >= 0 && decreaseIntensity20Button < buttons.Length) { if (!buttons[decreaseIntensity20Button] && isDecreaseIntensity20ButtonDown) { for (int i = 0; i < 20; i++) { facade.DecrementOverallIntensity(); } } isDecreaseIntensity20ButtonDown = buttons[decreaseIntensity20Button]; } if (increaseIntensity20Button >= 0 && increaseIntensity20Button < buttons.Length) { if (!buttons[increaseIntensity20Button] && isIncreaseIntensity20ButtonDown) { for (int i = 0; i < 20; i++) { facade.IncrementOverallIntensity(); } } isIncreaseIntensity20ButtonDown = buttons[increaseIntensity20Button]; } } } } catch (Exception e) { while (e.InnerException != null) { e = e.InnerException; Trace.Write(e.ToString()); } } }