private void ControllerReadingUpdate() { for (int i = 0; i < gamepads.Count; i++) { RawGameController gamepad = gamepads[i]; bool[] buttonArray = new bool[gamepad.ButtonCount]; GameControllerSwitchPosition[] switchArray = new GameControllerSwitchPosition[gamepad.SwitchCount]; double[] axisArray = new double[gamepad.AxisCount]; ulong timestamp = gamepad.GetCurrentReading(buttonArray, switchArray, axisArray); for (int j = 0; j < gamepad.AxisCount; j++) { AddOrUpdateValue($"HID/Gamepad/{i}/Axis/{j}", axisArray[j], true); } for (int j = 0; j < gamepad.ButtonCount; j++) { AddOrUpdateValue($"HID/Gamepad/{i}/Button/{j}", buttonArray[j], true); } for (int j = 0; j < gamepad.SwitchCount; j++) { AddOrUpdateValue($"HID/Gamepad/{i}/Switch/{j}", (int)switchArray[j], true); } //AddOrUpdateValue($"HID/Gamepad/{i}/Battery", (int)gamepad.TryGetBatteryReport().Status, true); } }
/// <summary> /// ButtonBackPressed maps to the Share button on a Playstation controller, or Back button of a Xbox controller. /// </summary> /// <returns> /// ButtonBackPressed returns true if pressed, false otherwise; /// </returns> public bool ButtonBackPressed() { if (Controller == null) { return(false); } Boolean[] ButtonArray = new Boolean[20]; GameControllerSwitchPosition[] SwitchArray = new GameControllerSwitchPosition[20]; Double[] AxisArray = new Double[20]; Controller.GetCurrentReading(ButtonArray, SwitchArray, AxisArray); return(ButtonArray[8]); }