public bool PlugXInputController(int index) { int xinputIndex = x360Bus.FirstController + index; LogDebug("Plugging in X360 Controller #" + xinputIndex); bool xinputResult = x360Bus.Plugin(index); if (xinputResult) { useDInputOnly[index] = false; LogDebug("X360 Controller # " + xinputIndex + " connected"); } else { useDInputOnly[index] = true; LogDebug("X360 Controller # " + xinputIndex + " failed. Using DInput only mode"); } return(xinputResult); }
public bool Start(object tempui, bool showlog = true) { if (x360Bus.Open() && x360Bus.Start()) { if (showlog) { LogDebug(Properties.Resources.Starting); } LogDebug("Connection to Scp Virtual Bus established"); DS4Devices.isExclusiveMode = getUseExclusiveMode(); if (showlog) { LogDebug(Properties.Resources.SearchingController); LogDebug(DS4Devices.isExclusiveMode ? Properties.Resources.UsingExclusive : Properties.Resources.UsingShared); } try { DS4Devices.findControllers(); IEnumerable <DS4Device> devices = DS4Devices.getDS4Controllers(); //int ind = 0; DS4LightBar.defaultLight = false; //foreach (DS4Device device in devices) for (int i = 0, devCount = devices.Count(); i < devCount; i++) { DS4Device device = devices.ElementAt(i); if (showlog) { LogDebug(Properties.Resources.FoundController + device.getMacAddress() + " (" + device.getConnectionType() + ")"); } Task task = new Task(() => { Thread.Sleep(5); WarnExclusiveModeFailure(device); }); task.Start(); DS4Controllers[i] = device; device.setUiContext(tempui as SynchronizationContext); device.Removal += this.On_DS4Removal; device.Removal += DS4Devices.On_Removal; device.SyncChange += this.On_SyncChange; device.SyncChange += DS4Devices.UpdateSerial; device.SerialChange += this.On_SerialChange; touchPad[i] = new Mouse(i, device); device.LightBarColor = getMainColor(i); if (!getDInputOnly(i) && device.isSynced()) { int xinputIndex = x360Bus.FirstController + i; LogDebug("Plugging in X360 Controller #" + xinputIndex); bool xinputResult = x360Bus.Plugin(i); if (xinputResult) { LogDebug("X360 Controller # " + xinputIndex + " connected"); useDInputOnly[i] = false; } else { LogDebug("X360 Controller # " + xinputIndex + " failed. Using DInput only mode"); useDInputOnly[i] = true; } } device.Report += this.On_Report; TouchPadOn(i, device); CheckProfileOptions(i, device, true); device.StartUpdate(); //string filename = ProfilePath[ind]; //ind++; if (showlog) { if (File.Exists(appdatapath + "\\Profiles\\" + ProfilePath[i] + ".xml")) { string prolog = Properties.Resources.UsingProfile.Replace("*number*", (i + 1).ToString()).Replace("*Profile name*", ProfilePath[i]); LogDebug(prolog); Log.LogToTray(prolog); } else { string prolog = Properties.Resources.NotUsingProfile.Replace("*number*", (i + 1).ToString()); LogDebug(prolog); Log.LogToTray(prolog); } } if (i >= 4) // out of Xinput devices! { break; } } } catch (Exception e) { LogDebug(e.Message); Log.LogToTray(e.Message); } running = true; if (_udpServer != null) { var UDP_SERVER_PORT = 26760; try { _udpServer.Start(UDP_SERVER_PORT); LogDebug("UDP server listening on port " + UDP_SERVER_PORT); } catch (System.Net.Sockets.SocketException ex) { var errMsg = String.Format("Couldn't start UDP server on port {0}, outside applications won't be able to access pad data ({1})", UDP_SERVER_PORT, ex.SocketErrorCode); LogDebug(errMsg, true); Log.LogToTray(errMsg, true, true); } } } else { string logMessage = "Could not connect to Scp Virtual Bus Driver. Please check the status of the System device in Device Manager"; LogDebug(logMessage); Log.LogToTray(logMessage); } runHotPlug = true; return(true); }
public bool Start(bool showlog = true) { if (x360Bus.Open() && x360Bus.Start()) { if (showlog) { LogDebug(Properties.Resources.Starting); } DS4Devices.isExclusiveMode = UseExclusiveMode; if (showlog) { LogDebug(Properties.Resources.SearchingController); LogDebug(DS4Devices.isExclusiveMode ? Properties.Resources.UsingExclusive: Properties.Resources.UsingShared); } try { DS4Devices.findControllers(); IEnumerable <DS4Device> devices = DS4Devices.getDS4Controllers(); int ind = 0; DS4LightBar.defualtLight = false; foreach (DS4Device device in devices) { if (showlog) { LogDebug(Properties.Resources.FoundController + device.MacAddress + " (" + device.ConnectionType + ")"); } WarnExclusiveModeFailure(device); DS4Controllers[ind] = device; device.Removal -= DS4Devices.On_Removal; device.Removal += this.On_DS4Removal; device.Removal += DS4Devices.On_Removal; touchPad[ind] = new Mouse(ind, device); device.LightBarColor = MainColor[ind]; if (!DinputOnly[ind]) { x360Bus.Plugin(ind); } device.Report += this.On_Report; TouchPadOn(ind, device); //string filename = ProfilePath[ind]; ind++; if (showlog) { if (System.IO.File.Exists(appdatapath + "\\Profiles\\" + ProfilePath[ind - 1] + ".xml")) { string prolog = Properties.Resources.UsingProfile.Replace("*number*", ind.ToString()).Replace("*Profile name*", ProfilePath[ind - 1]); LogDebug(prolog); Log.LogToTray(prolog); } else { string prolog = Properties.Resources.NotUsingProfile.Replace("*number*", (ind).ToString()); LogDebug(prolog); Log.LogToTray(prolog); } } if (ind >= 4) // out of Xinput devices! { break; } } } catch (Exception e) { LogDebug(e.Message); Log.LogToTray(e.Message); } running = true; } return(true); }
public bool Start(bool showlog = true) { if (x360Bus.Open() && x360Bus.Start()) { if (showlog) { LogDebug(Properties.Resources.Starting); } LogDebug("Connection to Scp Virtual Bus established"); DS4Devices.isExclusiveMode = getUseExclusiveMode(); if (showlog) { LogDebug(Properties.Resources.SearchingController); LogDebug(DS4Devices.isExclusiveMode ? Properties.Resources.UsingExclusive : Properties.Resources.UsingShared); } try { DS4Devices.findControllers(); IEnumerable <DS4Device> devices = DS4Devices.getDS4Controllers(); //int ind = 0; DS4LightBar.defaultLight = false; //foreach (DS4Device device in devices) for (int i = 0, devCount = devices.Count(); i < devCount; i++) { DS4Device device = devices.ElementAt(i); if (showlog) { LogDebug(Properties.Resources.FoundController + device.getMacAddress() + " (" + device.getConnectionType() + ")"); } WarnExclusiveModeFailure(device); DS4Controllers[i] = device; device.setUiContext(SynchronizationContext.Current); device.Removal += this.On_DS4Removal; device.Removal += DS4Devices.On_Removal; device.SyncChange += this.On_SyncChange; device.SyncChange += DS4Devices.UpdateSerial; device.SerialChange += this.On_SerialChange; touchPad[i] = new Mouse(i, device); device.LightBarColor = getMainColor(i); if (!getDInputOnly(i) && device.isSynced()) { int xinputIndex = x360Bus.FirstController + i; LogDebug("Plugging in X360 Controller #" + xinputIndex); bool xinputResult = x360Bus.Plugin(i); if (xinputResult) { LogDebug("X360 Controller # " + xinputIndex + " connected"); useDInputOnly[i] = false; } else { LogDebug("X360 Controller # " + xinputIndex + " failed. Using DInput only mode"); useDInputOnly[i] = true; } } device.Report += this.On_Report; TouchPadOn(i, device); CheckProfileOptions(i, device, true); device.StartUpdate(); //string filename = ProfilePath[ind]; //ind++; if (showlog) { if (File.Exists(appdatapath + "\\Profiles\\" + ProfilePath[i] + ".xml")) { string prolog = Properties.Resources.UsingProfile.Replace("*number*", (i + 1).ToString()).Replace("*Profile name*", ProfilePath[i]); LogDebug(prolog); Log.LogToTray(prolog); } else { string prolog = Properties.Resources.NotUsingProfile.Replace("*number*", (i + 1).ToString()); LogDebug(prolog); Log.LogToTray(prolog); } } if (i >= 4) // out of Xinput devices! { break; } } } catch (Exception e) { LogDebug(e.Message); Log.LogToTray(e.Message); } running = true; } else { string logMessage = "Could not connect to Scp Virtual Bus Driver. Please check the status of the System device in Device Manager"; LogDebug(logMessage); Log.LogToTray(logMessage); } runHotPlug = true; return(true); }