├── .gitattributes ├── .gitignore ├── Croak.sln ├── Croak ├── App.idl ├── App.xaml ├── App.xaml.cpp ├── App.xaml.h ├── Assets │ ├── LockScreenLogo.scale-200.png │ ├── SplashScreen.scale-200.png │ ├── Square150x150Logo.scale-200.png │ ├── Square44x44Logo.scale-200.png │ ├── Square44x44Logo.targetsize-24_altform-unplated.png │ ├── StoreLogo.png │ └── Wide310x150Logo.scale-200.png ├── AudioController.cpp ├── AudioController.h ├── AudioInterfacesSmartPtrs.h ├── AudioProfile.cpp ├── AudioProfile.h ├── AudioProfile.idl ├── AudioProfileEditPage.idl ├── AudioProfileEditPage.xaml ├── AudioProfileEditPage.xaml.cpp ├── AudioProfileEditPage.xaml.h ├── AudioProfilesPage.idl ├── AudioProfilesPage.xaml ├── AudioProfilesPage.xaml.cpp ├── AudioProfilesPage.xaml.h ├── AudioSession.cpp ├── AudioSession.h ├── AudioSessionStates.h ├── AudioSessionView.idl ├── AudioSessionView.xaml ├── AudioSessionView.xaml.cpp ├── AudioSessionView.xaml.h ├── AudioSessionsSettingsPage.idl ├── AudioSessionsSettingsPage.xaml ├── AudioSessionsSettingsPage.xaml.cpp ├── AudioSessionsSettingsPage.xaml.h ├── ComSmartPtrTypeDefs.h ├── Croak.rc ├── Croak.vcxproj ├── Croak.vcxproj.filters ├── DebugOutput.h ├── DefaultAudioEndpoint.cpp ├── DefaultAudioEndpoint.h ├── HotKeyView.idl ├── HotKeyView.xaml ├── HotKeyView.xaml.cpp ├── HotKeyView.xaml.h ├── HotKeysViewer.idl ├── HotKeysViewer.xaml ├── HotKeysViewer.xaml.cpp ├── HotKeysViewer.xaml.h ├── Hotkey.cpp ├── Hotkey.h ├── HotkeyManager.cpp ├── HotkeyManager.h ├── HotkeyViewModel.cpp ├── HotkeyViewModel.h ├── HotkeyViewModel.idl ├── HotkeysPage.idl ├── HotkeysPage.xaml ├── HotkeysPage.xaml.cpp ├── HotkeysPage.xaml.h ├── IComEventImplementation.h ├── IconButton.cpp ├── IconButton.h ├── IconButton.idl ├── IconHelper.cpp ├── IconHelper.h ├── IconToggleButton.cpp ├── IconToggleButton.h ├── IconToggleButton.idl ├── KeyIcon.cpp ├── KeyIcon.h ├── KeyIcon.idl ├── LetterKeyIcon.cpp ├── LetterKeyIcon.h ├── LetterKeyIcon.idl ├── MainWindow.idl ├── MainWindow.xaml ├── MainWindow.xaml.cpp ├── MainWindow.xaml.h ├── ManifestApplicationNode.cpp ├── ManifestApplicationNode.h ├── MessageBar.idl ├── MessageBar.xaml ├── MessageBar.xaml.cpp ├── MessageBar.xaml.h ├── NavigationBreadcrumbBarItem.cpp ├── NavigationBreadcrumbBarItem.h ├── NavigationBreadcrumbBarItem.idl ├── NewContentPage.idl ├── NewContentPage.xaml ├── NewContentPage.xaml.cpp ├── NewContentPage.xaml.h ├── NumberBlock.cpp ├── NumberBlock.h ├── NumberBlock.idl ├── Package.appxmanifest ├── ProcessInfo.cpp ├── ProcessInfo.h ├── Resources.lang-en-us.resw ├── Resources.lang-fr-fr.resw ├── SecondWindow.idl ├── SecondWindow.xaml ├── SecondWindow.xaml.cpp ├── SecondWindow.xaml.h ├── SettingsPage.idl ├── SettingsPage.xaml ├── SettingsPage.xaml.cpp ├── SettingsPage.xaml.h ├── SplashScreen.idl ├── SplashScreen.xaml ├── SplashScreen.xaml.cpp ├── SplashScreen.xaml.h ├── Themes │ └── Generic.xaml ├── app.manifest ├── cpp.hint ├── packages.config ├── pch.cpp ├── pch.h └── resource.h ├── LICENSE.txt └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Ww][Ii][Nn]32/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Oo]ut/ 33 | [Ll]og/ 34 | [Ll]ogs/ 35 | 36 | # Visual Studio 2015/2017 cache/options directory 37 | .vs/ 38 | # Uncomment if you have tasks that create the project's static files in wwwroot 39 | #wwwroot/ 40 | 41 | # Visual Studio 2017 auto generated files 42 | Generated\ Files/ 43 | 44 | # MSTest test Results 45 | [Tt]est[Rr]esult*/ 46 | [Bb]uild[Ll]og.* 47 | 48 | # NUnit 49 | *.VisualState.xml 50 | TestResult.xml 51 | nunit-*.xml 52 | 53 | # Build Results of an ATL Project 54 | [Dd]ebugPS/ 55 | [Rr]eleasePS/ 56 | dlldata.c 57 | 58 | # Benchmark Results 59 | BenchmarkDotNet.Artifacts/ 60 | 61 | # .NET Core 62 | project.lock.json 63 | project.fragment.lock.json 64 | artifacts/ 65 | 66 | # ASP.NET Scaffolding 67 | ScaffoldingReadMe.txt 68 | 69 | # StyleCop 70 | StyleCopReport.xml 71 | 72 | # Files built by Visual Studio 73 | *_i.c 74 | *_p.c 75 | *_h.h 76 | *.ilk 77 | *.meta 78 | *.obj 79 | *.iobj 80 | *.pch 81 | *.pdb 82 | *.ipdb 83 | *.pgc 84 | *.pgd 85 | *.rsp 86 | *.sbr 87 | *.tlb 88 | *.tli 89 | *.tlh 90 | *.tmp 91 | *.tmp_proj 92 | *_wpftmp.csproj 93 | *.log 94 | *.vspscc 95 | *.vssscc 96 | .builds 97 | *.pidb 98 | *.svclog 99 | *.scc 100 | 101 | # Chutzpah Test files 102 | _Chutzpah* 103 | 104 | # Visual C++ cache files 105 | ipch/ 106 | *.aps 107 | *.ncb 108 | *.opendb 109 | *.opensdf 110 | *.sdf 111 | *.cachefile 112 | *.VC.db 113 | *.VC.VC.opendb 114 | 115 | # Visual Studio profiler 116 | *.psess 117 | *.vsp 118 | *.vspx 119 | *.sap 120 | 121 | # Visual Studio Trace Files 122 | *.e2e 123 | 124 | # TFS 2012 Local Workspace 125 | $tf/ 126 | 127 | # Guidance Automation Toolkit 128 | *.gpState 129 | 130 | # ReSharper is a .NET coding add-in 131 | _ReSharper*/ 132 | *.[Rr]e[Ss]harper 133 | *.DotSettings.user 134 | 135 | # TeamCity is a build add-in 136 | _TeamCity* 137 | 138 | # DotCover is a Code Coverage Tool 139 | *.dotCover 140 | 141 | # AxoCover is a Code Coverage Tool 142 | .axoCover/* 143 | !.axoCover/settings.json 144 | 145 | # Coverlet is a free, cross platform Code Coverage Tool 146 | coverage*.json 147 | coverage*.xml 148 | coverage*.info 149 | 150 | # Visual Studio code coverage results 151 | *.coverage 152 | *.coveragexml 153 | 154 | # NCrunch 155 | _NCrunch_* 156 | .*crunch*.local.xml 157 | nCrunchTemp_* 158 | 159 | # MightyMoose 160 | *.mm.* 161 | AutoTest.Net/ 162 | 163 | # Web workbench (sass) 164 | .sass-cache/ 165 | 166 | # Installshield output folder 167 | [Ee]xpress/ 168 | 169 | # DocProject is a documentation generator add-in 170 | DocProject/buildhelp/ 171 | DocProject/Help/*.HxT 172 | DocProject/Help/*.HxC 173 | DocProject/Help/*.hhc 174 | DocProject/Help/*.hhk 175 | DocProject/Help/*.hhp 176 | DocProject/Help/Html2 177 | DocProject/Help/html 178 | 179 | # Click-Once directory 180 | publish/ 181 | 182 | # Publish Web Output 183 | *.[Pp]ublish.xml 184 | *.azurePubxml 185 | # Note: Comment the next line if you want to checkin your web deploy settings, 186 | # but database connection strings (with potential passwords) will be unencrypted 187 | *.pubxml 188 | *.publishproj 189 | 190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 191 | # checkin your Azure Web App publish settings, but sensitive information contained 192 | # in these scripts will be unencrypted 193 | PublishScripts/ 194 | 195 | # NuGet Packages 196 | *.nupkg 197 | # NuGet Symbol Packages 198 | *.snupkg 199 | # The packages folder can be ignored because of Package Restore 200 | **/[Pp]ackages/* 201 | # except build/, which is used as an MSBuild target. 202 | !**/[Pp]ackages/build/ 203 | # Uncomment if necessary however generally it will be regenerated when needed 204 | #!**/[Pp]ackages/repositories.config 205 | # NuGet v3's project.json files produces more ignorable files 206 | *.nuget.props 207 | *.nuget.targets 208 | 209 | # Microsoft Azure Build Output 210 | csx/ 211 | *.build.csdef 212 | 213 | # Microsoft Azure Emulator 214 | ecf/ 215 | rcf/ 216 | 217 | # Windows Store app package directories and files 218 | AppPackages/ 219 | BundleArtifacts/ 220 | Package.StoreAssociation.xml 221 | _pkginfo.txt 222 | *.appx 223 | *.appxbundle 224 | *.appxupload 225 | 226 | # Visual Studio cache files 227 | # files ending in .cache can be ignored 228 | *.[Cc]ache 229 | # but keep track of directories ending in .cache 230 | !?*.[Cc]ache/ 231 | 232 | # Others 233 | ClientBin/ 234 | ~$* 235 | *~ 236 | *.dbmdl 237 | *.dbproj.schemaview 238 | *.jfm 239 | *.pfx 240 | *.publishsettings 241 | orleans.codegen.cs 242 | 243 | # Including strong name files can present a security risk 244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 245 | #*.snk 246 | 247 | # Since there are multiple workflows, uncomment next line to ignore bower_components 248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 249 | #bower_components/ 250 | 251 | # RIA/Silverlight projects 252 | Generated_Code/ 253 | 254 | # Backup & report files from converting an old project file 255 | # to a newer Visual Studio version. Backup files are not needed, 256 | # because we have git ;-) 257 | _UpgradeReport_Files/ 258 | Backup*/ 259 | UpgradeLog*.XML 260 | UpgradeLog*.htm 261 | ServiceFabricBackup/ 262 | *.rptproj.bak 263 | 264 | # SQL Server files 265 | *.mdf 266 | *.ldf 267 | *.ndf 268 | 269 | # Business Intelligence projects 270 | *.rdl.data 271 | *.bim.layout 272 | *.bim_*.settings 273 | *.rptproj.rsuser 274 | *- [Bb]ackup.rdl 275 | *- [Bb]ackup ([0-9]).rdl 276 | *- [Bb]ackup ([0-9][0-9]).rdl 277 | 278 | # Microsoft Fakes 279 | FakesAssemblies/ 280 | 281 | # GhostDoc plugin setting file 282 | *.GhostDoc.xml 283 | 284 | # Node.js Tools for Visual Studio 285 | .ntvs_analysis.dat 286 | node_modules/ 287 | 288 | # Visual Studio 6 build log 289 | *.plg 290 | 291 | # Visual Studio 6 workspace options file 292 | *.opt 293 | 294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 295 | *.vbw 296 | 297 | # Visual Studio LightSwitch build output 298 | **/*.HTMLClient/GeneratedArtifacts 299 | **/*.DesktopClient/GeneratedArtifacts 300 | **/*.DesktopClient/ModelManifest.xml 301 | **/*.Server/GeneratedArtifacts 302 | **/*.Server/ModelManifest.xml 303 | _Pvt_Extensions 304 | 305 | # Paket dependency manager 306 | .paket/paket.exe 307 | paket-files/ 308 | 309 | # FAKE - F# Make 310 | .fake/ 311 | 312 | # CodeRush personal settings 313 | .cr/personal 314 | 315 | # Python Tools for Visual Studio (PTVS) 316 | __pycache__/ 317 | *.pyc 318 | 319 | # Cake - Uncomment if you are using it 320 | # tools/** 321 | # !tools/packages.config 322 | 323 | # Tabs Studio 324 | *.tss 325 | 326 | # Telerik's JustMock configuration file 327 | *.jmconfig 328 | 329 | # BizTalk build output 330 | *.btp.cs 331 | *.btm.cs 332 | *.odx.cs 333 | *.xsd.cs 334 | 335 | # OpenCover UI analysis results 336 | OpenCover/ 337 | 338 | # Azure Stream Analytics local run output 339 | ASALocalRun/ 340 | 341 | # MSBuild Binary and Structured Log 342 | *.binlog 343 | 344 | # NVidia Nsight GPU debugger configuration file 345 | *.nvuser 346 | 347 | # MFractors (Xamarin productivity tool) working folder 348 | .mfractor/ 349 | 350 | # Local History for Visual Studio 351 | .localhistory/ 352 | 353 | # BeatPulse healthcheck temp database 354 | healthchecksdb 355 | 356 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 357 | MigrationBackup/ 358 | 359 | # Ionide (cross platform F# VS Code tools) working folder 360 | .ionide/ 361 | 362 | # Fody - auto-generated XML schema 363 | FodyWeavers.xsd -------------------------------------------------------------------------------- /Croak.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.4.33205.214 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Croak", "Croak\Croak.vcxproj", "{653B209C-02F5-468B-B799-C2ACCFB2499E}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|ARM64 = Debug|ARM64 11 | Debug|x64 = Debug|x64 12 | Debug|x86 = Debug|x86 13 | Release|ARM64 = Release|ARM64 14 | Release|x64 = Release|x64 15 | Release|x86 = Release|x86 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {653B209C-02F5-468B-B799-C2ACCFB2499E}.Debug|ARM64.ActiveCfg = Debug|ARM64 19 | {653B209C-02F5-468B-B799-C2ACCFB2499E}.Debug|ARM64.Build.0 = Debug|ARM64 20 | {653B209C-02F5-468B-B799-C2ACCFB2499E}.Debug|ARM64.Deploy.0 = Debug|ARM64 21 | {653B209C-02F5-468B-B799-C2ACCFB2499E}.Debug|x64.ActiveCfg = Debug|x64 22 | {653B209C-02F5-468B-B799-C2ACCFB2499E}.Debug|x64.Build.0 = Debug|x64 23 | {653B209C-02F5-468B-B799-C2ACCFB2499E}.Debug|x64.Deploy.0 = Debug|x64 24 | {653B209C-02F5-468B-B799-C2ACCFB2499E}.Debug|x86.ActiveCfg = Debug|Win32 25 | {653B209C-02F5-468B-B799-C2ACCFB2499E}.Debug|x86.Build.0 = Debug|Win32 26 | {653B209C-02F5-468B-B799-C2ACCFB2499E}.Debug|x86.Deploy.0 = Debug|Win32 27 | {653B209C-02F5-468B-B799-C2ACCFB2499E}.Release|ARM64.ActiveCfg = Release|ARM64 28 | {653B209C-02F5-468B-B799-C2ACCFB2499E}.Release|ARM64.Build.0 = Release|ARM64 29 | {653B209C-02F5-468B-B799-C2ACCFB2499E}.Release|ARM64.Deploy.0 = Release|ARM64 30 | {653B209C-02F5-468B-B799-C2ACCFB2499E}.Release|x64.ActiveCfg = Release|x64 31 | {653B209C-02F5-468B-B799-C2ACCFB2499E}.Release|x64.Build.0 = Release|x64 32 | {653B209C-02F5-468B-B799-C2ACCFB2499E}.Release|x64.Deploy.0 = Release|x64 33 | {653B209C-02F5-468B-B799-C2ACCFB2499E}.Release|x86.ActiveCfg = Release|Win32 34 | {653B209C-02F5-468B-B799-C2ACCFB2499E}.Release|x86.Build.0 = Release|Win32 35 | {653B209C-02F5-468B-B799-C2ACCFB2499E}.Release|x86.Deploy.0 = Release|Win32 36 | EndGlobalSection 37 | GlobalSection(SolutionProperties) = preSolution 38 | HideSolutionNode = FALSE 39 | EndGlobalSection 40 | GlobalSection(ExtensibilityGlobals) = postSolution 41 | SolutionGuid = {C0F64FEB-6814-4754-8244-99C8ECE8EB70} 42 | EndGlobalSection 43 | EndGlobal 44 | -------------------------------------------------------------------------------- /Croak/App.idl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation and Contributors. 2 | // Licensed under the MIT License. 3 | 4 | namespace Croak 5 | { 6 | } 7 | -------------------------------------------------------------------------------- /Croak/App.xaml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 00:00:0.100 16 | 0:0:04 17 | 4 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /Croak/App.xaml.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation and Contributors. 2 | // Licensed under the MIT License. 3 | 4 | #include "pch.h" 5 | 6 | #include "App.xaml.h" 7 | #include "MainWindow.xaml.h" 8 | 9 | using namespace winrt; 10 | using namespace Windows::Foundation; 11 | using namespace Microsoft::UI::Xaml; 12 | using namespace Microsoft::UI::Xaml::Controls; 13 | using namespace Microsoft::UI::Xaml::Navigation; 14 | using namespace winrt::Croak; 15 | using namespace winrt::Croak::implementation; 16 | 17 | // To learn more about WinUI, the WinUI project structure, 18 | // and more about our project templates, see: http://aka.ms/winui-project-info. 19 | 20 | /// 21 | /// Initializes the singleton application object. This is the first line of authored code 22 | /// executed, and as such is the logical equivalent of main() or WinMain(). 23 | /// 24 | App::App() 25 | { 26 | InitializeComponent(); 27 | 28 | #if defined _DEBUG && !defined DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION 29 | UnhandledException([this](IInspectable const&, UnhandledExceptionEventArgs const& e) 30 | { 31 | if (IsDebuggerPresent()) 32 | { 33 | auto errorMessage = e.Message(); 34 | __debugbreak(); 35 | } 36 | }); 37 | #endif 38 | } 39 | 40 | /// 41 | /// Invoked when the application is launched. 42 | /// 43 | /// Details about the launch request and process. 44 | void App::OnLaunched(LaunchActivatedEventArgs const& e) 45 | { 46 | window = make(e.Arguments()); 47 | window.Activate(); 48 | } 49 | -------------------------------------------------------------------------------- /Croak/App.xaml.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation and Contributors. 2 | // Licensed under the MIT License. 3 | 4 | #pragma once 5 | 6 | #include "App.xaml.g.h" 7 | #include "IconButton.h" 8 | #include "IconToggleButton.h" 9 | #include "KeyIcon.h" 10 | #include "LetterKeyIcon.h" 11 | #include "NumberBlock.h" 12 | 13 | namespace winrt::Croak::implementation 14 | { 15 | enum AudioSessionState 16 | { 17 | Active, 18 | Inactive, 19 | Muted, 20 | Expired 21 | }; 22 | 23 | struct App : AppT 24 | { 25 | App(); 26 | 27 | void OnLaunched(Microsoft::UI::Xaml::LaunchActivatedEventArgs const&); 28 | 29 | private: 30 | winrt::Microsoft::UI::Xaml::Window window{ nullptr }; 31 | }; 32 | } 33 | -------------------------------------------------------------------------------- /Croak/Assets/LockScreenLogo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psyKomicron/Croak/dcd2d2bc5250f6b8dee56466b4557c50d4d2fd3d/Croak/Assets/LockScreenLogo.scale-200.png -------------------------------------------------------------------------------- /Croak/Assets/SplashScreen.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psyKomicron/Croak/dcd2d2bc5250f6b8dee56466b4557c50d4d2fd3d/Croak/Assets/SplashScreen.scale-200.png -------------------------------------------------------------------------------- /Croak/Assets/Square150x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psyKomicron/Croak/dcd2d2bc5250f6b8dee56466b4557c50d4d2fd3d/Croak/Assets/Square150x150Logo.scale-200.png -------------------------------------------------------------------------------- /Croak/Assets/Square44x44Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psyKomicron/Croak/dcd2d2bc5250f6b8dee56466b4557c50d4d2fd3d/Croak/Assets/Square44x44Logo.scale-200.png -------------------------------------------------------------------------------- /Croak/Assets/Square44x44Logo.targetsize-24_altform-unplated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psyKomicron/Croak/dcd2d2bc5250f6b8dee56466b4557c50d4d2fd3d/Croak/Assets/Square44x44Logo.targetsize-24_altform-unplated.png -------------------------------------------------------------------------------- /Croak/Assets/StoreLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psyKomicron/Croak/dcd2d2bc5250f6b8dee56466b4557c50d4d2fd3d/Croak/Assets/StoreLogo.png -------------------------------------------------------------------------------- /Croak/Assets/Wide310x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psyKomicron/Croak/dcd2d2bc5250f6b8dee56466b4557c50d4d2fd3d/Croak/Assets/Wide310x150Logo.scale-200.png -------------------------------------------------------------------------------- /Croak/AudioController.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "AudioController.h" 3 | 4 | using namespace winrt; 5 | using namespace std; 6 | 7 | namespace Croak::Audio 8 | { 9 | AudioController::AudioController(GUID const& guid) : 10 | audioSessionID(guid) 11 | { 12 | IMMDevicePtr pDevice; 13 | 14 | // Create the device enumerator. 15 | check_hresult(CoCreateInstance(__uuidof(MMDeviceEnumerator), NULL, CLSCTX_ALL, IID_PPV_ARGS(&deviceEnumerator))); 16 | // Get the default audio device. 17 | check_hresult(deviceEnumerator->GetDefaultAudioEndpoint(eRender, eMultimedia, &pDevice)); 18 | // Get the session manager. 19 | check_hresult(pDevice->Activate(__uuidof(IAudioSessionManager2), CLSCTX_ALL, NULL, (void**)&audioSessionManager)); 20 | // Get session enumerator 21 | check_hresult(audioSessionManager->GetSessionEnumerator(&audioSessionEnumerator)); 22 | } 23 | 24 | 25 | bool AudioController::Register() 26 | { 27 | if (!isRegistered) 28 | { 29 | isRegistered = 30 | SUCCEEDED(audioSessionManager->RegisterSessionNotification(this)) && 31 | SUCCEEDED(deviceEnumerator->RegisterEndpointNotificationCallback(this)); 32 | } 33 | return isRegistered; 34 | } 35 | 36 | bool AudioController::Unregister() 37 | { 38 | return SUCCEEDED(audioSessionManager->UnregisterSessionNotification(this)) && SUCCEEDED(deviceEnumerator->UnregisterEndpointNotificationCallback(this)); 39 | } 40 | 41 | #pragma region IUnknown 42 | IFACEMETHODIMP_(ULONG) AudioController::AddRef() 43 | { 44 | return ++refCount; 45 | } 46 | 47 | IFACEMETHODIMP_(ULONG) AudioController::Release() 48 | { 49 | const uint32_t remaining = --refCount; 50 | 51 | if (remaining == 0) 52 | { 53 | delete this; 54 | } 55 | 56 | return remaining; 57 | } 58 | 59 | IFACEMETHODIMP AudioController::QueryInterface(REFIID riid, VOID** ppvInterface) 60 | { 61 | if (riid == IID_IUnknown) 62 | { 63 | *ppvInterface = static_cast(static_cast(this)); 64 | AddRef(); 65 | } 66 | else if (riid == __uuidof(IAudioSessionNotification)) 67 | { 68 | *ppvInterface = static_cast(this); 69 | AddRef(); 70 | } 71 | else if (riid == __uuidof(IMMNotificationClient)) 72 | { 73 | *ppvInterface = static_cast(this); 74 | AddRef(); 75 | } 76 | else 77 | { 78 | *ppvInterface = NULL; 79 | return E_POINTER; 80 | } 81 | return S_OK; 82 | } 83 | #pragma endregion 84 | 85 | vector* AudioController::GetSessions() 86 | { 87 | vector* sessions = new vector(); 88 | int sessionCount; 89 | if (SUCCEEDED(audioSessionEnumerator->GetCount(&sessionCount))) 90 | { 91 | for (int i = 0; i < sessionCount; i++) 92 | { 93 | IAudioSessionControlPtr control; 94 | IAudioSessionControl2* control2 = nullptr; 95 | 96 | if (SUCCEEDED(audioSessionEnumerator->GetSession(i, &control)) && 97 | SUCCEEDED(control->QueryInterface(__uuidof(IAudioSessionControl2), (void**)&control2))) 98 | { 99 | sessions->push_back(new AudioSession(control2, audioSessionID)); 100 | } 101 | } 102 | } 103 | 104 | return sessions; 105 | } 106 | 107 | AudioSession* AudioController::NewSession() 108 | { 109 | if (newSessions.empty()) 110 | { 111 | return nullptr; 112 | } 113 | else 114 | { 115 | AudioSession* ptr = newSessions.top(); 116 | newSessions.pop(); 117 | return ptr; 118 | } 119 | } 120 | 121 | DefaultAudioEndpoint* AudioController::GetMainAudioEndpoint() 122 | { 123 | IMMDevice* pDevice = nullptr; 124 | // Get the default audio device. 125 | check_hresult(deviceEnumerator->GetDefaultAudioEndpoint(EDataFlow::eRender, ERole::eMultimedia, &pDevice)); 126 | return new DefaultAudioEndpoint(pDevice, audioSessionID); 127 | } 128 | 129 | 130 | STDMETHODIMP AudioController::OnSessionCreated(IAudioSessionControl* NewSession) 131 | { 132 | // HACK: Audio session creation notifications are sent in double. Once we receive one, we will ignore the next. This can cause non doubled events to be ignored. 133 | static bool ignoreNotification = false; 134 | 135 | if (!ignoreNotification) 136 | { 137 | IAudioSessionControl2* control2 = nullptr; 138 | if (SUCCEEDED(NewSession->QueryInterface(__uuidof(IAudioSessionControl2), (void**)&control2))) 139 | { 140 | // TODO: Insure thread safety. 141 | try 142 | { 143 | // Windows sends OnSessionCreated event when disabling audio enhancements. The IAudioSessionControl received is not usable, making any calls to it's functions or properties fail. 144 | auto newAudioSession = new AudioSession(control2, audioSessionID); 145 | OutputDebugWString(L"New session created " + newAudioSession->Name()); 146 | newSessions.push(newAudioSession); 147 | e_sessionAdded(nullptr, nullptr); 148 | } 149 | catch (const hresult_error& ex) 150 | { 151 | OutputDebugWString(L"AudioController::OnSessionCreated failed to create audio session : " + ex.message()); 152 | } 153 | } 154 | } 155 | else 156 | { 157 | OutputDebugString(L"Ignoring OnSessionCreated event."); 158 | } 159 | 160 | ignoreNotification = !ignoreNotification; 161 | return S_OK; 162 | } 163 | 164 | STDMETHODIMP AudioController::OnDefaultDeviceChanged(__in EDataFlow flow, __in ERole /*role*/, __in_opt LPCWSTR pwstrDefaultDeviceId) noexcept 165 | { 166 | static bool notified = false; 167 | 168 | assert(pwstrDefaultDeviceId != nullptr); 169 | 170 | wstring_view defaultDeviceId{ pwstrDefaultDeviceId }; 171 | if (!notified && flow == EDataFlow::eRender && 172 | (currentPwstrDefaultDeviceId.empty() || defaultDeviceId != currentPwstrDefaultDeviceId) 173 | ) 174 | { 175 | OutputDebugHString(L"Default device changed (id: " + defaultDeviceId + L")."); 176 | currentPwstrDefaultDeviceId = defaultDeviceId; 177 | e_endpointChanged(nullptr, nullptr); 178 | } 179 | else 180 | { 181 | OutputDebugHString(L"Ignored notification : Default device changed (id: " + defaultDeviceId + L")."); 182 | } 183 | 184 | notified = !notified; 185 | return S_OK; 186 | } 187 | 188 | STDMETHODIMP AudioController::OnDeviceStateChanged(__in LPCWSTR /*pwstrDeviceId*/, __in DWORD /*dwNewState*/) noexcept 189 | { 190 | return S_OK; 191 | } 192 | } -------------------------------------------------------------------------------- /Croak/AudioController.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "AudioSession.h" 5 | #include "DefaultAudioEndpoint.h" 6 | #include "AudioInterfacesSmartPtrs.h" 7 | #include "IComEventImplementation.h" 8 | 9 | namespace Croak::Audio 10 | { 11 | class AudioController : public IComEventImplementation, private IAudioSessionNotification, private IMMNotificationClient 12 | { 13 | public: 14 | AudioController(GUID const& guid); 15 | 16 | inline winrt::event_token EndpointChanged(const winrt::Windows::Foundation::TypedEventHandler& handler) 17 | { 18 | return e_endpointChanged.add(handler); 19 | } 20 | 21 | inline void EndpointChanged(const winrt::event_token& token) 22 | { 23 | return e_endpointChanged.remove(token); 24 | } 25 | 26 | winrt::event_token SessionAdded(const winrt::Windows::Foundation::EventHandler& handler) 27 | { 28 | return e_sessionAdded.add(handler); 29 | } 30 | 31 | void SessionAdded(const ::winrt::event_token& token) 32 | { 33 | e_sessionAdded.remove(token); 34 | } 35 | 36 | // IUnknown 37 | IFACEMETHODIMP_(ULONG) AddRef(); 38 | IFACEMETHODIMP_(ULONG) Release(); 39 | IFACEMETHODIMP QueryInterface(REFIID riid, VOID** ppvInterface); 40 | 41 | bool Register(); 42 | bool Unregister(); 43 | 44 | /** 45 | * @brief Enumerates current audio sessions. 46 | * @return Audio sessions currently active 47 | */ 48 | std::vector* GetSessions(); 49 | /** 50 | * @brief Newly created sessions. Call in loop to get all the new sessions. 51 | * @return 52 | */ 53 | AudioSession* NewSession(); 54 | /** 55 | * @brief 56 | * @return 57 | */ 58 | Croak::Audio::DefaultAudioEndpoint* GetMainAudioEndpoint(); 59 | 60 | private: 61 | ::winrt::impl::atomic_ref_count refCount{ 1 }; 62 | GUID audioSessionID; 63 | IAudioSessionManager2Ptr audioSessionManager{ nullptr }; 64 | IMMDeviceEnumeratorPtr deviceEnumerator{ nullptr }; 65 | IAudioSessionEnumeratorPtr audioSessionEnumerator{ nullptr }; 66 | std::stack newSessions{}; 67 | bool isRegistered = false; 68 | std::wstring currentPwstrDefaultDeviceId{}; 69 | 70 | winrt::event> e_sessionAdded {}; 71 | winrt::event> e_endpointChanged {}; 72 | 73 | STDMETHOD(OnSessionCreated)(IAudioSessionControl* NewSession); 74 | #pragma region IMMNotificationClient 75 | STDMETHODIMP OnDeviceStateChanged(__in LPCWSTR /*pwstrDeviceId*/, __in DWORD /*dwNewState*/) noexcept; 76 | STDMETHODIMP OnDefaultDeviceChanged(__in EDataFlow flow, __in ERole /*role*/, __in_opt LPCWSTR pwstrDefaultDeviceId) noexcept; 77 | // Not implemented. 78 | STDMETHOD(OnPropertyValueChanged)(__in LPCWSTR /*pwstrDeviceId*/, __in const PROPERTYKEY /*key*/) noexcept { return S_OK; }; 79 | STDMETHOD(OnDeviceAdded)(__in LPCWSTR /*pwstrDeviceId*/) noexcept { return S_OK; }; 80 | STDMETHOD(OnDeviceRemoved)(__in LPCWSTR /*pwstrDeviceId*/) noexcept { return S_OK; }; 81 | #pragma endregion 82 | }; 83 | } 84 | 85 | -------------------------------------------------------------------------------- /Croak/AudioInterfacesSmartPtrs.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | // IMMDevicePtr 6 | _COM_SMARTPTR_TYPEDEF(IMMDevice, __uuidof(IMMDevice)); 7 | // IMMDeviceEnumeratorPtr 8 | _COM_SMARTPTR_TYPEDEF(IMMDeviceEnumerator, __uuidof(IMMDeviceEnumerator)); 9 | // IAudioSessionManager2Ptr 10 | _COM_SMARTPTR_TYPEDEF(IAudioSessionManager2, __uuidof(IAudioSessionManager2)); 11 | // IAudioSessionManager2Ptr 12 | _COM_SMARTPTR_TYPEDEF(IAudioSessionManager2, __uuidof(IAudioSessionManager2)); 13 | // IAudioSessionEnumeratorPtr 14 | _COM_SMARTPTR_TYPEDEF(IAudioSessionEnumerator, __uuidof(IAudioSessionEnumerator)); 15 | // IAudioSessionControl2Ptr 16 | _COM_SMARTPTR_TYPEDEF(IAudioSessionControl2, __uuidof(IAudioSessionControl2)); 17 | // IAudioSessionControlPtr 18 | _COM_SMARTPTR_TYPEDEF(IAudioSessionControl, __uuidof(IAudioSessionControl)); 19 | // ISimpleAudioVolumePtr 20 | _COM_SMARTPTR_TYPEDEF(ISimpleAudioVolume, __uuidof(ISimpleAudioVolume)); 21 | // IAudioSessionNotificationPtr 22 | _COM_SMARTPTR_TYPEDEF(IAudioSessionNotification, __uuidof(IAudioSessionNotification)); 23 | // IAudioEndpointVolumePtr 24 | _COM_SMARTPTR_TYPEDEF(IAudioEndpointVolume, __uuidof(IAudioEndpointVolume)); 25 | // IAudioMeterInformationPtr 26 | _COM_SMARTPTR_TYPEDEF(IAudioMeterInformation, __uuidof(IAudioMeterInformation)); -------------------------------------------------------------------------------- /Croak/AudioProfile.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "AudioProfile.h" 3 | #if __has_include("AudioProfile.g.cpp") 4 | #include "AudioProfile.g.cpp" 5 | #endif 6 | 7 | using namespace winrt::Windows::Foundation; 8 | using namespace winrt::Windows::Storage; 9 | 10 | 11 | namespace winrt::Croak::implementation 12 | { 13 | void AudioProfile::Save(const ApplicationDataContainer& container) 14 | { 15 | ApplicationDataContainer props = container.Containers().TryLookup(profileName); 16 | if (!props) 17 | { 18 | props = container.CreateContainer(profileName, ApplicationDataCreateDisposition::Always); 19 | } 20 | 21 | props.Values().Insert(L"IsDefaultProfile", IReference(isDefaultProfile)); 22 | props.Values().Insert(L"DisableAnimations", IReference(disableAnimations)); 23 | props.Values().Insert(L"KeepOnTop", IReference(keepOnTop)); 24 | props.Values().Insert(L"ShowMenu", IReference(showMenu)); 25 | props.Values().Insert(L"SystemVolume", IReference(systemVolume)); 26 | props.Values().Insert(L"Layout", IReference(layout)); 27 | 28 | ApplicationDataCompositeValue audioLevelsContainer{}; 29 | for (auto&& pair : audioLevels) 30 | { 31 | hstring name = pair.Key(); 32 | float level = pair.Value(); 33 | audioLevelsContainer.Insert(name, IReference(level)); 34 | } 35 | props.Values().Insert(L"AudioLevels", audioLevelsContainer); 36 | 37 | ApplicationDataCompositeValue audioStatesContainer{}; 38 | for (auto&& pair : audioStates) 39 | { 40 | hstring name = pair.Key(); 41 | bool muted = pair.Value(); 42 | audioStatesContainer.Insert(name, IReference(muted)); 43 | } 44 | props.Values().Insert(L"AudioStates", audioStatesContainer); 45 | 46 | ApplicationDataCompositeValue indexes{}; 47 | for (auto&& pair : sessionsIndexes) 48 | { 49 | hstring name = pair.Key(); 50 | uint32_t index = pair.Value(); 51 | indexes.Insert(name, IReference(index)); 52 | } 53 | props.Values().Insert(L"SessionsIndexes", indexes); 54 | } 55 | 56 | void AudioProfile::Restore(const ApplicationDataContainer& container) 57 | { 58 | profileName = container.Name(); 59 | isDefaultProfile = unbox_value(container.Values().Lookup(L"IsDefaultProfile")); 60 | disableAnimations = unbox_value(container.Values().Lookup(L"DisableAnimations")); 61 | keepOnTop = unbox_value(container.Values().Lookup(L"KeepOnTop")); 62 | showMenu = unbox_value(container.Values().Lookup(L"ShowMenu")); 63 | systemVolume = unbox_value(container.Values().Lookup(L"SystemVolume")); 64 | layout = unbox_value(container.Values().Lookup(L"Layout")); 65 | 66 | auto audioLevelsContainer = container.Values().Lookup(L"AudioLevels").as(); 67 | auto audioStatesContainer = container.Values().Lookup(L"AudioStates").as(); 68 | auto sessionsIndexesContainer = container.Values().Lookup(L"SessionsIndexes").as(); 69 | 70 | for (auto pair : audioLevelsContainer) 71 | { 72 | hstring name = pair.Key(); 73 | float level = pair.Value().as(); 74 | audioLevels.Insert(name, level); 75 | } 76 | 77 | for (auto pair : audioStatesContainer) 78 | { 79 | hstring name = pair.Key(); 80 | bool muted = pair.Value().as(); 81 | audioStates.Insert(name, muted); 82 | } 83 | 84 | for (auto pair : sessionsIndexesContainer) 85 | { 86 | hstring name = pair.Key(); 87 | uint32_t index = pair.Value().as(); 88 | sessionsIndexes.Insert(name, index); 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /Croak/AudioProfile.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "AudioProfile.g.h" 4 | 5 | namespace winrt::Croak::implementation 6 | { 7 | struct AudioProfile : AudioProfileT 8 | { 9 | AudioProfile() = default; 10 | 11 | inline winrt::hstring ProfileName() 12 | { 13 | return profileName; 14 | } 15 | 16 | inline void ProfileName(const winrt::hstring& value) 17 | { 18 | profileName = value; 19 | e_propertyChanged(*this, Microsoft::UI::Xaml::Data::PropertyChangedEventArgs(L"ProfileName")); 20 | } 21 | 22 | inline winrt::Windows::Foundation::Collections::IMap AudioLevels() 23 | { 24 | return audioLevels; 25 | } 26 | 27 | inline void AudioLevels(const winrt::Windows::Foundation::Collections::IMap& value) 28 | { 29 | audioLevels = value; 30 | e_propertyChanged(*this, Microsoft::UI::Xaml::Data::PropertyChangedEventArgs(L"AudioLevels")); 31 | } 32 | 33 | inline winrt::Windows::Foundation::Collections::IMap AudioStates() 34 | { 35 | return audioStates; 36 | } 37 | 38 | inline void AudioStates(const winrt::Windows::Foundation::Collections::IMap& value) 39 | { 40 | audioStates = value; 41 | e_propertyChanged(*this, Microsoft::UI::Xaml::Data::PropertyChangedEventArgs(L"AudioStates")); 42 | } 43 | 44 | inline winrt::Windows::Foundation::Collections::IMap SessionsIndexes() const 45 | { 46 | return sessionsIndexes; 47 | } 48 | 49 | inline void SessionsIndexes(const winrt::Windows::Foundation::Collections::IMap& value) 50 | { 51 | sessionsIndexes = value; 52 | e_propertyChanged(*this, Microsoft::UI::Xaml::Data::PropertyChangedEventArgs(L"SessionsIndexes")); 53 | } 54 | 55 | inline bool IsDefaultProfile() 56 | { 57 | return isDefaultProfile; 58 | } 59 | 60 | inline void IsDefaultProfile(const bool& value) 61 | { 62 | isDefaultProfile = value; 63 | e_propertyChanged(*this, Microsoft::UI::Xaml::Data::PropertyChangedEventArgs(L"IsDefaultProfile")); 64 | } 65 | 66 | inline float SystemVolume() const 67 | { 68 | return systemVolume; 69 | } 70 | 71 | inline void SystemVolume(const float& value) 72 | { 73 | systemVolume = value; 74 | e_propertyChanged(*this, Microsoft::UI::Xaml::Data::PropertyChangedEventArgs(L"SystemVolume")); 75 | } 76 | 77 | inline bool DisableAnimations() const 78 | { 79 | return disableAnimations; 80 | } 81 | 82 | inline void DisableAnimations(const bool& value) 83 | { 84 | disableAnimations = value; 85 | e_propertyChanged(*this, Microsoft::UI::Xaml::Data::PropertyChangedEventArgs(L"DisableAnimations")); 86 | } 87 | 88 | inline bool KeepOnTop() const 89 | { 90 | return keepOnTop; 91 | } 92 | 93 | inline void KeepOnTop(const bool& value) 94 | { 95 | keepOnTop = value; 96 | e_propertyChanged(*this, Microsoft::UI::Xaml::Data::PropertyChangedEventArgs(L"KeepOnTop")); 97 | } 98 | 99 | inline bool ShowMenu() const 100 | { 101 | return showMenu; 102 | } 103 | 104 | inline void ShowMenu(const bool& value) 105 | { 106 | showMenu = value; 107 | e_propertyChanged(*this, Microsoft::UI::Xaml::Data::PropertyChangedEventArgs(L"ShowMenu")); 108 | } 109 | 110 | inline uint32_t Layout() const 111 | { 112 | return layout; 113 | } 114 | 115 | inline void Layout(const uint32_t& value) 116 | { 117 | layout = value; 118 | e_propertyChanged(*this, Microsoft::UI::Xaml::Data::PropertyChangedEventArgs(L"Layout")); 119 | } 120 | 121 | inline bool RestoreWindowState() const 122 | { 123 | return false; 124 | } 125 | 126 | void RestoreWindowState(const bool& value) 127 | { 128 | 129 | } 130 | 131 | inline winrt::Windows::Graphics::RectInt32 WindowDisplayRect() const 132 | { 133 | return {}; 134 | } 135 | 136 | inline void WindowDisplayRect(const winrt::Windows::Graphics::RectInt32& value) 137 | { 138 | } 139 | 140 | 141 | inline winrt::event_token PropertyChanged(Microsoft::UI::Xaml::Data::PropertyChangedEventHandler const& handler) 142 | { 143 | return e_propertyChanged.add(handler); 144 | } 145 | 146 | inline void PropertyChanged(winrt::event_token const& token) 147 | { 148 | e_propertyChanged.remove(token); 149 | } 150 | 151 | 152 | void Save(const winrt::Windows::Storage::ApplicationDataContainer& container); 153 | void Restore(const winrt::Windows::Storage::ApplicationDataContainer& container); 154 | 155 | private: 156 | winrt::hstring profileName{}; 157 | winrt::Windows::Foundation::Collections::IMap audioLevels{ winrt::single_threaded_map() }; 158 | winrt::Windows::Foundation::Collections::IMap audioStates{ winrt::single_threaded_map() }; 159 | winrt::Windows::Foundation::Collections::IMap sessionsIndexes{ winrt::single_threaded_map() }; 160 | bool isDefaultProfile = false; 161 | float systemVolume = 0.0; 162 | bool disableAnimations = false; 163 | bool keepOnTop = false; 164 | bool showMenu = false; 165 | uint32_t layout = 0u; 166 | 167 | winrt::event e_propertyChanged; 168 | }; 169 | } 170 | 171 | namespace winrt::Croak::factory_implementation 172 | { 173 | struct AudioProfile : AudioProfileT 174 | { 175 | }; 176 | } 177 | -------------------------------------------------------------------------------- /Croak/AudioProfile.idl: -------------------------------------------------------------------------------- 1 | namespace Croak 2 | { 3 | [bindable] 4 | [default_interface] 5 | runtimeclass AudioProfile 6 | { 7 | AudioProfile(); 8 | 9 | String ProfileName{ get; set; }; 10 | Windows.Foundation.Collections.IMap AudioLevels{ get; set; }; 11 | Windows.Foundation.Collections.IMap AudioStates{ get; set; }; 12 | Windows.Foundation.Collections.IMap SessionsIndexes{ get; set; }; 13 | Boolean IsDefaultProfile{ get; set; }; 14 | Single SystemVolume{ get; set; }; 15 | Boolean DisableAnimations{ get; set; }; 16 | Boolean KeepOnTop{ get; set; }; 17 | Boolean ShowMenu{ get; set; }; 18 | UInt32 Layout{ get; set; }; 19 | Boolean RestoreWindowState{ get; set; }; 20 | Windows.Graphics.RectInt32 WindowDisplayRect{ get; set; }; 21 | 22 | void Restore(Windows.Storage.ApplicationDataContainer container); 23 | void Save(Windows.Storage.ApplicationDataContainer container); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Croak/AudioProfileEditPage.idl: -------------------------------------------------------------------------------- 1 | import "AudioSessionView.idl"; 2 | 3 | namespace Croak 4 | { 5 | [default_interface] 6 | runtimeclass AudioProfileEditPage : Microsoft.UI.Xaml.Controls.Page, Microsoft.UI.Xaml.Data.INotifyPropertyChanged 7 | { 8 | AudioProfileEditPage(); 9 | 10 | Windows.Foundation.Collections.IObservableVector AudioSessions{ get; }; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Croak/AudioProfileEditPage.xaml.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "AudioProfileEditPage.g.h" 4 | 5 | namespace winrt::Croak::implementation 6 | { 7 | struct AudioProfileEditPage : AudioProfileEditPageT 8 | { 9 | public: 10 | AudioProfileEditPage(); 11 | 12 | winrt::Windows::Foundation::Collections::IObservableVector AudioSessions() const 13 | { 14 | return audioSessions; 15 | }; 16 | 17 | inline winrt::event_token PropertyChanged(Microsoft::UI::Xaml::Data::PropertyChangedEventHandler const& handler) 18 | { 19 | return e_propertyChanged.add(handler); 20 | }; 21 | inline void PropertyChanged(winrt::event_token const& token) 22 | { 23 | e_propertyChanged.remove(token); 24 | }; 25 | 26 | void OnNavigatedTo(winrt::Microsoft::UI::Xaml::Navigation::NavigationEventArgs const& args); 27 | winrt::Windows::Foundation::IAsyncAction OnNavigatingFrom(winrt::Microsoft::UI::Xaml::Navigation::NavigatingCancelEventArgs const& args); 28 | void Page_Loading(winrt::Microsoft::UI::Xaml::FrameworkElement const& sender, winrt::Windows::Foundation::IInspectable const& args); 29 | void NextButton_Click(winrt::Windows::Foundation::IInspectable const& sender, winrt::Microsoft::UI::Xaml::RoutedEventArgs const& e); 30 | void CancelButton_Click(winrt::Windows::Foundation::IInspectable const& sender, winrt::Microsoft::UI::Xaml::RoutedEventArgs const& e); 31 | void ProfileNameEditTextBox_TextChanged(winrt::Windows::Foundation::IInspectable const& sender, winrt::Microsoft::UI::Xaml::Controls::TextChangedEventArgs const& e); 32 | winrt::Windows::Foundation::IAsyncAction CreateAudioSessionButton_Click(winrt::Windows::Foundation::IInspectable const& sender, winrt::Microsoft::UI::Xaml::RoutedEventArgs const& e); 33 | winrt::Windows::Foundation::IAsyncAction AddAudioSessionButton_Click(winrt::Windows::Foundation::IInspectable const& sender, winrt::Microsoft::UI::Xaml::RoutedEventArgs const& e); 34 | void LockSessionAppBarButton_Click(winrt::Windows::Foundation::IInspectable const& sender, winrt::Microsoft::UI::Xaml::RoutedEventArgs const& e); 35 | void RemoveSessionAppBarButton_Click(winrt::Windows::Foundation::IInspectable const& sender, winrt::Microsoft::UI::Xaml::RoutedEventArgs const& e); 36 | void ProfileCreationTextBox_TextChanged(winrt::Windows::Foundation::IInspectable const& sender, winrt::Microsoft::UI::Xaml::Controls::TextChangedEventArgs const& e); 37 | 38 | private: 39 | winrt::Croak::AudioProfile audioProfile{ nullptr }; 40 | winrt::Microsoft::UI::Dispatching::DispatcherQueueTimer timer{ nullptr }; 41 | winrt::Windows::Foundation::Collections::IObservableVector audioSessions = winrt::single_threaded_observable_vector< winrt::Croak::AudioSessionView>(); 42 | bool navigationOutAllowed = false; 43 | std::vector existingProfileNames{}; 44 | 45 | winrt::event e_propertyChanged; 46 | 47 | void SaveProfile(); 48 | winrt::Croak::AudioSessionView CreateAudioSessionView(winrt::hstring header, float volume, bool muted); 49 | }; 50 | } 51 | 52 | namespace winrt::Croak::factory_implementation 53 | { 54 | struct AudioProfileEditPage : AudioProfileEditPageT 55 | { 56 | }; 57 | } 58 | -------------------------------------------------------------------------------- /Croak/AudioProfilesPage.idl: -------------------------------------------------------------------------------- 1 | import "AudioProfile.idl"; 2 | 3 | namespace Croak 4 | { 5 | [default_interface] 6 | runtimeclass AudioProfilesPage : Microsoft.UI.Xaml.Controls.Page 7 | { 8 | AudioProfilesPage(); 9 | 10 | IObservableVector AudioProfiles{ get; }; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Croak/AudioProfilesPage.xaml.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "AudioProfilesPage.xaml.h" 3 | #if __has_include("AudioProfilesPage.g.cpp") 4 | #include "AudioProfilesPage.g.cpp" 5 | #endif 6 | 7 | using namespace winrt; 8 | using namespace winrt::Microsoft::UI::Xaml; 9 | using namespace winrt::Microsoft::UI::Xaml::Controls; 10 | using namespace winrt::Windows::Foundation; 11 | using namespace winrt::Windows::Foundation::Collections; 12 | using namespace winrt::Windows::Storage; 13 | 14 | 15 | namespace winrt::Croak::implementation 16 | { 17 | AudioProfilesPage::AudioProfilesPage() 18 | { 19 | InitializeComponent(); 20 | 21 | ProfilesListView().ItemsSource(audioProfiles); 22 | } 23 | 24 | 25 | void AudioProfilesPage::Page_Loading(FrameworkElement const&, IInspectable const&) 26 | { 27 | AllowChangesToLoadedProfileToggleSwitch().IsOn( 28 | unbox_value_or(ApplicationData::Current().LocalSettings().Values().TryLookup(L"AllowChangesToLoadedProfile"), false) 29 | ); 30 | } 31 | 32 | void AudioProfilesPage::OnNavigatedTo(winrt::Microsoft::UI::Xaml::Navigation::NavigationEventArgs const& args) 33 | { 34 | int32_t size = SecondWindow::Current().Breadcrumbs().Size(); 35 | int32_t index = size - 1; 36 | if (args.NavigationMode() != ::Navigation::NavigationMode::Back && 37 | ( 38 | index < size || 39 | SecondWindow::Current().Breadcrumbs().GetAt(index).ItemTypeName().Name != xaml_typename().Name 40 | ) 41 | ) 42 | { 43 | winrt::Windows::ApplicationModel::Resources::ResourceLoader loader{}; 44 | SecondWindow::Current().Breadcrumbs().Append( 45 | NavigationBreadcrumbBarItem{ loader.GetString(L"AudioProfilesPageDisplayName"), xaml_typename() } 46 | ); 47 | } 48 | } 49 | 50 | void AudioProfilesPage::Page_Loaded(IInspectable const&, RoutedEventArgs const&) 51 | { 52 | // Load profiles into the page 53 | ApplicationDataContainer audioProfilesContainer = ApplicationData::Current().LocalSettings().Containers().TryLookup(L"AudioProfiles"); 54 | if (!audioProfilesContainer) 55 | { 56 | audioProfilesContainer = ApplicationData::Current().LocalSettings().CreateContainer(L"AudioProfiles", ApplicationDataCreateDisposition::Always); 57 | } 58 | else 59 | { 60 | for (auto&& profile : audioProfilesContainer.Containers()) 61 | { 62 | try 63 | { 64 | hstring key = profile.Key(); 65 | AudioProfile audioProfile{}; 66 | audioProfile.Restore(profile.Value()); 67 | audioProfiles.Append(audioProfile); 68 | } 69 | catch (const hresult_error&) 70 | { 71 | } 72 | } 73 | } 74 | } 75 | 76 | void AudioProfilesPage::AddProfileButton_Click(IInspectable const&, RoutedEventArgs const&) 77 | { 78 | // I18N: Audio profile. 79 | hstring profileName = L"Audio profile"; 80 | uint32_t count = 1u; 81 | for (uint32_t j = 0; j < audioProfiles.Size(); j++) 82 | { 83 | hstring test = audioProfiles.GetAt(j).ProfileName(); 84 | if (test == profileName) 85 | { 86 | profileName = L"Audio profile (" + to_hstring(count++) + L")"; 87 | } 88 | } 89 | 90 | Frame().Navigate(xaml_typename(), box_value(profileName), ::Media::Animation::DrillInNavigationTransitionInfo()); 91 | } 92 | 93 | void AudioProfilesPage::DeleteProfileButton_Click(IInspectable const& sender, RoutedEventArgs const&) 94 | { 95 | hstring tag = sender.as