├── .gitignore ├── Devices ├── HidApiDevice.cs ├── InstrumentMapperDevice.cs └── XInputDevice.cs ├── EpicLauncherDetection.cs ├── FestivalInstrumentMapper.csproj ├── FestivalInstrumentMapper.sln ├── HeroicLauncherDetection.cs ├── HidHideConfigWindow.Designer.cs ├── HidHideConfigWindow.cs ├── HidHideConfigWindow.resx ├── LICENSE.txt ├── MainWindow ├── MainWindow.Designer.cs ├── MainWindow.cs ├── MainWindow.resx └── MapperThread.cs ├── Native ├── GipSyntheticEx.cs ├── HidDeviceStream.cs ├── PDPJaguarValues.cs ├── SyntheticController.cs ├── ToGip.cs └── XInput.cs ├── NativeMethods.txt ├── Program.cs ├── README.md ├── app.manifest └── festivalinstrumentmapper.ico /.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/main/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 | [Ll]og/ 33 | [Ll]ogs/ 34 | 35 | # Visual Studio 2015/2017 cache/options directory 36 | .vs/ 37 | # Uncomment if you have tasks that create the project's static files in wwwroot 38 | #wwwroot/ 39 | 40 | # Visual Studio 2017 auto generated files 41 | Generated\ Files/ 42 | 43 | # MSTest test Results 44 | [Tt]est[Rr]esult*/ 45 | [Bb]uild[Ll]og.* 46 | 47 | # NUnit 48 | *.VisualState.xml 49 | TestResult.xml 50 | nunit-*.xml 51 | 52 | # Build Results of an ATL Project 53 | [Dd]ebugPS/ 54 | [Rr]eleasePS/ 55 | dlldata.c 56 | 57 | # Benchmark Results 58 | BenchmarkDotNet.Artifacts/ 59 | 60 | # .NET Core 61 | project.lock.json 62 | project.fragment.lock.json 63 | artifacts/ 64 | 65 | # ASP.NET Scaffolding 66 | ScaffoldingReadMe.txt 67 | 68 | # StyleCop 69 | StyleCopReport.xml 70 | 71 | # Files built by Visual Studio 72 | *_i.c 73 | *_p.c 74 | *_h.h 75 | *.ilk 76 | *.meta 77 | *.obj 78 | *.iobj 79 | *.pch 80 | *.pdb 81 | *.ipdb 82 | *.pgc 83 | *.pgd 84 | *.rsp 85 | *.sbr 86 | *.tlb 87 | *.tli 88 | *.tlh 89 | *.tmp 90 | *.tmp_proj 91 | *_wpftmp.csproj 92 | *.log 93 | *.tlog 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 6 auto-generated project file (contains which files were open etc.) 298 | *.vbp 299 | 300 | # Visual Studio 6 workspace and project file (working project files containing files to include in project) 301 | *.dsw 302 | *.dsp 303 | 304 | # Visual Studio 6 technical files 305 | *.ncb 306 | *.aps 307 | 308 | # Visual Studio LightSwitch build output 309 | **/*.HTMLClient/GeneratedArtifacts 310 | **/*.DesktopClient/GeneratedArtifacts 311 | **/*.DesktopClient/ModelManifest.xml 312 | **/*.Server/GeneratedArtifacts 313 | **/*.Server/ModelManifest.xml 314 | _Pvt_Extensions 315 | 316 | # Paket dependency manager 317 | .paket/paket.exe 318 | paket-files/ 319 | 320 | # FAKE - F# Make 321 | .fake/ 322 | 323 | # CodeRush personal settings 324 | .cr/personal 325 | 326 | # Python Tools for Visual Studio (PTVS) 327 | __pycache__/ 328 | *.pyc 329 | 330 | # Cake - Uncomment if you are using it 331 | # tools/** 332 | # !tools/packages.config 333 | 334 | # Tabs Studio 335 | *.tss 336 | 337 | # Telerik's JustMock configuration file 338 | *.jmconfig 339 | 340 | # BizTalk build output 341 | *.btp.cs 342 | *.btm.cs 343 | *.odx.cs 344 | *.xsd.cs 345 | 346 | # OpenCover UI analysis results 347 | OpenCover/ 348 | 349 | # Azure Stream Analytics local run output 350 | ASALocalRun/ 351 | 352 | # MSBuild Binary and Structured Log 353 | *.binlog 354 | 355 | # NVidia Nsight GPU debugger configuration file 356 | *.nvuser 357 | 358 | # MFractors (Xamarin productivity tool) working folder 359 | .mfractor/ 360 | 361 | # Local History for Visual Studio 362 | .localhistory/ 363 | 364 | # Visual Studio History (VSHistory) files 365 | .vshistory/ 366 | 367 | # BeatPulse healthcheck temp database 368 | healthchecksdb 369 | 370 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 371 | MigrationBackup/ 372 | 373 | # Ionide (cross platform F# VS Code tools) working folder 374 | .ionide/ 375 | 376 | # Fody - auto-generated XML schema 377 | FodyWeavers.xsd 378 | 379 | # VS Code files for those working on multiple tools 380 | .vscode/ 381 | *.code-workspace 382 | 383 | # Local History for Visual Studio Code 384 | .history/ 385 | 386 | # Windows Installer files from build outputs 387 | *.cab 388 | *.msi 389 | *.msix 390 | *.msm 391 | *.msp 392 | 393 | # JetBrains Rider 394 | *.sln.iml 395 | 396 | # Leftover archives from publishing 397 | *.zip 398 | *.tar.gz 399 | -------------------------------------------------------------------------------- /Devices/HidApiDevice.cs: -------------------------------------------------------------------------------- 1 | namespace FestivalInstrumentMapper 2 | { 3 | internal enum HidApiDeviceType 4 | { 5 | Unknown, 6 | Santroller_RB, 7 | Santroller_GH, 8 | Wii_RB, 9 | PS3_RB, 10 | PS3_GH, 11 | PS4_RB_PDP, 12 | PS4_RB_MadCatz, 13 | PS5_RB_PDP, 14 | Raphnet_GH, 15 | } 16 | 17 | internal class HidApiDevice : InstrumentMapperDevice 18 | { 19 | private readonly HidDeviceStream _stream; 20 | 21 | public HidApiDeviceType Type { get; } 22 | 23 | public HidApiDevice(HidDeviceStream stream) 24 | { 25 | _stream = stream; 26 | Type = GetDeviceType(stream); 27 | } 28 | 29 | private static HidApiDeviceType GetDeviceType(HidDeviceStream stream) 30 | { 31 | // Santroller 32 | if (stream.VendorId == 0x1209 && stream.ProductId == 0x2882) 33 | { 34 | // Santroller encodes the device type into the top byte of the revision 35 | byte deviceType = (byte)(stream.Revision >> 8); 36 | 37 | // Rock Band guitar mode 38 | if (deviceType == 0x04) 39 | return HidApiDeviceType.Santroller_RB; 40 | // Guitar Hero guitar mode 41 | if (deviceType == 0x03) 42 | return HidApiDeviceType.Santroller_GH; 43 | } 44 | 45 | // PS3 instruments 46 | if (stream.VendorId == 0x12BA) 47 | { 48 | // Rock Band guitars 49 | if (stream.ProductId == 0x0200) 50 | return HidApiDeviceType.PS3_RB; 51 | // Guitar Hero guitars 52 | if (stream.ProductId == 0x0100) 53 | return HidApiDeviceType.PS3_GH; 54 | } 55 | 56 | // RedOctane 57 | if (stream.VendorId == 0x1430) 58 | { 59 | // World Tour PC guitars 60 | if (stream.ProductId == 0x474C) 61 | return HidApiDeviceType.PS3_GH; 62 | } 63 | 64 | // MadCatz (older VID) 65 | if (stream.VendorId == 0x1BAD) 66 | { 67 | // Wii RB1 guitars 68 | if (stream.ProductId == 0x0004) 69 | return HidApiDeviceType.Wii_RB; 70 | // Wii RB2/3 guitars 71 | if (stream.ProductId == 0x3010) 72 | return HidApiDeviceType.Wii_RB; 73 | } 74 | 75 | // MadCatz (newer VID) 76 | if (stream.VendorId == 0x0738) 77 | { 78 | // PS4 RB4 Stratocasters 79 | if (stream.ProductId == 0x8261) 80 | return HidApiDeviceType.PS4_RB_MadCatz; 81 | } 82 | 83 | // PDP 84 | if (stream.VendorId == 0x0E6F) 85 | { 86 | // PS4 RB4 Jaguars 87 | if (stream.ProductId == 0x0173) 88 | return HidApiDeviceType.PS4_RB_PDP; 89 | // PS4 Riffmaster guitars 90 | if (stream.ProductId == 0x024A) 91 | return HidApiDeviceType.PS4_RB_PDP; 92 | // PS5 Riffmaster guitars 93 | if (stream.ProductId == 0x0249) 94 | return HidApiDeviceType.PS5_RB_PDP; 95 | } 96 | 97 | // Raphnet 98 | if (stream.VendorId == 0x289B) 99 | { 100 | if (stream.ProductId == 0x0080) 101 | return HidApiDeviceType.Raphnet_GH; 102 | } 103 | 104 | return HidApiDeviceType.Unknown; 105 | } 106 | 107 | public override string ToString() 108 | { 109 | string device_name = Type switch 110 | { 111 | HidApiDeviceType.Wii_RB => "Wii Rock Band Guitar", 112 | HidApiDeviceType.PS3_RB => "PS3 Rock Band Guitar", 113 | HidApiDeviceType.PS3_GH => "PS3 Guitar Hero Guitar", 114 | HidApiDeviceType.PS4_RB_MadCatz => "PS4 Stratocaster", 115 | HidApiDeviceType.PS4_RB_PDP => "PS4 Jaguar/Riffmaster", 116 | HidApiDeviceType.PS5_RB_PDP => "PS5 Riffmaster", 117 | HidApiDeviceType.Santroller_RB or 118 | HidApiDeviceType.Santroller_GH => "Santroller Guitar", 119 | HidApiDeviceType.Raphnet_GH => "Raphnet Wii Adapter", 120 | _ => $"Unknown - {_stream.VendorId:X4}:{_stream.ProductId:X4}:{_stream.Revision:X4}", 121 | }; 122 | return $"{device_name}"; 123 | } 124 | 125 | public override bool Exists() => true; 126 | 127 | public override void Open() 128 | { 129 | if (Type == HidApiDeviceType.Unknown) 130 | throw new Exception("That device is unknown?!"); 131 | 132 | if (!_stream.Open(exclusive: false)) 133 | throw new Exception("Failed to open HID device stream"); 134 | } 135 | 136 | public override void Close() 137 | { 138 | // Stream can be re-opened after disposing 139 | _stream.Dispose(); 140 | } 141 | 142 | public override void Read(Span buffer) 143 | { 144 | if (!_stream.Read(buffer)) 145 | throw new Exception("Failed to read HID device report"); 146 | } 147 | 148 | public override int GetReadLength() 149 | { 150 | int expected = Type switch 151 | { 152 | HidApiDeviceType.Wii_RB or 153 | HidApiDeviceType.PS3_RB => 28, 154 | HidApiDeviceType.PS3_GH => 28, 155 | HidApiDeviceType.PS4_RB_PDP or 156 | HidApiDeviceType.PS4_RB_MadCatz => 64, 157 | HidApiDeviceType.PS5_RB_PDP => 64, 158 | HidApiDeviceType.Santroller_RB => 7, 159 | HidApiDeviceType.Santroller_GH => 7, 160 | HidApiDeviceType.Raphnet_GH => 15, 161 | _ => throw new Exception($"Unhandled device type {Type}") 162 | }; 163 | 164 | if (_stream.InputLength < expected) 165 | throw new Exception($"Device read length ({_stream.InputLength}) is less than expected ({expected})"); 166 | 167 | return _stream.InputLength; 168 | } 169 | 170 | public override ToGipAction GetGipConverter() 171 | { 172 | return Type switch 173 | { 174 | HidApiDeviceType.Wii_RB or 175 | HidApiDeviceType.PS3_RB => ToGip.PS3Wii_RB, 176 | HidApiDeviceType.PS3_GH => ToGip.PS3_GH, 177 | HidApiDeviceType.PS4_RB_PDP or 178 | HidApiDeviceType.PS4_RB_MadCatz => ToGip.PS4_RB, 179 | HidApiDeviceType.PS5_RB_PDP => ToGip.PS5_RB, 180 | HidApiDeviceType.Santroller_RB => ToGip.Santroller_RB, 181 | HidApiDeviceType.Santroller_GH => ToGip.Santroller_GH, 182 | HidApiDeviceType.Raphnet_GH => ToGip.Raphnet_GH, 183 | _ => throw new Exception($"Unhandled device type {Type}") 184 | }; 185 | } 186 | } 187 | } 188 | -------------------------------------------------------------------------------- /Devices/InstrumentMapperDevice.cs: -------------------------------------------------------------------------------- 1 | namespace FestivalInstrumentMapper 2 | { 3 | internal abstract class InstrumentMapperDevice : IDisposable 4 | { 5 | ~InstrumentMapperDevice() 6 | { 7 | Dispose(false); 8 | } 9 | 10 | public abstract bool Exists(); 11 | public abstract void Open(); 12 | public abstract void Close(); 13 | 14 | public abstract int GetReadLength(); 15 | public abstract ToGipAction GetGipConverter(); 16 | public abstract void Read(Span buffer); 17 | 18 | public void Dispose() 19 | { 20 | Dispose(true); 21 | GC.SuppressFinalize(this); 22 | } 23 | 24 | private void Dispose(bool disposing) 25 | { 26 | if (disposing) 27 | DisposeManaged(); 28 | DisposeUnmanaged(); 29 | } 30 | 31 | protected virtual void DisposeManaged() {} 32 | protected virtual void DisposeUnmanaged() {} 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Devices/XInputDevice.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Net.Sockets; 6 | using System.Runtime.InteropServices; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | 10 | namespace FestivalInstrumentMapper.Devices 11 | { 12 | 13 | internal class XInputDevice : InstrumentMapperDevice 14 | { 15 | private readonly int _playerIndex; 16 | private readonly XInputCapabilities _capabilities; 17 | private readonly bool _exists; 18 | 19 | public override bool Exists() 20 | { 21 | if (_exists) 22 | { 23 | // only report our existence if we're a guitar 24 | // regular gamepads only show up here for the sake of ViGEmBus and x360ce 25 | return _capabilities.SubType == XInputControllerSubType.Guitar || 26 | _capabilities.SubType == XInputControllerSubType.GuitarBass || 27 | _capabilities.SubType == XInputControllerSubType.GuitarAlternate || 28 | _capabilities.SubType == XInputControllerSubType.Gamepad; 29 | } 30 | return false; 31 | } 32 | 33 | public XInputDevice(int playerIndex) 34 | { 35 | _playerIndex = playerIndex; 36 | _exists = XInput.GetCapabilities(playerIndex, out _capabilities) == 0; 37 | } 38 | 39 | public override string ToString() 40 | { 41 | string device_name = _capabilities.SubType switch 42 | { 43 | XInputControllerSubType.Guitar => "Xbox 360 Rock Band Guitar", 44 | XInputControllerSubType.GuitarBass => "Xbox 360 Rock Band Bass", 45 | XInputControllerSubType.GuitarAlternate => "Xbox 360 Guitar Hero Guitar", 46 | XInputControllerSubType.Gamepad => "Xbox 360 Gamepad", 47 | _ => $"Xbox 360 Unsupported", 48 | }; 49 | return $"{device_name} ({_playerIndex + 1})"; 50 | } 51 | 52 | public override void Open() 53 | { 54 | // double check that we can actually read the controller 55 | if (XInput.GetCapabilities(_playerIndex, out _) != 0) 56 | throw new Exception($"Xbox 360 instrument with {_playerIndex} has been disconnected!"); 57 | } 58 | 59 | public override void Close() 60 | { 61 | // we have nothing to dispose of 62 | } 63 | 64 | public override ToGipAction GetGipConverter() 65 | { 66 | return _capabilities.SubType switch 67 | { 68 | XInputControllerSubType.GuitarAlternate or 69 | XInputControllerSubType.Gamepad => ToGip.XInput_GH, 70 | XInputControllerSubType.Guitar or 71 | XInputControllerSubType.GuitarBass => ToGip.XInput_RB, 72 | _ => throw new Exception($"Unhandled XInput subtype {_capabilities.SubType}") 73 | }; 74 | } 75 | 76 | public override int GetReadLength() => Marshal.SizeOf(typeof(XInputGamepad)); 77 | 78 | public override void Read(Span buffer) 79 | { 80 | // Sleep before reading to prevent a delay between read and conversion/send 81 | Thread.Sleep(1); 82 | 83 | if (XInput.GetStateEx(_playerIndex, out var state) != 0) 84 | throw new Exception($"Xbox 360 instrument with {_playerIndex} has been disconnected!"); 85 | 86 | MemoryMarshal.Write(buffer, state.Gamepad); 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /EpicLauncherDetection.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Text.Json; 6 | using System.Threading.Tasks; 7 | 8 | namespace FestivalInstrumentMapper 9 | { 10 | internal class EGLManifest 11 | { 12 | public int FormatVersion { get; set; } 13 | public bool bIsIncompleteInstall { get; set; } 14 | public string? LaunchCommand { get; set; } 15 | public string? LaunchExecutable { get; set; } 16 | public string? ManifestLocation { get; set; } 17 | public string? ManifestHash { get; set; } 18 | public bool bIsApplication { get; set; } 19 | public bool bIsExecutable { get; set; } 20 | public bool bIsManaged { get; set; } 21 | public bool bNeedsValidation { get; set; } 22 | public bool bRequiresAuth { get; set; } 23 | public bool bAllowMultipleInstances { get; set; } 24 | public bool bCanRunOffline { get; set; } 25 | public bool bAllowUriCmdArgs { get; set; } 26 | public string[]? BaseURLs { get; set; } 27 | public string? BuildLabel { get; set; } 28 | public string[]? AppCategories { get; set; } 29 | public object[]? ChunkDbs { get; set; } 30 | public object[]? CompatibleApps { get; set; } 31 | public string? DisplayName { get; set; } 32 | public string? InstallationGuid { get; set; } 33 | public string? InstallLocation { get; set; } 34 | public string? InstallSessionId { get; set; } 35 | public object[]? InstallTags { get; set; } 36 | public object[]? InstallComponents { get; set; } 37 | public string? HostInstallationGuid { get; set; } 38 | public object[]? PrereqIds { get; set; } 39 | public string? PrereqSHA1Hash { get; set; } 40 | public string? LastPrereqSucceededSHA1Hash { get; set; } 41 | public string? StagingLocation { get; set; } 42 | public string? TechnicalType { get; set; } 43 | public string? VaultThumbnailUrl { get; set; } 44 | public string? VaultTitleText { get; set; } 45 | public long InstallSize { get; set; } 46 | public string? MainWindowProcessName { get; set; } 47 | public string[]? ProcessNames { get; set; } 48 | public string[]? BackgroundProcessNames { get; set; } 49 | public string? MandatoryAppFolderName { get; set; } 50 | public string? OwnershipToken { get; set; } 51 | public string? CatalogNamespace { get; set; } 52 | public string? CatalogItemId { get; set; } 53 | public string? AppName { get; set; } 54 | public string? AppVersionString { get; set; } 55 | public string? MainGameCatalogNamespace { get; set; } 56 | public string? MainGameCatalogItemId { get; set; } 57 | public string? MainGameAppName { get; set; } 58 | public string[]? AllowedUriEnvVars { get; set; } 59 | } 60 | 61 | internal class EpicLauncherDetection 62 | { 63 | public static string? GetInstallDirectory(string appName, string exeName) 64 | { 65 | string manifestFolder = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + 66 | "/Epic/EpicGamesLauncher/Data/Manifests"; 67 | IEnumerable files; 68 | try 69 | { 70 | files = Directory.EnumerateFiles(manifestFolder); 71 | } 72 | catch 73 | { 74 | return null; 75 | } 76 | foreach (string file in files) 77 | { 78 | try 79 | { 80 | string jsonstring = File.ReadAllText(file); 81 | EGLManifest? manifest = JsonSerializer.Deserialize(jsonstring); 82 | if (manifest != null && manifest.AppName != null && 83 | manifest.AppName.ToLower() == appName.ToLower() && 84 | File.Exists(Path.Combine(manifest!.InstallLocation!, exeName))) 85 | { 86 | return manifest!.InstallLocation; 87 | } 88 | } 89 | catch { } 90 | } 91 | return null; 92 | } 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /FestivalInstrumentMapper.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | WinExe 5 | net8.0-windows 6 | enable 7 | true 8 | enable 9 | true 10 | AnyCPU;x64 11 | festivalinstrumentmapper.ico 12 | app.manifest 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | all 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /FestivalInstrumentMapper.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.9.34701.34 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FestivalInstrumentMapper", "FestivalInstrumentMapper.csproj", "{38E066EA-A173-4E86-9E51-3CA580FFB436}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Debug|x64 = Debug|x64 12 | Release|Any CPU = Release|Any CPU 13 | Release|x64 = Release|x64 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {38E066EA-A173-4E86-9E51-3CA580FFB436}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {38E066EA-A173-4E86-9E51-3CA580FFB436}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {38E066EA-A173-4E86-9E51-3CA580FFB436}.Debug|x64.ActiveCfg = Debug|x64 19 | {38E066EA-A173-4E86-9E51-3CA580FFB436}.Debug|x64.Build.0 = Debug|x64 20 | {38E066EA-A173-4E86-9E51-3CA580FFB436}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {38E066EA-A173-4E86-9E51-3CA580FFB436}.Release|Any CPU.Build.0 = Release|Any CPU 22 | {38E066EA-A173-4E86-9E51-3CA580FFB436}.Release|x64.ActiveCfg = Release|x64 23 | {38E066EA-A173-4E86-9E51-3CA580FFB436}.Release|x64.Build.0 = Release|x64 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {57811FAB-7D7F-4497-B76B-90A2C47B6A0E} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /HeroicLauncherDetection.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net.Http.Json; 5 | using System.Text; 6 | using System.Text.Json; 7 | using System.Text.Json.Serialization; 8 | using System.Threading.Tasks; 9 | 10 | namespace FestivalInstrumentMapper 11 | { 12 | internal class LegendaryUninstallerManifest 13 | { 14 | [JsonPropertyName("args")] 15 | public string? Args { get; set; } 16 | [JsonPropertyName("path")] 17 | public string? Path { get; set; } 18 | } 19 | 20 | internal class LegendaryManifest 21 | { 22 | [JsonPropertyName("app_name")] 23 | public string? AppName { get; set; } 24 | [JsonPropertyName("base_urls")] 25 | public string[]? BaseURLs { get; set; } 26 | [JsonPropertyName("can_run_offline")] 27 | public bool CanRunOffline { get; set; } 28 | [JsonPropertyName("egl_guid")] 29 | public string? EGLGUID { get; set; } 30 | [JsonPropertyName("executable")] 31 | public string? Executable { get; set; } 32 | [JsonPropertyName("install_path")] 33 | public string? InstallPath { get; set; } 34 | [JsonPropertyName("install_size")] 35 | public long InstallSize { get; set; } 36 | [JsonPropertyName("install_tags")] 37 | public string[]? InstallTags { get; set; } 38 | [JsonPropertyName("is_dlc")] 39 | public bool IsDLC { get; set; } 40 | [JsonPropertyName("launch_parameters")] 41 | public string? LaunchParameters { get; set; } 42 | [JsonPropertyName("manifest_path")] 43 | public string? ManifestPath { get; set; } 44 | [JsonPropertyName("needs_verification")] 45 | public bool NeedsVerification { get; set; } 46 | [JsonPropertyName("platform")] 47 | public string? Platform { get; set; } 48 | [JsonPropertyName("prereq_info")] 49 | public string? PrereqInfo { get; set; } 50 | [JsonPropertyName("requires_ot")] 51 | public bool RequiresOT { get; set; } 52 | [JsonPropertyName("save_path")] 53 | public string? SavePath { get; set; } 54 | [JsonPropertyName("title")] 55 | public string? Title { get; set; } 56 | [JsonPropertyName("uninstaller")] 57 | public LegendaryUninstallerManifest? Uninstaller { get; set; } 58 | [JsonPropertyName("version")] 59 | public string? Version { get; set; } 60 | } 61 | 62 | internal class HeroicLauncherDetection 63 | { 64 | public static string? GetInstallDirectory(string appName) 65 | { 66 | string heroicInstallData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + 67 | "/heroic/legendaryConfig/legendary/installed.json"; 68 | var heroicGames = new Dictionary(); 69 | 70 | try 71 | { 72 | heroicGames = JsonSerializer.Deserialize>(File.ReadAllText(heroicInstallData)); 73 | } 74 | catch 75 | { 76 | return null; 77 | } 78 | 79 | if (heroicGames == null || heroicGames?.Count == 0) 80 | return null; 81 | 82 | var gameInstall = heroicGames?.FirstOrDefault(x => x.Key.Equals(appName, StringComparison.OrdinalIgnoreCase)); 83 | 84 | if (Directory.Exists(gameInstall?.Value.InstallPath)) 85 | return gameInstall?.Value.InstallPath; 86 | else 87 | return null; 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /HidHideConfigWindow.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace FestivalInstrumentMapper 2 | { 3 | partial class HidHideConfigWindow 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | infoLabel = new Label(); 32 | hidHideConfigBox = new CheckBox(); 33 | hidHideConfigLabel = new Label(); 34 | doneButton = new Button(); 35 | installHidHideLink = new LinkLabel(); 36 | refreshBlacklistButton = new Button(); 37 | SuspendLayout(); 38 | // 39 | // infoLabel 40 | // 41 | infoLabel.Location = new Point(12, 9); 42 | infoLabel.Name = "infoLabel"; 43 | infoLabel.Size = new Size(344, 71); 44 | infoLabel.TabIndex = 2; 45 | infoLabel.Text = "If you're running into Fortnite detecting 2 controllers when using FestivalInstrumentMapper with Xbox 360 instruments, you can configure HidHide to always hide Xbox 360 controllers from Fortnite."; 46 | // 47 | // hidHideConfigBox 48 | // 49 | hidHideConfigBox.AutoSize = true; 50 | hidHideConfigBox.Location = new Point(12, 83); 51 | hidHideConfigBox.Name = "hidHideConfigBox"; 52 | hidHideConfigBox.Size = new Size(313, 19); 53 | hidHideConfigBox.TabIndex = 3; 54 | hidHideConfigBox.Text = "Tell HidHide to hide Xbox 360 controllers from Fortnite"; 55 | hidHideConfigBox.UseVisualStyleBackColor = true; 56 | hidHideConfigBox.CheckedChanged += hidHideConfigBox_CheckedChanged; 57 | // 58 | // hidHideConfigLabel 59 | // 60 | hidHideConfigLabel.Location = new Point(29, 103); 61 | hidHideConfigLabel.Name = "hidHideConfigLabel"; 62 | hidHideConfigLabel.Size = new Size(326, 63); 63 | hidHideConfigLabel.TabIndex = 4; 64 | hidHideConfigLabel.Text = "Enabling or disabling this setting will override all existing HidHide settings. You may need to reconnect your controller for changes to take effect."; 65 | // 66 | // doneButton 67 | // 68 | doneButton.Location = new Point(280, 169); 69 | doneButton.Name = "doneButton"; 70 | doneButton.Size = new Size(75, 23); 71 | doneButton.TabIndex = 5; 72 | doneButton.Text = "Done"; 73 | doneButton.UseVisualStyleBackColor = true; 74 | doneButton.Click += doneButton_Click; 75 | // 76 | // installHidHideLink 77 | // 78 | installHidHideLink.AutoSize = true; 79 | installHidHideLink.Location = new Point(12, 173); 80 | installHidHideLink.Name = "installHidHideLink"; 81 | installHidHideLink.Size = new Size(85, 15); 82 | installHidHideLink.TabIndex = 6; 83 | installHidHideLink.TabStop = true; 84 | installHidHideLink.Text = "Install HidHide"; 85 | installHidHideLink.Visible = false; 86 | installHidHideLink.LinkClicked += installHidHideLink_LinkClicked; 87 | // 88 | // refreshBlacklistButton 89 | // 90 | refreshBlacklistButton.Location = new Point(145, 169); 91 | refreshBlacklistButton.Name = "refreshBlacklistButton"; 92 | refreshBlacklistButton.Size = new Size(129, 23); 93 | refreshBlacklistButton.TabIndex = 7; 94 | refreshBlacklistButton.Text = "Refresh Blacklist..."; 95 | refreshBlacklistButton.UseVisualStyleBackColor = true; 96 | refreshBlacklistButton.Visible = false; 97 | refreshBlacklistButton.Click += refreshBlacklistButton_Click; 98 | // 99 | // HidHideConfigWindow 100 | // 101 | AcceptButton = doneButton; 102 | AutoScaleDimensions = new SizeF(7F, 15F); 103 | AutoScaleMode = AutoScaleMode.Font; 104 | ClientSize = new Size(368, 201); 105 | Controls.Add(refreshBlacklistButton); 106 | Controls.Add(installHidHideLink); 107 | Controls.Add(doneButton); 108 | Controls.Add(hidHideConfigLabel); 109 | Controls.Add(hidHideConfigBox); 110 | Controls.Add(infoLabel); 111 | FormBorderStyle = FormBorderStyle.FixedDialog; 112 | MaximizeBox = false; 113 | MinimizeBox = false; 114 | Name = "HidHideConfigWindow"; 115 | StartPosition = FormStartPosition.CenterParent; 116 | Text = "Configure HidHide for Fortnite Festival"; 117 | Load += HidHideConfigWindow_Load; 118 | ResumeLayout(false); 119 | PerformLayout(); 120 | } 121 | 122 | #endregion 123 | private Label infoLabel; 124 | private CheckBox hidHideConfigBox; 125 | private Label hidHideConfigLabel; 126 | private Button doneButton; 127 | private LinkLabel installHidHideLink; 128 | private Button refreshBlacklistButton; 129 | } 130 | } -------------------------------------------------------------------------------- /HidHideConfigWindow.cs: -------------------------------------------------------------------------------- 1 | using Nefarius.Drivers.HidHide; 2 | using Nefarius.Utilities.DeviceManagement.PnP; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.ComponentModel; 6 | using System.Data; 7 | using System.Diagnostics; 8 | using System.Drawing; 9 | using System.Linq; 10 | using System.Security.Policy; 11 | using System.Text; 12 | using System.Threading.Tasks; 13 | using System.Windows.Forms; 14 | 15 | namespace FestivalInstrumentMapper 16 | { 17 | public partial class HidHideConfigWindow : Form 18 | { 19 | HidHideControlService hidHide = new HidHideControlService(); 20 | string? fortniteExePath = null; 21 | 22 | public HidHideConfigWindow() 23 | { 24 | InitializeComponent(); 25 | } 26 | 27 | private void doneButton_Click(object sender, EventArgs e) 28 | { 29 | Close(); 30 | } 31 | 32 | private void installHidHideLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 33 | { 34 | Process.Start(new ProcessStartInfo("https://github.com/nefarius/HidHide/releases/latest") { UseShellExecute = true }); 35 | } 36 | 37 | private bool IsHidHideSetUpForUs() 38 | { 39 | bool listHasFortniteGame = false; 40 | IReadOnlyList blacklistedApps = hidHide.ApplicationPaths; 41 | foreach (string app in blacklistedApps) 42 | if (app.ToLower().EndsWith("fortniteclient-win64-shipping.exe")) 43 | listHasFortniteGame = true; 44 | return listHasFortniteGame && hidHide.IsActive && hidHide.IsAppListInverted; 45 | } 46 | 47 | public static IEnumerable EnumerateXUSBDevices() 48 | { 49 | for (int i = 0; 50 | Devcon.FindByInterfaceGuid(DeviceInterfaceIds.XUsbDevice, out string _, out string instanceId, i); 51 | i++) 52 | { 53 | yield return instanceId; 54 | } 55 | } 56 | 57 | private void RefreshBlacklistedInstanceIDs() 58 | { 59 | hidHide.ClearBlockedInstancesList(); 60 | foreach (string device in EnumerateXUSBDevices()) 61 | hidHide.AddBlockedInstanceId(device); 62 | } 63 | 64 | private void SetUpHidHideForUs() 65 | { 66 | // I'm really sorry, this is just "the most convinient" way. 67 | // Removes all HidHide settings. I hope I give enough advance warning... :( 68 | hidHide.ClearApplicationsList(); 69 | // Sets up the app list to be inverted and add exclusively the FortniteGame exe. 70 | hidHide.IsAppListInverted = true; 71 | hidHide.AddApplicationPath(fortniteExePath!); 72 | // Reloads our list of blacklisted instance IDs 73 | RefreshBlacklistedInstanceIDs(); 74 | // Enables HidHide 75 | hidHide.IsActive = true; 76 | } 77 | 78 | private void DisableHidHideForUs() 79 | { 80 | hidHide.RemoveApplicationPath(fortniteExePath!); 81 | foreach (string device in EnumerateXUSBDevices()) 82 | hidHide.RemoveBlockedInstanceId(device); 83 | } 84 | 85 | private void HidHideConfigWindow_Load(object sender, EventArgs e) 86 | { 87 | if (!hidHide.IsInstalled) 88 | { 89 | hidHideConfigBox.Enabled = false; 90 | hidHideConfigLabel.Text = "This option can't be enabled as you don't have HidHide installed. Click the link below to download and install HidHide."; 91 | installHidHideLink.Visible = true; 92 | return; 93 | } 94 | 95 | // Check EGL first, then Heroic 96 | string? fortniteInstallDir = EpicLauncherDetection.GetInstallDirectory("Fortnite", "FortniteGame\\Binaries\\Win64\\FortniteClient-Win64-Shipping.exe"); 97 | fortniteInstallDir ??= HeroicLauncherDetection.GetInstallDirectory("Fortnite"); 98 | 99 | if (fortniteInstallDir == null) 100 | { 101 | hidHideConfigBox.Enabled = false; 102 | hidHideConfigLabel.Text = "This option can't be enabled because we can't find a Fortnite installation."; 103 | return; 104 | } 105 | fortniteExePath = Path.GetFullPath(Path.Combine(fortniteInstallDir, "FortniteGame\\Binaries\\Win64\\FortniteClient-Win64-Shipping.exe")); 106 | 107 | hidHideConfigBox.Checked = IsHidHideSetUpForUs(); 108 | refreshBlacklistButton.Visible = hidHideConfigBox.Checked; 109 | } 110 | 111 | private void hidHideConfigBox_CheckedChanged(object sender, EventArgs e) 112 | { 113 | if (hidHideConfigBox.Checked) 114 | SetUpHidHideForUs(); 115 | else 116 | DisableHidHideForUs(); 117 | refreshBlacklistButton.Visible = hidHideConfigBox.Checked; 118 | } 119 | 120 | private void refreshBlacklistButton_Click(object sender, EventArgs e) 121 | { 122 | RefreshBlacklistedInstanceIDs(); 123 | } 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /HidHideConfigWindow.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /MainWindow/MainWindow.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace FestivalInstrumentMapper 2 | { 3 | partial class MainWindow 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | components = new System.ComponentModel.Container(); 32 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainWindow)); 33 | deviceSelectPreLabel = new Label(); 34 | deviceSelectBox = new ComboBox(); 35 | statusGroupBox = new GroupBox(); 36 | statusLabel = new Label(); 37 | windowsVersionLabel = new Label(); 38 | startMappingButton = new Button(); 39 | faqAboutLinkLabel = new LinkLabel(); 40 | githubLinkLabel = new LinkLabel(); 41 | faqAboutNagLabel = new Label(); 42 | gayLabel = new Label(); 43 | refreshListButton = new Button(); 44 | disconnectMonitorTimer = new System.Windows.Forms.Timer(components); 45 | hidHideLinkLabel = new LinkLabel(); 46 | useSelectForTiltCheckbox = new CheckBox(); 47 | statusGroupBox.SuspendLayout(); 48 | SuspendLayout(); 49 | // 50 | // deviceSelectPreLabel 51 | // 52 | deviceSelectPreLabel.AutoSize = true; 53 | deviceSelectPreLabel.Location = new Point(12, 15); 54 | deviceSelectPreLabel.Name = "deviceSelectPreLabel"; 55 | deviceSelectPreLabel.Size = new Size(79, 15); 56 | deviceSelectPreLabel.TabIndex = 0; 57 | deviceSelectPreLabel.Text = "Select Device:"; 58 | // 59 | // deviceSelectBox 60 | // 61 | deviceSelectBox.DropDownStyle = ComboBoxStyle.DropDownList; 62 | deviceSelectBox.FormattingEnabled = true; 63 | deviceSelectBox.Location = new Point(97, 12); 64 | deviceSelectBox.Name = "deviceSelectBox"; 65 | deviceSelectBox.Size = new Size(196, 23); 66 | deviceSelectBox.TabIndex = 1; 67 | // 68 | // statusGroupBox 69 | // 70 | statusGroupBox.Controls.Add(statusLabel); 71 | statusGroupBox.Controls.Add(windowsVersionLabel); 72 | statusGroupBox.Location = new Point(12, 165); 73 | statusGroupBox.Name = "statusGroupBox"; 74 | statusGroupBox.Size = new Size(350, 100); 75 | statusGroupBox.TabIndex = 3; 76 | statusGroupBox.TabStop = false; 77 | statusGroupBox.Text = "Status and Stats"; 78 | // 79 | // statusLabel 80 | // 81 | statusLabel.Location = new Point(6, 19); 82 | statusLabel.Name = "statusLabel"; 83 | statusLabel.Size = new Size(338, 60); 84 | statusLabel.TabIndex = 1; 85 | statusLabel.Text = "Some status goes here!"; 86 | // 87 | // windowsVersionLabel 88 | // 89 | windowsVersionLabel.AutoSize = true; 90 | windowsVersionLabel.Location = new Point(6, 79); 91 | windowsVersionLabel.Name = "windowsVersionLabel"; 92 | windowsVersionLabel.Size = new Size(149, 15); 93 | windowsVersionLabel.TabIndex = 0; 94 | windowsVersionLabel.Text = "Windows: 99.99.99999.9999"; 95 | // 96 | // startMappingButton 97 | // 98 | startMappingButton.Location = new Point(255, 38); 99 | startMappingButton.Name = "startMappingButton"; 100 | startMappingButton.Size = new Size(107, 23); 101 | startMappingButton.TabIndex = 4; 102 | startMappingButton.Text = "Start Mapping"; 103 | startMappingButton.UseVisualStyleBackColor = true; 104 | startMappingButton.Click += startMappingButton_Click; 105 | // 106 | // faqAboutLinkLabel 107 | // 108 | faqAboutLinkLabel.AutoSize = true; 109 | faqAboutLinkLabel.Location = new Point(12, 100); 110 | faqAboutLinkLabel.Name = "faqAboutLinkLabel"; 111 | faqAboutLinkLabel.Size = new Size(88, 15); 112 | faqAboutLinkLabel.TabIndex = 5; 113 | faqAboutLinkLabel.TabStop = true; 114 | faqAboutLinkLabel.Text = "FAQ and About"; 115 | faqAboutLinkLabel.LinkClicked += faqAboutLinkLabel_LinkClicked; 116 | // 117 | // githubLinkLabel 118 | // 119 | githubLinkLabel.AutoSize = true; 120 | githubLinkLabel.Location = new Point(12, 141); 121 | githubLinkLabel.Name = "githubLinkLabel"; 122 | githubLinkLabel.Size = new Size(347, 15); 123 | githubLinkLabel.TabIndex = 6; 124 | githubLinkLabel.TabStop = true; 125 | githubLinkLabel.Text = "https://github.com/InvoxiPlayGames/FestivalInstrumentMapper"; 126 | githubLinkLabel.LinkClicked += githubLinkLabel_LinkClicked; 127 | // 128 | // faqAboutNagLabel 129 | // 130 | faqAboutNagLabel.AutoSize = true; 131 | faqAboutNagLabel.Location = new Point(97, 100); 132 | faqAboutNagLabel.Name = "faqAboutNagLabel"; 133 | faqAboutNagLabel.Size = new Size(160, 15); 134 | faqAboutNagLabel.TabIndex = 7; 135 | faqAboutNagLabel.Text = "<- click this if you need help!"; 136 | // 137 | // gayLabel 138 | // 139 | gayLabel.AutoSize = true; 140 | gayLabel.Location = new Point(12, 126); 141 | gayLabel.Name = "gayLabel"; 142 | gayLabel.Size = new Size(339, 15); 143 | gayLabel.TabIndex = 8; 144 | gayLabel.Text = "This is Free Software, made with <3 by Emma and contributors."; 145 | // 146 | // refreshListButton 147 | // 148 | refreshListButton.Location = new Point(299, 12); 149 | refreshListButton.Name = "refreshListButton"; 150 | refreshListButton.Size = new Size(63, 23); 151 | refreshListButton.TabIndex = 9; 152 | refreshListButton.Text = "Refresh..."; 153 | refreshListButton.UseVisualStyleBackColor = true; 154 | refreshListButton.Click += refreshListButton_Click; 155 | // 156 | // disconnectMonitorTimer 157 | // 158 | disconnectMonitorTimer.Interval = 1000; 159 | disconnectMonitorTimer.Tick += disconnectMonitorTimer_Tick; 160 | // 161 | // hidHideLinkLabel 162 | // 163 | hidHideLinkLabel.AutoSize = true; 164 | hidHideLinkLabel.Location = new Point(12, 42); 165 | hidHideLinkLabel.Name = "hidHideLinkLabel"; 166 | hidHideLinkLabel.Size = new Size(186, 15); 167 | hidHideLinkLabel.TabIndex = 10; 168 | hidHideLinkLabel.TabStop = true; 169 | hidHideLinkLabel.Text = "Set up Xbox 360 Controller Hiding"; 170 | hidHideLinkLabel.LinkClicked += hidHideLinkLabel_LinkClicked; 171 | // 172 | // useSelectForTiltCheckbox 173 | // 174 | useSelectForTiltCheckbox.AutoSize = true; 175 | useSelectForTiltCheckbox.Location = new Point(12, 69); 176 | useSelectForTiltCheckbox.Name = "useSelectForTiltCheckbox"; 177 | useSelectForTiltCheckbox.Size = new Size(233, 19); 178 | useSelectForTiltCheckbox.TabIndex = 11; 179 | useSelectForTiltCheckbox.Text = "Disable Tilt and use Select for Overdrive"; 180 | useSelectForTiltCheckbox.UseVisualStyleBackColor = true; 181 | // 182 | // MainWindow 183 | // 184 | AutoScaleDimensions = new SizeF(7F, 15F); 185 | AutoScaleMode = AutoScaleMode.Font; 186 | ClientSize = new Size(374, 276); 187 | Controls.Add(useSelectForTiltCheckbox); 188 | Controls.Add(hidHideLinkLabel); 189 | Controls.Add(refreshListButton); 190 | Controls.Add(gayLabel); 191 | Controls.Add(faqAboutNagLabel); 192 | Controls.Add(githubLinkLabel); 193 | Controls.Add(faqAboutLinkLabel); 194 | Controls.Add(startMappingButton); 195 | Controls.Add(statusGroupBox); 196 | Controls.Add(deviceSelectBox); 197 | Controls.Add(deviceSelectPreLabel); 198 | FormBorderStyle = FormBorderStyle.FixedSingle; 199 | Icon = (Icon)resources.GetObject("$this.Icon"); 200 | MaximizeBox = false; 201 | Name = "MainWindow"; 202 | StartPosition = FormStartPosition.CenterScreen; 203 | Text = "FestivalInstrumentMapper Beta 4"; 204 | FormClosing += MainWindow_FormClosing; 205 | Load += MainWindow_Load; 206 | statusGroupBox.ResumeLayout(false); 207 | statusGroupBox.PerformLayout(); 208 | ResumeLayout(false); 209 | PerformLayout(); 210 | } 211 | 212 | #endregion 213 | 214 | private Label deviceSelectPreLabel; 215 | private ComboBox deviceSelectBox; 216 | private GroupBox statusGroupBox; 217 | private Label windowsVersionLabel; 218 | private Button startMappingButton; 219 | private Label statusLabel; 220 | private LinkLabel faqAboutLinkLabel; 221 | private LinkLabel githubLinkLabel; 222 | private Label faqAboutNagLabel; 223 | private Label gayLabel; 224 | private Button refreshListButton; 225 | private System.Windows.Forms.Timer disconnectMonitorTimer; 226 | private LinkLabel hidHideLinkLabel; 227 | private CheckBox useSelectForTiltCheckbox; 228 | } 229 | } 230 | -------------------------------------------------------------------------------- /MainWindow/MainWindow.cs: -------------------------------------------------------------------------------- 1 | using FestivalInstrumentMapper.Devices; 2 | using System.Diagnostics; 3 | 4 | namespace FestivalInstrumentMapper 5 | { 6 | public partial class MainWindow : Form 7 | { 8 | private MapperThread? mapperThread = null; 9 | 10 | public MainWindow() 11 | { 12 | InitializeComponent(); 13 | } 14 | 15 | private void RefreshDevicesList() 16 | { 17 | deviceSelectBox.Items.Clear(); 18 | 19 | List<(ushort vendorId, ushort productId)> filterIds = 20 | [ 21 | // PS3 Guitars 22 | (0x12BA, 0x0100), 23 | (0x12BA, 0x0200), 24 | // Wii Guitars 25 | (0x1BAD, 0x0004), 26 | (0x1BAD, 0x3010), 27 | // Santroller 28 | (0x1209, 0x2882), 29 | // PS4 Guitars 30 | (0x0E6F, 0x0173), 31 | (0x0E6F, 0x024A), 32 | (0x0738, 0x8261), 33 | // PS5 Guitars 34 | (0x0E6F, 0x0249), 35 | // Raphnet 36 | (0x289B, 0x0028), 37 | (0x289B, 0x0029), 38 | (0x289B, 0x002B), 39 | (0x289B, 0x002C), 40 | (0x289B, 0x0080), 41 | (0x289B, 0x0081) 42 | ]; 43 | 44 | var enumeratedHidDevices = HidDeviceStream.Enumerate(filterIds); 45 | 46 | foreach (var enumeratedDevice in enumeratedHidDevices) 47 | { 48 | HidApiDevice hidApiDevice = new(enumeratedDevice); 49 | deviceSelectBox.Items.Add(hidApiDevice); 50 | } 51 | 52 | for (int i = 0; i < 4; i++) 53 | { 54 | XInputDevice xinputDevice = new(i); 55 | if (xinputDevice.Exists()) 56 | deviceSelectBox.Items.Add(xinputDevice); 57 | } 58 | 59 | if (deviceSelectBox.Items.Count <= 0) 60 | { 61 | deviceSelectBox.Items.Add("No devices found!"); 62 | deviceSelectBox.SelectedIndex = 0; 63 | deviceSelectBox.Enabled = false; 64 | startMappingButton.Enabled = false; 65 | return; 66 | } 67 | 68 | deviceSelectBox.SelectedIndex = 0; 69 | deviceSelectBox.Enabled = true; 70 | startMappingButton.Enabled = true; 71 | } 72 | 73 | private void startMappingButton_Click(object sender, EventArgs e) 74 | { 75 | if (deviceSelectBox.SelectedIndex >= 0) 76 | { 77 | var selectedDevice = (InstrumentMapperDevice?)deviceSelectBox.SelectedItem; 78 | if (selectedDevice == null) 79 | { 80 | MessageBox.Show("Couldn't open the device!"); 81 | return; 82 | } 83 | 84 | try 85 | { 86 | var synthController = new SyntheticController(); 87 | synthController.SetData(PDPJaguarValues.Arrival, PDPJaguarValues.Metadata); 88 | mapperThread = new(selectedDevice, synthController); 89 | mapperThread.RemapSelectToTilt = useSelectForTiltCheckbox.Checked; 90 | mapperThread.Start(); 91 | } 92 | catch (Exception ex) 93 | { 94 | mapperThread?.Dispose(); 95 | mapperThread = null; 96 | 97 | statusLabel.Text = $"Failed to initialise emulated controller.\nException: {ex.Message}"; 98 | // detect STATUS_ACCESS_DENIED and give a helpful hint 99 | if (ex.Message.Contains("80070005")) 100 | statusLabel.Text += "\nHave you enabled Windows Developer Mode?"; 101 | startMappingButton.Enabled = false; 102 | refreshListButton.Enabled = false; 103 | deviceSelectBox.Enabled = false; 104 | startMappingButton.Text = "Error :("; 105 | return; 106 | } 107 | 108 | startMappingButton.Enabled = false; 109 | refreshListButton.Enabled = false; 110 | deviceSelectBox.Enabled = false; 111 | hidHideLinkLabel.Enabled = false; 112 | useSelectForTiltCheckbox.Enabled = false; 113 | startMappingButton.Text = "Mapped!"; 114 | statusLabel.Text = $"Guitar is now mapped!\nPress the PS/Instrument/Guide button, or both select and start, on your guitar to disconnect."; 115 | disconnectMonitorTimer.Enabled = true; 116 | } 117 | else 118 | { 119 | MessageBox.Show("Please select a device first!"); 120 | } 121 | } 122 | 123 | private void MainWindow_Load(object sender, EventArgs e) 124 | { 125 | AppDomain.CurrentDomain.UnhandledException += OnUnhandledException; 126 | 127 | windowsVersionLabel.Text = $"Windows: {Environment.OSVersion.Version}"; 128 | try 129 | { 130 | int synthstartup_result = GipSyntheticEx.Startup(); 131 | if (synthstartup_result != 0) 132 | { 133 | statusLabel.Text = $"Failed to initialise GipSyntheticEx. ({synthstartup_result:X8})\nEither your Windows version is unsupported, or an error has occurred."; 134 | startMappingButton.Enabled = false; 135 | refreshListButton.Enabled = false; 136 | deviceSelectBox.Enabled = false; 137 | startMappingButton.Text = "Error :("; 138 | return; 139 | } 140 | } 141 | catch (Exception ex) 142 | { 143 | statusLabel.Text = $"Failed to initialise GipSyntheticEx.\nException: {ex.Message}"; 144 | startMappingButton.Enabled = false; 145 | refreshListButton.Enabled = false; 146 | deviceSelectBox.Enabled = false; 147 | startMappingButton.Text = "Error :("; 148 | return; 149 | } 150 | 151 | RefreshDevicesList(); 152 | statusLabel.Text = "Select your device from the list."; 153 | } 154 | 155 | private void OpenURL(string url) 156 | { 157 | Process.Start(new ProcessStartInfo(url) { UseShellExecute = true }); 158 | } 159 | 160 | private void githubLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 161 | { 162 | OpenURL("https://github.com/InvoxiPlayGames/FestivalInstrumentMapper"); 163 | } 164 | 165 | private void faqAboutLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 166 | { 167 | OpenURL("https://github.com/InvoxiPlayGames/FestivalInstrumentMapper/wiki/FAQ-and-About"); 168 | } 169 | 170 | private void refreshListButton_Click(object sender, EventArgs e) 171 | { 172 | RefreshDevicesList(); 173 | } 174 | 175 | private void disconnectMonitorTimer_Tick(object sender, EventArgs e) 176 | { 177 | if (mapperThread != null && !mapperThread.IsRunning) 178 | { 179 | mapperThread.Dispose(); 180 | mapperThread = null; 181 | 182 | startMappingButton.Enabled = true; 183 | refreshListButton.Enabled = true; 184 | deviceSelectBox.Enabled = true; 185 | hidHideLinkLabel.Enabled = true; 186 | useSelectForTiltCheckbox.Enabled = true; 187 | startMappingButton.Text = "Start Mapping"; 188 | statusLabel.Text = "Select your device from the list."; 189 | disconnectMonitorTimer.Enabled = false; 190 | } 191 | } 192 | 193 | private void hidHideLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 194 | { 195 | HidHideConfigWindow configWindow = new(); 196 | configWindow.ShowDialog(this); 197 | } 198 | 199 | private static void OnUnhandledException(object sender, UnhandledExceptionEventArgs args) 200 | { 201 | var exception = (Exception)args.ExceptionObject; 202 | 203 | string errorFile = Program.WriteErrorFile(exception); 204 | MessageBox.Show( 205 | $"An unhandled error has occurred:\n\n{exception.GetFirstLine()}\n\nPlease send the error log '{errorFile}' to the devs. The program will now exit.", 206 | "Fatal Error", 207 | MessageBoxButtons.OK, 208 | MessageBoxIcon.Error 209 | ); 210 | } 211 | 212 | private void MainWindow_FormClosing(object sender, FormClosingEventArgs e) 213 | { 214 | if (mapperThread != null) 215 | { 216 | // TODO(Emma): this hangs when using HID until the user clicks a button 217 | // mapperThread.Stop(); 218 | } 219 | } 220 | } 221 | } 222 | -------------------------------------------------------------------------------- /MainWindow/MapperThread.cs: -------------------------------------------------------------------------------- 1 | namespace FestivalInstrumentMapper 2 | { 3 | internal delegate void ToGipAction(ReadOnlySpan inputBuffer, Span gipBuffer); 4 | 5 | internal sealed class MapperThread 6 | { 7 | private readonly InstrumentMapperDevice _device; 8 | private readonly SyntheticController _controller; 9 | 10 | private volatile bool _shouldStop = false; 11 | private volatile Thread? _readThread = null; 12 | 13 | public bool IsRunning => _readThread != null; 14 | 15 | public bool RemapSelectToTilt = false; 16 | 17 | public MapperThread(InstrumentMapperDevice device, SyntheticController controller) 18 | { 19 | _device = device; 20 | _controller = controller; 21 | } 22 | 23 | public void Dispose() 24 | { 25 | Stop(); 26 | // Let's not take ownership of the device, it can last for more than one run 27 | // _device.Dispose(); 28 | _controller.Dispose(); 29 | } 30 | 31 | public void Start() 32 | { 33 | if (_readThread != null) 34 | return; 35 | 36 | _device.Open(); 37 | _controller.Connect(); 38 | 39 | _shouldStop = false; 40 | _readThread = new Thread(ReadThread) { IsBackground = true }; 41 | _readThread.Start(); 42 | } 43 | 44 | public void Stop() 45 | { 46 | if (_readThread == null) 47 | return; 48 | 49 | _shouldStop = true; 50 | _readThread.Join(); 51 | 52 | // Automatically done by the thread 53 | // _readThread = null; 54 | // _device.Close(); 55 | } 56 | 57 | private void ReadThread() 58 | { 59 | try 60 | { 61 | Span inputReport = new byte[_device.GetReadLength()]; 62 | Span gipReport = new byte[0xE]; 63 | ToGipAction toGip = _device.GetGipConverter(); 64 | 65 | while (!_shouldStop) 66 | { 67 | _device.Read(inputReport); 68 | toGip(inputReport, gipReport); 69 | 70 | // We use an unused bit in the GIP report to indicate the guide button, 71 | // which tells us to stop reading - we also check if Select+Start are held 72 | if ((gipReport[0] & 0x02) != 0 || (gipReport[0] & 0x0C) == 0x0C) 73 | { 74 | _shouldStop = true; 75 | gipReport[0] = 0x00; // last input shouldn't be sending buttons 76 | } 77 | 78 | // A set of hacks that remap Select to Tilt and disables tilt 79 | if (RemapSelectToTilt) 80 | { 81 | gipReport[3] = (byte)(((gipReport[0] & 0x08) == 0x08) ? 0xFF : 0x00); // tilt if select is held 82 | gipReport[0] &= 0xF7; // deselect select 83 | } 84 | _controller.SendData(gipReport); 85 | 86 | Thread.Yield(); 87 | } 88 | } 89 | catch (Exception ex) 90 | { 91 | string errorFile = Program.WriteErrorFile(ex); 92 | MessageBox.Show( 93 | $"Caught an unhandled mapping exception:\n\n{ex.GetFirstLine()}\n\nPlease send the error log '{errorFile}' to the devs.", 94 | "Mapping Error", 95 | MessageBoxButtons.OK, 96 | MessageBoxIcon.Warning 97 | ); 98 | } 99 | finally 100 | { 101 | _controller.Disconnect(); 102 | _device.Close(); 103 | _readThread = null; 104 | } 105 | } 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /Native/GipSyntheticEx.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace FestivalInstrumentMapper 4 | { 5 | internal static partial class GipSyntheticEx 6 | { 7 | private const string DllName = "GipSyntheticEx.dll"; 8 | 9 | [LibraryImport(DllName, EntryPoint = "GipSynthEx_Startup")] 10 | public static partial int Startup(); 11 | 12 | 13 | [LibraryImport(DllName, EntryPoint = "GipSynthEx_CreateController")] 14 | public static partial int CreateController(int type, ref ulong controller_handle); 15 | 16 | [LibraryImport(DllName, EntryPoint = "GipSynthEx_Connect")] 17 | public static partial int Connect(ulong controller_handle); 18 | 19 | [LibraryImport(DllName, EntryPoint = "GipSynthEx_ConnectEx")] 20 | public static partial int ConnectExNative(ulong controller_handle, ReadOnlySpan arrival, int arrival_size, ReadOnlySpan metadata, int metadata_size); 21 | 22 | public static int ConnectEx(ulong controller_handle, ReadOnlySpan arrival, ReadOnlySpan metadata) 23 | { 24 | return ConnectExNative(controller_handle, arrival, arrival.Length, metadata, metadata.Length); 25 | } 26 | 27 | [LibraryImport(DllName, EntryPoint = "GipSynthEx_SendReport")] 28 | public static partial int SendReportNative(ulong controller_handle, int report_type, ReadOnlySpan report_buf, int report_size); 29 | 30 | public static int SendReport(ulong controller_handle, ReadOnlySpan report_buf) 31 | { 32 | return SendReportNative(controller_handle, 0, report_buf, report_buf.Length); 33 | } 34 | 35 | [LibraryImport(DllName, EntryPoint = "GipSynthEx_Disconnect")] 36 | public static partial int Disconnect(ulong controller_handle); 37 | 38 | [LibraryImport(DllName, EntryPoint = "GipSynthEx_RemoveController")] 39 | public static partial int RemoveController(ulong controller_handle); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Native/HidDeviceStream.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using System.Runtime.InteropServices; 3 | using Microsoft.Win32.SafeHandles; 4 | using Nefarius.Utilities.DeviceManagement.PnP; 5 | using Windows.Win32; 6 | using Windows.Win32.Devices.HumanInterfaceDevice; 7 | using Windows.Win32.Foundation; 8 | using Windows.Win32.Storage.FileSystem; 9 | 10 | namespace FestivalInstrumentMapper 11 | { 12 | using static PInvoke; 13 | using static WIN32_ERROR; 14 | using static FILE_SHARE_MODE; 15 | using static FILE_CREATION_DISPOSITION; 16 | using static FILE_FLAGS_AND_ATTRIBUTES; 17 | 18 | public sealed class HidDeviceStream : IDisposable 19 | { 20 | private readonly string _path; 21 | private SafeFileHandle? _handle; 22 | 23 | private readonly EventWaitHandle _readWaitHandle = new(false, EventResetMode.AutoReset); 24 | private readonly EventWaitHandle _writeWaitHandle = new(false, EventResetMode.AutoReset); 25 | 26 | public ushort VendorId { get; } 27 | public ushort ProductId { get; } 28 | public ushort Revision { get; } 29 | 30 | public string? Serial { get; } 31 | 32 | public int InputLength { get; private set; } 33 | public int OutputLength { get; private set; } 34 | 35 | private HidDeviceStream(string path, HIDD_ATTRIBUTES attributes, HIDP_CAPS capabilities, string? serial) 36 | { 37 | _path = path; 38 | 39 | VendorId = attributes.VendorID; 40 | ProductId = attributes.ProductID; 41 | Revision = attributes.VersionNumber; 42 | 43 | Serial = serial; 44 | 45 | InputLength = capabilities.InputReportByteLength; 46 | OutputLength = capabilities.OutputReportByteLength; 47 | } 48 | 49 | public void Dispose() 50 | { 51 | _handle?.Close(); 52 | _handle = null; 53 | } 54 | 55 | public static IEnumerable Enumerate(List<(ushort vendorId, ushort productId)>? filterList) 56 | { 57 | for (int i = 0; 58 | Devcon.FindByInterfaceGuid(DeviceInterfaceIds.HidDevice, out string path, out _, i); 59 | i++) 60 | { 61 | // The HID devices created for XInput controllers have this in their device path 62 | if (path.Contains("IG_")) 63 | continue; 64 | 65 | if (!Open(path, exclusive: false, out var handle) || !GetHardwareIds(handle, out var attributes) || 66 | !GetCapabilities(handle, out var capabilities)) 67 | continue; 68 | 69 | // Skip devices that can't be read 70 | if (capabilities.InputReportByteLength < 1) 71 | continue; 72 | 73 | // Ignore devices not present in the filter 74 | if (filterList != null && !filterList.Any((id) => 75 | id.vendorId == attributes.VendorID && id.productId == attributes.ProductID)) 76 | continue; 77 | 78 | yield return new HidDeviceStream(path, attributes, capabilities, GetSerial(handle)); 79 | } 80 | } 81 | 82 | private static bool Open(string path, bool exclusive, out SafeFileHandle handle) 83 | { 84 | handle = CreateFile( 85 | path, 86 | (uint)(FILE_SHARE_READ | FILE_SHARE_WRITE), 87 | exclusive ? FILE_SHARE_NONE : (FILE_SHARE_READ | FILE_SHARE_WRITE), 88 | null, 89 | OPEN_EXISTING, 90 | FILE_FLAG_OVERLAPPED, 91 | null 92 | ); 93 | 94 | if (handle == null || handle.IsInvalid) 95 | { 96 | LogWin32Error("Failed to open HID device"); 97 | return false; 98 | } 99 | 100 | return true; 101 | } 102 | 103 | private static bool GetHardwareIds(SafeFileHandle handle, out HIDD_ATTRIBUTES attributes) 104 | { 105 | if (!HidD_GetAttributes(handle, out attributes)) 106 | { 107 | LogWin32Error("Could not get HID attributes"); 108 | attributes = default; 109 | return false; 110 | } 111 | 112 | return true; 113 | } 114 | 115 | private static bool GetCapabilities(SafeFileHandle handle, out HIDP_CAPS capabilities) 116 | { 117 | capabilities = default; 118 | 119 | if (!HidD_GetPreparsedData(handle, out var hidData) || hidData.Value == 0) 120 | { 121 | LogWin32Error("Could not get HID preparsed data"); 122 | return false; 123 | } 124 | 125 | var status = HidP_GetCaps(hidData, out capabilities); 126 | if (status < 0) // HRESULT, not Win32 error 127 | { 128 | LogWin32Error("Could not get HID capabilities", status); 129 | return false; 130 | } 131 | 132 | return true; 133 | } 134 | 135 | private static unsafe string? GetSerial(SafeFileHandle handle) 136 | { 137 | Span buffer = stackalloc char[4092 / 2]; // Buffer must be <= 4093 bytes 138 | fixed (char* ptr = buffer) 139 | { 140 | bool result = HidD_GetSerialNumberString(handle, ptr, (uint)(buffer.Length * sizeof(char))); 141 | if (!result && Marshal.GetLastPInvokeError() != 0) 142 | { 143 | LogWin32Error("Could not get HID serial number"); 144 | return null; 145 | } 146 | 147 | return new string(ptr); 148 | } 149 | } 150 | 151 | public bool Open(bool exclusive) 152 | { 153 | if (_handle != null && !_handle.IsInvalid) 154 | return true; 155 | 156 | return Open(_path, exclusive, out _handle); 157 | } 158 | 159 | private void CheckDisposed() 160 | { 161 | ObjectDisposedException.ThrowIf(_handle == null || _handle.IsInvalid, _handle); 162 | } 163 | 164 | public unsafe bool Read(Span buffer) 165 | { 166 | CheckDisposed(); 167 | 168 | if (buffer.Length < InputLength) 169 | return false; 170 | 171 | var overlapped = new NativeOverlapped() 172 | { 173 | EventHandle = _readWaitHandle.SafeWaitHandle.DangerousGetHandle() 174 | }; 175 | 176 | uint bytesRead; 177 | bool success = ReadFile(_handle, buffer, &bytesRead, &overlapped); 178 | 179 | WIN32_ERROR result = (WIN32_ERROR)Marshal.GetLastPInvokeError(); 180 | if (!success && result == ERROR_IO_PENDING) 181 | { 182 | _readWaitHandle.WaitOne(); 183 | success = GetOverlappedResult(_handle, in overlapped, out bytesRead, true); 184 | result = (WIN32_ERROR)Marshal.GetLastPInvokeError(); 185 | } 186 | 187 | if (!success && result != ERROR_SUCCESS) 188 | { 189 | LogWin32Error("Device read failed", result); 190 | return false; 191 | } 192 | 193 | SanityCheckResult(success, result); 194 | 195 | return bytesRead == InputLength; 196 | } 197 | 198 | public unsafe bool Write(Span buffer) 199 | { 200 | CheckDisposed(); 201 | 202 | if (buffer.Length > OutputLength) 203 | return false; 204 | 205 | Span writeBuffer = stackalloc byte[OutputLength]; 206 | buffer.CopyTo(writeBuffer); 207 | 208 | var overlapped = new NativeOverlapped 209 | { 210 | EventHandle = _writeWaitHandle.SafeWaitHandle.DangerousGetHandle() 211 | }; 212 | 213 | bool success = WriteFile(_handle, writeBuffer, null, &overlapped); 214 | 215 | WIN32_ERROR result = (WIN32_ERROR)Marshal.GetLastPInvokeError(); 216 | if (!success && result == ERROR_IO_PENDING) 217 | { 218 | _readWaitHandle.WaitOne(); 219 | success = GetOverlappedResult(_handle, in overlapped, out _, true); 220 | result = (WIN32_ERROR)Marshal.GetLastPInvokeError(); 221 | } 222 | 223 | if (!success && result != ERROR_SUCCESS) 224 | { 225 | LogWin32Error("Device write failed", result); 226 | return false; 227 | } 228 | 229 | SanityCheckResult(success, result); 230 | 231 | return true; 232 | } 233 | 234 | [Conditional("DEBUG")] 235 | private static void LogWin32Error(string message) 236 | => LogWin32Error(message, Marshal.GetLastPInvokeError()); 237 | 238 | [Conditional("DEBUG")] 239 | private static void LogWin32Error(string message, WIN32_ERROR result) 240 | => LogWin32Error(message, (int)result); 241 | 242 | [Conditional("DEBUG")] 243 | private static void LogWin32Error(string message, int result) 244 | { 245 | Debug.Write(message); 246 | Debug.WriteLine($": {Marshal.GetPInvokeErrorMessage(result)} ({result})"); 247 | } 248 | 249 | [Conditional("DEBUG")] 250 | private static void SanityCheckResult(bool success, WIN32_ERROR result) 251 | { 252 | if (!success && result != ERROR_SUCCESS) 253 | return; 254 | 255 | if (!success) 256 | Debug.WriteLine("Result was failure but GetLastPInvokeError returned success"); 257 | else if (result != ERROR_SUCCESS) 258 | LogWin32Error("Result was success but GetLastPInvokeError returned an error", result); 259 | } 260 | } 261 | } -------------------------------------------------------------------------------- /Native/PDPJaguarValues.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace FestivalInstrumentMapper 8 | { 9 | internal class PDPJaguarValues 10 | { 11 | // Information from 12 | // https://github.com/TheNathannator/PlasticBand/blob/main/Docs/Descriptor%20Dumps/Xbox%20One/PDP%20Jaguar%20Guitar.txt 13 | 14 | // The GipMsg_Hello from the PDP Jaguar. 15 | public static byte[] Arrival = 16 | { 17 | 0x7E, 0xED, 0x80, 0xF3, 0xB9, 0x50, 0x00, 0x00, 0x6F, 0x0E, 0x70, 0x01, 0x01, 0x00, 0x00, 0x00, 18 | 0x0A, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 19 | }; 20 | 21 | // The metadata descriptor from the PDP Jaguar, with a few modifications. 22 | // The GUID {DFD26825-110A-4E94-B937-B27CE47B2540} was added, which seems to be required for 23 | // xboxgipsynthetic to properly work with it. 24 | public static byte[] Metadata = 25 | { 26 | 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xEB, 0x00, 27 | 0xAC, 0x00, 0x16, 0x00, 0x1B, 0x00, 0x1C, 0x00, 0x23, 0x00, 0x29, 0x00, 0x6B, 0x00, 0x00, 0x00, 28 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x06, 0x01, 0x02, 0x03, 29 | 0x04, 0x06, 0x07, 0x05, 0x01, 0x04, 0x05, 0x06, 0x0A, 0x02, 0x16, 0x00, 0x50, 0x44, 0x50, 0x2E, 30 | 0x58, 0x62, 0x6F, 0x78, 0x2E, 0x47, 0x75, 0x69, 0x74, 0x61, 0x72, 0x2E, 0x4A, 0x61, 0x67, 0x75, 31 | 0x61, 0x72, 0x27, 0x00, 0x57, 0x69, 0x6E, 0x64, 0x6F, 0x77, 0x73, 0x2E, 0x58, 0x62, 0x6F, 0x78, 32 | 0x2E, 0x49, 0x6E, 0x70, 0x75, 0x74, 0x2E, 0x4E, 0x61, 0x76, 0x69, 0x67, 0x61, 0x74, 0x69, 0x6F, 33 | 0x6E, 0x43, 0x6F, 0x6E, 0x74, 0x72, 0x6F, 0x6C, 0x6C, 0x65, 0x72, 0x04, 0xF6, 0x6A, 0x26, 0x1A, 34 | 0x46, 0x3A, 0xE3, 0x45, 0xB9, 0xB6, 0x0F, 0x2C, 0x0B, 0x2C, 0x1E, 0xBE, 0xE7, 0x1F, 0xF3, 0xB8, 35 | 0x86, 0x73, 0xE9, 0x40, 0xA9, 0xF8, 0x2F, 0x21, 0x26, 0x3A, 0xCF, 0xB7, 0x56, 0xFF, 0x76, 0x97, 36 | 0xFD, 0x9B, 0x81, 0x45, 0xAD, 0x45, 0xB6, 0x45, 0xBB, 0xA5, 0x26, 0xD6, 0x25, 0x68, 0xD2, 0xDF, 37 | 0x0A, 0x11, 0x94, 0x4E, 0xB9, 0x37, 0xB2, 0x7C, 0xE4, 0x7B, 0x25, 0x40, 0x02, 0x17, 0x00, 0x20, 38 | 0x0E, 0x00, 0x01, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 39 | 0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x21, 0x05, 0x00, 0x01, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 40 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 41 | }; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Native/SyntheticController.cs: -------------------------------------------------------------------------------- 1 | namespace FestivalInstrumentMapper 2 | { 3 | internal class SyntheticController : IDisposable 4 | { 5 | private ulong _controllerHandle; 6 | private byte[]? _arrival = null; 7 | private byte[]? _metadata = null; 8 | 9 | public SyntheticController() 10 | { 11 | int rval = GipSyntheticEx.CreateController(0, ref _controllerHandle); 12 | if (rval != 0) 13 | throw new Exception($"Failed to create synthetic controller. (HRESULT: {rval:X8})"); 14 | } 15 | 16 | ~SyntheticController() 17 | { 18 | Dispose(false); 19 | } 20 | 21 | public void Dispose() 22 | { 23 | Dispose(true); 24 | GC.SuppressFinalize(this); 25 | } 26 | 27 | private void Dispose(bool disposing) 28 | { 29 | int rval = GipSyntheticEx.RemoveController(_controllerHandle); 30 | if (rval != 0) 31 | throw new Exception($"Failed to remove synthetic controller. (HRESULT: {rval:X8})"); 32 | } 33 | 34 | public void SetData(byte[]? arrival, byte[]? metadata) 35 | { 36 | _arrival = arrival; 37 | _metadata = metadata; 38 | } 39 | 40 | public void Connect() 41 | { 42 | int rval = 0; 43 | if (_arrival != null && _metadata != null) 44 | { 45 | rval = GipSyntheticEx.ConnectEx(_controllerHandle, _arrival, _metadata); 46 | } 47 | else 48 | { 49 | rval = GipSyntheticEx.Connect(_controllerHandle); 50 | } 51 | 52 | if (rval != 0) 53 | throw new Exception($"Failed to connect synthetic controller. (HRESULT: {rval:X8})"); 54 | } 55 | 56 | public void Disconnect() 57 | { 58 | int rval = GipSyntheticEx.Disconnect(_controllerHandle); 59 | if (rval != 0) 60 | throw new Exception($"Failed to disconnect synthetic controller. (HRESULT: {rval:X8})"); 61 | } 62 | 63 | public void SendData(ReadOnlySpan report) 64 | { 65 | int rval = GipSyntheticEx.SendReport(_controllerHandle, report); 66 | if (rval != 0) 67 | throw new Exception($"Failed to send report. (HRESULT: {rval:X8})"); 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /Native/ToGip.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace FestivalInstrumentMapper 4 | { 5 | internal static partial class ToGip 6 | { 7 | private const string DllName = "PlasticBandToGip.dll"; 8 | 9 | [LibraryImport(DllName, EntryPoint = "PS3Wii_RockBand_ToGip")] 10 | public static partial void PS3Wii_RB(ReadOnlySpan ps3rb_buf, Span gip_buf); 11 | 12 | [LibraryImport(DllName, EntryPoint = "PS3_GuitarHero_ToGip")] 13 | public static partial void PS3_GH(ReadOnlySpan ps3gh_buf, Span gip_buf); 14 | 15 | [LibraryImport(DllName, EntryPoint = "PS4_RockBand_ToGip")] 16 | public static partial void PS4_RB(ReadOnlySpan ps4rb_buf, Span gip_buf); 17 | 18 | [LibraryImport(DllName, EntryPoint = "PS5_RockBand_ToGip")] 19 | public static partial void PS5_RB(ReadOnlySpan ps5rb_buf, Span gip_buf); 20 | 21 | [LibraryImport(DllName, EntryPoint = "Santroller_RockBand_ToGip")] 22 | public static partial void Santroller_RB(ReadOnlySpan san_buf, Span gip_buf); 23 | 24 | [LibraryImport(DllName, EntryPoint = "Santroller_GuitarHero_ToGip")] 25 | public static partial void Santroller_GH(ReadOnlySpan san_buf, Span gip_buf); 26 | 27 | [LibraryImport(DllName, EntryPoint = "XInput_RockBand_ToGip")] 28 | public static partial void XInput_RB(ReadOnlySpan xinput_buf, Span gip_buf); 29 | 30 | [LibraryImport(DllName, EntryPoint = "XInput_GuitarHero_ToGip")] 31 | public static partial void XInput_GH(ReadOnlySpan xinput_buf, Span gip_buf); 32 | 33 | [LibraryImport(DllName, EntryPoint = "Raphnet_GuitarHero_ToGip")] 34 | public static partial void Raphnet_GH(ReadOnlySpan raph_buf, Span gip_buf); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Native/XInput.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace FestivalInstrumentMapper 4 | { 5 | [Flags] 6 | public enum XInputButton : ushort 7 | { 8 | DpadUp = 0x0001, 9 | DpadDown = 0x0002, 10 | DpadLeft = 0x0004, 11 | DpadRight = 0x0008, 12 | Start = 0x0010, 13 | Back = 0x0020, 14 | LeftThumb = 0x0040, 15 | RightThumb = 0x0080, 16 | LeftShoulder = 0x0100, 17 | RightShoulder = 0x0200, 18 | Guide = 0x0400, 19 | A = 0x1000, 20 | B = 0x2000, 21 | X = 0x4000, 22 | Y = 0x8000 23 | } 24 | 25 | [StructLayout(LayoutKind.Sequential, Pack = 1)] 26 | public struct XInputGamepad 27 | { 28 | public XInputButton Buttons; // WORD 29 | 30 | public byte LeftTrigger; // BYTE 31 | public byte RightTrigger; // BYTE 32 | 33 | public short LeftThumbX; // SHORT 34 | public short LeftThumbY; // SHORT 35 | 36 | public short RightThumbX; // SHORT 37 | public short RightThumbY; // SHORT 38 | } 39 | 40 | [StructLayout(LayoutKind.Sequential, Pack = 1)] 41 | public struct XInputState 42 | { 43 | public uint PacketNumber; // DWORD 44 | public XInputGamepad Gamepad; // XINPUT_GAMEPAD 45 | } 46 | 47 | [StructLayout(LayoutKind.Sequential, Pack = 1)] 48 | public struct XInputVibration(ushort left, ushort right) 49 | { 50 | public ushort LeftMotorSpeed = left; // WORD 51 | public ushort RightMotorSpeed = right; // WORD 52 | } 53 | 54 | public enum XInputControllerType : byte 55 | { 56 | Gamepad = 1 57 | } 58 | 59 | public enum XInputControllerSubType : byte 60 | { 61 | Unknown = 0, 62 | Gamepad = 1, 63 | Wheel = 2, 64 | ArcadeStick = 3, 65 | FlightStick = 4, 66 | DancePad = 5, 67 | Guitar = 6, 68 | GuitarAlternate = 7, 69 | DrumKit = 8, 70 | GuitarBass = 11, 71 | Keyboard = 15, 72 | ArcadePad = 19, 73 | Turntable = 23, 74 | } 75 | 76 | [Flags] 77 | public enum XInputCapabilityFlags : ushort 78 | { 79 | None = 0x00, 80 | ForceFeedback = 0x01, 81 | Wireless = 0x02, 82 | Voice = 0x04, 83 | PluginModules = 0x08, 84 | NoNavigation = 0x10 85 | } 86 | 87 | [StructLayout(LayoutKind.Sequential, Pack = 1)] 88 | public struct XInputCapabilities 89 | { 90 | public XInputControllerType Type; // BYTE 91 | public XInputControllerSubType SubType; // BYTE 92 | public XInputCapabilityFlags Flags; // WORD 93 | 94 | public XInputGamepad Gamepad; // XINPUT_GAMEPAD 95 | public XInputVibration Vibration; // XINPUT_VIBRATION 96 | } 97 | 98 | public static partial class XInput 99 | { 100 | private enum GetCapabilitiesFlags : uint 101 | { 102 | Gamepad = 1 103 | } 104 | 105 | private const string FileName = "xinput1_4.dll"; 106 | 107 | [LibraryImport(FileName, EntryPoint = "#2")] 108 | public static partial int GetState( 109 | int UserIndex, // DWORD 110 | out XInputState State // XINPUT_STATE* 111 | ); 112 | 113 | [LibraryImport(FileName, EntryPoint = "#3")] 114 | public static partial int SetState( 115 | int UserIndex, // DWORD 116 | in XInputVibration Vibration // XINPUT_VIBRATION* 117 | ); 118 | 119 | [LibraryImport(FileName, EntryPoint = "#4")] 120 | private static partial int GetCapabilities( 121 | int UserIndex, // DWORD 122 | GetCapabilitiesFlags Flags, // DWORD 123 | out XInputCapabilities Capabilities // XINPUT_CAPABILITIES* 124 | ); 125 | 126 | public static int GetCapabilities(int UserIndex, out XInputCapabilities Capabilities) 127 | => GetCapabilities(UserIndex, GetCapabilitiesFlags.Gamepad, out Capabilities); 128 | 129 | [LibraryImport(FileName, EntryPoint = "#100")] 130 | public static partial int GetStateEx( 131 | int UserIndex, // DWORD 132 | out XInputState State // XINPUT_STATE* 133 | ); 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /NativeMethods.txt: -------------------------------------------------------------------------------- 1 | WIN32_ERROR 2 | 3 | CreateFile 4 | ReadFile 5 | WriteFile 6 | GetOverlappedResult 7 | CancelIoEx 8 | 9 | HidD_GetAttributes 10 | HidD_GetSerialNumberString 11 | HidD_GetPreparsedData 12 | HidD_GetInputReport 13 | HidD_SetOutputReport 14 | HidP_GetCaps -------------------------------------------------------------------------------- /Program.cs: -------------------------------------------------------------------------------- 1 | namespace FestivalInstrumentMapper 2 | { 3 | internal static class Program 4 | { 5 | /// 6 | /// The main entry point for the application. 7 | /// 8 | [STAThread] 9 | static void Main() 10 | { 11 | // To customize application configuration such as set high DPI settings or default font, 12 | // see https://aka.ms/applicationconfiguration. 13 | ApplicationConfiguration.Initialize(); 14 | Application.Run(new MainWindow()); 15 | } 16 | 17 | // Exception.Message doesn't include the exception type 18 | public static string GetFirstLine(this Exception ex) 19 | { 20 | return ex.ToString().Split('\n')[0]; 21 | } 22 | 23 | public static string WriteErrorFile(Exception ex) 24 | { 25 | string fileName = $"error_{DateTime.Now:yyyy-MM-dd_HH-mm-ss}.txt"; 26 | File.WriteAllText(fileName, ex.ToString()); 27 | return fileName; 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # FestivalInstrumentMapper 2 | 3 | Maps a variety of Guitar Hero and Rock Band instruments as Xbox One guitars, for usage in Fortnite Festival's new plastic/"pro" modes. 4 | 5 | In theory, it supports Santroller, Xbox 360, PS3, Wii Rock Band, and Raphnet guitars and adapters. 6 | 7 | **Currently in beta, please expect bugs!** 8 | 9 | **This is an unofficial third-party tool, provided with NO WARRANTY OR GUARANTEE. This utility is not associated with or endorsed by Epic Games, Inc.** 10 | 11 | ## Looking for downloads? [See Releases](https://github.com/InvoxiPlayGames/FestivalInstrumentMapper/releases/latest) 12 | 13 | ## Instructions: 14 | 15 | Currently, only the latest versions of Windows 10 (10.0.19045.0) and Windows 11 (10.0.22631.0) are supported. 16 | 17 | 1. [Download FestivalInstrumentMapper](https://github.com/InvoxiPlayGames/FestivalInstrumentMapper/releases/latest) 18 | 2. Extract the ZIP file somewhere memorable on your computer. 19 | 3. Enable Windows Developer Mode. 20 | * On **Windows 11**: Settings -> System -> For developers -> Developer Mode 21 | * On **Windows 10**: Settings -> Update & Security -> For developers -> Developer Mode 22 | 4. Launch FestivalInstrumentMapper.exe. 23 | 5. Select your guitar from the drop down selection. 24 | 6. Hit "Start Mapping", and Fortnite should now see a guitar controller and let you play Plastic Lead and Plastic Bass. 25 | 26 | *For Xbox 360 guitars, please see info in the "Set up Xbox 360 Controller Hiding" page of FestivalInstrumentMapper.* 27 | 28 | ## Known Issues: 29 | 30 | * Whammy and tilt, for overdrive activations, can be tempremental. 31 | * Sometimes the app won't fully close and will be stuck in the background. 32 | * Xbox 360 controllers can cause framerate issues. 33 | * Versions of Windows with random services removed ("debloated") won't work. This can not be fixed. 34 | 35 | Please report any other issues you run into on the [issue tracker](https://github.com/InvoxiPlayGames/FestivalInstrumentMapper/issues). 36 | When reporting issues, please read the [FAQ](https://github.com/InvoxiPlayGames/FestivalInstrumentMapper/wiki/FAQ-and-About) and check 37 | for any existing issues before submitting a new report. 38 | 39 | ## Credits 40 | 41 | * [TheNathannator](https://github.com/TheNathannator) for helping get this project off the ground and documenting every guitar under the sun. 42 | * [sanjay900](https://github.com/sanjay900) for documentation help, testing and the amazing Santroller Guitar firmware. 43 | * [Nefarius](https://github.com/Nefarius) for the HidHide utility and DeviceManagement library. 44 | * xX760Xx, Acai, JasonParadise and aWiseMoose from Lore Hero for helping test a bunch of different guitars, and being cool. 45 | 46 | ## Building 47 | 48 | **This is only for advanced users and developers who want to work on the tool! If you just want to use it, 49 | download the latest release from the releases page.** 50 | 51 | To compile this yourself, you need Visual Studio 2022 with the C++ and C# development tools installed, as well 52 | as the .NET 8 SDK. 53 | 54 | Compiling the main mapper utility can be done by opening the .sln and building it normally. 55 | 56 | For the compiled ou'll need to compile the following 2 DLLs and put them next to the resulting EXE file: 57 | 58 | * [PlasticBandToGip](https://github.com/InvoxiPlayGames/PlasticBandToGip) - native components for translating controllers 59 | * [GipSyntheticEx](https://github.com/InvoxiPlayGames/GipSyntheticEx) - extensions to the Xbox GIP Synthetic library. 60 | 61 | ## License 62 | 63 | FestivalInstrumentMapper is Free Software, licensed to you under version 2 of the GNU General Public License. 64 | Read the LICENSE.txt file for more information. 65 | 66 | FestivalInstrumentMapper uses the following third-party libraries: 67 | 68 | * Nefarius.Drivers.HidHide, licensed under the MIT License. 69 | * Nefarius.Utilities.DeviceManagement, licensed under the MIT License. 70 | 71 | Code is used from [HedgeModManager](https://github.com/thesupersonic16/HedgeModManager/blob/rewrite/HedgeModManager/Epic.cs) 72 | for Heroic Games Launcher detection, licensed under the MIT License. 73 | -------------------------------------------------------------------------------- /app.manifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 54 | 62 | 63 | 64 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /festivalinstrumentmapper.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InvoxiPlayGames/FestivalInstrumentMapper/54b866125fc05f075057f6d88d128d68ee1caa37/festivalinstrumentmapper.ico --------------------------------------------------------------------------------