├── .clang-format ├── .gitignore ├── CHANGELOG.md ├── CMakeLists.txt ├── CMakePresets.json ├── LICENSE ├── README.md ├── cmake ├── Plugin.h.in ├── addpluginsources.cmake ├── build-release.ps1 ├── pluginconfig.cmake └── version.rc.in ├── dist └── MediaKeysFix.ini ├── src ├── Config.cpp ├── Config.h ├── Main.cpp ├── Main.h ├── PCH.h └── Plugin.cpp ├── vcpkg-configuration.json └── vcpkg.json /.clang-format: -------------------------------------------------------------------------------- 1 | AccessModifierOffset: -4 2 | BasedOnStyle: Google 3 | ColumnLimit: 130 4 | IndentWidth: 4 5 | NamespaceIndentation: All 6 | TabWidth: 4 7 | UseTab: Never 8 | AllowShortBlocksOnASingleLine: Never 9 | AllowShortFunctionsOnASingleLine: None 10 | AllowShortEnumsOnASingleLine: False 11 | AllowShortIfStatementsOnASingleLine: Never 12 | AllowShortLambdasOnASingleLine: None -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | vcpkg_installed/ 2 | 3 | 4 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider 5 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 6 | 7 | # User-specific stuff 8 | .idea/**/workspace.xml 9 | .idea/**/tasks.xml 10 | .idea/**/usage.statistics.xml 11 | .idea/**/dictionaries 12 | .idea/**/shelf 13 | 14 | # AWS User-specific 15 | .idea/**/aws.xml 16 | 17 | # Generated files 18 | .idea/**/contentModel.xml 19 | 20 | # Sensitive or high-churn files 21 | .idea/**/dataSources/ 22 | .idea/**/dataSources.ids 23 | .idea/**/dataSources.local.xml 24 | .idea/**/sqlDataSources.xml 25 | .idea/**/dynamic.xml 26 | .idea/**/uiDesigner.xml 27 | .idea/**/dbnavigator.xml 28 | 29 | # Gradle 30 | .idea/**/gradle.xml 31 | .idea/**/libraries 32 | 33 | # Gradle and Maven with auto-import 34 | # When using Gradle or Maven with auto-import, you should exclude module files, 35 | # since they will be recreated, and may cause churn. Uncomment if using 36 | # auto-import. 37 | # .idea/artifacts 38 | # .idea/compiler.xml 39 | # .idea/jarRepositories.xml 40 | # .idea/modules.xml 41 | # .idea/*.iml 42 | # .idea/modules 43 | # *.iml 44 | # *.ipr 45 | 46 | # CMake 47 | cmake-build-*/ 48 | 49 | # Mongo Explorer plugin 50 | .idea/**/mongoSettings.xml 51 | 52 | # File-based project format 53 | *.iws 54 | 55 | # IntelliJ 56 | out/ 57 | 58 | # mpeltonen/sbt-idea plugin 59 | .idea_modules/ 60 | 61 | # JIRA plugin 62 | atlassian-ide-plugin.xml 63 | 64 | # Cursive Clojure plugin 65 | .idea/replstate.xml 66 | 67 | # Crashlytics plugin (for Android Studio and IntelliJ) 68 | com_crashlytics_export_strings.xml 69 | crashlytics.properties 70 | crashlytics-build.properties 71 | fabric.properties 72 | 73 | # Editor-based Rest Client 74 | .idea/httpRequests 75 | 76 | # Android studio 3.1+ serialized cache file 77 | .idea/caches/build_file_checksums.ser 78 | 79 | ### CLion Patch ### 80 | # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 81 | 82 | # *.iml 83 | # modules.xml 84 | # .idea/misc.xml 85 | # *.ipr 86 | 87 | # Sonarlint plugin 88 | # https://plugins.jetbrains.com/plugin/7973-sonarlint 89 | .idea/**/sonarlint/ 90 | 91 | # SonarQube Plugin 92 | # https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin 93 | .idea/**/sonarIssues.xml 94 | 95 | # Markdown Navigator plugin 96 | # https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced 97 | .idea/**/markdown-navigator.xml 98 | .idea/**/markdown-navigator-enh.xml 99 | .idea/**/markdown-navigator/ 100 | 101 | # Cache file creation bug 102 | # See https://youtrack.jetbrains.com/issue/JBR-2257 103 | .idea/$CACHE_FILE$ 104 | 105 | # CodeStream plugin 106 | # https://plugins.jetbrains.com/plugin/12206-codestream 107 | .idea/codestream.xml 108 | 109 | ### CMake ### 110 | CMakeLists.txt.user 111 | CMakeCache.txt 112 | CMakeFiles 113 | CMakeScripts 114 | Testing 115 | Makefile 116 | cmake_install.cmake 117 | install_manifest.txt 118 | compile_commands.json 119 | CTestTestfile.cmake 120 | _deps 121 | 122 | ### CMake Patch ### 123 | # External projects 124 | *-prefix/ 125 | 126 | ### VisualStudioCode ### 127 | .vscode/* 128 | !.vscode/settings.json 129 | !.vscode/tasks.json 130 | !.vscode/launch.json 131 | !.vscode/extensions.json 132 | 133 | # Local History for Visual Studio Code 134 | .history/ 135 | 136 | ### VisualStudioCode Patch ### 137 | # Ignore all local history of files 138 | .history 139 | .ionide 140 | 141 | # Support for Project snippet scope 142 | !.vscode/*.code-snippets 143 | 144 | ### VisualStudio ### 145 | ## Ignore Visual Studio temporary files, build results, and 146 | ## files generated by popular Visual Studio add-ons. 147 | ## 148 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 149 | 150 | # User-specific files 151 | *.rsuser 152 | *.suo 153 | *.user 154 | *.userosscache 155 | *.sln.docstates 156 | 157 | # User-specific files (MonoDevelop/Xamarin Studio) 158 | *.userprefs 159 | 160 | # Mono auto generated files 161 | mono_crash.* 162 | 163 | # Build results 164 | [Dd]ebug/ 165 | [Dd]ebugPublic/ 166 | [Rr]elease/ 167 | [Rr]eleases/ 168 | x64/ 169 | x86/ 170 | [Ww][Ii][Nn]32/ 171 | [Aa][Rr][Mm]/ 172 | [Aa][Rr][Mm]64/ 173 | bld/ 174 | [Bb]in/ 175 | [Oo]bj/ 176 | [Ll]og/ 177 | [Ll]ogs/ 178 | 179 | # Visual Studio 2015/2017 cache/options directory 180 | .vs/ 181 | # Uncomment if you have tasks that create the project's static files in wwwroot 182 | #wwwroot/ 183 | 184 | # Visual Studio 2017 auto generated files 185 | Generated\ Files/ 186 | 187 | # MSTest test Results 188 | [Tt]est[Rr]esult*/ 189 | [Bb]uild[Ll]og.* 190 | 191 | # NUnit 192 | *.VisualState.xml 193 | TestResult.xml 194 | nunit-*.xml 195 | 196 | # Build Results of an ATL Project 197 | [Dd]ebugPS/ 198 | [Rr]eleasePS/ 199 | dlldata.c 200 | 201 | # Benchmark Results 202 | BenchmarkDotNet.Artifacts/ 203 | 204 | # .NET Core 205 | project.lock.json 206 | project.fragment.lock.json 207 | artifacts/ 208 | 209 | # ASP.NET Scaffolding 210 | ScaffoldingReadMe.txt 211 | 212 | # StyleCop 213 | StyleCopReport.xml 214 | 215 | # Files built by Visual Studio 216 | *_i.c 217 | *_p.c 218 | *_h.h 219 | *.ilk 220 | *.meta 221 | *.obj 222 | *.iobj 223 | *.pch 224 | *.pdb 225 | *.ipdb 226 | *.pgc 227 | *.pgd 228 | *.rsp 229 | *.sbr 230 | *.tlb 231 | *.tli 232 | *.tlh 233 | *.tmp 234 | *.tmp_proj 235 | *_wpftmp.csproj 236 | *.log 237 | *.tlog 238 | *.vspscc 239 | *.vssscc 240 | .builds 241 | *.pidb 242 | *.svclog 243 | *.scc 244 | 245 | # Chutzpah Test files 246 | _Chutzpah* 247 | 248 | # Visual C++ cache files 249 | ipch/ 250 | *.aps 251 | *.ncb 252 | *.opendb 253 | *.opensdf 254 | *.sdf 255 | *.cachefile 256 | *.VC.db 257 | *.VC.VC.opendb 258 | 259 | # Visual Studio profiler 260 | *.psess 261 | *.vsp 262 | *.vspx 263 | *.sap 264 | 265 | # Visual Studio Trace Files 266 | *.e2e 267 | 268 | # TFS 2012 Local Workspace 269 | $tf/ 270 | 271 | # Guidance Automation Toolkit 272 | *.gpState 273 | 274 | # ReSharper is a .NET coding add-in 275 | _ReSharper*/ 276 | *.[Rr]e[Ss]harper 277 | *.DotSettings.user 278 | 279 | # TeamCity is a build add-in 280 | _TeamCity* 281 | 282 | # DotCover is a Code Coverage Tool 283 | *.dotCover 284 | 285 | # AxoCover is a Code Coverage Tool 286 | .axoCover/* 287 | !.axoCover/settings.json 288 | 289 | # Coverlet is a free, cross platform Code Coverage Tool 290 | coverage*.json 291 | coverage*.xml 292 | coverage*.info 293 | 294 | # Visual Studio code coverage results 295 | *.coverage 296 | *.coveragexml 297 | 298 | # NCrunch 299 | _NCrunch_* 300 | .*crunch*.local.xml 301 | nCrunchTemp_* 302 | 303 | # MightyMoose 304 | *.mm.* 305 | AutoTest.Net/ 306 | 307 | # Web workbench (sass) 308 | .sass-cache/ 309 | 310 | # Installshield output folder 311 | [Ee]xpress/ 312 | 313 | # DocProject is a documentation generator add-in 314 | DocProject/buildhelp/ 315 | DocProject/Help/*.HxT 316 | DocProject/Help/*.HxC 317 | DocProject/Help/*.hhc 318 | DocProject/Help/*.hhk 319 | DocProject/Help/*.hhp 320 | DocProject/Help/Html2 321 | DocProject/Help/html 322 | 323 | # Click-Once directory 324 | publish/ 325 | 326 | # Publish Web Output 327 | *.[Pp]ublish.xml 328 | *.azurePubxml 329 | # Note: Comment the next line if you want to checkin your web deploy settings, 330 | # but database connection strings (with potential passwords) will be unencrypted 331 | *.pubxml 332 | *.publishproj 333 | 334 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 335 | # checkin your Azure Web App publish settings, but sensitive information contained 336 | # in these scripts will be unencrypted 337 | PublishScripts/ 338 | 339 | # NuGet Packages 340 | *.nupkg 341 | # NuGet Symbol Packages 342 | *.snupkg 343 | # The packages folder can be ignored because of Package Restore 344 | **/[Pp]ackages/* 345 | # except build/, which is used as an MSBuild target. 346 | !**/[Pp]ackages/build/ 347 | # Uncomment if necessary however generally it will be regenerated when needed 348 | #!**/[Pp]ackages/repositories.config 349 | # NuGet v3's project.json files produces more ignorable files 350 | *.nuget.props 351 | *.nuget.targets 352 | 353 | # Nuget personal access tokens and Credentials 354 | # nuget.config 355 | 356 | # Microsoft Azure Build Output 357 | csx/ 358 | *.build.csdef 359 | 360 | # Microsoft Azure Emulator 361 | ecf/ 362 | rcf/ 363 | 364 | # Windows Store app package directories and files 365 | AppPackages/ 366 | BundleArtifacts/ 367 | Package.StoreAssociation.xml 368 | _pkginfo.txt 369 | *.appx 370 | *.appxbundle 371 | *.appxupload 372 | 373 | # Visual Studio cache files 374 | # files ending in .cache can be ignored 375 | *.[Cc]ache 376 | # but keep track of directories ending in .cache 377 | !?*.[Cc]ache/ 378 | 379 | # Others 380 | ClientBin/ 381 | ~$* 382 | *~ 383 | *.dbmdl 384 | *.dbproj.schemaview 385 | *.jfm 386 | *.pfx 387 | *.publishsettings 388 | orleans.codegen.cs 389 | 390 | # Including strong name files can present a security risk 391 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 392 | #*.snk 393 | 394 | # Since there are multiple workflows, uncomment next line to ignore bower_components 395 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 396 | #bower_components/ 397 | 398 | # RIA/Silverlight projects 399 | Generated_Code/ 400 | 401 | # Backup & report files from converting an old project file 402 | # to a newer Visual Studio version. Backup files are not needed, 403 | # because we have git ;-) 404 | _UpgradeReport_Files/ 405 | Backup*/ 406 | UpgradeLog*.XML 407 | UpgradeLog*.htm 408 | ServiceFabricBackup/ 409 | *.rptproj.bak 410 | 411 | # SQL Server files 412 | *.mdf 413 | *.ldf 414 | *.ndf 415 | 416 | # Business Intelligence projects 417 | *.rdl.data 418 | *.bim.layout 419 | *.bim_*.settings 420 | *.rptproj.rsuser 421 | *- [Bb]ackup.rdl 422 | *- [Bb]ackup ([0-9]).rdl 423 | *- [Bb]ackup ([0-9][0-9]).rdl 424 | 425 | # Microsoft Fakes 426 | FakesAssemblies/ 427 | 428 | # GhostDoc plugin setting file 429 | *.GhostDoc.xml 430 | 431 | # Node.js Tools for Visual Studio 432 | .ntvs_analysis.dat 433 | node_modules/ 434 | 435 | # Visual Studio 6 build log 436 | *.plg 437 | 438 | # Visual Studio 6 workspace options file 439 | *.opt 440 | 441 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 442 | *.vbw 443 | 444 | # Visual Studio LightSwitch build output 445 | **/*.HTMLClient/GeneratedArtifacts 446 | **/*.DesktopClient/GeneratedArtifacts 447 | **/*.DesktopClient/ModelManifest.xml 448 | **/*.Server/GeneratedArtifacts 449 | **/*.Server/ModelManifest.xml 450 | _Pvt_Extensions 451 | 452 | # Paket dependency manager 453 | .paket/paket.exe 454 | paket-files/ 455 | 456 | # FAKE - F# Make 457 | .fake/ 458 | 459 | # CodeRush personal settings 460 | .cr/personal 461 | 462 | # Python Tools for Visual Studio (PTVS) 463 | __pycache__/ 464 | *.pyc 465 | 466 | # Cake - Uncomment if you are using it 467 | # tools/** 468 | # !tools/packages.config 469 | 470 | # Tabs Studio 471 | *.tss 472 | 473 | # Telerik's JustMock configuration file 474 | *.jmconfig 475 | 476 | # BizTalk build output 477 | *.btp.cs 478 | *.btm.cs 479 | *.odx.cs 480 | *.xsd.cs 481 | 482 | # OpenCover UI analysis results 483 | OpenCover/ 484 | 485 | # Azure Stream Analytics local run output 486 | ASALocalRun/ 487 | 488 | # MSBuild Binary and Structured Log 489 | *.binlog 490 | 491 | # NVidia Nsight GPU debugger configuration file 492 | *.nvuser 493 | 494 | # MFractors (Xamarin productivity tool) working folder 495 | .mfractor/ 496 | 497 | # Local History for Visual Studio 498 | .localhistory/ 499 | 500 | # BeatPulse healthcheck temp database 501 | healthchecksdb 502 | 503 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 504 | MigrationBackup/ 505 | 506 | # Ionide (cross platform F# VS Code tools) working folder 507 | .ionide/ 508 | 509 | # Fody - auto-generated XML schema 510 | FodyWeavers.xsd 511 | 512 | # VS Code files for those working on multiple tools 513 | 514 | # Local History for Visual Studio Code 515 | 516 | # Windows Installer files from build outputs 517 | *.cab 518 | *.msi 519 | *.msix 520 | *.msm 521 | *.msp 522 | 523 | # JetBrains Rider 524 | .idea/ 525 | *.sln.iml 526 | 527 | ### VisualStudio Patch ### 528 | # Additional files built by Visual Studio 529 | build/ 530 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | ## [1.0.1] - 2024-05-21 3 | ### Changed 4 | - Fixed wrong log directory on Skyrim version 1.6.1130 and above 5 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.25) 2 | 3 | project( 4 | MediaKeysFix 5 | VERSION 1.0.1 6 | LANGUAGES CXX) 7 | set(PROJECT_LICENSE "LGPLv3") 8 | set(PROJECT_COPYRIGHT "Copyright (c) 2023 Emerson Pinter") 9 | set(PROJECT_FRIENDLY_NAME ${PROJECT_NAME}) 10 | set(PROJECT_LONG_NAME "Media Keys Fix") 11 | set(PROJECT_DESCRIPTION ${PROJECT_LONG_NAME}) 12 | 13 | list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") 14 | include(GNUInstallDirs) 15 | include(addpluginsources) 16 | include(pluginconfig) 17 | 18 | ######## dependencies 19 | find_package(CommonLibSSE REQUIRED) 20 | add_commonlibsse_plugin(${PROJECT_NAME} SOURCES ${HEADER_FILES} ${SOURCE_FILES} 21 | NAME ${PROJECT_NAME} 22 | AUTHOR "Emerson Pinter" 23 | VERSION ${PROJECT_VERSION} 24 | ) 25 | target_include_directories(${PROJECT_NAME} PRIVATE ${SIMPLEINI_INCLUDE_DIRS}) 26 | 27 | ######## target 28 | add_library("${PROJECT_NAME}::${PROJECT_NAME}" ALIAS "${PROJECT_NAME}") 29 | 30 | target_include_directories(${PROJECT_NAME} 31 | PRIVATE 32 | $ 33 | $ 34 | $) 35 | 36 | target_include_directories(${PROJECT_NAME} 37 | PUBLIC 38 | $) 39 | 40 | if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/PCH.h") 41 | target_precompile_headers(${PROJECT_NAME} 42 | PRIVATE 43 | "${CMAKE_CURRENT_SOURCE_DIR}/src/PCH.h") 44 | endif() 45 | 46 | ######## install and distribution 47 | install(TARGETS ${PROJECT_NAME} 48 | RUNTIME DESTINATION "SKSE/Plugins") 49 | 50 | install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/dist/${PROJECT_NAME}.ini" 51 | DESTINATION "SKSE/Plugins") 52 | 53 | set(CPACK_GENERATOR 7Z) 54 | set(CPACK_PACKAGE_NAME ${PROJECT_LONG_NAME}) 55 | set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CMAKE_PROJECT_VERSION}") 56 | set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY 0) 57 | include(CPack) 58 | -------------------------------------------------------------------------------- /CMakePresets.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 5, 3 | "cmakeMinimumRequired": { 4 | "major": 3, 5 | "minor": 21, 6 | "patch": 0 7 | }, 8 | "buildPresets": [ 9 | { 10 | "name": "ALL-release", 11 | "displayName": "Release ALL", 12 | "configurePreset": "ALL", 13 | "configuration": "Release" 14 | }, 15 | { 16 | "name": "ALL-debug", 17 | "displayName": "Debug ALL", 18 | "configurePreset": "ALL", 19 | "configuration": "Debug" 20 | }, 21 | { 22 | "name": "FLATRIM-release", 23 | "displayName": "Release SE+AE", 24 | "configurePreset": "FLATRIM", 25 | "configuration": "Release" 26 | }, 27 | { 28 | "name": "FLATRIM-debug", 29 | "displayName": "Debug SE+AE", 30 | "configurePreset": "FLATRIM", 31 | "configuration": "Debug" 32 | }, 33 | { 34 | "name": "AE-release", 35 | "displayName": "Release AE-only", 36 | "configurePreset": "AE", 37 | "configuration": "Release" 38 | }, 39 | { 40 | "name": "AE-debug", 41 | "displayName": "Debug AE-only", 42 | "configurePreset": "AE", 43 | "configuration": "Debug" 44 | }, 45 | { 46 | "name": "SE-release", 47 | "displayName": "Release SE-only", 48 | "configurePreset": "SE", 49 | "configuration": "Release" 50 | }, 51 | { 52 | "name": "SE-debug", 53 | "displayName": "Debug SE-only", 54 | "configurePreset": "SE", 55 | "configuration": "Debug" 56 | } 57 | ], 58 | "configurePresets": [ 59 | { 60 | "name": "common", 61 | "installDir": "${sourceDir}/build/install", 62 | "hidden": true, 63 | "cacheVariables": { 64 | "SKSE_SUPPORT_XBYAK": "ON" 65 | }, 66 | "binaryDir": "${sourceDir}/build" 67 | }, 68 | { 69 | "name": "vcpkg", 70 | "hidden": true, 71 | "cacheVariables": { 72 | "CMAKE_BUILD_TYPE": "Release", 73 | "CMAKE_TOOLCHAIN_FILE": { 74 | "type": "STRING", 75 | "value": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" 76 | }, 77 | "VCPKG_TARGET_TRIPLET": "x64-windows-static-md" 78 | } 79 | }, 80 | { 81 | "name": "win64", 82 | "hidden": true, 83 | "architecture": "x64", 84 | "cacheVariables": { 85 | "CMAKE_BUILD_TYPE": "Release", 86 | "CMAKE_MSVC_RUNTIME_LIBRARY": "MultiThreaded$<$:Debug>DLL" 87 | } 88 | }, 89 | { 90 | "name": "msvc", 91 | "hidden": true, 92 | "cacheVariables": { 93 | "CMAKE_CXX_FLAGS": "/EHsc /MP /W4 /WX $penv{CXXFLAGS}" 94 | }, 95 | "generator": "Visual Studio 17 2022", 96 | "vendor": { 97 | "microsoft.com/VisualStudioSettings/CMake/1.0": { 98 | "intelliSenseMode": "windows-msvc-x64", 99 | "enableMicrosoftCodeAnalysis": true, 100 | "enableClangTidyCodeAnalysis": true 101 | } 102 | } 103 | }, 104 | { 105 | "name": "ALL", 106 | "hidden": false, 107 | "cacheVariables": { 108 | "BUILD_SKYRIM": true, 109 | "ENABLE_SKYRIM_AE": "ON", 110 | "ENABLE_SKYRIM_SE": "ON", 111 | "ENABLE_SKYRIM_VR": "ON" 112 | }, 113 | "inherits": [ 114 | "common", 115 | "vcpkg", 116 | "win64", 117 | "msvc" 118 | ] 119 | }, 120 | { 121 | "name": "FLATRIM", 122 | "hidden": true, 123 | "cacheVariables": { 124 | "BUILD_SKYRIM": true, 125 | "ENABLE_SKYRIM_AE": "ON", 126 | "ENABLE_SKYRIM_SE": "ON", 127 | "ENABLE_SKYRIM_VR": "OFF" 128 | }, 129 | "inherits": [ 130 | "common", 131 | "vcpkg", 132 | "win64", 133 | "msvc" 134 | ] 135 | }, 136 | { 137 | "name": "AE", 138 | "hidden": true, 139 | "cacheVariables": { 140 | "BUILD_SKYRIM": true, 141 | "ENABLE_SKYRIM_AE": "ON", 142 | "ENABLE_SKYRIM_SE": "OFF", 143 | "ENABLE_SKYRIM_VR": "OFF" 144 | }, 145 | "inherits": [ 146 | "common", 147 | "vcpkg", 148 | "win64", 149 | "msvc" 150 | ] 151 | }, 152 | { 153 | "name": "SE", 154 | "hidden": true, 155 | "cacheVariables": { 156 | "BUILD_SKYRIM": true, 157 | "ENABLE_SKYRIM_AE": "OFF", 158 | "ENABLE_SKYRIM_SE": "ON", 159 | "ENABLE_SKYRIM_VR": "OFF" 160 | }, 161 | "inherits": [ 162 | "common", 163 | "vcpkg", 164 | "win64", 165 | "msvc" 166 | ] 167 | }, 168 | { 169 | "name": "VR", 170 | "hidden": true, 171 | "cacheVariables": { 172 | "BUILD_SKYRIM": true, 173 | "ENABLE_SKYRIM_AE": "OFF", 174 | "ENABLE_SKYRIM_SE": "OFF", 175 | "ENABLE_SKYRIM_VR": "ON" 176 | }, 177 | "inherits": [ 178 | "common", 179 | "vcpkg", 180 | "win64", 181 | "msvc" 182 | ] 183 | }, 184 | { 185 | "name": "PRE_AE", 186 | "hidden": true, 187 | "cacheVariables": { 188 | "BUILD_SKYRIM": true, 189 | "ENABLE_SKYRIM_AE": "OFF", 190 | "ENABLE_SKYRIM_SE": "ON", 191 | "ENABLE_SKYRIM_VR": "ON" 192 | }, 193 | "inherits": [ 194 | "common", 195 | "vcpkg", 196 | "win64", 197 | "msvc" 198 | ] 199 | } 200 | ] 201 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | 9 | This version of the GNU Lesser General Public License incorporates 10 | the terms and conditions of version 3 of the GNU General Public 11 | License, supplemented by the additional permissions listed below. 12 | 13 | 0. Additional Definitions. 14 | 15 | As used herein, "this License" refers to version 3 of the GNU Lesser 16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 17 | General Public License. 18 | 19 | "The Library" refers to a covered work governed by this License, 20 | other than an Application or a Combined Work as defined below. 21 | 22 | An "Application" is any work that makes use of an interface provided 23 | by the Library, but which is not otherwise based on the Library. 24 | Defining a subclass of a class defined by the Library is deemed a mode 25 | of using an interface provided by the Library. 26 | 27 | A "Combined Work" is a work produced by combining or linking an 28 | Application with the Library. The particular version of the Library 29 | with which the Combined Work was made is also called the "Linked 30 | Version". 31 | 32 | The "Minimal Corresponding Source" for a Combined Work means the 33 | Corresponding Source for the Combined Work, excluding any source code 34 | for portions of the Combined Work that, considered in isolation, are 35 | based on the Application, and not on the Linked Version. 36 | 37 | The "Corresponding Application Code" for a Combined Work means the 38 | object code and/or source code for the Application, including any data 39 | and utility programs needed for reproducing the Combined Work from the 40 | Application, but excluding the System Libraries of the Combined Work. 41 | 42 | 1. Exception to Section 3 of the GNU GPL. 43 | 44 | You may convey a covered work under sections 3 and 4 of this License 45 | without being bound by section 3 of the GNU GPL. 46 | 47 | 2. Conveying Modified Versions. 48 | 49 | If you modify a copy of the Library, and, in your modifications, a 50 | facility refers to a function or data to be supplied by an Application 51 | that uses the facility (other than as an argument passed when the 52 | facility is invoked), then you may convey a copy of the modified 53 | version: 54 | 55 | a) under this License, provided that you make a good faith effort to 56 | ensure that, in the event an Application does not supply the 57 | function or data, the facility still operates, and performs 58 | whatever part of its purpose remains meaningful, or 59 | 60 | b) under the GNU GPL, with none of the additional permissions of 61 | this License applicable to that copy. 62 | 63 | 3. Object Code Incorporating Material from Library Header Files. 64 | 65 | The object code form of an Application may incorporate material from 66 | a header file that is part of the Library. You may convey such object 67 | code under terms of your choice, provided that, if the incorporated 68 | material is not limited to numerical parameters, data structure 69 | layouts and accessors, or small macros, inline functions and templates 70 | (ten or fewer lines in length), you do both of the following: 71 | 72 | a) Give prominent notice with each copy of the object code that the 73 | Library is used in it and that the Library and its use are 74 | covered by this License. 75 | 76 | b) Accompany the object code with a copy of the GNU GPL and this license 77 | document. 78 | 79 | 4. Combined Works. 80 | 81 | You may convey a Combined Work under terms of your choice that, 82 | taken together, effectively do not restrict modification of the 83 | portions of the Library contained in the Combined Work and reverse 84 | engineering for debugging such modifications, if you also do each of 85 | the following: 86 | 87 | a) Give prominent notice with each copy of the Combined Work that 88 | the Library is used in it and that the Library and its use are 89 | covered by this License. 90 | 91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 92 | document. 93 | 94 | c) For a Combined Work that displays copyright notices during 95 | execution, include the copyright notice for the Library among 96 | these notices, as well as a reference directing the user to the 97 | copies of the GNU GPL and this license document. 98 | 99 | d) Do one of the following: 100 | 101 | 0) Convey the Minimal Corresponding Source under the terms of this 102 | License, and the Corresponding Application Code in a form 103 | suitable for, and under terms that permit, the user to 104 | recombine or relink the Application with a modified version of 105 | the Linked Version to produce a modified Combined Work, in the 106 | manner specified by section 6 of the GNU GPL for conveying 107 | Corresponding Source. 108 | 109 | 1) Use a suitable shared library mechanism for linking with the 110 | Library. A suitable mechanism is one that (a) uses at run time 111 | a copy of the Library already present on the user's computer 112 | system, and (b) will operate properly with a modified version 113 | of the Library that is interface-compatible with the Linked 114 | Version. 115 | 116 | e) Provide Installation Information, but only if you would otherwise 117 | be required to provide such information under section 6 of the 118 | GNU GPL, and only to the extent that such information is 119 | necessary to install and execute a modified version of the 120 | Combined Work produced by recombining or relinking the 121 | Application with a modified version of the Linked Version. (If 122 | you use option 4d0, the Installation Information must accompany 123 | the Minimal Corresponding Source and Corresponding Application 124 | Code. If you use option 4d1, you must provide the Installation 125 | Information in the manner specified by section 6 of the GNU GPL 126 | for conveying Corresponding Source.) 127 | 128 | 5. Combined Libraries. 129 | 130 | You may place library facilities that are a work based on the 131 | Library side by side in a single library together with other library 132 | facilities that are not Applications and are not covered by this 133 | License, and convey such a combined library under terms of your 134 | choice, if you do both of the following: 135 | 136 | a) Accompany the combined library with a copy of the same work based 137 | on the Library, uncombined with any other library facilities, 138 | conveyed under the terms of this License. 139 | 140 | b) Give prominent notice with the combined library that part of it 141 | is a work based on the Library, and explaining where to find the 142 | accompanying uncombined form of the same work. 143 | 144 | 6. Revised Versions of the GNU Lesser General Public License. 145 | 146 | The Free Software Foundation may publish revised and/or new versions 147 | of the GNU Lesser General Public License from time to time. Such new 148 | versions will be similar in spirit to the present version, but may 149 | differ in detail to address new problems or concerns. 150 | 151 | Each version is given a distinguishing version number. If the 152 | Library as you received it specifies that a certain numbered version 153 | of the GNU Lesser General Public License "or any later version" 154 | applies to it, you have the option of following the terms and 155 | conditions either of that published version or of any later version 156 | published by the Free Software Foundation. If the Library as you 157 | received it does not specify a version number of the GNU Lesser 158 | General Public License, you may choose any version of the GNU Lesser 159 | General Public License ever published by the Free Software Foundation. 160 | 161 | If the Library as you received it specifies that a proxy can decide 162 | whether future versions of the GNU Lesser General Public License shall 163 | apply, that proxy's public statement of acceptance of any version is 164 | permanent authorization for you to choose that version for the 165 | Library. 166 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ***Media Keys Fix*** 2 | [![C++20](https://img.shields.io/static/v1?label=standard&message=C%2B%2B20&color=blue&logo=c%2B%2B&&logoColor=white&style=flat)](https://en.cppreference.com/w/cpp/compiler_support) 3 | [![Latest Release](https://img.shields.io/github/release/epinter/MediaKeysFix.svg)](https://github.com/epinter/MediaKeysFix/releases/latest) 4 | [![Downloads](https://img.shields.io/github/downloads/epinter/MediaKeysFix/total.svg)](https://github.com/epinter/MediaKeysFix/releases/latest) 5 | [![Release Date](https://img.shields.io/github/release-date/epinter/MediaKeysFix.svg)](https://github.com/epinter/MediaKeysFix/releases/latest) 6 | [![License](https://img.shields.io/github/license/epinter/MediaKeysFix.svg)](https://github.com/epinter/MediaKeysFix/blob/main/LICENSE) 7 | [![Site](https://img.shields.io/static/v1?label=site&message=NexusMods&color=blue)](https://www.nexusmods.com/skyrimspecialedition) 8 | 9 | ## The problem 10 | Skyrim starts with exclusive access to keyboard and mouse, in a way that media keys, Windows key or any other key not handled by DirectInput are ignored. This makes the user life harder, to change volume you need to ALT+TAB or use an overlay. 11 | 12 | ## The solution 13 | This mod changes DirectInput flags so the game doesn't starts with exclusive access anymore. This leads to another problem, dead keys (for diacritics) are ignored, so some users with keyboard layouts that has accents (US-international, for example) wouldn't be able to type single-quotes or double-quotes in console. This mod fixes this side effect too, but the option must be enabled in .INI (DisableDeadKeys). More details about the exclusive/non-exclusive access of DirectInput can be found [here](https://learn.microsoft.com/en-us/previous-versions/windows/desktop/ee417921%28v=vs.85%29). 14 | 15 | ## ***Runtime requirements*** 16 | 17 | - [Skyrim Script Extender (SKSE)](https://skse.silverlock.org/) 18 | - [Address Library for SKSE Plugins](https://www.nexusmods.com/skyrimspecialedition/mods/32444) 19 | 20 | ## ***Configuration*** 21 | 22 | The MediaKeysFix.ini has the following options: 23 | ~~~ 24 | [General] 25 | ;; Disable Windows key. Set to true to disable windows key. 26 | DisableWindowsKey = true 27 | 28 | ;; Disable dead keys. When Skyrim doesn't have exclusive access to keyboard, dead keys stops working. 29 | ;; Users with keyboards layout like US-International or any other that uses dead keys may experience 30 | ;; difficulties to type characters like quotes in console. A way to fix this is effectively disable 31 | ;; dead keys in game. 32 | ;; Set to true to disable dead keys. 33 | DisableDeadKeys = false 34 | 35 | ;; Allow background access. STRONGLY RECOMMENDED TO BE SET = false, only useful for DEBUGGING. 36 | ;; If background access is granted, the device can be acquired at any time, 37 | ;; even when the associated window is not the active window. 38 | ;; The game will receive input even if not active window!! 39 | ;; Set to true to allow background (replaces DISCL_FOREGROUND with DISCL_BACKGROUND) 40 | BackgroundAccess = false 41 | ~~~ 42 | ## ***Build requirements*** 43 | 44 | - [CMake](https://cmake.org/) 45 | - [vcpkg](https://vcpkg.io/en/) 46 | - [Visual Studio Community 2022](https://visualstudio.microsoft.com/vs/community/) 47 | - [CommonLibSSE-NG](https://github.com/CharmedBaryon/CommonLibSSE-NG) 48 | - [SimpleIni](https://github.com/brofield/simpleini) 49 | 50 | ## ***Building*** 51 | 52 | In `Developer Command Prompt for VS 2022` or `Developer PowerShell for VS 2022`, run: 53 | 54 | ~~~ 55 | git clone https://github.com/epinter/MediaKeysFix.git 56 | cd MediaKeysFix 57 | ~~~ 58 | 59 | then 60 | 61 | ~~~ 62 | cmake\build-release.ps1 63 | ~~~ 64 | 65 | or 66 | 67 | ~~~ 68 | cmake -B build -S . --preset ALL --fresh 69 | cmake --build build --config Release 70 | ~~~ 71 | 72 | Then get the .dll in build/Release, or the .7z (ready to install using mod manager) in build. 73 | -------------------------------------------------------------------------------- /cmake/Plugin.h.in: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace Plugin 6 | { 7 | using namespace std::literals; 8 | 9 | inline constexpr REL::Version VERSION 10 | { 11 | // clang-format off 12 | @PROJECT_VERSION_MAJOR@u, 13 | @PROJECT_VERSION_MINOR@u, 14 | @PROJECT_VERSION_PATCH@u, 15 | // clang-format on 16 | }; 17 | 18 | inline constexpr auto NAME = "@PROJECT_NAME@"sv; 19 | } -------------------------------------------------------------------------------- /cmake/addpluginsources.cmake: -------------------------------------------------------------------------------- 1 | configure_file( 2 | ${CMAKE_CURRENT_SOURCE_DIR}/cmake/version.rc.in 3 | ${CMAKE_CURRENT_BINARY_DIR}/cmake/version.rc 4 | @ONLY) 5 | 6 | configure_file( 7 | ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Plugin.h.in 8 | ${CMAKE_CURRENT_BINARY_DIR}/cmake/Plugin.h 9 | @ONLY) 10 | 11 | file(GLOB_RECURSE PUBLIC_HEADER_FILES 12 | LIST_DIRECTORIES false 13 | CONFIGURE_DEPENDS 14 | "${CMAKE_CURRENT_SOURCE_DIR}/include/*.h" 15 | ) 16 | 17 | file(GLOB_RECURSE HEADER_FILES 18 | LIST_DIRECTORIES false 19 | CONFIGURE_DEPENDS 20 | "${CMAKE_CURRENT_SOURCE_DIR}/src/*.h" 21 | ) 22 | 23 | file(GLOB_RECURSE SOURCE_FILES 24 | LIST_DIRECTORIES false 25 | CONFIGURE_DEPENDS 26 | "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp" 27 | ${CMAKE_CURRENT_BINARY_DIR}/cmake/Plugin.h 28 | ${CMAKE_CURRENT_BINARY_DIR}/cmake/version.rc) 29 | 30 | source_group("Source" 31 | TREE ${CMAKE_CURRENT_SOURCE_DIR} 32 | FILES 33 | ${PUBLIC_HEADER_FILES} 34 | ${HEADER_FILES} 35 | ${SOURCE_FILES}) 36 | -------------------------------------------------------------------------------- /cmake/build-release.ps1: -------------------------------------------------------------------------------- 1 | param([string]$buildType="Release") 2 | $ErrorActionPreference = "Stop" 3 | Set-StrictMode -Version 3.0 4 | 5 | $projectRoot = Resolve-Path "$PSScriptRoot/.." 6 | 7 | Set-Location $projectRoot 8 | cmake -B build -S "$projectRoot" --preset ALL --fresh 9 | cmake --build "$projectRoot/build" --config "$($buildType)" 10 | Set-Location "$projectRoot/build" 11 | cpack 12 | Set-Location $projectRoot -------------------------------------------------------------------------------- /cmake/pluginconfig.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_CXX_STANDARD 20) 2 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 3 | set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON) 4 | -------------------------------------------------------------------------------- /cmake/version.rc.in: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 1 VERSIONINFO 4 | FILEVERSION @PROJECT_VERSION_MAJOR@, @PROJECT_VERSION_MINOR@, @PROJECT_VERSION_PATCH@, 0 5 | PRODUCTVERSION @PROJECT_VERSION_MAJOR@, @PROJECT_VERSION_MINOR@, @PROJECT_VERSION_PATCH@, 0 6 | FILEFLAGSMASK 0x17L 7 | #ifdef _DEBUG 8 | FILEFLAGS 0x1L 9 | #else 10 | FILEFLAGS 0x0L 11 | #endif 12 | FILEOS 0x4L 13 | FILETYPE 0x1L 14 | FILESUBTYPE 0x0L 15 | BEGIN 16 | BLOCK "StringFileInfo" 17 | BEGIN 18 | BLOCK "040904b0" 19 | BEGIN 20 | VALUE "FileDescription", "@PROJECT_DESCRIPTION@" 21 | VALUE "FileVersion", "@PROJECT_VERSION@" 22 | VALUE "InternalName", "@PROJECT_NAME@" 23 | VALUE "LegalCopyright", "@PROJECT_COPYRIGHT@" 24 | VALUE "License", "@PROJECT_LICENSE@" 25 | VALUE "ProductName", "@PROJECT_NAME@" 26 | VALUE "ProductVersion", "@PROJECT_VERSION@" 27 | END 28 | END 29 | BLOCK "VarFileInfo" 30 | BEGIN 31 | VALUE "Translation", 0x409, 1200 32 | END 33 | END 34 | -------------------------------------------------------------------------------- /dist/MediaKeysFix.ini: -------------------------------------------------------------------------------- 1 | [General] 2 | 3 | ;; Disable Windows key. Set to true to disable windows key. 4 | DisableWindowsKey = true 5 | 6 | ;; Disable dead keys. When Skyrim doesn't have exclusive access to keyboard, dead keys stops working. 7 | ;; Users with keyboards layout like US-International or any other that uses dead keys may experience 8 | ;; difficulties to type characters like quotes in console. A way to fix this is effectively disable 9 | ;; dead keys in game. 10 | ;; Set to true to disable dead keys. 11 | DisableDeadKeys = false 12 | 13 | ;; Allow background access. STRONGLY RECOMMENDED TO BE SET = false, only useful for DEBUGGING. 14 | ;; If background access is granted, the device can be acquired at any time, 15 | ;; even when the associated window is not the active window. 16 | ;; The game will receive input even if not active window!! 17 | ;; Set to true to allow background (replaces DISCL_FOREGROUND with DISCL_BACKGROUND) 18 | BackgroundAccess = false 19 | -------------------------------------------------------------------------------- /src/Config.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | /* 3 | Copyright (c) 2023 Emerson Pinter 4 | 5 | This file is part of Media Keys Fix. Licensed under LGPL-3.0-or-later . 6 | */ 7 | 8 | using namespace constants; 9 | 10 | namespace mdkf { 11 | Config::Config() { 12 | CSimpleIniA ini; 13 | ini.SetQuotes(true); 14 | ini.SetAllowKeyOnly(false); 15 | ini.SetUnicode(true); 16 | ini.SetMultiKey(false); 17 | std::string fileName = std::string("Data\\SKSE\\Plugins\\").append(CONFIG_FILE); 18 | 19 | bool save = false; 20 | if (ini.LoadFile(fileName.c_str()) == 0) { 21 | disableWindowsKey = ini.GetBoolValue(INI_SECTION, OPT_INIDISWINKEY, disableWindowsKey); 22 | backgroundAccess = ini.GetBoolValue(INI_SECTION, OPT_INIBACKGN, backgroundAccess); 23 | disableDeadKeys = ini.GetBoolValue(INI_SECTION, OPT_INIDISDEADK, disableDeadKeys); 24 | } else { 25 | logger::error("Can't open config file '{}'. Trying to create a new.", CONFIG_FILE); 26 | } 27 | 28 | if (!ini.KeyExists(INI_SECTION, OPT_INIDISWINKEY)) { 29 | ini.SetBoolValue(INI_SECTION, OPT_INIDISWINKEY, disableWindowsKey, COMMENT_INIWINKEY, true); 30 | save = true; 31 | } 32 | if (!ini.KeyExists(INI_SECTION, OPT_INIDISDEADK)) { 33 | ini.SetBoolValue(INI_SECTION, OPT_INIDISDEADK, disableDeadKeys, COMMENT_INIDISDEADK, true); 34 | save = true; 35 | } 36 | if (!ini.KeyExists(INI_SECTION, OPT_INIBACKGN)) { 37 | ini.SetBoolValue(INI_SECTION, OPT_INIBACKGN, backgroundAccess, COMMENT_INIBACKGND, true); 38 | save = true; 39 | } 40 | 41 | if (save) { 42 | ini.SaveFile(fileName.c_str()); 43 | } 44 | 45 | logger::info("Config: {}='{}'; {}='{}'; {}='{}';", OPT_INIDISWINKEY, disableWindowsKey, OPT_INIBACKGN, backgroundAccess, 46 | OPT_INIDISDEADK, disableDeadKeys); 47 | } 48 | 49 | const Config& Config::getInstance() { 50 | static Config instance; 51 | return instance; 52 | } 53 | 54 | [[nodiscard]] bool Config::isDisableWindowsKey() const { 55 | return disableWindowsKey; 56 | } 57 | 58 | [[nodiscard]] bool Config::isBackgroundAccess() const { 59 | return backgroundAccess; 60 | } 61 | 62 | [[nodiscard]] bool Config::isDisableDeadKeys() const { 63 | return disableDeadKeys; 64 | } 65 | } // namespace mdkf 66 | -------------------------------------------------------------------------------- /src/Config.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | /* 3 | Copyright (c) 2023 Emerson Pinter 4 | 5 | This file is part of Media Keys Fix. Licensed under LGPL-3.0-or-later . 6 | */ 7 | 8 | #include 9 | 10 | namespace constants { 11 | static constexpr const char* CONFIG_FILE = "MediaKeysFix.ini"; 12 | static constexpr const char* INI_SECTION = "General"; 13 | static constexpr const char* OPT_INIDISWINKEY = "DisableWindowsKey"; 14 | static constexpr const char* OPT_INIBACKGN = "BackgroundAccess"; 15 | static constexpr const char* OPT_INIDISDEADK = "DisableDeadKeys"; 16 | static constexpr const char* COMMENT_INIWINKEY = ";; Disable Windows key. Set to true to disable windows key."; 17 | static constexpr const char* COMMENT_INIBACKGND = 18 | ";; Allow background access. STRONGLY RECOMMENDED TO BE SET = false, only useful for DEBUGGING.\n" 19 | ";; If background access is granted, the device can be acquired at any time,\n" 20 | ";; even when the associated window is not the active window.\n" 21 | ";; The game will receive input even if not active window!!\n" 22 | ";; Set to true to allow background (replaces DISCL_FOREGROUND with DISCL_BACKGROUND)"; 23 | const static constexpr char* COMMENT_INIDISDEADK = 24 | ";; Disable dead keys. When Skyrim doesn't have exclusive access to keyboard, dead keys stops working.\n" 25 | ";; Users with keyboards layout like US-International or any other that uses dead keys may experience\n" 26 | ";; difficulties to type characters like quotes in console. A way to fix this is effectively disable\n" 27 | ";; dead keys in game.\n" 28 | ";; Set to true to disable dead keys."; 29 | } // namespace constants 30 | 31 | namespace mdkf { 32 | class Config { 33 | private: 34 | explicit Config(); 35 | bool disableWindowsKey = true; 36 | bool backgroundAccess = false; 37 | bool disableDeadKeys = false; 38 | 39 | public: 40 | Config(Config&) = delete; 41 | Config& operator=(Config&&) = delete; 42 | void operator=(Config&) = delete; 43 | 44 | [[nodiscard]] static const Config& getInstance(); 45 | 46 | [[nodiscard]] bool isDisableWindowsKey() const; 47 | 48 | [[nodiscard]] bool isBackgroundAccess() const; 49 | 50 | [[nodiscard]] bool isDisableDeadKeys() const; 51 | }; 52 | } // namespace mdkf 53 | -------------------------------------------------------------------------------- /src/Main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023 Emerson Pinter 3 | 4 | This file is part of Media Keys Fix. Licensed under LGPL-3.0-or-later . 5 | */ 6 | 7 | #include "Main.h" 8 | 9 | #include "Config.h" 10 | 11 | using namespace constants; 12 | 13 | namespace mdkf { 14 | void load() { 15 | patchCooperativeLevel(); 16 | if (Config::getInstance().isDisableDeadKeys()) { 17 | initializeTounicodeHook(); 18 | } 19 | } 20 | 21 | void patchCooperativeLevel() { 22 | uint32_t newFlags = Config::getInstance().isBackgroundAccess() ? DIFLAGS_BACKGROUND : DIFLAGS_DEFAULT; 23 | 24 | if (Config::getInstance().isDisableWindowsKey()) { 25 | newFlags |= DISCL_NOWINKEY; // disable windows key 26 | } 27 | writeDwFlags(newFlags); 28 | } 29 | 30 | void writeDwFlags(int newFlags) { 31 | REL::RelocationID initDirectInputDevice = REL::RelocationID(INITDINPUT_SE, INITDINPUT_AE); 32 | int instructionOffset = REL::Relocate(DWFLAGS_INST_OFFSET_SE, DWFLAGS_INST_OFFSET_AE); 33 | 34 | if (REL::make_pattern().match(initDirectInputDevice.address() + instructionOffset)) { 35 | int dwFlagsOffset = instructionOffset + 2; // instruction len = 2 bytes 36 | 37 | logger::info("SetCooperativeLevel dwFlags found at address 0x{:08X}, setting to 0x{:02X}", 38 | initDirectInputDevice.offset() + dwFlagsOffset, newFlags); 39 | REL::safe_write(initDirectInputDevice.address() + dwFlagsOffset, newFlags); 40 | } else { 41 | logger::info("DwFlags patch failed, address didn't match. Fix not applied."); 42 | } 43 | } 44 | 45 | REL::Relocation originalToUnicode; 46 | 47 | void initializeTounicodeHook() { 48 | uintptr_t call = REL::RelocationID(PROCESSINPUT_SE, PROCESSINPUT_AE).address() + 49 | REL::Relocate(TOUNICODECALL_OFFSET_SE, TOUNICODECALL_OFFSET_AE); 50 | 51 | if (REL::make_pattern().match(call)) { 52 | logger::info("Disabling dead keys."); 53 | auto& trampoline = SKSE::GetTrampoline(); 54 | trampoline.create(64); 55 | 56 | originalToUnicode = *reinterpret_cast(trampoline.write_call<6>(call, toUnicode)); 57 | } else { 58 | logger::info("Unable to write trampoline, address didn't match. Dead keys not disabled."); 59 | } 60 | } 61 | 62 | int toUnicode(UINT wVirtKey, UINT wScanCode, const BYTE* lpKeyState, LPWSTR pwszBuff, int cchBuff, UINT wFlags) { 63 | int ret = originalToUnicode(wVirtKey, wScanCode, lpKeyState, pwszBuff, cchBuff, wFlags); 64 | return ret > 0 ? 1 : ret; 65 | } 66 | } // namespace mdkf 67 | -------------------------------------------------------------------------------- /src/Main.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | /* 3 | Copyright (c) 2023 Emerson Pinter 4 | 5 | This file is part of Media Keys Fix. Licensed under LGPL-3.0-or-later . 6 | */ 7 | 8 | namespace constants { 9 | // cooperativelevel 10 | static constexpr SKSE::stl::nttp::string PATTERN_CHECK_DWFLAGS = "41 B8 15 00 00 00 48 8B D0 FF"; 11 | static constexpr int INITDINPUT_SE = 67471; // 1.5.97 = C1A060 12 | static constexpr int INITDINPUT_AE = 68781; // 1.6.640 = C52D00 13 | static constexpr int DWFLAGS_INST_OFFSET_SE = 0x55; 14 | static constexpr int DWFLAGS_INST_OFFSET_AE = 0x55; 15 | static constexpr uint32_t DIFLAGS_DEFAULT = DISCL_FOREGROUND | DISCL_NONEXCLUSIVE; 16 | static constexpr uint32_t DIFLAGS_BACKGROUND = DISCL_BACKGROUND | DISCL_NONEXCLUSIVE; 17 | // tounicode 18 | static constexpr SKSE::stl::nttp::string PATTERN_CHECK_TOUNICODE = "FF 15 ?? ?? ?? ?? 83 F8 01 75"; 19 | static constexpr int PROCESSINPUT_SE = 67472; // 1.5.97 = C1A130 20 | static constexpr int PROCESSINPUT_AE = 68782; // 1.6.640 = C52DD0 21 | static constexpr int TOUNICODECALL_OFFSET_SE = 0x20D; 22 | static constexpr int TOUNICODECALL_OFFSET_AE = 0x2CB; 23 | } // namespace constants 24 | 25 | namespace mdkf { 26 | void load(); 27 | void patchCooperativeLevel(); 28 | void writeDwFlags(int dwFlags); 29 | void initializeTounicodeHook(); 30 | 31 | int toUnicode(UINT wVirtKey, UINT wScanCode, const BYTE *lpKeyState, LPWSTR pwszBuff, int cchBuff, UINT wFlags); 32 | } // namespace mdkf 33 | -------------------------------------------------------------------------------- /src/PCH.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include 51 | #include 52 | #include 53 | #include 54 | #include 55 | #include 56 | #include 57 | #include 58 | #include 59 | #include 60 | #include 61 | #include 62 | #include 63 | #include 64 | #include 65 | #include 66 | #include 67 | #include 68 | #include 69 | #include 70 | #include 71 | #include 72 | #include 73 | #include 74 | #include 75 | #include 76 | #include 77 | #include 78 | #include 79 | #include 80 | #include 81 | #include 82 | #include 83 | #include 84 | #include 85 | #include 86 | #include 87 | #include 88 | #include 89 | #include 90 | #include 91 | #include 92 | #include 93 | #include 94 | #include 95 | #include 96 | #include 97 | 98 | #define SPDLOG_WCHAR_TO_UTF8_SUPPORT 99 | #include 100 | #include 101 | #include 102 | 103 | #include 104 | #include 105 | #include 106 | 107 | #include 108 | #include 109 | #include 110 | 111 | #undef cdecl // Workaround for Clang 14 CMake configure error. 112 | 113 | #define DIRECTINPUT_VERSION 0x0800 114 | #include 115 | 116 | #define DLLEXPORT __declspec(dllexport) 117 | 118 | using namespace std::literals; 119 | using namespace REL::literals; 120 | 121 | namespace logger = SKSE::log; -------------------------------------------------------------------------------- /src/Plugin.cpp: -------------------------------------------------------------------------------- 1 | #include "Main.h" 2 | 3 | using namespace SKSE; 4 | using namespace SKSE::log; 5 | using namespace SKSE::stl; 6 | 7 | namespace mdkf { 8 | std::optional getLogDirectory() { 9 | PWSTR buf; 10 | SHGetKnownFolderPath(FOLDERID_Documents, KF_FLAG_DEFAULT, nullptr, &buf); 11 | std::unique_ptr documentsPath{buf, CoTaskMemFree}; 12 | std::filesystem::path directory{documentsPath.get()}; 13 | directory.append("My Games"sv); 14 | 15 | if (SKYRIM_REL_VR_CONSTEXPR(REL::Module::IsVR())) { 16 | directory.append("Skyrim VR"sv); 17 | } else if (std::filesystem::exists("steam_api64.dll"sv)) { 18 | directory.append("Skyrim Special Edition"sv); 19 | } else if (std::filesystem::exists("Galaxy64.dll"sv)) { 20 | directory.append("Skyrim Special Edition GOG"sv); 21 | } else if (std::filesystem::exists("eossdk-win64-shipping.dll"sv)) { 22 | directory.append("Skyrim Special Edition EPIC"sv); 23 | } else { 24 | return std::filesystem::current_path().append("skselogs"); 25 | } 26 | return directory.append("SKSE"sv); 27 | } 28 | 29 | void initializeLogging() { 30 | auto path = getLogDirectory(); 31 | if (!path) { 32 | report_and_fail("Can't find SKSE log directory"); 33 | } 34 | *path /= fmt::format("{}.log"sv, PluginDeclaration::GetSingleton()->GetName()); 35 | 36 | std::shared_ptr log; 37 | if (IsDebuggerPresent()) { 38 | log = std::make_shared("Global", std::make_shared()); 39 | } else { 40 | log = std::make_shared("Global", 41 | std::make_shared(path->string(), true)); 42 | } 43 | log->set_level(spdlog::level::info); 44 | log->flush_on(spdlog::level::info); 45 | 46 | spdlog::set_default_logger(std::move(log)); 47 | spdlog::set_pattern("[%Y-%m-%d %H:%M:%S.%e] [%n] [%l] [%t] %v"); 48 | } 49 | } // namespace mdkf 50 | 51 | using namespace mdkf; 52 | 53 | SKSEPluginLoad(const LoadInterface* skse) { 54 | initializeLogging(); 55 | const auto* plugin = PluginDeclaration::GetSingleton(); 56 | auto version = plugin->GetVersion(); 57 | 58 | logger::info("'{} {}' is loading, game version '{}'...", plugin->GetName(), version, REL::Module::get().version()); 59 | Init(skse); 60 | 61 | load(); 62 | 63 | logger::info("{} has finished loading.", plugin->GetName()); 64 | return true; 65 | } 66 | -------------------------------------------------------------------------------- /vcpkg-configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "default-registry": { 3 | "kind": "git", 4 | "repository": "https://github.com/Microsoft/vcpkg", 5 | "baseline": "85c222bc31ce1a747c98f0dd74ab47baab91744c" 6 | }, 7 | "registries": [ 8 | { 9 | "kind": "git", 10 | "repository": "https://gitlab.com/colorglass/vcpkg-colorglass", 11 | "baseline": "6309841a1ce770409708a67a9ba5c26c537d2937", 12 | "packages": [ 13 | "articuno", 14 | "bethesda-fallout4-scripts", 15 | "bethesda-skyrim-scripts", 16 | "commonlibf4", 17 | "commonlibsse", 18 | "commonlibsse-ng", 19 | "commonlibsse-ng-ae", 20 | "commonlibsse-ng-flatrim", 21 | "commonlibsse-ng-prebuilt", 22 | "commonlibsse-ng-se", 23 | "commonlibsse-ng-vr", 24 | "commonlibsse-po3-ae", 25 | "commonlibsse-po3-se", 26 | "commonlibvr", 27 | "f4se", 28 | "fully-dynamic-game-engine", 29 | "gluino", 30 | "hoshi", 31 | "script-extender-common", 32 | "skse", 33 | "tsl-hat-trie" 34 | ] 35 | } 36 | ] 37 | } 38 | -------------------------------------------------------------------------------- /vcpkg.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mediakeysfix", 3 | "version-string": "1.0.0", 4 | "description": "Media Keys Fix", 5 | "homepage": "https://github.com/epinter/MediaKeysFix", 6 | "license": "LGPL-3.0-or-later", 7 | "features": { 8 | "plugin": { 9 | "description": "SKSE plugin", 10 | "dependencies": [ 11 | "commonlibsse-ng", 12 | "simpleini" 13 | ] 14 | } 15 | }, 16 | "default-features": [ 17 | "plugin" 18 | ] 19 | } 20 | --------------------------------------------------------------------------------