From 6641caa2b9677f821a12f964cf56642ef82d5d04 Mon Sep 17 00:00:00 2001 From: GittyMac Date: Sun, 18 Apr 2021 12:52:58 -0400 Subject: [PATCH] Fixed constant bitty switching --- OpenFK/Form1.cs | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/OpenFK/Form1.cs b/OpenFK/Form1.cs index e30774b..97694f4 100644 --- a/OpenFK/Form1.cs +++ b/OpenFK/Form1.cs @@ -68,6 +68,7 @@ namespace OpenFK const int PROCESS_WM_READ = 0x0010; public string bittyID; //Current bitty connected. + public string usbBittyID; //Items @@ -228,10 +229,10 @@ namespace OpenFK { s = "FFFFFFF0"; } - if (s != bittyID) //If it's still the same, it won't repeat the actions + if (s != usbBittyID) //If it's still the same, it won't repeat the actions { + usbBittyID = s; Debug.WriteLine("BittyID - " + s); - bittyID = s; setBitty(s); } } @@ -861,24 +862,28 @@ namespace OpenFK //SET BITTY // - void setBitty(string bittyID) + void setBitty(string localBittyID) { - setVar(@""); - currentBitty = bittyID.ToLower(); - if (Settings.Default.RPC == true) + if(bittyID != localBittyID) { - try + setVar(@""); + bittyID = localBittyID; + currentBitty = localBittyID.ToLower(); + if (Settings.Default.RPC == true) { - XmlNodeList nodes = bittyData.SelectNodes("//funkey[@id='" + bittyID + "']"); - foreach (XmlNode xn in nodes) + try { - currentBittyName = xn.Attributes["name"].Value; + XmlNodeList nodes = bittyData.SelectNodes("//funkey[@id='" + localBittyID + "']"); + foreach (XmlNode xn in nodes) + { + currentBittyName = xn.Attributes["name"].Value; + } + setRP(currentWorld, currentActivity, currentBitty, currentBittyName); } - setRP(currentWorld, currentActivity, currentBitty, currentBittyName); - } - catch - { + catch + { + } } } }