diff --git a/Installer/MainWindow.xaml.cs b/Installer/MainWindow.xaml.cs index 69c68bd..f186db0 100644 --- a/Installer/MainWindow.xaml.cs +++ b/Installer/MainWindow.xaml.cs @@ -27,7 +27,7 @@ public partial class MainWindow { const string REG_PATH = "HKEY_CURRENT_USER\\SOFTWARE\\DCS-SimpleRadio"; - const string version = "1.3.0"; + const string version = "1.4.1"; string currentPath; string currentDirectory; diff --git a/Plugin/ClientMetaData.cpp b/Plugin/ClientMetaData.cpp index e26a58f..b874756 100644 --- a/Plugin/ClientMetaData.cpp +++ b/Plugin/ClientMetaData.cpp @@ -24,6 +24,8 @@ namespace SimpleRadio this->radio[i].modulation = 0; this->radio[i].volume = 1.0; this->radio[i].secondaryFrequency = -1; + this->radio[i].freqMin = -1; + this->radio[i].freqMax = -1; } } @@ -45,6 +47,8 @@ namespace SimpleRadio current["modulation"] = this->radio[i].modulation; current["volume"] = this->radio[i].volume; current["secondaryFrequency"] = this->radio[i].secondaryFrequency; + // current["freqMin"] = this->radio[i].freqMin; + // current["freqMax"] = this->radio[i].freqMax; array.append(current); } @@ -97,6 +101,24 @@ namespace SimpleRadio data.radio[i].secondaryFrequency = -1; } + try { + data.radio[i].freqMax = std::stod(root["radios"][i]["freqMax"].asString()); + } + catch (...) + { + //catch older versions + data.radio[i].freqMax = -1; + } + + try { + data.radio[i].freqMin = std::stod(root["radios"][i]["freqMin"].asString()); + } + catch (...) + { + //catch older versions + data.radio[i].freqMin = -1; + } + } diff --git a/Plugin/Plugin.cpp b/Plugin/Plugin.cpp index a4a0fa1..99fc891 100644 --- a/Plugin/Plugin.cpp +++ b/Plugin/Plugin.cpp @@ -41,7 +41,7 @@ static SimpleRadio::Plugin plugin; namespace SimpleRadio { const char* Plugin::NAME = "DCS-SimpleRadio"; - const char* Plugin::VERSION = "1.3.0"; + const char* Plugin::VERSION = "1.4.1"; const char* Plugin::AUTHOR = "Ciribob - GitHub.com/ciribob"; const char* Plugin::DESCRIPTION = "DCS-SimpleRadio "; const char* Plugin::COMMAND_KEYWORD = "sr"; @@ -68,8 +68,6 @@ namespace SimpleRadio //Delete other things?! delete[] this->pluginId; } - - } void Plugin::start() @@ -155,7 +153,7 @@ namespace SimpleRadio } - void Plugin::writeFilterSetting(bool filterSetting) {\ + void Plugin::writeFilterSetting(bool filterSetting) { RegHelper helper; if (filterSetting) { @@ -205,8 +203,6 @@ namespace SimpleRadio size_t len = strlen(id); this->pluginId = new char[len + 1]; strcpy_s(this->pluginId, len + 1, id); - - } bool Plugin::processCommand(uint64 serverConnectionHandlerId, const char* command) @@ -245,8 +241,6 @@ namespace SimpleRadio return true; } - - return false; } @@ -257,7 +251,7 @@ namespace SimpleRadio infoDataStr.precision(2); infoDataStr.setf(infoDataStr.fixed, infoDataStr.floatfield); //infoDataStr.fixed = 3; - + try { @@ -265,7 +259,7 @@ namespace SimpleRadio anyID myID; if (this->teamspeak.getClientID(serverConnectionHandlerId, &myID) != ERROR_ok) { - + return "\nStatus: [B]Not connected to a server[/B]"; } @@ -279,8 +273,9 @@ namespace SimpleRadio clientInfoData = this->connectedClient.at(clientId); } - //do we have any valid update at all - if (clientInfoData.lastUpdate > 5000ull) + //do we have any valid update at all and when was it last valid? + //clean up if more than 15 seconds have passed + if (clientInfoData.lastUpdate > 5000ull && clientInfoData.lastUpdate < 15000ull) { const double MHZ = 1000000; @@ -357,7 +352,7 @@ namespace SimpleRadio } else { - return "\nStatus: [B]Not In Game[/B]"; + return "\nStatus: [B]Not in game or not in Aircraft[/B]"; } } catch (...) @@ -382,35 +377,67 @@ namespace SimpleRadio return data; } - void Plugin::toggleMuteOnNonUsers() + void Plugin::toggleMuteOnNonUsers() + { + this->allowNonPlayers = !this->allowNonPlayers; + + if (this->allowNonPlayers) + { + MuteOffNonUsers(); + } + else + { + MuteOnNonUsers(); + } + } + + void Plugin::toggleForceON() { + this->forceOn = !this->forceOn; + + if (this->forceOn) + { + ForceON(); + } + else + { + ForceOFF(); + } + } + + void Plugin::MuteOnNonUsers() { - this->allowNonPlayers = !this->allowNonPlayers; + this->allowNonPlayers = false; + this->teamspeak.printMessageToCurrentTab("Muting clients NOT in an aircraft"); + plugin.disableMenuItem(10); + plugin.enableMenuItem(11); + } - if (this->allowNonPlayers) - { - this->teamspeak.printMessageToCurrentTab("Un-muting clients NOT in an aircraft"); - } - else - { - this->teamspeak.printMessageToCurrentTab("Muting clients NOT in an aircraft"); - } + void Plugin::MuteOffNonUsers() + { + this->allowNonPlayers = true; + this->teamspeak.printMessageToCurrentTab("Un-muting clients NOT in an aircraft"); + plugin.disableMenuItem(11); + plugin.enableMenuItem(10); } - void Plugin::toggleForceON() { - this->forceOn = !this->forceOn; + void Plugin::ForceON() + { + this->forceOn = true; + this->teamspeak.printMessageToCurrentTab("Forcing ON in Ground Mode"); + plugin.disableMenuItem(12); + plugin.enableMenuItem(13); + } - if (this->forceOn) - { - this->teamspeak.printMessageToCurrentTab("Forcing ON in Ground Mode"); - } - else - { - this->teamspeak.printMessageToCurrentTab("Forcing OFF in Ground Mode"); - } + void Plugin::ForceOFF() + { + this->forceOn = false; + this->teamspeak.printMessageToCurrentTab("Forcing OFF in Ground Mode"); + plugin.disableMenuItem(13); + plugin.enableMenuItem(12); } void Plugin::onHotKeyEvent(const char * hotkeyCommand) { - + this->sendHotKeyToGUI(hotkeyCommand); if (strcmp("DCS-SR-TOGGLE-MUTE", hotkeyCommand) == 0) @@ -425,6 +452,34 @@ namespace SimpleRadio return; } + else if (strcmp("DCS-SR-MUTE-ENABLE", hotkeyCommand) == 0) + { + this->MuteOnNonUsers(); + return; + } + else if (strcmp("DCS-SR-MUTE-DISABLE", hotkeyCommand) == 0) + { + this->MuteOffNonUsers(); + return; + } + else if (strcmp("DCS-SR-FORCE-ON-ENABLE", hotkeyCommand) == 0) + { + this->ForceON(); + return; + } + else if (strcmp("DCS-SR-FORCE-ON-DISABLE", hotkeyCommand) == 0) + { + this->ForceOFF(); + return; + } + else if (strcmp("DCS-SR-PLUGIN-ENABLE", hotkeyCommand) == 0) + { + this->disablePlugin = false; + this->teamspeak.printMessageToCurrentTab("Enabling DCS-SimpleRadio"); + plugin.disableMenuItem(5); + plugin.enableMenuItem(6); + return; + } else if (strcmp("DCS-SR-TOGGLE-ENABLE", hotkeyCommand) == 0) { this->disablePlugin = !this->disablePlugin; @@ -432,13 +487,24 @@ namespace SimpleRadio if (this->disablePlugin) { this->teamspeak.printMessageToCurrentTab("Disabling DCS-SimpleRadio"); + plugin.disableMenuItem(6); + plugin.enableMenuItem(5); } else { this->teamspeak.printMessageToCurrentTab("Enabling DCS-SimpleRadio"); + plugin.disableMenuItem(5); + plugin.enableMenuItem(6); } return; - + } + else if (strcmp("DCS-SR-PLUGIN-DISABLE", hotkeyCommand) == 0) + { + this->disablePlugin = true; + this->teamspeak.printMessageToCurrentTab("Disabling DCS-SimpleRadio"); + plugin.disableMenuItem(6); + plugin.enableMenuItem(5); + return; } if (teamSpeakControlledClientData.selected < 0) @@ -449,8 +515,9 @@ namespace SimpleRadio RadioInformation &selectedRadio = this->teamSpeakControlledClientData.radio[teamSpeakControlledClientData.selected]; + - if (selectedRadio.frequency < 100 || selectedRadio.frequency == 0 || this->myClientData.hasRadio == true) + if (selectedRadio.frequency < 100 || selectedRadio.frequency == 0 || this->myClientData.hasRadio == true || selectedRadio.modulation >= 2) { //IGNORE return; @@ -463,7 +530,7 @@ namespace SimpleRadio if (strcmp("DCS-SR-FREQ-10-UP", hotkeyCommand) == 0) { - selectedRadio.frequency = selectedRadio.frequency + (10.0 * MHZ); + selectedRadio.frequency = changeFrequency((10.0 * MHZ), selectedRadio); sprintf_s(buffer, 256, "Up 10MHz - Current Freq (MHz): %.4f", selectedRadio.frequency / MHZ); @@ -471,7 +538,7 @@ namespace SimpleRadio } else if (strcmp("DCS-SR-FREQ-10-DOWN", hotkeyCommand) == 0) { - selectedRadio.frequency = selectedRadio.frequency - (10.0 * MHZ); + selectedRadio.frequency = changeFrequency((-10.0 * MHZ), selectedRadio); sprintf_s(buffer, 256, "Down 10MHz - Current Freq (MHz): %.4f", selectedRadio.frequency / MHZ); @@ -479,7 +546,7 @@ namespace SimpleRadio } else if (strcmp("DCS-SR-FREQ-1-UP", hotkeyCommand) == 0) { - selectedRadio.frequency = selectedRadio.frequency + (1.0 * MHZ); + selectedRadio.frequency = changeFrequency((1.0 * MHZ), selectedRadio); sprintf_s(buffer, 256, "Up 1MHz - Current Freq (MHz): %.4f", selectedRadio.frequency / MHZ); @@ -487,7 +554,7 @@ namespace SimpleRadio } else if (strcmp("DCS-SR-FREQ-1-DOWN", hotkeyCommand) == 0) { - selectedRadio.frequency = selectedRadio.frequency - (1.0 * MHZ); + selectedRadio.frequency = changeFrequency((-1.0 * MHZ), selectedRadio); sprintf_s(buffer, 256, "Down 1MHz - Current Freq (MHz): %.4f", selectedRadio.frequency / MHZ); @@ -495,7 +562,7 @@ namespace SimpleRadio } else if (strcmp("DCS-SR-FREQ-01-UP", hotkeyCommand) == 0) { - selectedRadio.frequency = selectedRadio.frequency + (0.1 * MHZ); + selectedRadio.frequency = changeFrequency((0.1 * MHZ), selectedRadio); sprintf_s(buffer, 256, "UP 0.1MHz - Current Freq (MHz): %.4f", selectedRadio.frequency / MHZ); @@ -503,7 +570,7 @@ namespace SimpleRadio } else if (strcmp("DCS-SR-FREQ-01-DOWN", hotkeyCommand) == 0) { - selectedRadio.frequency = selectedRadio.frequency - (0.1 * MHZ); + selectedRadio.frequency = changeFrequency((-0.1 * MHZ), selectedRadio); sprintf_s(buffer, 256, "Down 0.1MHz - Current Freq (MHz): %.4f", selectedRadio.frequency / MHZ); @@ -513,7 +580,7 @@ namespace SimpleRadio { this->teamSpeakControlledClientData.selected = 0; - sprintf_s(buffer, 256, "Selected UHF - Current Freq (MHz): %.4f", teamSpeakControlledClientData.radio[teamSpeakControlledClientData.selected].frequency / MHZ); + sprintf_s(buffer, 256, "Selected Radio 1 - Current Freq (MHz): %.4f", teamSpeakControlledClientData.radio[teamSpeakControlledClientData.selected].frequency / MHZ); this->teamspeak.printMessageToCurrentTab(buffer); } @@ -521,7 +588,7 @@ namespace SimpleRadio { this->teamSpeakControlledClientData.selected = 1; - sprintf_s(buffer, 256, "Selected VHF - Current Freq (MHz): %.4f", teamSpeakControlledClientData.radio[teamSpeakControlledClientData.selected].frequency / MHZ); + sprintf_s(buffer, 256, "Selected Radio 2 - Current Freq (MHz): %.4f", teamSpeakControlledClientData.radio[teamSpeakControlledClientData.selected].frequency / MHZ); this->teamspeak.printMessageToCurrentTab(buffer); } @@ -529,7 +596,7 @@ namespace SimpleRadio { this->teamSpeakControlledClientData.selected = 2; - sprintf_s(buffer, 256, "Selected FM - Current Freq (MHz): %.4f", teamSpeakControlledClientData.radio[teamSpeakControlledClientData.selected].frequency / MHZ); + sprintf_s(buffer, 256, "Selected Radio 3 - Current Freq (MHz): %.4f", teamSpeakControlledClientData.radio[teamSpeakControlledClientData.selected].frequency / MHZ); this->teamspeak.printMessageToCurrentTab(buffer); } @@ -557,8 +624,28 @@ namespace SimpleRadio this->teamspeak.printMessageToCurrentTab("Volume Down"); } + } + //limit frequencies to a known limit + double Plugin::changeFrequency(double amount, RadioInformation radio) { + + double tempFreq = radio.frequency + amount; + + if (radio.freqMax == -1 || radio.freqMax == -1) + { + return tempFreq; + } + if (tempFreq > radio.freqMax) + { + return radio.freqMax; + } + if (tempFreq < radio.freqMin) + { + return radio.freqMin; + } + + return tempFreq; } void Plugin::sendUpdateToGUI() @@ -1086,7 +1173,6 @@ namespace SimpleRadio ReceiveBuf[ByteReceived - 1] = 0; //add terminator - //this->teamspeak.printMessageToCurrentTab(ReceiveBuf); ClientMetaData clientMetaData = ClientMetaData::deserialize(ReceiveBuf, true); processUDPUpdate(clientMetaData); @@ -1095,7 +1181,10 @@ namespace SimpleRadio if (this->shouldSendUpdate(clientMetaData)) { - //this->teamspeak.printMessageToCurrentTab("Sending..."); + //this->teamspeak.printMessageToCurrentTab("Received:"); + //this->teamspeak.printMessageToCurrentTab(ReceiveBuf); + //this->teamspeak.printMessageToCurrentTab("Sent:"); + //this->teamspeak.printMessageToCurrentTab(serialised.c_str()); //////Send Client METADATA if (this->teamspeak.setClientSelfVariableAsString(serverHandlerID, CLIENT_META_DATA, serialised.c_str()) != ERROR_ok) { //printf("Error setting CLIENT_META_DATA!!!\n"); @@ -1276,6 +1365,7 @@ namespace SimpleRadio this->teamSpeakControlledClientData.radio[i].frequency = clientMetaData.radio[i].frequency; this->teamSpeakControlledClientData.radio[i].volume = clientMetaData.radio[i].volume; this->teamSpeakControlledClientData.radio[i].secondaryFrequency = clientMetaData.radio[i].secondaryFrequency; + } //init selected @@ -1292,6 +1382,10 @@ namespace SimpleRadio clientMetaData.radio[i].frequency = this->teamSpeakControlledClientData.radio[i].frequency; clientMetaData.radio[i].volume = this->teamSpeakControlledClientData.radio[i].volume; clientMetaData.radio[i].secondaryFrequency = this->teamSpeakControlledClientData.radio[i].secondaryFrequency; + + //keep this up todate + this->teamSpeakControlledClientData.radio[i].freqMin = clientMetaData.radio[i].freqMin; + this->teamSpeakControlledClientData.radio[i].freqMax = clientMetaData.radio[i].freqMax; } //overrwrite selected @@ -1393,7 +1487,7 @@ namespace SimpleRadio */ switch (updateCommand.cmdType) { case 1: - this->teamSpeakControlledClientData.radio[updateCommand.radio].frequency += updateCommand.freq; + this->teamSpeakControlledClientData.radio[updateCommand.radio].frequency = changeFrequency(updateCommand.freq, this->teamSpeakControlledClientData.radio[updateCommand.radio]); break; case 2: this->teamSpeakControlledClientData.radio[updateCommand.radio].volume = updateCommand.volume; @@ -1616,10 +1710,10 @@ void ts3plugin_initHotkeys(struct PluginHotkey*** hotkeys) { /* Register hotkeys giving a keyword and a description. * The keyword will be later passed to ts3plugin_onHotkeyEvent to identify which hotkey was triggered. * The description is shown in the clients hotkey dialog. */ - BEGIN_CREATE_HOTKEYS(15); /* Create 15 hotkeys. Size must be correct for allocating memory. */ - CREATE_HOTKEY("DCS-SR-TRANSMIT-UHF", "Select UHF AM"); - CREATE_HOTKEY("DCS-SR-TRANSMIT-VHF", "Select VHF AM"); - CREATE_HOTKEY("DCS-SR-TRANSMIT-FM", "Select FM"); + BEGIN_CREATE_HOTKEYS(21); /* Create 21 hotkeys. Size must be correct for allocating memory. */ + CREATE_HOTKEY("DCS-SR-TRANSMIT-UHF", "Select Radio 1"); + CREATE_HOTKEY("DCS-SR-TRANSMIT-VHF", "Select Radio 2"); + CREATE_HOTKEY("DCS-SR-TRANSMIT-FM", "Select Radio 3"); CREATE_HOTKEY("DCS-SR-FREQ-10-UP", "Frequency Up - 10MHz"); CREATE_HOTKEY("DCS-SR-FREQ-10-DOWN", "Frequency Down - 10MHz"); @@ -1636,6 +1730,15 @@ void ts3plugin_initHotkeys(struct PluginHotkey*** hotkeys) { CREATE_HOTKEY("DCS-SR-TOGGLE-ENABLE", "Toggles Plugin On/Off"); + CREATE_HOTKEY("DCS-SR-MUTE-ENABLE", "Mute on Outsiders"); + CREATE_HOTKEY("DCS-SR-MUTE-DISABLE", "UnMute on Outsiders"); + + CREATE_HOTKEY("DCS-SR-FORCE-ON-ENABLE", "Radio ON for Spectating or CA"); + CREATE_HOTKEY("DCS-SR-FORCE-ON-DISABLE", "Radio OFF for Spectating or CA"); + + CREATE_HOTKEY("DCS-SR-PLUGIN-ENABLE", "Plugin ON"); + CREATE_HOTKEY("DCS-SR-PLUGIN-DISABLE", "Plugin OFF") + CREATE_HOTKEY("DCS-SR-VOLUME-10-UP", "VOLUME Up - 10%"); CREATE_HOTKEY("DCS-SR-VOLUME-10-DOWN", "VOLUME Down - 10%"); @@ -1674,25 +1777,35 @@ void ts3plugin_initMenus(struct PluginMenuItem*** menuItems, char** menuIcon) { */ - BEGIN_CREATE_MENUS(10) + BEGIN_CREATE_MENUS(13) CREATE_MENU_ITEM(PLUGIN_MENU_TYPE_GLOBAL, 1, "Check For Update", ""); CREATE_MENU_ITEM(PLUGIN_MENU_TYPE_GLOBAL, 2, "Show Radio Status", ""); CREATE_MENU_ITEM(PLUGIN_MENU_TYPE_GLOBAL, 3, "Enable Radio FX", ""); CREATE_MENU_ITEM(PLUGIN_MENU_TYPE_GLOBAL, 4, "Disable Radio FX", ""); - CREATE_MENU_ITEM(PLUGIN_MENU_TYPE_GLOBAL, 5, "Plugin ON/OFF", ""); - CREATE_MENU_ITEM(PLUGIN_MENU_TYPE_GLOBAL, 6, "Select UHF AM", ""); - CREATE_MENU_ITEM(PLUGIN_MENU_TYPE_GLOBAL, 7, "Select VHF AM", ""); - CREATE_MENU_ITEM(PLUGIN_MENU_TYPE_GLOBAL, 8, "Select FM", ""); - CREATE_MENU_ITEM(PLUGIN_MENU_TYPE_GLOBAL, 9, "Mute/Unmute on Non Radio Users", ""); - CREATE_MENU_ITEM(PLUGIN_MENU_TYPE_GLOBAL, 10, "Radio ON/OFF for Spectating / CA", ""); + CREATE_MENU_ITEM(PLUGIN_MENU_TYPE_GLOBAL, 5, "Plugin ON", ""); + CREATE_MENU_ITEM(PLUGIN_MENU_TYPE_GLOBAL, 6, "Plugin OFF", ""); + CREATE_MENU_ITEM(PLUGIN_MENU_TYPE_GLOBAL, 7, "Select Radio 1", ""); + CREATE_MENU_ITEM(PLUGIN_MENU_TYPE_GLOBAL, 8, "Select Radio 2", ""); + CREATE_MENU_ITEM(PLUGIN_MENU_TYPE_GLOBAL, 9, "Select Radio 3", ""); + CREATE_MENU_ITEM(PLUGIN_MENU_TYPE_GLOBAL, 10, "Mute Non Radio Users", ""); + CREATE_MENU_ITEM(PLUGIN_MENU_TYPE_GLOBAL, 11, "UnMute Non Radio Users", ""); + CREATE_MENU_ITEM(PLUGIN_MENU_TYPE_GLOBAL, 12, "Radio ON for Spectating / CA", ""); + CREATE_MENU_ITEM(PLUGIN_MENU_TYPE_GLOBAL, 13, "Radio OFF for Spectating / CA", ""); END_CREATE_MENUS; //read settings to configure the menu plugin.readSettings(); - plugin.disableMenuItem(6); + //plugin ENABLED by default + plugin.disableMenuItem(5); + plugin.disableMenuItem(7); plugin.disableMenuItem(8); + plugin.disableMenuItem(9); + + plugin.disableMenuItem(11); //Default - Can hear non users + + plugin.disableMenuItem(13); //Default - Radio off for Spectating /* All memory allocated in this function will be automatically released by the TeamSpeak client later by calling ts3plugin_freeMemory */ } @@ -1715,22 +1828,31 @@ void ts3plugin_onMenuItemEvent(uint64 serverConnectionHandlerID, enum PluginMenu plugin.writeFilterSetting(false); break; case 5: - plugin.onHotKeyEvent("DCS-SR-TOGGLE-ENABLE"); + plugin.onHotKeyEvent("DCS-SR-PLUGIN-ENABLE"); break; case 6: - plugin.onHotKeyEvent("DCS-SR-TRANSMIT-UHF"); + plugin.onHotKeyEvent("DCS-SR-PLUGIN-DISABLE"); break; case 7: - plugin.onHotKeyEvent("DCS-SR-TRANSMIT-VHF"); + plugin.onHotKeyEvent("DCS-SR-TRANSMIT-UHF"); break; case 8: - plugin.onHotKeyEvent("DCS-SR-TRANSMIT-FM"); + plugin.onHotKeyEvent("DCS-SR-TRANSMIT-VHF"); break; case 9: - plugin.onHotKeyEvent("DCS-SR-TOGGLE-MUTE"); + plugin.onHotKeyEvent("DCS-SR-TRANSMIT-FM"); break; case 10: - plugin.onHotKeyEvent("DCS-SR-TOGGLE-FORCE-ON"); + plugin.onHotKeyEvent("DCS-SR-MUTE-ENABLE"); + break; + case 11: + plugin.onHotKeyEvent("DCS-SR-MUTE-DISABLE"); + break; + case 12: + plugin.onHotKeyEvent("DCS-SR-FORCE-ON-ENABLE"); + break; + case 13: + plugin.onHotKeyEvent("DCS-SR-FORCE-ON-DISABLE"); break; default: break; diff --git a/Plugin/Plugin.h b/Plugin/Plugin.h index 2634f2d..8962ca5 100644 --- a/Plugin/Plugin.h +++ b/Plugin/Plugin.h @@ -54,12 +54,19 @@ namespace SimpleRadio std::string getClientMetaData(uint64 serverConnectionHandlerId, uint64 clientId) const; void toggleMuteOnNonUsers(); + void MuteOnNonUsers(); + void MuteOffNonUsers(); void toggleForceON(); + void ForceON(); + void ForceOFF(); + void onClientUpdated(uint64 serverConnectionHandlerId, anyID clientId, anyID invokerId); void onHotKeyEvent(const char * hotkeyCommand); + double changeFrequency(double amount, RadioInformation radio); + void onEditPlaybackVoiceDataEvent(uint64 serverConnectionHandlerId, anyID clientId, short* samples, int sampleCount, int channels); static void processMessage(const char* message); diff --git a/Plugin/Plugin.rc b/Plugin/Plugin.rc index 699d89f..332ecbe 100644 Binary files a/Plugin/Plugin.rc and b/Plugin/Plugin.rc differ diff --git a/Plugin/RadioInformation.h b/Plugin/RadioInformation.h index 2a3c60d..008b658 100644 --- a/Plugin/RadioInformation.h +++ b/Plugin/RadioInformation.h @@ -7,4 +7,6 @@ struct RadioInformation int modulation; float volume; double secondaryFrequency; + double freqMin; + double freqMax; }; \ No newline at end of file diff --git a/RadioGui/Properties/AssemblyInfo.cs b/RadioGui/Properties/AssemblyInfo.cs index 2d6ac8a..8334938 100644 --- a/RadioGui/Properties/AssemblyInfo.cs +++ b/RadioGui/Properties/AssemblyInfo.cs @@ -51,5 +51,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.3.0.0")] -[assembly: AssemblyFileVersion("1.3.0.0")] +[assembly: AssemblyVersion("1.4.1.0")] +[assembly: AssemblyFileVersion("1.4.1.0")] diff --git a/RadioGui/RadioControlGroup.xaml.cs b/RadioGui/RadioControlGroup.xaml.cs index ef4436d..0c42d43 100644 --- a/RadioGui/RadioControlGroup.xaml.cs +++ b/RadioGui/RadioControlGroup.xaml.cs @@ -183,6 +183,10 @@ internal void update(RadioUpdate lastUpdate, TimeSpan elapsedSpan) { radioFrequency.Text = "INTERCOM"; } + else if(currentRadio.modulation >=3) + { + radioFrequency.Text = "NO RADIO"; + } else { radioFrequency.Text = (currentRadio.frequency / MHz).ToString("0.000") + (currentRadio.modulation == 0 ? "AM" : "FM"); diff --git a/Scripts/DCS-SimpleRadio/SimpleRadioInit.lua b/Scripts/DCS-SimpleRadio/SimpleRadioInit.lua index d1a9087..cde15ae 100644 --- a/Scripts/DCS-SimpleRadio/SimpleRadioInit.lua +++ b/Scripts/DCS-SimpleRadio/SimpleRadioInit.lua @@ -1,6 +1,9 @@ --- Version 1.3.0 +-- Version 1.4.1 +-- Special thanks to Cap. Zeen, Tarres and Splash for all the help +-- with getting the radio information :) SR = {} +SR.enableInternalPTT = false -- set this to TRUE to use the in-cockpit PTT SR.unicast = false -- if you've setup DCS Correctly and the plugin isn't talking to DCS, -- set unicast to true and type "/sr switch" in the TeamSpeak chat window @@ -32,7 +35,7 @@ local _prevExport = {} _prevExport.LuaExportActivityNextEvent = LuaExportActivityNextEvent LuaExportActivityNextEvent = function(tCurrent) - local tNext = tCurrent + 0.3 + local tNext = tCurrent + 0.2 local _status,_result = pcall(function() @@ -45,9 +48,9 @@ LuaExportActivityNextEvent = function(tCurrent) radios = { - { id = 1, name = "init", frequency = 0, modulation = 0, volume = 1.0, secondaryFrequency = 1}, - { id = 2, name = "init", frequency = 0, modulation = 0, volume = 1.0, secondaryFrequency = 1 }, - { id = 3, name = "init", frequency = 0, modulation = 0, volume = 1.0, secondaryFrequency = 1 } + { id = 1, name = "init", frequency = 0, modulation = 0, volume = 1.0, secondaryFrequency = 1, freqMin = 200*1000000, freqMax = 400*1000000}, + { id = 2, name = "init", frequency = 0, modulation = 0, volume = 1.0, secondaryFrequency = 1, freqMin = 100*1000000, freqMax = 200*1000000 }, + { id = 3, name = "init", frequency = 0, modulation = 0, volume = 1.0, secondaryFrequency = 1, freqMin = 10*1000000, freqMax = 60*1000000 } }, hasRadio = true, groundCommander = false, @@ -92,6 +95,16 @@ LuaExportActivityNextEvent = function(tCurrent) _update = SR.exportRadioHawk(_update) elseif _update.unit == "M-2000C" then _update = SR.exportRadioM2000C(_update) + elseif _update.unit == "A-10A" then + _update = SR.exportRadioA10A(_update) + elseif _update.unit == "F-15C" then + _update = SR.exportRadioF15C(_update) + elseif _update.unit == "MiG-29A" or _update.unit == "MiG-29S" or _update.unit == "MiG-29G" then + _update = SR.exportRadioMiG29(_update) + elseif _update.unit == "Su-27" or _update.unit == "Su-33" then + _update = SR.exportRadioSU27(_update) + elseif _update.unit == "Su-25" or _update.unit == "Su-25T" then + _update = SR.exportRadioSU25(_update) else -- FC 3 _update.radios[1].name = "FC3 UHF" @@ -133,9 +146,9 @@ LuaExportActivityNextEvent = function(tCurrent) selected = 0, radios = { - { id = 1, name = "CA UHF", frequency = 251.0*1000000, modulation = 0,volume = 1.0, secondaryFrequency = 243.0*1000000 }, - { id = 2, name = "CA VHF", frequency = 124.8*1000000, modulation = 0,volume = 1.0, secondaryFrequency = 121.5*1000000 }, - { id = 3, name = "CA FM", frequency = 30.0*1000000, modulation = 1,volume = 1.0, secondaryFrequency = 1 } + { id = 1, name = "CA UHF", frequency = 251.0*1000000, modulation = 0,volume = 1.0, secondaryFrequency = 243.0*1000000, freqMin = 200*1000000, freqMax = 400*1000000 }, + { id = 2, name = "CA VHF", frequency = 124.8*1000000, modulation = 0,volume = 1.0, secondaryFrequency = 121.5*1000000, freqMin = 100*1000000, freqMax = 200*1000000 }, + { id = 3, name = "CA FM", frequency = 30.0*1000000, modulation = 1,volume = 1.0, secondaryFrequency = 1, freqMin = 10*1000000, freqMax = 60*1000000 } }, hasRadio = false, groundCommander = true @@ -163,6 +176,147 @@ LuaExportActivityNextEvent = function(tCurrent) return tNext end +function SR.exportRadioA10A(_data) + _data.radios[1].name = "AN/ARC-164 UHF" + _data.radios[1].frequency = 251.0*1000000 --225-399.975 MHZ + _data.radios[1].modulation = 0 + _data.radios[1].secondaryFrequency = 243.0*1000000 + _data.radios[1].volume = 1.0 + _data.radios[1].freqMin = 225*1000000 + _data.radios[1].freqMax = 399.975*1000000 + + _data.radios[2].name = "AN/ARC-186(V)" + _data.radios[2].frequency = 124.8*1000000 --116,00-151,975 MHz + _data.radios[2].modulation = 0 + _data.radios[2].secondaryFrequency = 121.5*1000000 + _data.radios[2].volume = 1.0 + _data.radios[2].freqMin = 116*1000000 + _data.radios[2].freqMax = 151.975*1000000 + + _data.radios[3].name = "AN/ARC-186(V)FM" + _data.radios[3].frequency = 30.0*1000000 --VHF/FM opera entre 30.000 y 76.000 MHz. + _data.radios[3].modulation = 1 + _data.radios[3].volume = 1.0 + _data.radios[3].freqMin = 30*1000000 + _data.radios[3].freqMax = 76*1000000 + + _data.hasRadio = false; + _data.selected = 0 + + return _data +end + +function SR.exportRadioMiG29(_data) + + _data.radios[1].name = "R-862" + _data.radios[1].frequency = 251.0*1000000 --V/UHF, frequencies are: VHF range of 100 to 149.975 MHz and UHF range of 220 to 399.975 MHz + _data.radios[1].modulation = 0 + _data.radios[1].secondaryFrequency = 121.5*1000000 + _data.radios[1].volume = 1.0 + _data.radios[1].freqMin = 100*1000000 + _data.radios[1].freqMax = 399.975*1000000 + + _data.radios[2].name = "No Radio" + _data.radios[2].frequency = 0 + _data.radios[2].modulation = 3 + _data.radios[2].volume = 1.0 + + _data.radios[3].name = "No radio" + _data.radios[3].frequency = 0 + _data.radios[3].modulation = 3 + _data.radios[3].volume = 1 + + _data.hasRadio = false; + _data.selected = 0 + + return _data +end + +function SR.exportRadioSU25(_data) + + _data.radios[1].name = "R-862" + _data.radios[1].frequency = 251.0*1000000 --V/UHF, frequencies are: VHF range of 100 to 149.975 MHz and UHF range of 220 to 399.975 MHz + _data.radios[1].modulation = 0 + _data.radios[1].secondaryFrequency = 121.5*1000000 + _data.radios[1].volume = 1.0 + _data.radios[1].freqMin = 100*1000000 + _data.radios[1].freqMax = 399.975*1000000 + + _data.radios[2].name = "R-828" + _data.radios[2].frequency = 30.0*1000000 --20 - 60 MHz. + _data.radios[2].modulation = 1 + _data.radios[2].volume = 1.0 + _data.radios[2].freqMin = 20*1000000 + _data.radios[2].freqMax = 60*1000000 + + _data.radios[3].name = "No radio" + _data.radios[3].frequency = 0 + _data.radios[3].modulation = 3 -- no radio + _data.radios[3].volume = 1 + + _data.hasRadio = false; + _data.selected = 0 + + return _data +end + +function SR.exportRadioSU27(_data) + + _data.radios[1].name = "R-800" + _data.radios[1].frequency = 251.0*1000000 --V/UHF, frequencies are: VHF range of 100 to 149.975 MHz and UHF range of 220 to 399.975 MHz + _data.radios[1].modulation = 0 + _data.radios[1].secondaryFrequency = 121.5*1000000 + _data.radios[1].volume = 1.0 + _data.radios[1].freqMin = 100*1000000 + _data.radios[1].freqMax = 399.975*1000000 + + _data.radios[2].name = "R-864" + _data.radios[2].frequency = 3.5*1000000 --HF frequencies in the 3-10Mhz, like the Jadro + _data.radios[2].modulation = 0 + _data.radios[2].volume = 1.0 + _data.radios[2].freqMin = 3*1000000 + _data.radios[2].freqMax = 10*1000000 + + + _data.radios[3].name = "No radio" + _data.radios[3].frequency = 0 + _data.radios[3].modulation = 3 + _data.radios[3].volume = 1 + + _data.hasRadio = false; + _data.selected = 0 + + return _data +end + +function SR.exportRadioF15C(_data) + + _data.radios[1].name = "UHF-1" + _data.radios[1].frequency = 251.0*1000000 --225 to 399.975MHZ + _data.radios[1].modulation = 0 + _data.radios[1].secondaryFrequency = 243.0*1000000 + _data.radios[1].volume = 1.0 + _data.radios[1].freqMin = 225*1000000 + _data.radios[1].freqMax = 399.975*1000000 + + _data.radios[2].name = "UHF-2" + _data.radios[2].frequency = 231.0*1000000 --225 to 399.975MHZ + _data.radios[2].modulation = 0 + _data.radios[2].freqMin = 225*1000000 + _data.radios[2].freqMax = 399.975*1000000 + + + _data.radios[3].name = "No radio" + _data.radios[3].frequency = 0 + _data.radios[3].modulation = 3 -- to avoid to show a number until we can "hide the non radios" + _data.radios[3].volume = 1 + + _data.hasRadio = false; + _data.selected = 0 + + return _data +end + function SR.exportRadioUH1H(_data) _data.radios[1].name = "AN/ARC-51BX - UHF" @@ -223,12 +377,12 @@ function SR.exportRadioKA50(_data) _data.radios[2].name = "R-828" _data.radios[2].frequency = SR.getRadioFrequency(49,50000) - _data.radios[2].modulation = 0 + _data.radios[2].modulation = 1 _data.radios[2].volume = SR.getRadioVolume(0, 372,{0.0,1.0},false) _data.radios[3].name = "N/A" _data.radios[3].frequency = 1 - _data.radios[3].modulation = 1 + _data.radios[3].modulation = 3 _data.radios[3].volume = 1.0 local switch = _panel:get_argument_value(428) @@ -261,7 +415,7 @@ function SR.exportRadioMI8(_data) _data.radios[2].name = "R-828" _data.radios[2].frequency = SR.getRadioFrequency(39,50000) - _data.radios[2].modulation = 0 + _data.radios[2].modulation = 1 _data.radios[2].volume = SR.getRadioVolume(0, 737,{0.0,1.0},false) _data.radios[3].name = "JADRO-1A" @@ -306,18 +460,22 @@ function SR.exportRadioL39(_data) _data.radios[3].name = "No Radio" _data.radios[3].frequency =1.0 - _data.radios[3].modulation = 0 + _data.radios[3].modulation = 3 _data.radios[3].volume = 0 + -- Intercom button depressed if(SR.getButtonPosition(133) > 0.5 or SR.getButtonPosition(546) > 0.5) then _data.selected = 1 + elseif (SR.getButtonPosition(134) > 0.5 or SR.getButtonPosition(547) > 0.5) then + _data.selected= 0 else - _data.selected = 0 + if SR.enableInternalPTT then + _data.selected = -1 -- PTT Not pressed + else + _data.selected = 0 + end end - - --SR.log(SR.getButtonPosition(133) .." - ".. SR.getButtonPosition(546)) - return _data end @@ -334,7 +492,7 @@ function SR.exportRadioA10C(_data) _data.radios[2].modulation = 0 _data.radios[2].volume = SR.getRadioVolume(0, 133,{0.0,1.0},false) - _data.radios[3].name = "FM" + _data.radios[3].name = "AN/ARC-186(V)FM" _data.radios[3].frequency = SR.getRadioFrequency(56) _data.radios[3].modulation = 1 _data.radios[3].volume = SR.getRadioVolume(0, 147,{0.0,1.0},false) @@ -362,7 +520,6 @@ function SR.exportRadioA10C(_data) return _data end - function SR.exportRadioF86Sabre(_data) _data.radios[1].name = "AN/ARC-27" @@ -372,11 +529,11 @@ function SR.exportRadioF86Sabre(_data) _data.radios[2].name = "N/A" _data.radios[2].frequency = 1 - _data.radios[2].modulation = 0 + _data.radios[2].modulation = 3 _data.radios[3].name = "N/A" _data.radios[3].frequency = 1 - _data.radios[3].modulation = 0 + _data.radios[3].modulation = 3 _data.radios[2].volume = 1.0 _data.radios[3].volume = 1.0 @@ -401,43 +558,58 @@ function SR.exportRadioMIG15(_data) _data.radios[2].name = "N/A" _data.radios[2].frequency = 1 - _data.radios[2].modulation = 0 + _data.radios[2].modulation = 3 _data.radios[3].name = "N/A" _data.radios[3].frequency = 1 - _data.radios[3].modulation = 0 + _data.radios[3].modulation = 3 _data.radios[2].volume = 1.0 _data.radios[3].volume = 1.0 - _data.noMicSwitch = true; - _data.selected = 0 + if SR.enableInternalPTT then + -- Check PTT + if(SR.getButtonPosition(202)) > 0.5 then + _data.selected = 0 + else + _data.selected = -1 + end + end + + return _data; end function SR.exportRadioMIG21(_data) - _data.radios[1].name = "R-828" + _data.radios[1].name = "R-832" _data.radios[1].frequency = SR.getRadioFrequency(22) _data.radios[1].modulation = 0 _data.radios[1].volume = SR.getRadioVolume(0, 210,{0.0,1.0},false) _data.radios[2].name = "N/A" _data.radios[2].frequency = 1 - _data.radios[2].modulation = 0 + _data.radios[2].modulation = 3 _data.radios[3].name = "N/A" _data.radios[3].frequency = 1 - _data.radios[3].modulation = 0 - + _data.radios[3].modulation = 3 _data.radios[2].volume = 1.0 _data.radios[3].volume = 1.0 _data.selected = 0 + if SR.enableInternalPTT then + if(SR.getButtonPosition(315)) > 0.5 then + _data.selected = 0 + else + _data.selected = -1 + end + end + return _data; end @@ -450,11 +622,11 @@ function SR.exportRadioP51(_data) _data.radios[2].name = "N/A" _data.radios[2].frequency = 1 - _data.radios[2].modulation = 0 + _data.radios[2].modulation = 3 _data.radios[3].name = "N/A" _data.radios[3].frequency = 1 - _data.radios[3].modulation = 1 + _data.radios[3].modulation = 3 _data.radios[2].volume = 1.0 @@ -462,6 +634,14 @@ function SR.exportRadioP51(_data) _data.selected = 0 + if SR.enableInternalPTT then + if(SR.getButtonPosition(44)) > 0.5 then + _data.selected = 0 + else + _data.selected = -1 + end + end + return _data; end @@ -474,11 +654,11 @@ function SR.exportRadioFW190(_data) _data.radios[2].name = "N/A" _data.radios[2].frequency = 1 - _data.radios[2].modulation = 0 + _data.radios[2].modulation = 3 _data.radios[3].name = "N/A" _data.radios[3].frequency = 1 - _data.radios[3].modulation = 0 + _data.radios[3].modulation = 3 _data.radios[2].volume = 1.0 @@ -498,11 +678,11 @@ function SR.exportRadioBF109(_data) _data.radios[2].name = "N/A" _data.radios[2].frequency = 1 - _data.radios[2].modulation = 0 + _data.radios[2].modulation = 3 _data.radios[3].name = "N/A" _data.radios[3].frequency = 1 - _data.radios[3].modulation = 0 + _data.radios[3].modulation = 3 _data.radios[2].volume = 1.0 @@ -591,7 +771,6 @@ function SR.exportRadioC101(_data) return _data; end - function SR.exportRadioHawk(_data) local MHZ = 1000000