/// <summary> /// Raised whenever a button is released. /// </summary> /// <param name="Button">The DS4Button that was released.</param> private void OnButtonUp(DS4Button Button) { }
private void Controller_ButtonUp(DS4Button Button) { switch (Button) { case DS4Button.Cross: OnButtonUp(InputButton.RFaceDown); break; case DS4Button.Circle: OnButtonUp(InputButton.RFaceRight); break; case DS4Button.Triangle: OnButtonUp(InputButton.RFaceUp); break; case DS4Button.Square: OnButtonUp(InputButton.RFaceLeft); break; case DS4Button.L1: OnButtonUp(InputButton.BumperLeft); break; case DS4Button.L2: OnButtonUp(InputButton.TriggerLeft); break; case DS4Button.L3: OnButtonUp(InputButton.StickLeft); break; case DS4Button.R1: OnButtonUp(InputButton.BumperRight); break; case DS4Button.R2: OnButtonUp(InputButton.TriggerRight); break; case DS4Button.R3: OnButtonUp(InputButton.StickRight); break; case DS4Button.DpadUp: OnButtonUp(InputButton.LFaceUp); break; case DS4Button.DpadDown: OnButtonUp(InputButton.LFaceDown); break; case DS4Button.DpadRight: OnButtonUp(InputButton.LFaceRight); break; case DS4Button.DpadLeft: OnButtonUp(InputButton.LFaceLeft); break; case DS4Button.Share: OnButtonUp(InputButton.CenterLeft); break; case DS4Button.Options: OnButtonUp(InputButton.CenterRight); break; case DS4Button.PS: OnButtonUp(InputButton.CenterMiddle); break; case DS4Button.TouchLeft: OnButtonUp(InputButton.Extra1); break; case DS4Button.TouchRight: OnButtonUp(InputButton.Extra2); break; case DS4Button.TouchUpper: OnButtonUp(InputButton.Extra3); break; } }
/// <summary> /// Raised whenever a button is pressed. /// </summary> /// <param name="Button">The DS4Button that was pressed.</param> private void OnButtonDown(DS4Button Button) { }
private void DoButtonUp(DS4Button Button) { buttonStates[(int)Button] = false; }
private void DoButtonDown(DS4Button Button) { // if button already pressed, ignore if (buttonStates[(int)Button] == true) return; buttonStates[(int)Button] = true; Thread buttWatcher = new Thread(() => { // Handle button events ButtonDown(Button); while (buttonStates[(int)Button]) { Thread.Sleep(5); } buttonStates[(int)Button] = false; ButtonUp(Button); return; }); buttWatcher.Start(); }
public bool IsButtonPressed(DS4Button Button) { return buttonStates[(int)Button]; }
public bool GetButtonState(DS4Button Button) { return buttonStates[(int)Button]; }