Audio notifications for install progress
This commit is contained in:
parent
c9e020da74
commit
2a88b56ce2
@ -18,4 +18,5 @@ namespace inst::util {
|
||||
std::vector<uint32_t> setClockSpeed(int deviceToClock, uint32_t clockSpeed);
|
||||
std::string getIPAddress();
|
||||
int getUsbState();
|
||||
void playAudio(std::string audioPath);
|
||||
}
|
BIN
romfs/audio/awoo.wav
Executable file
BIN
romfs/audio/awoo.wav
Executable file
Binary file not shown.
BIN
romfs/audio/bark.wav
Executable file
BIN
romfs/audio/bark.wav
Executable file
Binary file not shown.
@ -28,6 +28,7 @@ SOFTWARE.
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <machine/endian.h>
|
||||
#include <thread>
|
||||
|
||||
#include "nx/ncm.hpp"
|
||||
#include "install/nca.hpp"
|
||||
@ -40,6 +41,7 @@ SOFTWARE.
|
||||
#include "util/title_util.hpp"
|
||||
#include "sdInstall.hpp"
|
||||
#include "ui/MainApplication.hpp"
|
||||
#include "util/util.hpp"
|
||||
|
||||
namespace inst::ui {
|
||||
extern MainApplication *mainApp;
|
||||
@ -129,7 +131,9 @@ namespace tin::install::nsp
|
||||
|
||||
if (!Crypto::rsa2048PssVerify(&header.magic, 0x200, header.fixed_key_sig, Crypto::NCAHeaderSignature))
|
||||
{
|
||||
std::thread audioThread(inst::util::playAudio,"romfs:/audio/bark.wav");
|
||||
int rc = inst::ui::mainApp->CreateShowDialog("Invalid NCA signature detected!", "Improperly signed software should only be installed from trustworthy\nsources. Files containing cartridge repacks and DLC unlockers will always\nshow this warning. You can disable this check in Awoo Installer's settings.\n\nAre you sure you want to continue the installation?", {"Cancel", "Yes, I understand the risks"}, false);
|
||||
audioThread.join();
|
||||
if (rc != 1)
|
||||
THROW_FORMAT(("The requested NCA (" + tin::util::GetNcaIdString(ncaId) + ") is not properly signed").c_str());
|
||||
declinedValidation = true;
|
||||
|
@ -23,6 +23,8 @@ SOFTWARE.
|
||||
#include "install/install_nsp_remote.hpp"
|
||||
|
||||
#include <machine/endian.h>
|
||||
#include <thread>
|
||||
|
||||
#include "install/nca.hpp"
|
||||
#include "nx/fs.hpp"
|
||||
#include "nx/ncm.hpp"
|
||||
@ -33,6 +35,7 @@ SOFTWARE.
|
||||
#include "util/debug.h"
|
||||
#include "util/error.hpp"
|
||||
#include "ui/MainApplication.hpp"
|
||||
#include "util/util.hpp"
|
||||
|
||||
namespace inst::ui {
|
||||
extern MainApplication *mainApp;
|
||||
@ -107,7 +110,9 @@ namespace tin::install::nsp
|
||||
|
||||
if (!Crypto::rsa2048PssVerify(&header->magic, 0x200, header->fixed_key_sig, Crypto::NCAHeaderSignature))
|
||||
{
|
||||
std::thread audioThread(inst::util::playAudio,"romfs:/audio/bark.wav");
|
||||
int rc = inst::ui::mainApp->CreateShowDialog("Invalid NCA signature detected!", "Improperly signed software should only be installed from trustworthy\nsources. Files containing cartridge repacks and DLC unlockers will always\nshow this warning. You can disable this check in Awoo Installer's settings.\n\nAre you sure you want to continue the installation?", {"Cancel", "Yes, I understand the risks"}, false);
|
||||
audioThread.join();
|
||||
if (rc != 1)
|
||||
THROW_FORMAT(("The requested NCA (" + tin::util::GetNcaIdString(ncaId) + ") is not properly signed").c_str());
|
||||
declinedValidation = true;
|
||||
|
@ -20,6 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <thread>
|
||||
|
||||
#include "install/install_xci.hpp"
|
||||
#include "util/file_util.hpp"
|
||||
#include "util/title_util.hpp"
|
||||
@ -30,6 +32,7 @@ SOFTWARE.
|
||||
#include "install/nca.hpp"
|
||||
#include "sdInstall.hpp"
|
||||
#include "ui/MainApplication.hpp"
|
||||
#include "util/util.hpp"
|
||||
|
||||
namespace inst::ui {
|
||||
extern MainApplication *mainApp;
|
||||
@ -108,7 +111,9 @@ namespace tin::install::xci
|
||||
|
||||
if (!Crypto::rsa2048PssVerify(&header->magic, 0x200, header->fixed_key_sig, Crypto::NCAHeaderSignature))
|
||||
{
|
||||
std::thread audioThread(inst::util::playAudio,"romfs:/audio/awoo.wav");
|
||||
int rc = inst::ui::mainApp->CreateShowDialog("Invalid NCA signature detected!", "Improperly signed software should only be installed from trustworthy\nsources. Files containing cartridge repacks and DLC unlockers will always\nshow this warning. You can disable this check in Awoo Installer's settings.\n\nAre you sure you want to continue the installation?", {"Cancel", "Yes, I understand the risks"}, false);
|
||||
audioThread.join();
|
||||
if (rc != 1)
|
||||
THROW_FORMAT(("The requested NCA (" + tin::util::GetNcaIdString(ncaId) + ") is not properly signed").c_str());
|
||||
declinedValidation = true;
|
||||
|
@ -26,6 +26,7 @@ SOFTWARE.
|
||||
#include <fcntl.h>
|
||||
#include <sstream>
|
||||
#include <curl/curl.h>
|
||||
#include <thread>
|
||||
|
||||
#include <switch.h>
|
||||
#include "util/network_util.hpp"
|
||||
@ -171,7 +172,9 @@ namespace netInstStuff{
|
||||
fprintf(stdout, "%s", e.what());
|
||||
inst::ui::setInstInfoText("Failed to install " + urlNames[urlItr]);
|
||||
inst::ui::setInstBarPerc(0);
|
||||
std::thread audioThread(inst::util::playAudio,"romfs:/audio/bark.wav");
|
||||
inst::ui::mainApp->CreateShowDialog("Failed to install " + urlNames[urlItr] + "!", "Partially installed contents can be removed from the System Settings applet.\n\n" + (std::string)e.what(), {"OK"}, true);
|
||||
audioThread.join();
|
||||
nspInstalled = false;
|
||||
}
|
||||
|
||||
@ -189,8 +192,10 @@ namespace netInstStuff{
|
||||
if(nspInstalled) {
|
||||
inst::ui::setInstInfoText("Install complete");
|
||||
inst::ui::setInstBarPerc(100);
|
||||
std::thread audioThread(inst::util::playAudio,"romfs:/audio/awoo.wav");
|
||||
if (ourUrlList.size() > 1) inst::ui::mainApp->CreateShowDialog(std::to_string(ourUrlList.size()) + " files installed successfully!", nspInstStuff::finishedMessage(), {"OK"}, true);
|
||||
else inst::ui::mainApp->CreateShowDialog(urlNames[0] + " installed!", nspInstStuff::finishedMessage(), {"OK"}, true);
|
||||
audioThread.join();
|
||||
}
|
||||
|
||||
LOG_DEBUG("Done");
|
||||
|
@ -24,6 +24,7 @@ SOFTWARE.
|
||||
#include <sstream>
|
||||
#include <filesystem>
|
||||
#include <ctime>
|
||||
#include <thread>
|
||||
|
||||
#include "install/install_nsp.hpp"
|
||||
#include "install/install_xci.hpp"
|
||||
@ -140,7 +141,9 @@ namespace nspInstStuff {
|
||||
fprintf(stdout, "%s", e.what());
|
||||
inst::ui::setInstInfoText("Failed to install " + inst::util::shortenString(ourTitleList[titleItr].filename().string(), 42, true));
|
||||
inst::ui::setInstBarPerc(0);
|
||||
std::thread audioThread(inst::util::playAudio,"romfs:/audio/bark.wav");
|
||||
inst::ui::mainApp->CreateShowDialog("Failed to install " + inst::util::shortenString(ourTitleList[titleItr].filename().string(), 42, true) + "!", "Partially installed contents can be removed from the System Settings applet.\n\n" + (std::string)e.what(), {"OK"}, true);
|
||||
audioThread.join();
|
||||
nspInstalled = false;
|
||||
}
|
||||
|
||||
@ -160,6 +163,7 @@ namespace nspInstStuff {
|
||||
if(nspInstalled) {
|
||||
inst::ui::setInstInfoText("Install complete");
|
||||
inst::ui::setInstBarPerc(100);
|
||||
std::thread audioThread(inst::util::playAudio,"romfs:/audio/awoo.wav");
|
||||
if (ourTitleList.size() > 1) {
|
||||
if (inst::config::deletePrompt) {
|
||||
if(inst::ui::mainApp->CreateShowDialog(std::to_string(ourTitleList.size()) + " files installed successfully! Delete them from the SD card?", "The original files aren't needed anymore after they've been installed", {"No","Yes"}, false) == 1) {
|
||||
@ -173,6 +177,7 @@ namespace nspInstStuff {
|
||||
if(inst::ui::mainApp->CreateShowDialog(inst::util::shortenString(ourTitleList[0].filename().string(), 32, true) + " installed! Delete it from the SD card?", "The original file isn't needed anymore after it's been installed", {"No","Yes"}, false) == 1) if (std::filesystem::exists(ourTitleList[0])) std::filesystem::remove(ourTitleList[0]);
|
||||
} else inst::ui::mainApp->CreateShowDialog(inst::util::shortenString(ourTitleList[0].filename().string(), 42, true) + " installed!", nspInstStuff::finishedMessage(), {"OK"}, true);
|
||||
}
|
||||
audioThread.join();
|
||||
}
|
||||
|
||||
LOG_DEBUG("Done");
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include "util/error.hpp"
|
||||
#include "usbInstall.hpp"
|
||||
#include "install/usb_nsp.hpp"
|
||||
@ -31,8 +32,6 @@ namespace usbInstStuff {
|
||||
} PACKED;
|
||||
|
||||
std::vector<std::string> OnSelected() {
|
||||
Result rc = 0;
|
||||
|
||||
TUSHeader header;
|
||||
while(true) {
|
||||
if (tin::util::USBRead(&header, sizeof(TUSHeader)) != 0) break;
|
||||
@ -111,7 +110,9 @@ namespace usbInstStuff {
|
||||
fprintf(stdout, "%s", e.what());
|
||||
inst::ui::setInstInfoText("Failed to install " + fileNames[fileItr]);
|
||||
inst::ui::setInstBarPerc(0);
|
||||
std::thread audioThread(inst::util::playAudio,"romfs:/audio/bark.wav");
|
||||
inst::ui::mainApp->CreateShowDialog("Failed to install " + fileNames[fileItr] + "!", "Partially installed contents can be removed from the System Settings applet.\n\n" + (std::string)e.what(), {"OK"}, true);
|
||||
audioThread.join();
|
||||
nspInstalled = false;
|
||||
}
|
||||
|
||||
@ -125,8 +126,10 @@ namespace usbInstStuff {
|
||||
tin::util::USBCmdManager::SendExitCmd();
|
||||
inst::ui::setInstInfoText("Install complete");
|
||||
inst::ui::setInstBarPerc(100);
|
||||
std::thread audioThread(inst::util::playAudio,"romfs:/audio/awoo.wav");
|
||||
if (ourTitleList.size() > 1) inst::ui::mainApp->CreateShowDialog(std::to_string(ourTitleList.size()) + " files installed successfully!", nspInstStuff::finishedMessage(), {"OK"}, true);
|
||||
else inst::ui::mainApp->CreateShowDialog(fileNames[0] + " installed!", nspInstStuff::finishedMessage(), {"OK"}, true);
|
||||
audioThread.join();
|
||||
}
|
||||
|
||||
LOG_DEBUG("Done");
|
||||
|
@ -264,4 +264,35 @@ namespace inst::util {
|
||||
usbDsGetState(&usbState);
|
||||
return usbState;
|
||||
}
|
||||
|
||||
void playAudio(std::string audioPath) {
|
||||
int audio_rate = 22050;
|
||||
Uint16 audio_format = AUDIO_S16SYS;
|
||||
int audio_channels = 2;
|
||||
int audio_buffers = 4096;
|
||||
|
||||
if(Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers) != 0) return;
|
||||
|
||||
Mix_Chunk *sound = NULL;
|
||||
sound = Mix_LoadWAV(audioPath.c_str());
|
||||
if(sound == NULL) {
|
||||
Mix_FreeChunk(sound);
|
||||
Mix_CloseAudio();
|
||||
return;
|
||||
}
|
||||
|
||||
int channel = Mix_PlayChannel(-1, sound, 0);
|
||||
if(channel == -1) {
|
||||
Mix_FreeChunk(sound);
|
||||
Mix_CloseAudio();
|
||||
return;
|
||||
}
|
||||
|
||||
while(Mix_Playing(channel) != 0);
|
||||
|
||||
Mix_FreeChunk(sound);
|
||||
Mix_CloseAudio();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user