public RequestAccess( Market market, Product product, RequestStatus status, ControllerStatus cstatus, string description, int submittedByID) { this.Status = status; this.ControllerStatus = cstatus; this.Description = description; this.SubmittedByUserId = submittedByID; this.MarketAccess = market; this.ProductAccess = product; }
public BaseController(Switch device, ControllerStatus controllerType) { Device = device; HidControllerType = controllerType; }
/// <summary> /// Raises the controller status changed event. /// </summary> /// <param name="args">Arguments.</param> protected virtual void OnControllerStatusChanged(ControllerStatusEventArgs args) { controllerStatus = args.Status; Utility.logger.Debug("{0}", controllerStatus); if (controllerStatus == ControllerStatus.Disconnected) queuedMessages.Clear(); if (ControllerStatusChanged != null) ControllerStatusChanged(this, args); }
internal Controller(CapiApplication application, uint id) { _application = application; _id = id; _status = ControllerStatus.Idle; }
public ControllerEventArgs(byte nodeId, ControllerStatus status) { this.Status = status; this.NodeId = nodeId; }
private string OpenDevice(out ControllerStatus status, out string info) { status = ControllerStatus.DeviceError; info = ""; //Get number of devices _ftStatus = _myFtdiDevice.GetNumberOfDevices(ref _ftdiDeviceCount); if (_ftStatus != FT_STATUS.FT_OK) return string.Format("Failed to get number of devices (error {0})", _ftStatus); if (_ftdiDeviceCount == 0) { status = ControllerStatus.DeviceAbsent; return "No connected devices"; } //Get list of devices _ftdiDeviceList = new FT_DEVICE_INFO_NODE[_ftdiDeviceCount]; _ftStatus = _myFtdiDevice.GetDeviceList(_ftdiDeviceList); if (_ftStatus != FT_STATUS.FT_OK) return string.Format("Failed to get list of devices (error {0})", _ftStatus); int ourDeviceIndex = -1; StringBuilder list = new StringBuilder(); for (int i = 0; i < _ftdiDeviceCount; i++) { if (_ftdiDeviceList[i].Description.IndexOf(_description) != -1) ourDeviceIndex = i; list.Append(string.Format("flags:{0},type:{1},ID:{2},loc.ID:{3},SN:{4},desc:'{5}'; ", string.Format("{0:x}", _ftdiDeviceList[i].Flags), _ftdiDeviceList[i].Type, string.Format("{0:x}", _ftdiDeviceList[i].ID), string.Format("{0:x}", _ftdiDeviceList[i].LocId), _ftdiDeviceList[i].SerialNumber, _ftdiDeviceList[i].Description)); } string devices = list.ToString(); if (ourDeviceIndex == -1) { status = ControllerStatus.DeviceAbsent; return string.Format("Device '{0}' is absent", _description + (devices != "" ? " (" + devices + ")" : "")); } //Open device _ftStatus = _myFtdiDevice.OpenByIndex(ourDeviceIndex); if (_ftStatus != FT_STATUS.FT_OK) { status = ControllerStatus.Error; return string.Format("Failed to open device (error {0})", _ftStatus); } else info = string.Format("Device '{0}' was opened", _description); //Set baud rate _ftStatus = _myFtdiDevice.SetBaudRate(_speed); if (_ftStatus != FT_STATUS.FT_OK) { status = ControllerStatus.Error; return string.Format("Failed to set Baud rate (error {0})", _ftStatus); } //Set timeout _ftStatus = _myFtdiDevice.SetTimeouts(_readTimeout, _writeTimeout); if (_ftStatus != FT_STATUS.FT_OK) { status = ControllerStatus.Error; return string.Format("Failed to set timeouts (error {0})", _ftStatus); } //Set flow control _ftStatus = _myFtdiDevice.SetFlowControl(FT_FLOW_CONTROL.FT_FLOW_NONE, 0, 0); if (_ftStatus != FT_STATUS.FT_OK) { status = ControllerStatus.Error; return string.Format("Failed to set flow control (error {0})", _ftStatus); } //Device ready status = ControllerStatus.DeviceOpened; return ""; }
//Check if controller shortcut is pressed async Task <bool> ControllerShortcut(ControllerStatus Controller) { bool ControllerUsed = false; bool ControllerDelay125 = false; bool ControllerDelay750 = false; try { if (GetSystemTicksMs() >= Controller.Delay_ControllerShortcut) { //Activate the controller if (Controller.InputCurrent.ButtonGuide.PressedShort) { Debug.WriteLine("Shortcut activate controller has been pressed."); bool controllerActivated = await ControllerActivate(Controller); ControllerUsed = true; ControllerDelay125 = true; if (controllerActivated) { return(ControllerUsed); } } //Hide popups with guide button if (Controller.InputCurrent.ButtonGuide.PressedShort && (App.vWindowKeyboard.vWindowVisible || App.vWindowKeypad.vWindowVisible)) { await HideOpenPopups(); ControllerUsed = true; ControllerDelay750 = true; } //Show or launch CtrlUI application else if (Controller.InputCurrent.ButtonGuide.PressedShort) { if (Convert.ToBoolean(Setting_Load(vConfigurationDirectXInput, "ShortcutLaunchCtrlUI"))) { Debug.WriteLine("Shortcut launch CtrlUI has been pressed."); Debug.WriteLine("Guide short press showing CtrlUI."); await ProcessFunctions.LaunchShowCtrlUI(); ControllerUsed = true; ControllerDelay750 = true; } } //Show the keyboard or keypad else if (Controller.InputCurrent.ButtonGuide.PressedLong) { if (!App.vWindowKeyboard.vWindowVisible && !App.vWindowKeypad.vWindowVisible) { if (vKeyboardKeypadLastActive == "Keyboard") { await KeyboardPopupHideShow(false); } else { await KeypadPopupHideShow(false); } } else { await KeyboardKeypadPopupSwitch(); } ControllerUsed = true; ControllerDelay750 = true; } //Mute or unmute the input/microphone else if (Controller.InputCurrent.ButtonMedia.PressedRaw) { int muteFunction = Convert.ToInt32(Setting_Load(vConfigurationDirectXInput, "ShortcutMuteFunction")); if (muteFunction == 0) { if (AudioMuteSwitch(true)) { await App.vWindowOverlay.Notification_Show_Status("MicrophoneMute", "Input muted"); } else { await App.vWindowOverlay.Notification_Show_Status("MicrophoneMute", "Input unmuted"); } } else { if (AudioMuteSwitch(false)) { await App.vWindowOverlay.Notification_Show_Status("VolumeMute", "Output muted"); } else { await App.vWindowOverlay.Notification_Show_Status("VolumeMute", "Output unmuted"); } } ControllerUsed = true; ControllerDelay750 = true; } //Press Alt+Enter else if (Controller.InputCurrent.ButtonStart.PressedRaw && Controller.InputCurrent.ButtonShoulderRight.PressedRaw) { if (Convert.ToBoolean(Setting_Load(vConfigurationDirectXInput, "ShortcutAltEnter"))) { Debug.WriteLine("Button Global - Alt+Enter"); NotificationDetails notificationDetails = new NotificationDetails(); notificationDetails.Icon = "AppMiniMaxi"; notificationDetails.Text = "Pressing Alt+Enter"; await App.vWindowOverlay.Notification_Show_Status(notificationDetails); vFakerInputDevice.KeyboardPressRelease(KeyboardModifiers.AltLeft, KeyboardModifiers.None, KeyboardKeys.Enter, KeyboardKeys.None, KeyboardKeys.None, KeyboardKeys.None, KeyboardKeys.None, KeyboardKeys.None); ControllerUsed = true; ControllerDelay750 = true; } } //Press Alt+Tab else if (Controller.InputCurrent.ButtonStart.PressedRaw && Controller.InputCurrent.ButtonShoulderLeft.PressedRaw) { if (Convert.ToBoolean(Setting_Load(vConfigurationDirectXInput, "ShortcutAltTab"))) { Debug.WriteLine("Button Global - Alt+Tab"); NotificationDetails notificationDetails = new NotificationDetails(); notificationDetails.Icon = "AppMiniMaxi"; notificationDetails.Text = "Pressing Alt+Tab"; await App.vWindowOverlay.Notification_Show_Status(notificationDetails); vFakerInputDevice.KeyboardPressRelease(KeyboardModifiers.AltLeft, KeyboardModifiers.None, KeyboardKeys.Tab, KeyboardKeys.None, KeyboardKeys.None, KeyboardKeys.None, KeyboardKeys.None, KeyboardKeys.None); ControllerUsed = true; ControllerDelay750 = true; } } //Make screenshot else if (Controller.InputCurrent.ButtonTouchpad.PressedRaw) { if (Convert.ToBoolean(Setting_Load(vConfigurationDirectXInput, "ShortcutScreenshotController"))) { Debug.WriteLine("Button Global - Screenshot"); await CaptureScreen.CaptureScreenToFile(); ControllerUsed = true; ControllerDelay750 = true; } } //Disconnect controller from Bluetooth else if (Controller.InputCurrent.ButtonStart.PressedRaw && Controller.InputCurrent.ButtonGuide.PressedRaw && Controller.Details.Wireless) { if (Convert.ToBoolean(Setting_Load(vConfigurationDirectXInput, "ShortcutDisconnectBluetooth"))) { Debug.WriteLine("Shortcut disconnect Bluetooth has been pressed."); StopControllerTask(Controller, "manually", string.Empty); ControllerUsed = true; ControllerDelay750 = true; } } if (ControllerDelay125) { Controller.Delay_ControllerShortcut = GetSystemTicksMs() + vControllerDelayTicks125; } else if (ControllerDelay750) { Controller.Delay_ControllerShortcut = GetSystemTicksMs() + vControllerDelayTicks750; } } } catch { } return(ControllerUsed); }
/// <summary> /// Exchange data with devices /// </summary> /// <param name="address">Address</param> /// <param name="command">Command</param> /// <param name="isDataString">Is data string</param> /// <param name="writeData">Write data</param> /// <param name="readData">Read data</param> /// <param name="readString">Read data</param> /// <param name="status">Status of exchange</param> /// <param name="info">Info string</param> /// <returns>Error string</returns> public string Exchange(byte address, byte command, bool isDataString, byte[] writeData, out byte[] readData, out string readString, out ControllerStatus status, out string info) { // Prepare byte array _countRewrite = 0; readData = null; readString = ""; status = ControllerStatus.DeviceError; info = ""; if (_myFtdiDevice == null) return AddinManager.CurrentLocalizer.GetString("UnsupportedOS"); byte[] data = new byte[3 + writeData.Length]; data[0] = address; data[1] = (byte)(writeData.Length + 1); data[2] = command; for (int i = 0; i < writeData.Length; i++) data[i + 3] = writeData[i]; byte[] fullData = new byte[data.Length + 1]; for (int i = 1; i < data.Length; i++) fullData[i - 1] = data[i]; byte[] crc = _crc16Ccitt.ComputeChecksumBytes(data); fullData[fullData.Length - 2] = crc[0]; fullData[fullData.Length - 1] = crc[1]; while (true) { //Reopen device if it need if (!_myFtdiDevice.IsOpen) { string error = OpenDevice(out status, out info); if (error != "") return error; else status = ControllerStatus.DeviceOpened; } //Write data byte[] addr = new byte[] { address }; _wStatus[0] = _myFtdiDevice.SetDataCharacteristics(FT_DATA_BITS.FT_BITS_8, FT_STOP_BITS.FT_STOP_BITS_1, FT_PARITY.FT_PARITY_MARK); _wStatus[1] = _myFtdiDevice.Write(addr, addr.Length, ref _numBytesWritten); _wStatus[2] = _myFtdiDevice.SetDataCharacteristics(FT_DATA_BITS.FT_BITS_8, FT_STOP_BITS.FT_STOP_BITS_1, FT_PARITY.FT_PARITY_SPACE); _wStatus[3] = _myFtdiDevice.Write(fullData, fullData.Length, ref _numBytesWritten); //Read address _rStatus[0] = _myFtdiDevice.Read(_answerAddress, _one, ref _numBytesRead0); //Is read address if (_numBytesRead0 != 1) { //_myFtdiDevice.Purge(FT_PURGE.FT_PURGE_RX | FT_PURGE.FT_PURGE_TX); if (++_countRewrite > _maxCountRewrite) { status = ControllerStatus.Error; return AddinManager.CurrentLocalizer.GetString("CantReadData"); } } else break; } //Continue reading _rStatus[1] = _myFtdiDevice.Read(_answerLength, _one, ref _numBytesRead1); if (isDataString) _rStatus[2] = _myFtdiDevice.Read(out readString, _answerLength[0], ref _numBytesRead2); else { readData = new byte[_answerLength[0]]; _rStatus[2] = _myFtdiDevice.Read(readData, _answerLength[0], ref _numBytesRead2); } _rStatus[3] = _myFtdiDevice.Read(_answerCRC16, _two, ref _numBytesRead3); //Check statuses if (_wStatus[0] != FT_STATUS.FT_OK) { status = ControllerStatus.Error; return AddinManager.CurrentLocalizer.GetString("FailedToSetDataCharacteristics", _wStatus[1]); } if (_wStatus[1] != FT_STATUS.FT_OK) { status = ControllerStatus.Error; return AddinManager.CurrentLocalizer.GetString("FailedToWriteToDevice", _wStatus[2]); } if (_wStatus[2] != FT_STATUS.FT_OK) { status = ControllerStatus.Error; return AddinManager.CurrentLocalizer.GetString("FailedToSetDataCharacteristics", _wStatus[3]); } if (_wStatus[3] != FT_STATUS.FT_OK) { status = ControllerStatus.Error; return AddinManager.CurrentLocalizer.GetString("FailedToWriteToDevice", _wStatus[4]); } if (_rStatus[0] != FT_STATUS.FT_OK) { status = ControllerStatus.Error; return AddinManager.CurrentLocalizer.GetString("FailedToReadFromDevice", _rStatus[0]); } if (_numBytesRead0 != 1) { status = ControllerStatus.Error; return AddinManager.CurrentLocalizer.GetString("CantReadData"); } if (_answerAddress[0] != address) { status = ControllerStatus.Error; return AddinManager.CurrentLocalizer.GetString("ReadDataHasWrongAddress"); } if (_rStatus[1] != FT_STATUS.FT_OK) { status = ControllerStatus.Error; return string.Format(AddinManager.CurrentLocalizer.GetString("FailedToReadFromDevice", _rStatus[1])); } if (_numBytesRead1 != 1) { status = ControllerStatus.Error; return AddinManager.CurrentLocalizer.GetString("CantReadData"); } if (_answerLength[0] == 0) { status = ControllerStatus.Error; return AddinManager.CurrentLocalizer.GetString("ReadDataHasZeroLength"); } if (_rStatus[2] != FT_STATUS.FT_OK) { status = ControllerStatus.Error; return AddinManager.CurrentLocalizer.GetString("FailedToReadFromDevice", _rStatus[2]); } if (_numBytesRead2 != _answerLength[0]) { status = ControllerStatus.Error; return AddinManager.CurrentLocalizer.GetString("CantReadData"); } if (_rStatus[3] != FT_STATUS.FT_OK) { status = ControllerStatus.Error; return AddinManager.CurrentLocalizer.GetString("FailedToReadFromDevice", _rStatus[3]); } if (_numBytesRead3 != 2) { status = ControllerStatus.Error; return AddinManager.CurrentLocalizer.GetString("CantReadData"); } //Check CRC16 _answer = new byte[_answerLength[0] + 2]; _answer[0] = _answerAddress[0]; _answer[1] = _answerLength[0]; if (isDataString) for (int i = 2; i < _answer.Length; i++) _answer[i] = (byte)readString[i - 2]; else for (int i = 2; i < _answer.Length; i++) _answer[i] = readData[i - 2]; _checkCRC16 = _crc16Ccitt.ComputeChecksumBytes(_answer); if (_checkCRC16[0] != _answerCRC16[0] || _checkCRC16[1] != _answerCRC16[1]) { status = ControllerStatus.Error; return AddinManager.CurrentLocalizer.GetString("ReadDataHasWrongCRC16"); } else { if (status != ControllerStatus.DeviceOpened) status = ControllerStatus.OK; return ""; } }
public StatusChangedEventArgs(ControllerStatus status) { Status = status; }
/// <summary> /// Initializes a new instance of the /// ControllerPowerStateChangeRequestInner class. /// </summary> /// <param name="action">The power state that the request is expecting /// for the controller of the device. Possible values include: 'Start', /// 'Restart', 'Shutdown'</param> /// <param name="activeController">The active controller that the /// request is expecting on the device. Possible values include: /// 'Unknown', 'None', 'Controller0', 'Controller1'</param> /// <param name="controller0State">The controller 0's status that the /// request is expecting on the device. Possible values include: /// 'NotPresent', 'PoweredOff', 'Ok', 'Recovering', 'Warning', /// 'Failure'</param> /// <param name="controller1State">The controller 1's status that the /// request is expecting on the device. Possible values include: /// 'NotPresent', 'PoweredOff', 'Ok', 'Recovering', 'Warning', /// 'Failure'</param> /// <param name="id">The path ID that uniquely identifies the /// object.</param> /// <param name="name">The name of the object.</param> /// <param name="type">The hierarchical type of the object.</param> /// <param name="kind">The Kind of the object. Currently only /// Series8000 is supported. Possible values include: /// 'Series8000'</param> public ControllerPowerStateChangeRequestInner(ControllerPowerStateAction action, ControllerId activeController, ControllerStatus controller0State, ControllerStatus controller1State, string id = default(string), string name = default(string), string type = default(string), Kind?kind = default(Kind?)) : base(id, name, type, kind) { Action = action; ActiveController = activeController; Controller0State = controller0State; Controller1State = controller1State; CustomInit(); }
//Stop the desired controller as async private async Task <bool> StopControllerAsync(ControllerStatus Controller, string disconnectInfo, string controllerInfo) { try { //Check if the controller is connected if (Controller == null || !Controller.Connected()) { Debug.WriteLine("Controller " + Controller.NumberId + " is already disconnected."); return(false); } //Check if the controller is disconnecting if (Controller.Disconnecting) { Debug.WriteLine("Controller " + Controller.NumberId + " is currently disconnecting."); return(false); } //Update controller disconnecting status Controller.Disconnecting = true; //Get controller display number Debug.WriteLine("Disconnecting the controller " + Controller.NumberId + ": " + Controller.Details.DisplayName); string controllerNumberDisplay = (Controller.NumberId + 1).ToString(); //Show controller disconnect notification NotificationDetails notificationDetails = new NotificationDetails(); notificationDetails.Icon = "Controller"; if (string.IsNullOrWhiteSpace(disconnectInfo)) { notificationDetails.Text = "Disconnected (" + controllerNumberDisplay + ")"; } else { notificationDetails.Text = "Disconnected " + disconnectInfo + " (" + controllerNumberDisplay + ")"; } notificationDetails.Color = Controller.Color; await App.vWindowOverlay.Notification_Show_Status(notificationDetails); //Update user interface controller status AVActions.ActionDispatcherInvoke(delegate { if (string.IsNullOrWhiteSpace(controllerInfo)) { txt_Controller_Information.Text = "Disconnected controller " + controllerNumberDisplay + ": " + Controller.Details.DisplayName; } else { txt_Controller_Information.Text = controllerInfo; } if (Controller.NumberId == 0) { image_Controller0.Source = vImagePreloadIconControllerDark; textblock_Controller0.Text = "No controller connected"; textblock_Controller0CodeName.Text = string.Empty; ResetControllerDebugInformation(); } else if (Controller.NumberId == 1) { image_Controller1.Source = vImagePreloadIconControllerDark; textblock_Controller1.Text = "No controller connected"; textblock_Controller1CodeName.Text = string.Empty; ResetControllerDebugInformation(); } else if (Controller.NumberId == 2) { image_Controller2.Source = vImagePreloadIconControllerDark; textblock_Controller2.Text = "No controller connected"; textblock_Controller2CodeName.Text = string.Empty; ResetControllerDebugInformation(); } else if (Controller.NumberId == 3) { image_Controller3.Source = vImagePreloadIconControllerDark; textblock_Controller3.Text = "No controller connected"; textblock_Controller3CodeName.Text = string.Empty; ResetControllerDebugInformation(); } }); //Disconnect gyro dsu if (Controller.SupportedCurrent.HasGyroscope) { //Stop gyro controller loop task await TaskStopLoop(Controller.OutputGyroTask, 1000); //Send empty input to gyro dsu await SendGyroMotionEmpty(Controller); } //Disconnect virtual controller if (vVirtualBusDevice != null) { //Stop virtual controller loop task await TaskStopLoop(Controller.OutputVirtualTask, 1000); //Send empty input to virtual device SendInputVirtualEmpty(Controller); //Close the controller virtual events SetAndCloseEvent(Controller.InputVirtualOverlapped.EventHandle); SetAndCloseEvent(Controller.OutputVirtualOverlapped.EventHandle); //Disconnect the virtual controller vVirtualBusDevice.VirtualUnplug(Controller.NumberId); } //Disconnect Hid or WinUsb Device if (Controller.WinUsbDevice != null) { //Stop controller device loop tasks await TaskStopLoop(Controller.InputControllerTask, 1000); await TaskStopLoop(Controller.OutputControllerTask, 1000); //Dispose and stop connection with the controller try { Controller.WinUsbDevice.CloseDevice(); } catch { } } else if (Controller.HidDevice != null) { //Stop controller device loop tasks await TaskStopLoop(Controller.InputControllerTask, 1000); await TaskStopLoop(Controller.OutputControllerTask, 1000); //Disconnect controller from bluetooth if (Controller.Details.Wireless) { try { Controller.HidDevice.BluetoothDisconnect(); } catch { Debug.WriteLine("Failed disconnecting device from bluetooth."); } } //Signal Windows disconnection to prevent ghost controller if (Controller.Details.Wireless) { try { Controller.HidDevice.GetFeature(0x02); Controller.HidDevice.GetFeature(0x05); } catch { Debug.WriteLine("Failed signaling controller disconnection to Windows."); } } //Dispose and stop connection with the controller try { Controller.HidDevice.CloseDevice(); } catch { Debug.WriteLine("Failed disposing and stopping the controller."); } } //Reset the controller status Controller.ResetControllerStatus(); //Check if any controller is connected if (!vControllerAnyConnected() && Convert.ToBoolean(Setting_Load(vConfigurationDirectXInput, "KeyboardCloseNoController"))) { Debug.WriteLine("No controller connected closing open popups."); await HideOpenPopups(); } Debug.WriteLine("Succesfully stopped direct input controller " + Controller.NumberId); return(true); } catch (Exception ex) { Debug.WriteLine("Failed stopping the controller direct input " + Controller.NumberId + ": " + ex.Message); return(false); } }
//Start Monitoring Direct Input Controllers async Task <bool> StartControllerDirectInput(ControllerStatus Controller) { try { //Check if controller is connected if (!Controller.Connected()) { Debug.WriteLine("Direct input controller is not connected: " + Controller.Details.DisplayName); return(false); } Debug.WriteLine("Initializing direct input for: " + Controller.Details.DisplayName); //Allow controller in HidHide if (Controller.Details.Type == ControllerType.HidDevice) { await vHidHideDevice.ListDeviceAdd(Controller.Details.ModelId); } //Set controller interface information string controllerNumberDisplay = (Controller.NumberId + 1).ToString(); //Open the selected controller if (!OpenController(Controller)) { Debug.WriteLine("Failed to initialize direct input for: " + Controller.Details.DisplayName); StopControllerTask(Controller, "failed", "Controller " + controllerNumberDisplay + " is no longer connected or failed."); return(false); } //Unplug and plugin the virtual device vVirtualBusDevice.VirtualUnplug(Controller.NumberId); await Task.Delay(500); vVirtualBusDevice.VirtualPlugin(Controller.NumberId); NotificationDetails notificationDetailsConnected = new NotificationDetails(); notificationDetailsConnected.Icon = "Controller"; notificationDetailsConnected.Text = "Connected (" + controllerNumberDisplay + ")"; notificationDetailsConnected.Color = Controller.Color; await App.vWindowOverlay.Notification_Show_Status(notificationDetailsConnected); AVActions.ActionDispatcherInvoke(delegate { txt_Controller_Information.Text = "Connected controller " + controllerNumberDisplay + ": " + Controller.Details.DisplayName; }); //Update the controller interface settings ControllerUpdateSettingsInterface(Controller); //Update the controller last read time Controller.PrevInputTicks = GetSystemTicksMs(); Controller.LastInputTicks = GetSystemTicksMs(); //Update the controller last active time Controller.LastActiveTicks = GetSystemTicksMs(); //Set the controller supported profile Controller.SupportedCurrent = vDirectControllersSupported.Where(x => x.ProductIDs.Any(z => z.ToLower() == Controller.Details.Profile.ProductID.ToLower() && x.VendorID.ToLower() == Controller.Details.Profile.VendorID.ToLower())).FirstOrDefault(); if (Controller.SupportedCurrent == null) { Debug.WriteLine("Unsupported controller detected, using default profile."); Controller.SupportedCurrent = new ControllerSupported(); } //Start controller input task loop async Task TaskActionInput() { try { await LoopInputDirectInput(Controller, Controller.Details.Type); } catch { } } AVActions.TaskStartLoop(TaskActionInput, Controller.InputControllerTask); //Start virtual output task loop void TaskActionOutputVirtual() { try { LoopOutputVirtual(Controller); } catch { } } AVActions.TaskStartLoop(TaskActionOutputVirtual, Controller.OutputVirtualTask); //Start controller output task loop async void TaskActionOutputController() { try { await LoopOutputController(Controller); } catch { } } AVActions.TaskStartLoop(TaskActionOutputController, Controller.OutputControllerTask); //Start gyroscope task loop if (Controller.SupportedCurrent.HasGyroscope) { async Task TaskActionOutputGyro() { try { await LoopOutputGyro(Controller); } catch { } } AVActions.TaskStartLoop(TaskActionOutputGyro, Controller.OutputGyroTask); } return(true); } catch { Debug.WriteLine("Failed initializing direct input for: " + Controller.Details.DisplayName); return(false); } }
//Update the controller interface settings public void ControllerUpdateSettingsInterface(ControllerStatus Controller) { try { AVActions.ActionDispatcherInvoke(delegate { //Check if controller supports trigger rumble if (Controller.SupportedCurrent.HasRumbleTrigger) { stackpanel_TriggerRumbleSettings.Visibility = Visibility.Visible; } else { stackpanel_TriggerRumbleSettings.Visibility = Visibility.Collapsed; } cb_ControllerFakeGuideButton.IsChecked = Controller.Details.Profile.FakeGuideButton; cb_ControllerFakeMediaButton.IsChecked = Controller.Details.Profile.FakeMediaButton; cb_ControllerFakeTouchpadButton.IsChecked = Controller.Details.Profile.FakeTouchpadButton; cb_ControllerUseButtonTriggers.IsChecked = Controller.Details.Profile.UseButtonTriggers; textblock_ControllerDeadzoneTriggerLeft.Text = textblock_ControllerDeadzoneTriggerLeft.Tag.ToString() + Convert.ToInt32(Controller.Details.Profile.DeadzoneTriggerLeft) + "%"; slider_ControllerDeadzoneTriggerLeft.Value = Controller.Details.Profile.DeadzoneTriggerLeft; textblock_ControllerDeadzoneTriggerRight.Text = textblock_ControllerDeadzoneTriggerRight.Tag.ToString() + Convert.ToInt32(Controller.Details.Profile.DeadzoneTriggerRight) + "%"; slider_ControllerDeadzoneTriggerRight.Value = Controller.Details.Profile.DeadzoneTriggerRight; textblock_ControllerSensitivityTriggerLeft.Text = textblock_ControllerSensitivityTriggerLeft.Tag.ToString() + Controller.Details.Profile.SensitivityTriggerLeft.ToString("0.00"); slider_ControllerSensitivityTriggerLeft.Value = Controller.Details.Profile.SensitivityTriggerLeft; textblock_ControllerSensitivityTriggerRight.Text = textblock_ControllerSensitivityTriggerRight.Tag.ToString() + Controller.Details.Profile.SensitivityTriggerRight.ToString("0.00"); slider_ControllerSensitivityTriggerRight.Value = Controller.Details.Profile.SensitivityTriggerRight; cb_ControllerDPadFourWayMovement.IsChecked = Controller.Details.Profile.DPadFourWayMovement; cb_ControllerThumbFlipMovement.IsChecked = Controller.Details.Profile.ThumbFlipMovement; cb_ControllerThumbFlipAxesLeft.IsChecked = Controller.Details.Profile.ThumbFlipAxesLeft; cb_ControllerThumbFlipAxesRight.IsChecked = Controller.Details.Profile.ThumbFlipAxesRight; cb_ControllerThumbReverseAxesLeft.IsChecked = Controller.Details.Profile.ThumbReverseAxesLeft; cb_ControllerThumbReverseAxesRight.IsChecked = Controller.Details.Profile.ThumbReverseAxesRight; textblock_ControllerDeadzoneThumbLeft.Text = textblock_ControllerDeadzoneThumbLeft.Tag.ToString() + Convert.ToInt32(Controller.Details.Profile.DeadzoneThumbLeft) + "%"; slider_ControllerDeadzoneThumbLeft.Value = Controller.Details.Profile.DeadzoneThumbLeft; textblock_ControllerDeadzoneThumbRight.Text = textblock_ControllerDeadzoneThumbRight.Tag.ToString() + Convert.ToInt32(Controller.Details.Profile.DeadzoneThumbRight) + "%"; slider_ControllerDeadzoneThumbRight.Value = Controller.Details.Profile.DeadzoneThumbRight; textblock_ControllerSensitivityThumb.Text = textblock_ControllerSensitivityThumb.Tag.ToString() + Controller.Details.Profile.SensitivityThumb.ToString("0.00"); slider_ControllerSensitivityThumb.Value = Controller.Details.Profile.SensitivityThumb; cb_ControllerRumbleEnabled.IsChecked = Controller.Details.Profile.ControllerRumbleEnabled; if (Controller.Details.Profile.ControllerRumbleEnabled) { slider_ControllerRumbleStrength.IsEnabled = true; slider_ControllerRumbleLimit.IsEnabled = true; } else { slider_ControllerRumbleStrength.IsEnabled = false; slider_ControllerRumbleLimit.IsEnabled = false; } textblock_ControllerRumbleLimit.Text = textblock_ControllerRumbleLimit.Tag.ToString() + Convert.ToInt32(Controller.Details.Profile.ControllerRumbleLimit) + "%"; slider_ControllerRumbleLimit.Value = Controller.Details.Profile.ControllerRumbleLimit; textblock_ControllerRumbleStrength.Text = textblock_ControllerRumbleStrength.Tag.ToString() + Convert.ToInt32(Controller.Details.Profile.ControllerRumbleStrength) + "%"; slider_ControllerRumbleStrength.Value = Controller.Details.Profile.ControllerRumbleStrength; cb_TriggerRumbleEnabled.IsChecked = Controller.Details.Profile.TriggerRumbleEnabled; if (Controller.Details.Profile.TriggerRumbleEnabled) { slider_TriggerRumbleStrengthLeft.IsEnabled = true; slider_TriggerRumbleStrengthRight.IsEnabled = true; } else { slider_TriggerRumbleStrengthLeft.IsEnabled = false; slider_TriggerRumbleStrengthRight.IsEnabled = false; } textblock_TriggerRumbleStrengthLeft.Text = textblock_TriggerRumbleStrengthLeft.Tag.ToString() + Convert.ToInt32(Controller.Details.Profile.TriggerRumbleStrengthLeft) + "%"; slider_TriggerRumbleStrengthLeft.Value = Controller.Details.Profile.TriggerRumbleStrengthLeft; textblock_TriggerRumbleStrengthRight.Text = textblock_TriggerRumbleStrengthRight.Tag.ToString() + Convert.ToInt32(Controller.Details.Profile.TriggerRumbleStrengthRight) + "%"; slider_TriggerRumbleStrengthRight.Value = Controller.Details.Profile.TriggerRumbleStrengthRight; textblock_ControllerLedBrightness.Text = textblock_ControllerLedBrightness.Tag.ToString() + Convert.ToInt32(Controller.Details.Profile.LedBrightness) + "%"; slider_ControllerLedBrightness.Value = Controller.Details.Profile.LedBrightness; }); } catch { } }
public ControllerStatusEventArgs(ControllerStatus status) { Status = status; Timestamp = DateTime.UtcNow; }
//Check if the controller is currently idle bool CheckControllerIdle(ControllerStatus controllerStatus) { try { //D-Pad if (controllerStatus.InputCurrent.DPadLeft.PressedRaw || controllerStatus.InputCurrent.DPadUp.PressedRaw || controllerStatus.InputCurrent.DPadRight.PressedRaw || controllerStatus.InputCurrent.DPadDown.PressedRaw) { return(false); } //Buttons if (controllerStatus.InputCurrent.ButtonA.PressedRaw || controllerStatus.InputCurrent.ButtonB.PressedRaw || controllerStatus.InputCurrent.ButtonX.PressedRaw || controllerStatus.InputCurrent.ButtonY.PressedRaw) { return(false); } if (controllerStatus.InputCurrent.ButtonBack.PressedRaw || controllerStatus.InputCurrent.ButtonStart.PressedRaw || controllerStatus.InputCurrent.ButtonGuide.PressedRaw) { return(false); } if (controllerStatus.InputCurrent.ButtonTouchpad.PressedRaw || controllerStatus.InputCurrent.ButtonMedia.PressedRaw) { return(false); } if (controllerStatus.InputCurrent.ButtonShoulderLeft.PressedRaw || controllerStatus.InputCurrent.ButtonShoulderRight.PressedRaw) { return(false); } if (controllerStatus.InputCurrent.ButtonThumbLeft.PressedRaw || controllerStatus.InputCurrent.ButtonThumbRight.PressedRaw) { return(false); } //Triggers if (!controllerStatus.Details.Profile.UseButtonTriggers) { if (controllerStatus.InputCurrent.TriggerLeft >= 10 || controllerStatus.InputCurrent.TriggerRight >= 10) { return(false); } } else { if (controllerStatus.InputCurrent.ButtonTriggerLeft.PressedRaw || controllerStatus.InputCurrent.ButtonTriggerRight.PressedRaw) { return(false); } } //Left stick movement if (Math.Abs(controllerStatus.InputCurrent.ThumbLeftY) > vControllerOffsetSmall || Math.Abs(controllerStatus.InputCurrent.ThumbLeftX) > vControllerOffsetSmall) { return(false); } //Right stick movement if (Math.Abs(controllerStatus.InputCurrent.ThumbRightY) > vControllerOffsetSmall || Math.Abs(controllerStatus.InputCurrent.ThumbRightX) > vControllerOffsetSmall) { return(false); } //Debug.WriteLine("Controller " + Controller.NumberId + " is currently idle."); } catch { } return(true); }
public ControllerStatusEventArgs(ControllerStatus status) { Status = status; }
/// <summary> /// This method checks for input on a gamepad /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void WatchButtons(object sender, DoWorkEventArgs e) { GamePadButtons prevState = new GamePadButtons(); BackgroundWorker worker = sender as BackgroundWorker; while (true) { if (worker.CancellationPending) { return; } var controller = GamePad.GetState(PlayerIndex.One); GamePadButtons currentState = controller.Buttons; Status = controller.IsConnected ? ControllerStatus.Attached : ControllerStatus.Detached; if (!controller.IsConnected) { // It's not plugged in, we might as well wait a full second // before checking again Thread.Sleep(1000); } else { // check for new key downs (was released, now pressed) if (prevState.A == ButtonState.Released && currentState.A == ButtonState.Pressed) { ButtonDown(Buttons.A); } if (prevState.B == ButtonState.Released && currentState.B == ButtonState.Pressed) { ButtonDown(Buttons.B); } if (prevState.Back == ButtonState.Released && currentState.Back == ButtonState.Pressed) { ButtonDown(Buttons.Back); } if (prevState.BigButton == ButtonState.Released && currentState.BigButton == ButtonState.Pressed) { ButtonDown(Buttons.BigButton); } if (prevState.LeftShoulder == ButtonState.Released && currentState.LeftShoulder == ButtonState.Pressed) { ButtonDown(Buttons.LeftShoulder); } if (prevState.LeftStick == ButtonState.Released && currentState.LeftStick == ButtonState.Pressed) { ButtonDown(Buttons.LeftStick); } if (prevState.RightShoulder == ButtonState.Released && currentState.RightShoulder == ButtonState.Pressed) { ButtonDown(Buttons.RightShoulder); } if (prevState.RightStick == ButtonState.Released && currentState.RightStick == ButtonState.Pressed) { ButtonDown(Buttons.RightStick); } if (prevState.Start == ButtonState.Released && currentState.Start == ButtonState.Pressed) { ButtonDown(Buttons.Start); } if (prevState.X == ButtonState.Released && currentState.X == ButtonState.Pressed) { ButtonDown(Buttons.X); } if (prevState.Y == ButtonState.Released && currentState.Y == ButtonState.Pressed) { ButtonDown(Buttons.Y); } // check for new key ups (was pressed, now released) if (prevState.A == ButtonState.Pressed && currentState.A == ButtonState.Released) { ButtonUp(Buttons.A); } if (prevState.B == ButtonState.Pressed && currentState.B == ButtonState.Released) { ButtonUp(Buttons.B); } if (prevState.Back == ButtonState.Pressed && currentState.Back == ButtonState.Released) { ButtonUp(Buttons.Back); } if (prevState.BigButton == ButtonState.Pressed && currentState.BigButton == ButtonState.Released) { ButtonUp(Buttons.BigButton); } if (prevState.LeftShoulder == ButtonState.Pressed && currentState.LeftShoulder == ButtonState.Released) { ButtonUp(Buttons.LeftShoulder); } if (prevState.LeftStick == ButtonState.Pressed && currentState.LeftStick == ButtonState.Released) { ButtonUp(Buttons.LeftStick); } if (prevState.RightShoulder == ButtonState.Pressed && currentState.RightShoulder == ButtonState.Released) { ButtonUp(Buttons.RightShoulder); } if (prevState.RightStick == ButtonState.Pressed && currentState.RightStick == ButtonState.Released) { ButtonUp(Buttons.RightStick); } if (prevState.Start == ButtonState.Pressed && currentState.Start == ButtonState.Released) { ButtonUp(Buttons.Start); } if (prevState.X == ButtonState.Pressed && currentState.X == ButtonState.Released) { ButtonUp(Buttons.X); } if (prevState.Y == ButtonState.Pressed && currentState.Y == ButtonState.Released) { ButtonUp(Buttons.Y); } prevState = currentState; } Thread.Sleep(50); } }
//Update interface controller buttons preview void UpdateControllerPreviewButtons(ControllerStatus Controller) { try { AVActions.ActionDispatcherInvoke(delegate { //Update name and type txt_ActiveControllerType.Text = Controller.Details.Wireless ? "Wireless" : "Wired"; txt_ActiveControllerName.Text = Controller.Details.DisplayName; txt_ActiveControllerName.Foreground = new SolidColorBrush((Color)Controller.Color); //Update latency long latencyMs = Controller.LastInputTicks - Controller.PrevInputTicks; txt_ActiveControllerLatency.Text = "Latency " + latencyMs + "ms"; //Update battery if (Controller.BatteryCurrent.BatteryStatus == BatteryStatus.Charging) { txt_ActiveControllerBattery.Text = "Battery charging"; } else if (Controller.BatteryCurrent.BatteryStatus == BatteryStatus.Unknown) { txt_ActiveControllerBattery.Text = "Battery unknown"; } else { txt_ActiveControllerBattery.Text = "Battery is at " + Controller.BatteryCurrent.BatteryPercentage + "%"; } //DPad if (Controller.InputCurrent.DPadLeft.PressedRaw) { img_ControllerPreview_DPadLeft.Visibility = Visibility.Visible; } else { img_ControllerPreview_DPadLeft.Visibility = Visibility.Collapsed; } if (Controller.InputCurrent.DPadUp.PressedRaw) { img_ControllerPreview_DPadUp.Visibility = Visibility.Visible; } else { img_ControllerPreview_DPadUp.Visibility = Visibility.Collapsed; } if (Controller.InputCurrent.DPadRight.PressedRaw) { img_ControllerPreview_DPadRight.Visibility = Visibility.Visible; } else { img_ControllerPreview_DPadRight.Visibility = Visibility.Collapsed; } if (Controller.InputCurrent.DPadDown.PressedRaw) { img_ControllerPreview_DPadDown.Visibility = Visibility.Visible; } else { img_ControllerPreview_DPadDown.Visibility = Visibility.Collapsed; } //Buttons if (Controller.InputCurrent.ButtonA.PressedRaw) { img_ControllerPreview_ButtonA.Visibility = Visibility.Visible; } else { img_ControllerPreview_ButtonA.Visibility = Visibility.Collapsed; } if (Controller.InputCurrent.ButtonB.PressedRaw) { img_ControllerPreview_ButtonB.Visibility = Visibility.Visible; } else { img_ControllerPreview_ButtonB.Visibility = Visibility.Collapsed; } if (Controller.InputCurrent.ButtonX.PressedRaw) { img_ControllerPreview_ButtonX.Visibility = Visibility.Visible; } else { img_ControllerPreview_ButtonX.Visibility = Visibility.Collapsed; } if (Controller.InputCurrent.ButtonY.PressedRaw) { img_ControllerPreview_ButtonY.Visibility = Visibility.Visible; } else { img_ControllerPreview_ButtonY.Visibility = Visibility.Collapsed; } if (Controller.InputCurrent.ButtonBack.PressedRaw) { img_ControllerPreview_ButtonBack.Visibility = Visibility.Visible; } else { img_ControllerPreview_ButtonBack.Visibility = Visibility.Collapsed; } if (Controller.InputCurrent.ButtonStart.PressedRaw) { img_ControllerPreview_ButtonStart.Visibility = Visibility.Visible; } else { img_ControllerPreview_ButtonStart.Visibility = Visibility.Collapsed; } if (Controller.InputCurrent.ButtonGuide.PressedRaw) { img_ControllerPreview_ButtonGuide.Visibility = Visibility.Visible; } else { img_ControllerPreview_ButtonGuide.Visibility = Visibility.Collapsed; } if (Controller.InputCurrent.ButtonTouchpad.PressedRaw) { img_ControllerPreview_ButtonTouchpad.Visibility = Visibility.Visible; } else { img_ControllerPreview_ButtonTouchpad.Visibility = Visibility.Collapsed; } if (Controller.InputCurrent.ButtonMedia.PressedRaw) { img_ControllerPreview_ButtonMedia.Visibility = Visibility.Visible; } else { img_ControllerPreview_ButtonMedia.Visibility = Visibility.Collapsed; } if (Controller.InputCurrent.ButtonShoulderLeft.PressedRaw) { img_ControllerPreview_ButtonShoulderLeft.Visibility = Visibility.Visible; } else { img_ControllerPreview_ButtonShoulderLeft.Visibility = Visibility.Collapsed; } if (Controller.InputCurrent.ButtonShoulderRight.PressedRaw) { img_ControllerPreview_ButtonShoulderRight.Visibility = Visibility.Visible; } else { img_ControllerPreview_ButtonShoulderRight.Visibility = Visibility.Collapsed; } if (Controller.InputCurrent.ButtonThumbLeft.PressedRaw) { img_ControllerPreview_ButtonThumbLeft.Visibility = Visibility.Visible; } else { img_ControllerPreview_ButtonThumbLeft.Visibility = Visibility.Collapsed; } if (Controller.InputCurrent.ButtonThumbRight.PressedRaw) { img_ControllerPreview_ButtonThumbRight.Visibility = Visibility.Visible; } else { img_ControllerPreview_ButtonThumbRight.Visibility = Visibility.Collapsed; } //Triggers if (!Controller.Details.Profile.UseButtonTriggers) { textblock_Trigger_Left.Text = Controller.InputCurrent.TriggerLeft.ToString(); textblock_Trigger_Right.Text = Controller.InputCurrent.TriggerRight.ToString(); img_ControllerPreview_TriggerLeft.Opacity = (double)(Controller.InputCurrent.TriggerLeft * 257) / 65535; img_ControllerPreview_TriggerRight.Opacity = (double)(Controller.InputCurrent.TriggerRight * 257) / 65535; } else { if (Controller.InputCurrent.ButtonTriggerLeft.PressedRaw) { textblock_Trigger_Left.Text = "255"; img_ControllerPreview_TriggerLeft.Opacity = 1.00; } else { textblock_Trigger_Left.Text = "0"; img_ControllerPreview_TriggerLeft.Opacity = 0.00; } if (Controller.InputCurrent.ButtonTriggerRight.PressedRaw) { textblock_Trigger_Right.Text = "255"; img_ControllerPreview_TriggerRight.Opacity = 1.00; } else { textblock_Trigger_Right.Text = "0"; img_ControllerPreview_TriggerRight.Opacity = 0.00; } } //Thumb Left and Right Image int LeftX = Controller.InputCurrent.ThumbLeftX / 1000; int LeftY = -Controller.InputCurrent.ThumbLeftY / 1000; int RightX = Controller.InputCurrent.ThumbRightX / 1000; int RightY = -Controller.InputCurrent.ThumbRightY / 1000; img_ControllerPreview_LeftAxe.Margin = new Thickness(LeftX, LeftY, 0, 0); img_ControllerPreview_RightAxe.Margin = new Thickness(RightX, RightY, 0, 0); //Thumb Left and Right Percentage int PercentageLeftYUp = (Controller.InputCurrent.ThumbLeftY * 257) / 65535; if (PercentageLeftYUp < 0) { PercentageLeftYUp = 0; } int PercentageLeftYDown = (-Controller.InputCurrent.ThumbLeftY * 257) / 65535; if (PercentageLeftYDown < 0) { PercentageLeftYDown = 0; } int PercentageLeftXLeft = (-Controller.InputCurrent.ThumbLeftX * 257) / 65535; if (PercentageLeftXLeft < 0) { PercentageLeftXLeft = 0; } int PercentageLeftXRight = (Controller.InputCurrent.ThumbLeftX * 257) / 65535; if (PercentageLeftXRight < 0) { PercentageLeftXRight = 0; } textblock_Thumb_Left_Y_Up.Text = PercentageLeftYUp.ToString(); textblock_Thumb_Left_Y_Down.Text = PercentageLeftYDown.ToString(); textblock_Thumb_Left_X_Left.Text = PercentageLeftXLeft.ToString(); textblock_Thumb_Left_X_Right.Text = PercentageLeftXRight.ToString(); int PercentageRightYUp = (Controller.InputCurrent.ThumbRightY * 257) / 65535; if (PercentageRightYUp < 0) { PercentageRightYUp = 0; } int PercentageRightYDown = (-Controller.InputCurrent.ThumbRightY * 257) / 65535; if (PercentageRightYDown < 0) { PercentageRightYDown = 0; } int PercentageRightXLeft = (-Controller.InputCurrent.ThumbRightX * 257) / 65535; if (PercentageRightXLeft < 0) { PercentageRightXLeft = 0; } int PercentageRightXRight = (Controller.InputCurrent.ThumbRightX * 257) / 65535; if (PercentageRightXRight < 0) { PercentageRightXRight = 0; } textblock_Thumb_Right_Y_Up.Text = PercentageRightYUp.ToString(); textblock_Thumb_Right_Y_Down.Text = PercentageRightYDown.ToString(); textblock_Thumb_Right_X_Left.Text = PercentageRightXLeft.ToString(); textblock_Thumb_Right_X_Right.Text = PercentageRightXRight.ToString(); }); } catch { } }
private void OnMouseUp() { // Changing the status of the Card Status = ControllerStatus.Inactive; InterfaceManager.Instance.DisableArrow(); InterfaceManager.Instance.IsDragging = false; // Checking if it's the turn of the Player if (GameManager.Instance.CurrentPlayer == Card.Player) { // Checking if the Player has enough mana to play the Card if (Card.Player.AvailableMana >= Card.CurrentCost) { switch (Card.GetCardType()) { case CardType.Minion: if (Card.Player.BoardController.SelfBoardContainsPoint(Util.GetWorldMousePosition())) { if (Card.Player.Minions.Count < 7) { Card.Play(); } } break; case CardType.Weapon: if (Card.Player.BoardController.AllBoardContainsPoint(Util.GetWorldMousePosition())) { Card.Play(); } break; case CardType.Spell: SpellCard spellCard = Card.As <SpellCard>(); if (spellCard.TargetType == TargetType.NoTarget) { if (Card.Player.BoardController.AllBoardContainsPoint(Util.GetWorldMousePosition())) { spellCard.PlayOn(null); } } else { Character target = Util.GetCharacterAtMouse(); if (spellCard.CanTarget(target)) { spellCard.PlayOn(target); } } break; } } else { // TODO : Display not enough mana message } } }
//Update and prepare XInput byte data void PrepareXInputDataCurrent(ControllerStatus Controller) { try { //Set report structure XUSB_REPORT usbReport = new XUSB_REPORT(); //Set current input //Thumbs usbReport.sThumbLX = (short)Controller.InputCurrent.ThumbLeftX; usbReport.sThumbLY = (short)Controller.InputCurrent.ThumbLeftY; usbReport.sThumbRX = (short)Controller.InputCurrent.ThumbRightX; usbReport.sThumbRY = (short)Controller.InputCurrent.ThumbRightY; //Triggers if (!Controller.Details.Profile.UseButtonTriggers) { usbReport.bLeftTrigger = Controller.InputCurrent.TriggerLeft; usbReport.bRightTrigger = Controller.InputCurrent.TriggerRight; } else { if (Controller.InputCurrent.ButtonTriggerLeft.PressedRaw) { usbReport.bLeftTrigger = 255; } if (Controller.InputCurrent.ButtonTriggerRight.PressedRaw) { usbReport.bRightTrigger = 255; } } //DPad if (Controller.InputCurrent.DPadLeft.PressedRaw) { usbReport.wButtons |= XUSB_BUTTON.XUSB_GAMEPAD_DPAD_LEFT; } if (Controller.InputCurrent.DPadUp.PressedRaw) { usbReport.wButtons |= XUSB_BUTTON.XUSB_GAMEPAD_DPAD_UP; } if (Controller.InputCurrent.DPadRight.PressedRaw) { usbReport.wButtons |= XUSB_BUTTON.XUSB_GAMEPAD_DPAD_RIGHT; } if (Controller.InputCurrent.DPadDown.PressedRaw) { usbReport.wButtons |= XUSB_BUTTON.XUSB_GAMEPAD_DPAD_DOWN; } //Buttons if (Controller.InputCurrent.ButtonA.PressedRaw) { usbReport.wButtons |= XUSB_BUTTON.XUSB_GAMEPAD_A; } if (Controller.InputCurrent.ButtonB.PressedRaw) { usbReport.wButtons |= XUSB_BUTTON.XUSB_GAMEPAD_B; } if (Controller.InputCurrent.ButtonX.PressedRaw) { usbReport.wButtons |= XUSB_BUTTON.XUSB_GAMEPAD_X; } if (Controller.InputCurrent.ButtonY.PressedRaw) { usbReport.wButtons |= XUSB_BUTTON.XUSB_GAMEPAD_Y; } if (Controller.InputCurrent.ButtonBack.PressedRaw) { usbReport.wButtons |= XUSB_BUTTON.XUSB_GAMEPAD_BACK; } if (Controller.InputCurrent.ButtonStart.PressedRaw) { usbReport.wButtons |= XUSB_BUTTON.XUSB_GAMEPAD_START; } if (Controller.InputCurrent.ButtonGuide.PressedRaw) { usbReport.wButtons |= XUSB_BUTTON.XUSB_GAMEPAD_GUIDE; } if (Controller.InputCurrent.ButtonShoulderLeft.PressedRaw) { usbReport.wButtons |= XUSB_BUTTON.XUSB_GAMEPAD_LEFT_SHOULDER; } if (Controller.InputCurrent.ButtonShoulderRight.PressedRaw) { usbReport.wButtons |= XUSB_BUTTON.XUSB_GAMEPAD_RIGHT_SHOULDER; } if (Controller.InputCurrent.ButtonThumbLeft.PressedRaw) { usbReport.wButtons |= XUSB_BUTTON.XUSB_GAMEPAD_LEFT_THUMB; } if (Controller.InputCurrent.ButtonThumbRight.PressedRaw) { usbReport.wButtons |= XUSB_BUTTON.XUSB_GAMEPAD_RIGHT_THUMB; } //Set submit structure Controller.XInputData = new XUSB_INPUT_REPORT(); Controller.XInputData.Size = Marshal.SizeOf(Controller.XInputData); Controller.XInputData.SerialNo = Controller.NumberId + 1; Controller.XInputData.Report = usbReport; } catch { } }
/// <summary> /// Exchange data with devices /// </summary> /// <param name="address">Address</param> /// <param name="command">Command</param> /// <param name="writeData">Write data</param> /// <param name="readData">Read data</param> /// <param name="readString">Read data</param> /// <param name="status">Status of exchange</param> /// <param name="info">Info string</param> /// <returns>Error string</returns> public string Exchange(byte address, byte command, byte[] writeData, out byte[] readData, out string readString, out ControllerStatus status, out string info) { // Prepare byte array readData = null; readString = ""; status = ControllerStatus.DeviceError; info = ""; if (_myFtdiDevice == null) return "Unsupported OS"; byte[] data = new byte[3 + writeData.Length]; data[0] = address; data[1] = (byte)(writeData.Length + 1); data[2] = command; for (int i = 0; i < writeData.Length; i++) data[i + 3] = writeData[i]; byte[] fullData = new byte[data.Length + 1]; for (int i = 1; i < data.Length; i++) fullData[i - 1] = data[i]; byte[] crc = _crc16Ccitt.ComputeChecksumBytes(data); fullData[fullData.Length - 2] = crc[0]; fullData[fullData.Length - 1] = crc[1]; //Reopen device if it need if (!_myFtdiDevice.IsOpen) { string error = OpenDevice(out status, out info); if (error != "") return error; } //Write data byte[] addr = new byte[] { address }; _wStatus[0] = _myFtdiDevice.Purge(FT_PURGE.FT_PURGE_RX | FT_PURGE.FT_PURGE_TX); _wStatus[1] = _myFtdiDevice.SetDataCharacteristics(FT_DATA_BITS.FT_BITS_8, FT_STOP_BITS.FT_STOP_BITS_1, FT_PARITY.FT_PARITY_MARK); _wStatus[2] = _myFtdiDevice.Write(addr, addr.Length, ref _numBytesWritten); _wStatus[3] = _myFtdiDevice.SetDataCharacteristics(FT_DATA_BITS.FT_BITS_8, FT_STOP_BITS.FT_STOP_BITS_1, FT_PARITY.FT_PARITY_SPACE); _wStatus[4] = _myFtdiDevice.Write(fullData, fullData.Length, ref _numBytesWritten); //Read data _rStatus[0] = _myFtdiDevice.Read(_answerAddress, _one, ref _numBytesRead0); _rStatus[1] = _myFtdiDevice.Read(_answerLength, _one, ref _numBytesRead1); if (command == 0) _rStatus[2] = _myFtdiDevice.Read(out readString, _answerLength[0], ref _numBytesRead2); else { readData = new byte[_answerLength[0]]; _rStatus[2] = _myFtdiDevice.Read(readData, _answerLength[0], ref _numBytesRead2); } _rStatus[3] = _myFtdiDevice.Read(_answerCRC16, _two, ref _numBytesRead3); //Check statuses if (_wStatus[0] != FT_STATUS.FT_OK) { status = ControllerStatus.Error; return string.Format("Failed to purge buffers (error {0})", _wStatus[0]); } if (_wStatus[1] != FT_STATUS.FT_OK) { status = ControllerStatus.Error; return string.Format("Failed to set data characteristics (error {0})", _wStatus[1]); } if (_wStatus[2] != FT_STATUS.FT_OK) { status = ControllerStatus.Error; return string.Format("Failed to write to device (error {0})", _wStatus[2]); } if (_wStatus[3] != FT_STATUS.FT_OK) { status = ControllerStatus.Error; return string.Format("Failed to set data characteristics (error {0})", _wStatus[3]); } if (_wStatus[4] != FT_STATUS.FT_OK) { status = ControllerStatus.Error; return string.Format("Failed to write to device (error {0})", _wStatus[4]); } if (_rStatus[0] != FT_STATUS.FT_OK) { status = ControllerStatus.Error; return string.Format("Failed to read data from device (error {0})", _rStatus[0]); } if (_numBytesRead0 != 1) { status = ControllerStatus.Error; return "Can't to read data from device"; } if (_answerAddress[0] != address) { status = ControllerStatus.Error; return "Was read wrong address of data from device"; } if (_rStatus[1] != FT_STATUS.FT_OK) { status = ControllerStatus.Error; return string.Format("Failed to read data from device (error {0})", _rStatus[1]); } if (_numBytesRead1 != 1) { status = ControllerStatus.Error; return "Can't to read data from device"; } if (_answerLength[0] == 0) { status = ControllerStatus.Error; return "Was read zero length of data from device"; } if (_rStatus[2] != FT_STATUS.FT_OK) { status = ControllerStatus.Error; return string.Format("Failed to read data from device (error {0})", _rStatus[2]); } if (_numBytesRead2 != _answerLength[0]) { status = ControllerStatus.Error; return "Can't to read data from device"; } if (_rStatus[3] != FT_STATUS.FT_OK) { status = ControllerStatus.Error; return string.Format("Failed to read data from device (error {0})", _rStatus[3]); } if (_numBytesRead3 != 2) { status = ControllerStatus.Error; return "Can't to read data from device"; } //Check CRC16 _answer = new byte[_answerLength[0] + 2]; _answer[0] = _answerAddress[0]; _answer[1] = _answerLength[0]; if (command == 0) for (int i = 2; i < _answer.Length; i++) _answer[i] = (byte)readString[i - 2]; else for (int i = 2; i < _answer.Length; i++) _answer[i] = readData[i - 2]; _checkCRC16 = _crc16Ccitt.ComputeChecksumBytes(_answer); if (_checkCRC16[0] != _answerCRC16[0] || _checkCRC16[1] != _answerCRC16[1]) { status = ControllerStatus.Error; return "Was read wrong CRC16 from device"; } else { if (status != ControllerStatus.DeviceOpened) status = ControllerStatus.OK; return ""; } }
protected void Idle() { cStatus = ControllerStatus.Idle; timeStamp = Time.time; }
protected void Parry() { cStatus = ControllerStatus.Parry; animator[parryAnim.name].speed = 1; animator.Play(parryAnim.name); }
public void EndListen(IAsyncResult asyncResult) { try { MessageAsyncResult result = asyncResult as MessageAsyncResult; if (asyncResult == null || result == null) { throw (asyncResult == null) ? new ArgumentNullException("asyncResult") : new ArgumentException(); } object o = result.InternalWaitForCompletion(); if (o is Exception) { throw ((Exception)o); } _status = ControllerStatus.Listen; } catch (Exception e) { Trace.TraceError("Controller#{0}::EndListen, Exception = {1}", ValidationHelper.HashString(this), e); throw; } }
protected void Dodge() { cStatus = ControllerStatus.Dodge; stamina -= dodgeStaminaCost; animator.Play(dodgeAnim.name); }
public IAsyncResult BeginConnect(string callingPartyNumber, string calledPartyNumber, CIPServices service, B1Protocol b1, B2Protocol b2, B3Protocol b3, AsyncCallback callback, object state) { try { ConnectRequest request = new ConnectRequest(_id); UInt16 CIPValue = 0; int s = (int)service; if (s != 0) { do { if ((s & 1) != 0) break; s >>= 1; CIPValue++; } while (CIPValue < 31); } request.CIPValue = CIPValue; request.CalledPartyNumber = calledPartyNumber; request.CallingPartyNumber = callingPartyNumber; request.BPtotocol.B1 = b1; request.BPtotocol.B2 = b2; request.BPtotocol.B3 = b3; MessageAsyncResult result = new MessageAsyncResult(this, request, callback, state); _application.SendRequestMessage(result); _status = ControllerStatus.Connecting; return result; } catch (Exception e) { Trace.TraceError("Controller#{0}::BeginListen, Exception = {1}", ValidationHelper.HashString(this), e); throw; } }
static void Controller_ControllerStatusChanged(object sender, ControllerStatusEventArgs args) { Console.WriteLine("ControllerStatusChange {0}", args.Status); ToggleDebug(true); var controller = (sender as ZWaveController); controllerStatus = args.Status; switch (controllerStatus) { case ControllerStatus.Connected: // Initialize the controller and get the node list controller.Initialize(); break; case ControllerStatus.Disconnected: ShowMenu(); break; case ControllerStatus.Initializing: break; case ControllerStatus.Ready: // Query all nodes (Supported Classes, Routing Info, Node Information Frame, Manufacturer Specific) controller.Discovery(); ShowMenu(); break; case ControllerStatus.Error: Console.WriteLine("\nEnter [+] to try reconnect\n"); ShowMenu(); break; } ToggleDebug(false); }
//Register Interface Handlers void RegisterInterfaceHandlers() { try { //Make sure the correct window style is set StateChanged += CheckWindowStateAndStyle; //Main menu functions lb_Menu.PreviewKeyUp += lb_Menu_KeyPressUp; lb_Menu.PreviewMouseUp += lb_Menu_MousePressUp; //Connection functions button_Controller0.Click += Button_Controller0_Click; button_Controller1.Click += Button_Controller1_Click; button_Controller2.Click += Button_Controller2_Click; button_Controller3.Click += Button_Controller3_Click; btn_IgnoreController.Click += btn_IgnoreController_Click; btn_DisconnectController.Click += Btn_DisconnectController_Click; btn_DisconnectControllerAll.Click += Btn_DisconnectControllerAll_Click; btn_RemoveController.Click += Btn_RemoveController_Click; btn_CopyDebugInformation.Click += Btn_CopyDebugInformation_Click; btn_CheckControllers.Click += btn_CheckControllers_Click; btn_CheckDeviceManager.Click += btn_CheckDeviceManager_Click; //Ignore functions listbox_ControllerIgnore.PreviewKeyUp += Listbox_ControllerIgnore_PreviewKeyUp; listbox_ControllerIgnore.PreviewMouseUp += Listbox_ControllerIgnore_PreviewMouseUp; //Controller functions btn_RumbleTestLight.Click += Btn_TestRumble_Click; btn_RumbleTestHeavy.Click += Btn_TestRumble_Click; //Save button settings cb_ControllerFakeGuideButton.Click += (sender, e) => { ControllerStatus activeController = vActiveController(); if (activeController != null) { activeController.Details.Profile.FakeGuideButton = cb_ControllerFakeGuideButton.IsChecked.Value; if (cb_ControllerFakeGuideButton.IsChecked.Value) { cb_ControllerFakeMediaButton.IsChecked = false; activeController.Details.Profile.FakeMediaButton = false; } //Save changes to Json file JsonSaveObject(activeController.Details.Profile, GenerateJsonNameControllerProfile(activeController.Details.Profile)); } }; cb_ControllerFakeMediaButton.Click += (sender, e) => { ControllerStatus activeController = vActiveController(); if (activeController != null) { activeController.Details.Profile.FakeMediaButton = cb_ControllerFakeMediaButton.IsChecked.Value; if (cb_ControllerFakeMediaButton.IsChecked.Value) { cb_ControllerFakeGuideButton.IsChecked = false; activeController.Details.Profile.FakeGuideButton = false; } //Save changes to Json file JsonSaveObject(activeController.Details.Profile, GenerateJsonNameControllerProfile(activeController.Details.Profile)); } }; cb_ControllerFakeTouchpadButton.Click += (sender, e) => { ControllerStatus activeController = vActiveController(); if (activeController != null) { activeController.Details.Profile.FakeTouchpadButton = cb_ControllerFakeTouchpadButton.IsChecked.Value; //Save changes to Json file JsonSaveObject(activeController.Details.Profile, GenerateJsonNameControllerProfile(activeController.Details.Profile)); } }; //Controller Trigger cb_ControllerUseButtonTriggers.Click += (sender, e) => { ControllerStatus activeController = vActiveController(); if (activeController != null) { activeController.Details.Profile.UseButtonTriggers = cb_ControllerUseButtonTriggers.IsChecked.Value; //Save changes to Json file JsonSaveObject(activeController.Details.Profile, GenerateJsonNameControllerProfile(activeController.Details.Profile)); } }; slider_ControllerDeadzoneTriggerLeft.ValueChanged += (sender, e) => { ControllerStatus activeController = vActiveController(); if (activeController != null) { textblock_ControllerDeadzoneTriggerLeft.Text = textblock_ControllerDeadzoneTriggerLeft.Tag.ToString() + Convert.ToInt32(slider_ControllerDeadzoneTriggerLeft.Value) + "%"; activeController.Details.Profile.DeadzoneTriggerLeft = Convert.ToInt32(slider_ControllerDeadzoneTriggerLeft.Value); //Save changes to Json file JsonSaveObject(activeController.Details.Profile, GenerateJsonNameControllerProfile(activeController.Details.Profile)); } }; slider_ControllerDeadzoneTriggerRight.ValueChanged += (sender, e) => { ControllerStatus activeController = vActiveController(); if (activeController != null) { textblock_ControllerDeadzoneTriggerRight.Text = textblock_ControllerDeadzoneTriggerRight.Tag.ToString() + Convert.ToInt32(slider_ControllerDeadzoneTriggerRight.Value) + "%"; activeController.Details.Profile.DeadzoneTriggerRight = Convert.ToInt32(slider_ControllerDeadzoneTriggerRight.Value); //Save changes to Json file JsonSaveObject(activeController.Details.Profile, GenerateJsonNameControllerProfile(activeController.Details.Profile)); } }; slider_ControllerSensitivityTriggerLeft.ValueChanged += (sender, e) => { ControllerStatus activeController = vActiveController(); if (activeController != null) { textblock_ControllerSensitivityTriggerLeft.Text = textblock_ControllerSensitivityTriggerLeft.Tag.ToString() + slider_ControllerSensitivityTriggerLeft.Value.ToString("0.00"); activeController.Details.Profile.SensitivityTriggerLeft = slider_ControllerSensitivityTriggerLeft.Value; //Save changes to Json file JsonSaveObject(activeController.Details.Profile, GenerateJsonNameControllerProfile(activeController.Details.Profile)); } }; slider_ControllerSensitivityTriggerRight.ValueChanged += (sender, e) => { ControllerStatus activeController = vActiveController(); if (activeController != null) { textblock_ControllerSensitivityTriggerRight.Text = textblock_ControllerSensitivityTriggerRight.Tag.ToString() + slider_ControllerSensitivityTriggerRight.Value.ToString("0.00"); activeController.Details.Profile.SensitivityTriggerRight = slider_ControllerSensitivityTriggerRight.Value; //Save changes to Json file JsonSaveObject(activeController.Details.Profile, GenerateJsonNameControllerProfile(activeController.Details.Profile)); } }; //Controller DPad cb_ControllerDPadFourWayMovement.Click += (sender, e) => { ControllerStatus activeController = vActiveController(); if (activeController != null) { activeController.Details.Profile.DPadFourWayMovement = cb_ControllerDPadFourWayMovement.IsChecked.Value; //Save changes to Json file JsonSaveObject(activeController.Details.Profile, GenerateJsonNameControllerProfile(activeController.Details.Profile)); } }; //Controller Thumb Stick cb_ControllerThumbFlipMovement.Click += (sender, e) => { ControllerStatus activeController = vActiveController(); if (activeController != null) { activeController.Details.Profile.ThumbFlipMovement = cb_ControllerThumbFlipMovement.IsChecked.Value; //Save changes to Json file JsonSaveObject(activeController.Details.Profile, GenerateJsonNameControllerProfile(activeController.Details.Profile)); } }; cb_ControllerThumbFlipAxesLeft.Click += (sender, e) => { ControllerStatus activeController = vActiveController(); if (activeController != null) { activeController.Details.Profile.ThumbFlipAxesLeft = cb_ControllerThumbFlipAxesLeft.IsChecked.Value; //Save changes to Json file JsonSaveObject(activeController.Details.Profile, GenerateJsonNameControllerProfile(activeController.Details.Profile)); } }; cb_ControllerThumbFlipAxesRight.Click += (sender, e) => { ControllerStatus activeController = vActiveController(); if (activeController != null) { activeController.Details.Profile.ThumbFlipAxesRight = cb_ControllerThumbFlipAxesRight.IsChecked.Value; //Save changes to Json file JsonSaveObject(activeController.Details.Profile, GenerateJsonNameControllerProfile(activeController.Details.Profile)); } }; cb_ControllerThumbReverseAxesLeft.Click += (sender, e) => { ControllerStatus activeController = vActiveController(); if (activeController != null) { activeController.Details.Profile.ThumbReverseAxesLeft = cb_ControllerThumbReverseAxesLeft.IsChecked.Value; //Save changes to Json file JsonSaveObject(activeController.Details.Profile, GenerateJsonNameControllerProfile(activeController.Details.Profile)); } }; cb_ControllerThumbReverseAxesRight.Click += (sender, e) => { ControllerStatus activeController = vActiveController(); if (activeController != null) { activeController.Details.Profile.ThumbReverseAxesRight = cb_ControllerThumbReverseAxesRight.IsChecked.Value; //Save changes to Json file JsonSaveObject(activeController.Details.Profile, GenerateJsonNameControllerProfile(activeController.Details.Profile)); } }; slider_ControllerDeadzoneThumbLeft.ValueChanged += (sender, e) => { ControllerStatus activeController = vActiveController(); if (activeController != null) { textblock_ControllerDeadzoneThumbLeft.Text = textblock_ControllerDeadzoneThumbLeft.Tag.ToString() + Convert.ToInt32(slider_ControllerDeadzoneThumbLeft.Value) + "%"; activeController.Details.Profile.DeadzoneThumbLeft = Convert.ToInt32(slider_ControllerDeadzoneThumbLeft.Value); //Save changes to Json file JsonSaveObject(activeController.Details.Profile, GenerateJsonNameControllerProfile(activeController.Details.Profile)); } }; slider_ControllerDeadzoneThumbRight.ValueChanged += (sender, e) => { ControllerStatus activeController = vActiveController(); if (activeController != null) { textblock_ControllerDeadzoneThumbRight.Text = textblock_ControllerDeadzoneThumbRight.Tag.ToString() + Convert.ToInt32(slider_ControllerDeadzoneThumbRight.Value) + "%"; activeController.Details.Profile.DeadzoneThumbRight = Convert.ToInt32(slider_ControllerDeadzoneThumbRight.Value); //Save changes to Json file JsonSaveObject(activeController.Details.Profile, GenerateJsonNameControllerProfile(activeController.Details.Profile)); } }; slider_ControllerSensitivityThumb.ValueChanged += (sender, e) => { ControllerStatus activeController = vActiveController(); if (activeController != null) { textblock_ControllerSensitivityThumb.Text = textblock_ControllerSensitivityThumb.Tag.ToString() + slider_ControllerSensitivityThumb.Value.ToString("0.00"); activeController.Details.Profile.SensitivityThumb = slider_ControllerSensitivityThumb.Value; //Save changes to Json file JsonSaveObject(activeController.Details.Profile, GenerateJsonNameControllerProfile(activeController.Details.Profile)); } }; cb_ControllerRumbleEnabled.Click += (sender, e) => { ControllerStatus activeController = vActiveController(); if (activeController != null) { activeController.Details.Profile.ControllerRumbleEnabled = cb_ControllerRumbleEnabled.IsChecked.Value; //Save changes to Json file JsonSaveObject(activeController.Details.Profile, GenerateJsonNameControllerProfile(activeController.Details.Profile)); //Update settings interface if (activeController.Details.Profile.ControllerRumbleEnabled) { slider_ControllerRumbleStrength.IsEnabled = true; slider_ControllerRumbleLimit.IsEnabled = true; } else { slider_ControllerRumbleStrength.IsEnabled = false; slider_ControllerRumbleLimit.IsEnabled = false; } } }; slider_ControllerRumbleLimit.ValueChanged += (sender, e) => { ControllerStatus activeController = vActiveController(); if (activeController != null) { textblock_ControllerRumbleLimit.Text = textblock_ControllerRumbleLimit.Tag.ToString() + Convert.ToInt32(slider_ControllerRumbleLimit.Value) + "%"; activeController.Details.Profile.ControllerRumbleLimit = Convert.ToInt32(slider_ControllerRumbleLimit.Value); //Save changes to Json file JsonSaveObject(activeController.Details.Profile, GenerateJsonNameControllerProfile(activeController.Details.Profile)); } }; slider_ControllerRumbleStrength.ValueChanged += (sender, e) => { ControllerStatus activeController = vActiveController(); if (activeController != null) { textblock_ControllerRumbleStrength.Text = textblock_ControllerRumbleStrength.Tag.ToString() + Convert.ToInt32(slider_ControllerRumbleStrength.Value) + "%"; activeController.Details.Profile.ControllerRumbleStrength = Convert.ToInt32(slider_ControllerRumbleStrength.Value); //Save changes to Json file JsonSaveObject(activeController.Details.Profile, GenerateJsonNameControllerProfile(activeController.Details.Profile)); } }; cb_TriggerRumbleEnabled.Click += (sender, e) => { ControllerStatus activeController = vActiveController(); if (activeController != null) { activeController.Details.Profile.TriggerRumbleEnabled = cb_TriggerRumbleEnabled.IsChecked.Value; //Save changes to Json file JsonSaveObject(activeController.Details.Profile, GenerateJsonNameControllerProfile(activeController.Details.Profile)); //Update settings interface if (activeController.Details.Profile.TriggerRumbleEnabled) { slider_TriggerRumbleStrengthLeft.IsEnabled = true; slider_TriggerRumbleStrengthRight.IsEnabled = true; } else { slider_TriggerRumbleStrengthLeft.IsEnabled = false; slider_TriggerRumbleStrengthRight.IsEnabled = false; } } }; slider_TriggerRumbleStrengthLeft.ValueChanged += (sender, e) => { ControllerStatus activeController = vActiveController(); if (activeController != null) { textblock_TriggerRumbleStrengthLeft.Text = textblock_TriggerRumbleStrengthLeft.Tag.ToString() + Convert.ToInt32(slider_TriggerRumbleStrengthLeft.Value) + "%"; activeController.Details.Profile.TriggerRumbleStrengthLeft = Convert.ToInt32(slider_TriggerRumbleStrengthLeft.Value); //Save changes to Json file JsonSaveObject(activeController.Details.Profile, GenerateJsonNameControllerProfile(activeController.Details.Profile)); } }; slider_TriggerRumbleStrengthRight.ValueChanged += (sender, e) => { ControllerStatus activeController = vActiveController(); if (activeController != null) { textblock_TriggerRumbleStrengthRight.Text = textblock_TriggerRumbleStrengthRight.Tag.ToString() + Convert.ToInt32(slider_TriggerRumbleStrengthRight.Value) + "%"; activeController.Details.Profile.TriggerRumbleStrengthRight = Convert.ToInt32(slider_TriggerRumbleStrengthRight.Value); //Save changes to Json file JsonSaveObject(activeController.Details.Profile, GenerateJsonNameControllerProfile(activeController.Details.Profile)); } }; slider_ControllerLedBrightness.ValueChanged += (sender, e) => { ControllerStatus activeController = vActiveController(); if (activeController != null) { textblock_ControllerLedBrightness.Text = textblock_ControllerLedBrightness.Tag.ToString() + Convert.ToInt32(slider_ControllerLedBrightness.Value) + "%"; activeController.Details.Profile.LedBrightness = Convert.ToInt32(slider_ControllerLedBrightness.Value); //Save changes to Json file JsonSaveObject(activeController.Details.Profile, GenerateJsonNameControllerProfile(activeController.Details.Profile)); //Controller update led color ControllerLedColor(activeController); } }; //Controller button mapping functions btn_SetA.PreviewMouseLeftButtonUp += Btn_MapController_Mouse_Set; btn_SetB.PreviewMouseLeftButtonUp += Btn_MapController_Mouse_Set; btn_SetX.PreviewMouseLeftButtonUp += Btn_MapController_Mouse_Set; btn_SetY.PreviewMouseLeftButtonUp += Btn_MapController_Mouse_Set; btn_SetShoulderLeft.PreviewMouseLeftButtonUp += Btn_MapController_Mouse_Set; btn_SetShoulderRight.PreviewMouseLeftButtonUp += Btn_MapController_Mouse_Set; btn_SetThumbLeft.PreviewMouseLeftButtonUp += Btn_MapController_Mouse_Set; btn_SetThumbRight.PreviewMouseLeftButtonUp += Btn_MapController_Mouse_Set; btn_SetBack.PreviewMouseLeftButtonUp += Btn_MapController_Mouse_Set; btn_SetGuide.PreviewMouseLeftButtonUp += Btn_MapController_Mouse_Set; btn_SetStart.PreviewMouseLeftButtonUp += Btn_MapController_Mouse_Set; btn_SetTriggerLeft.PreviewMouseLeftButtonUp += Btn_MapController_Mouse_Set; btn_SetTriggerRight.PreviewMouseLeftButtonUp += Btn_MapController_Mouse_Set; btn_SetTouchpad.PreviewMouseLeftButtonUp += Btn_MapController_Mouse_Set; btn_SetMedia.PreviewMouseLeftButtonUp += Btn_MapController_Mouse_Set; button_SetController_Map.PreviewMouseLeftButtonUp += Btn_MapController_Mouse_Map; button_SetController_Unmap.PreviewMouseLeftButtonUp += Btn_MapController_Mouse_Unmap; button_SetController_Cancel.PreviewMouseLeftButtonUp += Btn_MapController_Mouse_Cancel; //Keypad button mapping functions btn_SetPadDPadLeft.PreviewMouseLeftButtonUp += Btn_MapKeypad_Mouse_Set; btn_SetPadDPadUp.PreviewMouseLeftButtonUp += Btn_MapKeypad_Mouse_Set; btn_SetPadDPadRight.PreviewMouseLeftButtonUp += Btn_MapKeypad_Mouse_Set; btn_SetPadDPadDown.PreviewMouseLeftButtonUp += Btn_MapKeypad_Mouse_Set; btn_SetPadThumbLeftLeft.PreviewMouseLeftButtonUp += Btn_MapKeypad_Mouse_Set; btn_SetPadThumbLeftUp.PreviewMouseLeftButtonUp += Btn_MapKeypad_Mouse_Set; btn_SetPadThumbLeftRight.PreviewMouseLeftButtonUp += Btn_MapKeypad_Mouse_Set; btn_SetPadThumbLeftDown.PreviewMouseLeftButtonUp += Btn_MapKeypad_Mouse_Set; btn_SetPadThumbLeft.PreviewMouseLeftButtonUp += Btn_MapKeypad_Mouse_Set; btn_SetPadThumbRightLeft.PreviewMouseLeftButtonUp += Btn_MapKeypad_Mouse_Set; btn_SetPadThumbRightUp.PreviewMouseLeftButtonUp += Btn_MapKeypad_Mouse_Set; btn_SetPadThumbRightRight.PreviewMouseLeftButtonUp += Btn_MapKeypad_Mouse_Set; btn_SetPadThumbRightDown.PreviewMouseLeftButtonUp += Btn_MapKeypad_Mouse_Set; btn_SetPadThumbRight.PreviewMouseLeftButtonUp += Btn_MapKeypad_Mouse_Set; btn_SetPadA.PreviewMouseLeftButtonUp += Btn_MapKeypad_Mouse_Set; btn_SetPadB.PreviewMouseLeftButtonUp += Btn_MapKeypad_Mouse_Set; btn_SetPadX.PreviewMouseLeftButtonUp += Btn_MapKeypad_Mouse_Set; btn_SetPadY.PreviewMouseLeftButtonUp += Btn_MapKeypad_Mouse_Set; btn_SetPadShoulderLeft.PreviewMouseLeftButtonUp += Btn_MapKeypad_Mouse_Set; btn_SetPadTriggerLeft.PreviewMouseLeftButtonUp += Btn_MapKeypad_Mouse_Set; btn_SetPadShoulderRight.PreviewMouseLeftButtonUp += Btn_MapKeypad_Mouse_Set; btn_SetPadTriggerRight.PreviewMouseLeftButtonUp += Btn_MapKeypad_Mouse_Set; btn_SetPadBack.PreviewMouseLeftButtonUp += Btn_MapKeypad_Mouse_Set; btn_SetPadStart.PreviewMouseLeftButtonUp += Btn_MapKeypad_Mouse_Set; button_SetPad_Unmap.PreviewMouseLeftButtonUp += Btn_MapKeypad_Mouse_Unmap; combobox_SetPad_Modifier0.SelectionChanged += ComboBox_MapKeypad_Save; combobox_SetPad_Modifier1.SelectionChanged += ComboBox_MapKeypad_Save; combobox_SetPad_Keyboard.SelectionChanged += ComboBox_MapKeypad_Save; btn_Settings_KeyboardTextString_Add.Click += Btn_Settings_KeyboardTextString_Add_Click; btn_Settings_KeyboardTextString_Remove.Click += Btn_Settings_KeyboardTextString_Remove_Click; btn_Settings_KeypadProcessProfile_Add.Click += Btn_Settings_KeypadProcessProfile_Add_Click; btn_Settings_KeypadProcessProfile_Remove.Click += Btn_Settings_KeypadProcessProfile_Remove_Click; combobox_KeypadProcessProfile.SelectionChanged += Combobox_KeypadProcessProfile_SelectionChanged; //Settings functions btn_Settings_InstallDrivers.Click += btn_Settings_InstallDrivers_Click; //Help functions btn_Help_ProjectWebsite.Click += btn_Help_ProjectWebsite_Click; btn_Help_OpenDonation.Click += btn_Help_OpenDonation_Click; } catch { } }