mirror of
https://github.com/cemu-project/DS4Windows.git
synced 2024-12-26 16:41:50 +01:00
Merge branch 'mika-n-jay' into jay
This commit is contained in:
commit
147d9666b6
@ -212,15 +212,16 @@ namespace DS4Windows
|
||||
Task.Run(() =>
|
||||
{
|
||||
var UDP_SERVER_PORT = Global.getUDPServerPortNum();
|
||||
var UDP_SERVER_LISTEN_ADDRESS = Global.getUDPServerListenAddress();
|
||||
|
||||
try
|
||||
{
|
||||
_udpServer.Start(UDP_SERVER_PORT);
|
||||
LogDebug("UDP server listening on port " + UDP_SERVER_PORT);
|
||||
_udpServer.Start(UDP_SERVER_PORT, UDP_SERVER_LISTEN_ADDRESS);
|
||||
LogDebug($"UDP server listening on address {UDP_SERVER_LISTEN_ADDRESS} 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);
|
||||
var errMsg = String.Format("Couldn't start UDP server on address {0}:{1}, outside applications won't be able to access pad data ({2})", UDP_SERVER_LISTEN_ADDRESS, UDP_SERVER_PORT, ex.SocketErrorCode);
|
||||
|
||||
LogDebug(errMsg, true);
|
||||
AppLogger.LogToTray(errMsg, true, true);
|
||||
@ -286,9 +287,11 @@ namespace DS4Windows
|
||||
await Task.Delay(100);
|
||||
|
||||
var UDP_SERVER_PORT = Global.getUDPServerPortNum();
|
||||
var UDP_SERVER_LISTEN_ADDRESS = Global.getUDPServerListenAddress();
|
||||
|
||||
try
|
||||
{
|
||||
_udpServer.Start(UDP_SERVER_PORT);
|
||||
_udpServer.Start(UDP_SERVER_PORT, UDP_SERVER_LISTEN_ADDRESS);
|
||||
foreach (DS4Device dev in devices)
|
||||
{
|
||||
dev.queueEvent(() =>
|
||||
@ -296,11 +299,11 @@ namespace DS4Windows
|
||||
dev.Report += dev.MotionEvent;
|
||||
});
|
||||
}
|
||||
LogDebug("UDP server listening on port " + UDP_SERVER_PORT);
|
||||
LogDebug($"UDP server listening on address {UDP_SERVER_LISTEN_ADDRESS} 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);
|
||||
var errMsg = String.Format("Couldn't start UDP server on address {0}:{1}, outside applications won't be able to access pad data ({2})", UDP_SERVER_LISTEN_ADDRESS, UDP_SERVER_PORT, ex.SocketErrorCode);
|
||||
|
||||
LogDebug(errMsg, true);
|
||||
AppLogger.LogToTray(errMsg, true, true);
|
||||
@ -517,15 +520,16 @@ namespace DS4Windows
|
||||
{
|
||||
//var UDP_SERVER_PORT = 26760;
|
||||
var UDP_SERVER_PORT = Global.getUDPServerPortNum();
|
||||
var UDP_SERVER_LISTEN_ADDRESS = Global.getUDPServerListenAddress();
|
||||
|
||||
try
|
||||
{
|
||||
_udpServer.Start(UDP_SERVER_PORT);
|
||||
LogDebug("UDP server listening on port " + UDP_SERVER_PORT);
|
||||
_udpServer.Start(UDP_SERVER_PORT, UDP_SERVER_LISTEN_ADDRESS);
|
||||
LogDebug($"UDP server listening on address {UDP_SERVER_LISTEN_ADDRESS} 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);
|
||||
var errMsg = String.Format("Couldn't start UDP server on address {0}:{1}, outside applications won't be able to access pad data ({2})", UDP_SERVER_LISTEN_ADDRESS, UDP_SERVER_PORT, ex.SocketErrorCode);
|
||||
|
||||
LogDebug(errMsg, true);
|
||||
AppLogger.LogToTray(errMsg, true, true);
|
||||
|
@ -709,6 +709,15 @@ namespace DS4Windows
|
||||
m_Config.udpServPort = value;
|
||||
}
|
||||
|
||||
public static string getUDPServerListenAddress()
|
||||
{
|
||||
return m_Config.udpServListenAddress;
|
||||
}
|
||||
public static void setUDPServerListenAddress(string value)
|
||||
{
|
||||
m_Config.udpServListenAddress = value.Trim();
|
||||
}
|
||||
|
||||
public static bool UseWhiteIcon
|
||||
{
|
||||
set { m_Config.useWhiteIcon = value; }
|
||||
@ -1721,6 +1730,7 @@ namespace DS4Windows
|
||||
public int flashWhenLateAt = 20;
|
||||
public bool useUDPServ = false;
|
||||
public int udpServPort = 26760;
|
||||
public string udpServListenAddress = "127.0.0.1"; // 127.0.0.1=IPAddress.Loopback (default), 0.0.0.0=IPAddress.Any as all interfaces, x.x.x.x = Specific ipv4 interface address or hostname
|
||||
public bool useCustomSteamFolder;
|
||||
public string customSteamFolder;
|
||||
// Cache whether profile has custom action
|
||||
@ -3385,6 +3395,8 @@ namespace DS4Windows
|
||||
catch { missingSetting = true; }
|
||||
try { Item = m_Xdoc.SelectSingleNode("/Profile/UDPServerPort"); int temp; int.TryParse(Item.InnerText, out temp); udpServPort = Math.Min(Math.Max(temp, 1024), 65535); }
|
||||
catch { missingSetting = true; }
|
||||
try { Item = m_Xdoc.SelectSingleNode("/Profile/UDPServerListenAddress"); udpServListenAddress = Item.InnerText; }
|
||||
catch { missingSetting = true; }
|
||||
try { Item = m_Xdoc.SelectSingleNode("/Profile/UseCustomSteamFolder"); Boolean.TryParse(Item.InnerText, out useCustomSteamFolder); }
|
||||
catch { missingSetting = true; }
|
||||
try { Item = m_Xdoc.SelectSingleNode("/Profile/CustomSteamFolder"); customSteamFolder = Item.InnerText; }
|
||||
@ -3458,6 +3470,7 @@ namespace DS4Windows
|
||||
XmlNode xmlWhiteIcon = m_Xdoc.CreateNode(XmlNodeType.Element, "WhiteIcon", null); xmlWhiteIcon.InnerText = useWhiteIcon.ToString(); Node.AppendChild(xmlWhiteIcon);
|
||||
XmlNode xmlUseUDPServ = m_Xdoc.CreateNode(XmlNodeType.Element, "UseUDPServer", null); xmlUseUDPServ.InnerText = useUDPServ.ToString(); Node.AppendChild(xmlUseUDPServ);
|
||||
XmlNode xmlUDPServPort = m_Xdoc.CreateNode(XmlNodeType.Element, "UDPServerPort", null); xmlUDPServPort.InnerText = udpServPort.ToString(); Node.AppendChild(xmlUDPServPort);
|
||||
XmlNode xmlUDPServListenAddress = m_Xdoc.CreateNode(XmlNodeType.Element, "UDPServerListenAddress", null); xmlUDPServListenAddress.InnerText = udpServListenAddress; Node.AppendChild(xmlUDPServListenAddress);
|
||||
XmlNode xmlUseCustomSteamFolder = m_Xdoc.CreateNode(XmlNodeType.Element, "UseCustomSteamFolder", null); xmlUseCustomSteamFolder.InnerText = useCustomSteamFolder.ToString(); Node.AppendChild(xmlUseCustomSteamFolder);
|
||||
XmlNode xmlCustomSteamFolder = m_Xdoc.CreateNode(XmlNodeType.Element, "CustomSteamFolder", null); xmlCustomSteamFolder.InnerText = customSteamFolder; Node.AppendChild(xmlCustomSteamFolder);
|
||||
|
||||
|
@ -396,7 +396,7 @@ namespace DS4Windows
|
||||
}
|
||||
}
|
||||
|
||||
public void Start(int port)
|
||||
public void Start(int port, string listenAddress = "")
|
||||
{
|
||||
if (running)
|
||||
{
|
||||
@ -409,7 +409,35 @@ namespace DS4Windows
|
||||
}
|
||||
|
||||
udpSock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
|
||||
try { udpSock.Bind(new IPEndPoint(IPAddress.Loopback, port)); }
|
||||
try
|
||||
{
|
||||
IPAddress udpListenIPAddress;
|
||||
if (listenAddress == "127.0.0.1" || listenAddress == "")
|
||||
{
|
||||
// Listen on local looback interface (default option). Does not allow remote client connections
|
||||
udpListenIPAddress = IPAddress.Loopback;
|
||||
}
|
||||
else if (listenAddress == "0.0.0.0")
|
||||
{
|
||||
// Listen on all IPV4 interfaces.
|
||||
// Remote client connections allowed. If the local network is not "safe" then may not be a good idea, because at the moment incoming connections are not authenticated in any way
|
||||
udpListenIPAddress = IPAddress.Any;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Listen on a specific hostname or IPV4 interface address. If the hostname has multiple interfaces then use the first IPV4 address because it is usually the primary IP addr.
|
||||
// Remote client connections allowed.
|
||||
IPAddress[] ipAddresses = Dns.GetHostAddresses(listenAddress);
|
||||
udpListenIPAddress = null;
|
||||
foreach (IPAddress ip4 in ipAddresses.Where(ip => ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork))
|
||||
{
|
||||
udpListenIPAddress = ip4;
|
||||
break;
|
||||
}
|
||||
if (udpListenIPAddress == null) throw new SocketException(10049 /*WSAEADDRNOTAVAIL*/);
|
||||
}
|
||||
udpSock.Bind(new IPEndPoint(udpListenIPAddress, port));
|
||||
}
|
||||
catch (SocketException ex)
|
||||
{
|
||||
udpSock.Close();
|
||||
|
9
DS4Windows/DS4Forms/DS4Form.Designer.cs
generated
9
DS4Windows/DS4Forms/DS4Form.Designer.cs
generated
@ -154,6 +154,7 @@
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.ckUdpServ = new System.Windows.Forms.CheckBox();
|
||||
this.nUDUdpPortNum = new System.Windows.Forms.NumericUpDown();
|
||||
this.tBUdpListenAddress = new System.Windows.Forms.TextBox();
|
||||
this.languagePackComboBox1 = new DS4Windows.DS4Forms.LanguagePackComboBox();
|
||||
this.cBCustomSteam = new System.Windows.Forms.CheckBox();
|
||||
this.tBSteamFolder = new System.Windows.Forms.TextBox();
|
||||
@ -1171,6 +1172,7 @@
|
||||
this.panel4.Controls.Add(this.label2);
|
||||
this.panel4.Controls.Add(this.ckUdpServ);
|
||||
this.panel4.Controls.Add(this.nUDUdpPortNum);
|
||||
this.panel4.Controls.Add(this.tBUdpListenAddress);
|
||||
resources.ApplyResources(this.panel4, "panel4");
|
||||
this.panel4.Name = "panel4";
|
||||
//
|
||||
@ -1204,6 +1206,12 @@
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
//
|
||||
// tBUdpListenAddress
|
||||
//
|
||||
resources.ApplyResources(this.tBUdpListenAddress, "tBUdpListenAddress");
|
||||
this.tBUdpListenAddress.Name = "tBUdpListenAddress";
|
||||
this.tBUdpListenAddress.TextChanged += new System.EventHandler(this.tBUdpListenAddress_TextChanged);
|
||||
//
|
||||
// languagePackComboBox1
|
||||
//
|
||||
@ -1520,6 +1528,7 @@
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.CheckBox ckUdpServ;
|
||||
private System.Windows.Forms.NumericUpDown nUDUdpPortNum;
|
||||
private System.Windows.Forms.TextBox tBUdpListenAddress;
|
||||
private System.Windows.Forms.CheckBox cBCustomSteam;
|
||||
private System.Windows.Forms.TextBox tBSteamFolder;
|
||||
//private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem2;
|
||||
|
@ -328,12 +328,14 @@ namespace DS4Windows.Forms
|
||||
StartWindowsCheckBox.CheckedChanged += new EventHandler(StartWindowsCheckBox_CheckedChanged);
|
||||
new ToolTip().SetToolTip(StartWindowsCheckBox, Properties.Resources.RunAtStartup);
|
||||
|
||||
ckUdpServ.Checked = nUDUdpPortNum.Enabled = isUsingUDPServer();
|
||||
ckUdpServ.Checked = nUDUdpPortNum.Enabled = tBUdpListenAddress.Enabled = isUsingUDPServer();
|
||||
nUDUdpPortNum.Value = getUDPServerPortNum();
|
||||
tBUdpListenAddress.Text = getUDPServerListenAddress();
|
||||
new ToolTip().SetToolTip(ckUdpServ, Properties.Resources.UdpServer);
|
||||
|
||||
ckUdpServ.CheckedChanged += CkUdpServ_CheckedChanged;
|
||||
nUDUdpPortNum.Leave += NUDUdpPortNum_Leave;
|
||||
|
||||
|
||||
populateHoverTextDict();
|
||||
|
||||
cBController1.KeyPress += CBController_KeyPress;
|
||||
@ -2594,6 +2596,7 @@ Properties.Resources.DS4Update, MessageBoxButtons.YesNo, MessageBoxIcon.Question
|
||||
}
|
||||
|
||||
nUDUdpPortNum.Enabled = state;
|
||||
tBUdpListenAddress.Enabled = state;
|
||||
}
|
||||
|
||||
private void NUDUdpPortNum_Leave(object sender, EventArgs e)
|
||||
@ -2603,6 +2606,7 @@ Properties.Resources.DS4Update, MessageBoxButtons.YesNo, MessageBoxIcon.Question
|
||||
{
|
||||
setUDPServerPort(curValue);
|
||||
nUDUdpPortNum.Enabled = false;
|
||||
tBUdpListenAddress.Enabled = false;
|
||||
WaitUDPPortChange();
|
||||
}
|
||||
}
|
||||
@ -2614,9 +2618,15 @@ Properties.Resources.DS4Update, MessageBoxButtons.YesNo, MessageBoxIcon.Question
|
||||
{
|
||||
await TaskRunner.Run(() => Program.rootHub.UseUDPPort());
|
||||
nUDUdpPortNum.Enabled = true;
|
||||
tBUdpListenAddress.Enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void tBUdpListenAddress_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
setUDPServerListenAddress(tBUdpListenAddress.Text.Trim());
|
||||
}
|
||||
|
||||
private void cBFlashWhenLate_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
FlashWhenLate = cBFlashWhenLate.Checked;
|
||||
|
@ -2707,7 +2707,7 @@
|
||||
<value>NoControl</value>
|
||||
</data>
|
||||
<data name="label2.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>118, 2</value>
|
||||
<value>200, 2</value>
|
||||
</data>
|
||||
<data name="label2.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>26, 13</value>
|
||||
@ -2764,7 +2764,7 @@
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="nUDUdpPortNum.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>150, 0</value>
|
||||
<value>230, 0</value>
|
||||
</data>
|
||||
<data name="nUDUdpPortNum.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>66, 20</value>
|
||||
@ -2784,11 +2784,35 @@
|
||||
<data name=">>nUDUdpPortNum.ZOrder" xml:space="preserve">
|
||||
<value>2</value>
|
||||
</data>
|
||||
<data name="tBUdpListenAddress.Enabled" type="System.Boolean, mscorlib">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="tBUdpListenAddress.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>90, 0</value>
|
||||
</data>
|
||||
<data name="tBUdpListenAddress.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>100, 20</value>
|
||||
</data>
|
||||
<data name="tBUdpListenAddress.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>64</value>
|
||||
</data>
|
||||
<data name=">>tBUdpListenAddress.Name" xml:space="preserve">
|
||||
<value>tBUdpListenAddress</value>
|
||||
</data>
|
||||
<data name=">>tBUdpListenAddress.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>tBUdpListenAddress.Parent" xml:space="preserve">
|
||||
<value>panel4</value>
|
||||
</data>
|
||||
<data name=">>tBUdpListenAddress.ZOrder" xml:space="preserve">
|
||||
<value>3</value>
|
||||
</data>
|
||||
<data name="panel4.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>274, 82</value>
|
||||
</data>
|
||||
<data name="panel4.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>219, 23</value>
|
||||
<value>300, 23</value>
|
||||
</data>
|
||||
<data name="panel4.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>64</value>
|
||||
|
@ -49,6 +49,7 @@ namespace DS4Windows
|
||||
new VidPidInfo(RAZER_VID, 0x1004), // Razer Raiju Ultimate Edition (wired)
|
||||
new VidPidInfo(RAZER_VID, 0x1009), // Razer Raiju Ultimate Edition (BT). Doesn't work yet for some reason even when non-steam Razer driver lists the BT Razer Ultimate with this ID.
|
||||
new VidPidInfo(SONY_VID, 0x05C5), // CronusMax (PS4 Output Mode)
|
||||
new VidPidInfo(0x0C12, 0x57AB), // Warrior Joypad JS083 (wired). Custom lightbar color doesn't work, but everything else works OK (except touchpad and gyro because the gamepad doesnt have those).
|
||||
};
|
||||
|
||||
private static string devicePathToInstanceId(string devicePath)
|
||||
|
9
DS4Windows/Properties/Resources.Designer.cs
generated
9
DS4Windows/Properties/Resources.Designer.cs
generated
@ -2099,6 +2099,15 @@ namespace DS4Windows.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Enable UDP server. Server listen address and port. Address value options: 127.0.0.1 localhost only | 0.0.0.0 all addresses | Specific host name or IP address..
|
||||
/// </summary>
|
||||
public static string UdpServer {
|
||||
get {
|
||||
return ResourceManager.GetString("UdpServer", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Unassigned.
|
||||
/// </summary>
|
||||
|
@ -600,4 +600,7 @@
|
||||
<data name="UACTask" xml:space="preserve">
|
||||
<value>DS4Windows sovellus pitää käynnistää järjestelmävalvojan oikeuksilla tämän toiminnon käyttämiseksi.</value>
|
||||
</data>
|
||||
<data name="UdpServer" xml:space="preserve">
|
||||
<value>Aktivoi UDP palvelu. Palvelun osoite ja portti. Osoitevaihtoehdot: 127.0.0.1 paikallinen | 0.0.0.0 kaikki liittymät | Tietty palvelinnimi tai IP numero.</value>
|
||||
</data>
|
||||
</root>
|
@ -823,4 +823,7 @@
|
||||
<data name="EnableTouchToggle" xml:space="preserve">
|
||||
<value>Allow touchpad mouse function to get toggled with PS + Touchpad Click.</value>
|
||||
</data>
|
||||
<data name="UdpServer" xml:space="preserve">
|
||||
<value>Enable UDP server. Server listen address and port. Address value options: 127.0.0.1 localhost only | 0.0.0.0 all addresses | Specific host name or IP address.</value>
|
||||
</data>
|
||||
</root>
|
Loading…
Reference in New Issue
Block a user